- escapeRegExp
- hasProperty
- humanize
- intersection
- isInteger
- isNumeric
- isObject
- isPrimitive
- isPromiseLike
- trim
- truncate
Ƭ PrimitiveValue: string
| number
| boolean
| symbol
| undefined
| null
| bigint
Javascript primitive types. Also see: https://developer.mozilla.org/en-US/docs/Glossary/Primitive
▸ escapeRegExp<S
>(string
): string
| S
Makes a string safe for use inside a regular expression by escaping regex special characters.
Name |
---|
S |
Name | Type |
---|---|
string |
S |
string
| S
▸ hasProperty(obj
, val
): val is string | number | symbol
Tests whether an enumerable property with the provided name exists on the given object.
Name | Type |
---|---|
obj |
any |
val |
string | number | symbol |
val is string | number | symbol
▸ humanize(input
, titleCase?
): string
Takes a camelCased, snake_cased, or skeleton-cased string and puts in some nice looking spaces.
humanize('fooBarBaz'); // "Foo bar baz"
humanize('foo_bar_baz'); // "Foo bar baz"
humanize('foo-bar-baz'); // "Foo bar baz"
// Optional title casing
humanize('foo-bar-baz', true); // "Foo Bar Baz"
Name | Type | Default value |
---|---|---|
input |
string |
undefined |
titleCase |
boolean |
false |
string
▸ intersection<T
>(arrayA
, arrayB
): T
[]
Given two array arguments, creates a new array that contains only the elements found in both arguments.
Name |
---|
T |
Name | Type |
---|---|
arrayA |
T [] |
arrayB |
T [] |
T
[]
▸ isInteger(value
): value is number
Tests whether the argument is a whole number.
Name | Type |
---|---|
value |
any |
value is number
▸ isNumeric(value
): value is number
Tests whether the argument is a finite number. Strings that could be parsed as such are valid as well.
Name | Type |
---|---|
value |
any |
value is number
▸ isObject(value
): value is Record<string, unknown>
Tests whether the argument is a plain old javascript object (POJO) or class instance.
Name | Type |
---|---|
value |
any |
value is Record<string, unknown>
▸ isPrimitive(value
): value is PrimitiveValue
Tests whether the argument is one of Javascript's primitive types.
Name | Type |
---|---|
value |
any |
value is PrimitiveValue
▸ isPromiseLike(obj
): obj is PromiseLike<unknown>
Tests whether the argument is "then-able", e.g. it has a then()
method.
Name | Type |
---|---|
obj |
any |
obj is PromiseLike<unknown>
▸ trim(value
): string
A type-safe String.trim()
that will return either the trimmed argument, or an empty string.
Name | Type |
---|---|
value |
any |
string
▸ truncate(string
, maxLen?
, postfix?
): string
Truncates a string of characters to the nearest whitespace either on or before a maximum length.
Name | Type | Default value | Description |
---|---|---|---|
string |
string |
undefined |
The string to truncate. |
maxLen |
number |
40 |
- |
postfix |
string |
' ...' |
- |
string