@olmokit/utils
Interfaces
Other
AnyAsyncFunction
Ƭ AnyAsyncFunction: (...args
: any
[]) => Promise
<any
>
Type declaration
▸ (...args
): Promise
<any
>
Parameters
Name | Type |
---|---|
...args | any [] |
Returns
Promise
<any
>
Defined in
AnyClass
Ƭ AnyClass: (...args
: any
[]) => any
Type declaration
• (...args
)
Parameters
Name | Type |
---|---|
...args | any [] |
Defined in
AnyFunction
Ƭ AnyFunction: (...args
: any
[]) => any
Type declaration
▸ (...args
): any
Parameters
Name | Type |
---|---|
...args | any [] |
Returns
any
File
Same as is-what plus:
isFormData
isInt
isFloat
Defined in
AnythingFalsy
Ƭ AnythingFalsy: null
| undefined
| 0
| ""
Whatever that in javascript returns false
when checked in an if
condition
Defined in
ClsxClassValue
Ƭ ClsxClassValue: ClassValue
Defined in
DebounceOptions
Ƭ DebounceOptions<Result
>: Object
Categroy
functionn
Type parameters
Name |
---|
Result |
Type declaration
Name | Type |
---|---|
callback? | (data : Result ) => void |
isImmediate? | boolean |
maxWait? | number |
Defined in
KeysStartsWith
Ƭ KeysStartsWith<T
, S
>: keyof PickStartsWith
<T
, S
>
Returns a union of all the keys of an object T
which starts with S
.
Type parameters
Name | Type |
---|---|
T | extends object |
S | extends string |
Defined in
KeysTailsStartsWith
Ƭ KeysTailsStartsWith<T
, S
>: keyof PickStartsWithTails
<T
, S
>
Returns a union of all the keys of an object T
which starts with S
.
The strings in the produced union have S
removed.
Type parameters
Name | Type |
---|---|
T | extends object |
S | extends string |
Defined in
PickStartsWith
Ƭ PickStartsWith<T
, S
>: { [K in keyof T as K extends `${S}${string}` ? K : never]: T[K] }
Pick the keys of an object T
that starts with S
. It produces a mapped type
with a subset of T
whose keys start with S
.
Type parameters
Name | Type |
---|---|
T | extends object |
S | extends string |
Defined in
PickStartsWithTails
Ƭ PickStartsWithTails<T
, S
>: { [K in keyof T as K extends `${S}${string}` ? Replace<K, S, ""> : never]: T[K] }
Pick the keys of an object T
that starts with S
. It produces a mapped type
with a subset of T
whose keys start with S
and have S
removed.
Type parameters
Name | Type |
---|---|
T | extends object |
S | extends string |
Defined in
PlainObject
Ƭ PlainObject: Record
<string
| number
| symbol
, any
>
Defined in
TypeGuard
Ƭ TypeGuard<A
, B
>: (payload
: A
) => payload is B
Type parameters
Name | Type |
---|---|
A | A |
B | extends A |
Type declaration
▸ (payload
): payload is B
Parameters
Name | Type |
---|---|
payload | A |
Returns
payload is B
Defined in
getType
▸ getType(payload
): string
Returns the object type of the given payload
Parameters
Name | Type |
---|---|
payload | any |
Returns
string
Defined in
matchSorter
▸ matchSorter<ItemType
>(items
, value
, options?
): ItemType
[]
Takes an array of items and a value and returns a new array with the items that match the given value
Type parameters
Name | Type |
---|---|
ItemType | string |
Parameters
Name | Type | Description |
---|---|---|
items | readonly ItemType [] | the items to sort |
value | string | the value to use for ranking |
options | MatchSorterOptions <ItemType > | Some options to configure the sorter |
Returns
ItemType
[]
- the new sorted array
Defined in
array
addOrReplaceAtIdx
▸ addOrReplaceAtIdx<T
>(list
, newItem
, newIdx?
): T
[]
Add or replace an item in the given array, it returns a new array (immutable).
Typescript wise this is meant to keep the same type on the newly returned
array, therefore the newItem
must match the type of the list
items.
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
list | T [] |
newItem | T |
newIdx? | number |
Returns
T
[]
Defined in
arrayOfAll
▸ arrayOfAll<T
>(): <U>(array
: U
& [T
] extends [U
[number
]] ? unknown
: "Invalid"
) => U
& [T
] extends [U
[number
]] ? unknown
: "Invalid"
Ensure an array contains all desired values
Type parameters
Name |
---|
T |
Returns
fn
▸ <U
>(array
): U
& [T
] extends [U
[number
]] ? unknown
: "Invalid"
Type parameters
Name | Type |
---|---|
U | extends T [] |
Parameters
Name | Type |
---|---|
array | U & [T ] extends [U [number ]] ? unknown : "Invalid" |
Returns
U
& [T
] extends [U
[number
]] ? unknown
: "Invalid"
Borrows
SO comment by CertainPerformance
Usage
type Fruit = "pear" | "apple" | "orange";
const arrayOfAllFruits = arrayOfAll<Fruit>();
const allFruits = arrayOfAllFruits([
"pear",
"apple",
"orange"
]); // ts compiler ok
const allFruits = arrayOfAllFruits([
"pear",
"apple",
]); // ts compiler fails
Defined in
arraySum
▸ arraySum(numbers
): number
Sum array of numbers
Parameters
Name | Type |
---|---|
numbers | number [] |
Returns
number
Defined in
arrayToLookup
▸ arrayToLookup<T
>(array?
): Record
<T
, 1
>
Maps a simple flat array to a lookup dictionary object
Type parameters
Name | Type |
---|---|
T | extends string | number | symbol |
Parameters
Name | Type |
---|---|
array | T [] |
Returns
Record
<T
, 1
>
Defined in
chunkByChunks
▸ chunkByChunks<T
>(arr
, nrOfChunks
, balanced?
): T
[][]
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
arr | T [] |
nrOfChunks | number |
balanced? | boolean |
Returns
T
[][]
See
https://stackoverflow.com/a/8189268/1938970 TODO: untested
Defined in
chunkBySize
▸ chunkBySize<T
>(arr
, size
): T
[][]
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
arr | T [] |
size | number |
Returns
T
[][]
See
https://stackoverflow.com/a/40682136/1938970
Defined in
findDuplicatedIndexes
▸ findDuplicatedIndexes(arr
): Record
<number
, true
>
Parameters
Name | Type |
---|---|
arr | any [] |
Returns
Record
<number
, true
>
Defined in
getEmptyArray
▸ getEmptyArray(length
): undefined
[]
Returns an array of undefined values of the desired length, useful to build skeleton UIs.
Parameters
Name | Type |
---|---|
length | string | number |
Returns
undefined
[]
Defined in
mapListBy
▸ mapListBy<T
>(array?
, key?
): Record
<T
[keyof T
], T
>
Maps an array of objects into a map keyed with the given key
Type parameters
Name | Type |
---|---|
T | extends Record <string | number | symbol , any > |
Parameters
Name | Type |
---|---|
array | T [] |
key | keyof T |
Returns
Record
<T
[keyof T
], T
>
Defined in
moveSortableArrayItemByKey
▸ moveSortableArrayItemByKey<T
, K
>(items
, key
, fromItem
, toItem
): T
[]
Move item from one place to another in a sortable array of objects, re-ordering the array accrodingly (no swapping of position). This is useful for drag and drop functionalities
Type parameters
Name | Type |
---|---|
T | T |
K | extends string | number | symbol |
Parameters
Name | Type |
---|---|
items | T [] |
key | K |
fromItem | Pick <T , K > |
toItem | Pick <T , K > |
Returns
T
[]
Defined in
moveSortableArrayItemByKey.ts:8
removeDuplicatesByKey
▸ removeDuplicatesByKey<T
>(array?
, key
): T
[]
Remove duplicated array objects, equality is determined by a strict (===
)
comparison of each object's given key
Type parameters
Name | Type |
---|---|
T | extends Record <string | number | symbol , any > |
Parameters
Name | Type |
---|---|
array | T [] |
key | keyof T |
Returns
T
[]
Defined in
removeDuplicatesComparing
▸ removeDuplicatesComparing<T
>(from
, to
): T
[]
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
from | any [] |
to | T [] |
Returns
T
[]
Defined in
removeDuplicatesComparing.ts:7
removeIndexesFromArray
▸ removeIndexesFromArray<T
>(arr
, indexes
): T
[]
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
arr | T [] |
indexes | Record <number , true > |
Returns
T
[]
Defined in
shuffle
▸ shuffle<T
>(array
): T
[]
Creates an array of shuffled values, using a version of the Fisher-Yates shuffle.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
array | T [] | The array to shuffle. |
Returns
T
[]
The new shuffled array.
Borrows
Example
shuffle([1, 2, 3, 4])
// => [4, 1, 3, 2]
Defined in
async
Deferred
Ƭ Deferred<T
>: Promise
<T
> & { reject
: PromiseConstructor
["reject"
] ; resolve
: PromiseConstructor
["resolve"
] }
Type parameters
Name |
---|
T |
Defined in
Defer
▸ Defer<T
>(): Deferred
<T
>
Type parameters
Name |
---|
T |
Returns
Deferred
<T
>
See
https://stackoverflow.com/a/37673534/1938970
Example
const deferred = Defer();
deferred.resolve();
deferred.then(handleSuccess, handleError);
Defined in
tryUntil
▸ tryUntil(test
, timeout
, interval
, resolve
, reject?
): void
Parameters
Name | Type | Description |
---|---|---|
test | () => boolean | - |
timeout | number | in ms |
interval | number | in ms |
resolve | () => void | - |
reject? | () => void | - |
Returns
void
Borrows
Javascript: Wait Until Something Happens or Timeout
Defined in
wait
▸ wait(milliseconds
): Promise
<unknown
>
A promisified setTimeout
Parameters
Name | Type |
---|---|
milliseconds | number |
Returns
Promise
<unknown
>
Defined in
cast
ensureInt
▸ ensureInt(input
): number
Ensure input to be an integer
Parameters
Name | Type |
---|---|
input | string | number |
Returns
number
Defined in
errorToString
▸ errorToString(e
): string
Ensure to transform a JavaScript Error
into a string (uses its message
)
Parameters
Name | Type |
---|---|
e | unknown |
Returns
string
Defined in
toNumber
▸ toNumber(input?
, fallback?
): number
Parameters
Name | Type |
---|---|
input? | string | number |
fallback? | number |
Returns
number
Defined in
colors
createPalette
▸ createPalette<TName
, TShades
, TColor
, TMap
>(name
, shades
): readonly [TMap
, Record
<`${TName}-${TShades[number][0]}`, string
>, TColor
[]]
Create palette, this is primarily thought to improve the reuse of a palette definition between TailwindCSS and straight ES imports
Type parameters
Name | Type |
---|---|
TName | extends string |
TShades | extends PaletteShades |
TColor | TShades [number ][``1``] |
TMap | PaletteMap <TShades > |
Parameters
Name | Type |
---|---|
name | TName |
shades | TShades |
Returns
readonly [TMap
, Record
<`${TName}-${TShades[number][0]}`, string
>, TColor
[]]
An array with: 1) A flat palette map 2) A TailwindCSS ready palette
object 3) A flat array of colors (no special sorting, same order as the shades
given as argument)
Defined in
toRgba
▸ toRgba(hex
, alpha?
): string
Parameters
Name | Type | Default value |
---|---|---|
hex | string | undefined |
alpha | number | 1 |
Returns
string
Defined in
cookie
CookieAttributesClient
Ƭ CookieAttributesClient: CookieAttributes
Defined in
CookieAttributesServer
Ƭ CookieAttributesServer: CookieAttributes
& { decode?
: (input
: string
) => string
; encode?
: (input
: string
) => string
; httpOnly?
: boolean
; maxAge?
: number
}
Defined in
parseCookie
▸ parseCookie<T
>(str
, attributes?
): T
Parse a cookie header.
Parse the given cookie header string into an object The object has the various cookies as keys(names) => values
Type parameters
Name | Type |
---|---|
T | extends Record <string , unknown > = Record <string , string > |
Parameters
Name | Type |
---|---|
str | string |
attributes | CookieAttributesServer |
Returns
T
Defined in
readCookie
▸ readCookie<T
>(name?
): T
Read cookie
Type parameters
Name | Type |
---|---|
T | extends Record <string , unknown > = Record <string , string > |
Parameters
Name | Type |
---|---|
name? | null |
Returns
T
Defined in
▸ readCookie<T
, N
>(name
): T
[N
]
Type parameters
Name | Type |
---|---|
T | extends Record <string , unknown > = Record <string , string > |
N | extends string | number | symbol = keyof T |
Parameters
Name | Type |
---|---|
name | N |
Returns
T
[N
]
Defined in
removeCookie
▸ removeCookie(name
, attributes?
): void
Parameters
Name | Type |
---|---|
name | string |
attributes | CookieAttributes |
Returns
void
Defined in
serializeCookie
▸ serializeCookie(name
, val
, attributes?
): string
Serialize data into a cookie header.
Serialize the a name value pair into a cookie string suitable for http headers. An optional attributes object specified cookie parameters.
serialize('foo', 'bar', { httpOnly: true }) => "foo=bar; httpOnly"
Parameters
Name | Type |
---|---|
name | string |
val | string |
attributes | CookieAttributesServer |
Returns
string
Defined in
setCookie
▸ setCookie<T
>(name
, value
, attributes?
): string
| undefined
Type parameters
Name | Type |
---|---|
T | extends string = string |
Parameters
Name | Type |
---|---|
name | string |
value | string | T |
attributes | CookieAttributes |
Returns
string
| undefined
Defined in
error
errorToString
▸ errorToString(e
): string
Ensure to transform a JavaScript Error
into a string (uses its message
)
Parameters
Name | Type |
---|---|
e | unknown |
Returns
string
Defined in
format
gbToBytes
▸ gbToBytes(bytes
): number
Gigabytes to bytes
Parameters
Name | Type |
---|---|
bytes | number |
Returns
number
Defined in
kbToBytes
▸ kbToBytes(bytes
): number
Kilobytes to bytes
Parameters
Name | Type |
---|---|
bytes | number |
Returns
number
Defined in
mbToBytes
▸ mbToBytes(bytes
): number
Megabytes to bytes
Parameters
Name | Type |
---|---|
bytes | number |
Returns
number
Defined in
function
debounce
▸ debounce<T
>(fn
, wait?
, immediate?
): (this
: unknown
, ...args
: Parameters
<T
>) => void
Debounce function (with setTimeout
)
Type parameters
Name | Type |
---|---|
T | extends (...args : any []) => any |
Parameters
Name | Type |
---|---|
fn | T |
wait? | number |
immediate? | boolean |
Returns
fn
▸ (this
, ...args
): void
Parameters
Name | Type |
---|---|
this | unknown |
...args | Parameters <T > |
Returns
void
Borrows
Defined in
debouncePromise
▸ debouncePromise<Args
, F
>(func
, waitMilliseconds?
, options?
): DebouncedFunction
<Args
, F
>
Debounce function (with Promise
)
Type parameters
Name | Type |
---|---|
Args | extends any [] |
F | extends (...args : Args ) => any |
Parameters
Name | Type | Default value |
---|---|---|
func | F | undefined |
waitMilliseconds | number | 50 |
options | DebounceOptions <ReturnType <F >> | {} |
Returns
DebouncedFunction
<Args
, F
>
Borrows
License
MIT: Jakub Chodorowicz
Defined in
debounceRaf
▸ debounceRaf<T
>(this
, fn
): (this
: unknown
, ...args
: Parameters
<T
>) => void
Debounce function (with requestAnimationFrame
)
Type parameters
Name | Type |
---|---|
T | extends (...args : any []) => any |
Parameters
Name | Type |
---|---|
this | unknown |
fn | T |
Returns
fn
▸ (this
, ...args
): void
Parameters
Name | Type |
---|---|
this | unknown |
...args | Parameters <T > |
Returns
void
Borrows
License
(c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
Defined in
throttle
▸ throttle<TFn
, TContext
>(fn
, limit
, context?
): (this
: TContext
, ...args
: any
[]) => undefined
| Timeout
Throttle function (e.g. for resize / scroll handlers)
Type parameters
Name | Type |
---|---|
TFn | extends Function |
TContext | TContext |
Parameters
Name | Type |
---|---|
fn | TFn |
limit | number |
context? | TContext |
Returns
fn
▸ (this
, ...args
): undefined
| Timeout
Parameters
Name | Type |
---|---|
this | TContext |
...args | any [] |
Returns
undefined
| Timeout
Borrows
Defined in
tryUntil
▸ tryUntil(test
, timeout
, interval
, resolve
, reject?
): void
Parameters
Name | Type | Description |
---|---|---|
test | () => boolean | - |
timeout | number | in ms |
interval | number | in ms |
resolve | () => void | - |
reject? | () => void | - |
Returns
void
Borrows
Javascript: Wait Until Something Happens or Timeout
Defined in
img
imgEmptyPixel
• Const
imgEmptyPixel: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="
Empty img pixel as a string to inline
Defined in
impl
Emitter
▸ Emitter<EventMap
>(namespace
): Object
Emitter super simple class
Events will be prefixed with the given namespace
plus a .
so:
{namespace}.myevent
Adapted from https://github.com/developit/mitt
Regarding typescript support see:
Type parameters
Name | Type |
---|---|
EventMap | extends Object |
Parameters
Name | Type |
---|---|
namespace | string |
Returns
Object
Name | Type |
---|---|
emit | <EventName>(name : EventName , data? : EventMap [EventName ]) => void |
on | <EventName>(name : EventName , handler : (data? : EventMap [EventName ]) => any ) => void |
Defined in
clsx
▸ clsx(...args
): string
Class names utility
Parameters
Name | Type |
---|---|
...args | ClassValue [] |
Returns
string
Borrows
License
MIT Luke Edwards https://github.com/lukeed/clsx/blob/master/license
Defined in
quaranteneProps
▸ quaranteneProps<TProps
, TSupectPropsKeys
>(props
, propsKeysToQuarantene
): Omit
<TProps
, TSupectPropsKeys
[number
]> & { _
: Pick
<TProps
, TSupectPropsKeys
[number
]> }
Type parameters
Name | Type |
---|---|
TProps | extends Record <never , never > |
TSupectPropsKeys | extends QuaranteneProps <TProps > |
Parameters
Name | Type |
---|---|
props | TProps |
propsKeysToQuarantene | TSupectPropsKeys |
Returns
Omit
<TProps
, TSupectPropsKeys
[number
]> & { _
: Pick
<TProps
, TSupectPropsKeys
[number
]> }
Example
const { _: { onKeyDown }, myOwnProp, ...rest } = quaranteneProps([
"onPointerLeave",
"onPointerMove",
"onClick",
"onPointerDown",
"onPointerUp",
"onKeyDown",
]);
Defined in
is
isBrowser
• Const
isBrowser: boolean
Defined in
isServer
• Const
isServer: boolean
= !isBrowser
Defined in
isAnyObject
▸ isAnyObject(payload
): payload is PlainObject
Returns whether the payload is an any kind of object (including special classes or objects with different prototypes)
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is PlainObject
Defined in
isArray
▸ isArray(payload
): payload is any[]
Returns whether the payload is an array
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is any[]
Defined in
isBlob
▸ isBlob(payload
): payload is Blob
Returns whether the payload is a Blob
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is Blob
Defined in
isBoolean
▸ isBoolean(payload
): payload is boolean
Returns whether the payload is a boolean
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is boolean
Defined in
isBrowserNow
▸ isBrowserNow(): boolean
Returns
boolean
Defined in
isDate
▸ isDate(payload
): payload is Date
Returns whether the payload is a Date, and that the date is valid
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is Date
Defined in
isEmptyArray
▸ isEmptyArray(payload
): payload is []
Returns whether the payload is a an empty array
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is []
Defined in
isEmptyObject
▸ isEmptyObject(payload
): payload is Object
Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is Object
Defined in
isEmptyString
▸ isEmptyString(payload
): payload is string
Returns whether the payload is ''
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is string
Defined in
isError
▸ isError(payload
): payload is Error
Returns whether the payload is an Error
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is Error
Defined in
isFile
▸ isFile(payload
): payload is File
Returns whether the payload is a File
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is File
Defined in
isFloat
▸ isFloat(payload
): payload is number
Returns whether the payload is a float number
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is number
Defined in
isFormData
▸ isFormData(payload
): payload is FormData
Returns whether the payload is a FormData
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is FormData
Defined in
isFullArray
▸ isFullArray(payload
): payload is any[]
Returns whether the payload is a an array with at least 1 item
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is any[]
Defined in
isFullObject
▸ isFullObject(payload
): payload is PlainObject
Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is PlainObject
Defined in
isFullString
▸ isFullString(payload
): payload is string
Returns whether the payload is a string, BUT returns false for ''
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is string
Defined in
isFunction
▸ isFunction(payload
): payload is AnyFunction
Returns whether the payload is a function (regular or async)
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is AnyFunction
Defined in
isInt
▸ isInt(payload
): payload is number
Returns whether the payload is an integer number
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is number
Defined in
isMap
▸ isMap(payload
): payload is Map<any, any>
Returns whether the payload is a Map
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is Map<any, any>
Defined in
isNaNValue
▸ isNaNValue(payload
): payload is number
Returns whether the payload is literally the value NaN
(it's NaN
and also a number
)
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is number
Defined in
isNegativeNumber
▸ isNegativeNumber(payload
): payload is number
Returns whether the payload is a negative number (but not 0)
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is number
Defined in
isNull
▸ isNull(payload
): payload is null
Returns whether the payload is null
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is null
Defined in
isNullOrUndefined
▸ isNullOrUndefined(payload
): payload is undefined | null
Returns true whether the payload is null or undefined
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is undefined | null
Defined in
isNumber
▸ isNumber(payload
): payload is number
Returns whether the payload is a number (but not NaN)
This will return false
for NaN
!!
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is number
Defined in
isObject
▸ isObject(payload
): payload is PlainObject
Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is PlainObject
Defined in
isObjectLike
▸ isObjectLike<T
>(payload
): payload is T
Returns whether the payload is an object like a type passed in < >
Usage: isObjectLike<{id: any}>(payload) // will make sure it's an object and has an id
prop.
Type parameters
Name | Type |
---|---|
T | extends PlainObject |
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is T
Defined in
isOneOf
▸ isOneOf<A
, B
, C
>(a
, b
): TypeGuard
<A
, B
| C
>
Type parameters
Name |
---|
A |
B |
C |
Parameters
Name | Type |
---|---|
a | TypeGuard <A , B > |
b | TypeGuard <A , C > |
Returns
TypeGuard
<A
, B
| C
>
Defined in
▸ isOneOf<A
, B
, C
, D
>(a
, b
, c
): TypeGuard
<A
, B
| C
| D
>
Type parameters
Name |
---|
A |
B |
C |
D |
Parameters
Name | Type |
---|---|
a | TypeGuard <A , B > |
b | TypeGuard <A , C > |
c | TypeGuard <A , D > |
Returns
TypeGuard
<A
, B
| C
| D
>
Defined in
▸ isOneOf<A
, B
, C
, D
, E
>(a
, b
, c
, d
): TypeGuard
<A
, B
| C
| D
| E
>
Type parameters
Name |
---|
A |
B |
C |
D |
E |
Parameters
Name | Type |
---|---|
a | TypeGuard <A , B > |
b | TypeGuard <A , C > |
c | TypeGuard <A , D > |
d | TypeGuard <A , E > |
Returns
TypeGuard
<A
, B
| C
| D
| E
>
Defined in
▸ isOneOf<A
, B
, C
, D
, E
, F
>(a
, b
, c
, d
, e
): TypeGuard
<A
, B
| C
| D
| E
| F
>
Type parameters
Name |
---|
A |
B |
C |
D |
E |
F |
Parameters
Name | Type |
---|---|
a | TypeGuard <A , B > |
b | TypeGuard <A , C > |
c | TypeGuard <A , D > |
d | TypeGuard <A , E > |
e | TypeGuard <A , F > |
Returns
TypeGuard
<A
, B
| C
| D
| E
| F
>
Defined in
isPlainObject
▸ isPlainObject(payload
): payload is PlainObject
Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is PlainObject
Defined in
isPositiveNumber
▸ isPositiveNumber(payload
): payload is number
Returns whether the payload is a positive number (but not 0)
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is number
Defined in
isPrimitive
▸ isPrimitive(payload
): payload is undefined | null | string | number | boolean | symbol
Returns whether the payload is a primitive type (eg. Boolean | Null | Undefined | Number | String | Symbol)
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is undefined | null | string | number | boolean | symbol
Defined in
isPromise
▸ isPromise(payload
): payload is Promise<any>
Returns whether the payload is a Promise
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is Promise<any>
Defined in
isRegExp
▸ isRegExp(payload
): payload is RegExp
Returns whether the payload is a regular expression (RegExp)
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is RegExp
Defined in
isServerNow
▸ isServerNow(): boolean
Returns
boolean
Defined in
isSet
▸ isSet(payload
): payload is Set<any>
Returns whether the payload is a Set
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is Set<any>
Defined in
isString
▸ isString(payload
): payload is string
Returns whether the payload is a string
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is string
Defined in
isSymbol
▸ isSymbol(payload
): payload is symbol
Returns whether the payload is a Symbol
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is symbol
Defined in
isType
▸ isType<T
>(payload
, type
): payload is T
Does a generic check to check that the given payload is of a given type. In cases like Number, it will return true for NaN as NaN is a Number (thanks javascript!); It will, however, differentiate between object and null
Type parameters
Name | Type |
---|---|
T | extends AnyFunction | AnyClass |
Parameters
Name | Type |
---|---|
payload | any |
type | T |
Returns
payload is T
Throws
Will throw type error if type is an invalid type
Defined in
isUndefined
▸ isUndefined(payload
): payload is undefined
Returns whether the payload is undefined
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is undefined
Defined in
isWeakMap
▸ isWeakMap(payload
): payload is WeakMap<any, any>
Returns whether the payload is a WeakMap
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is WeakMap<any, any>
Defined in
isWeakSet
▸ isWeakSet(payload
): payload is WeakSet<any>
Returns whether the payload is a WeakSet
Parameters
Name | Type |
---|---|
payload | any |
Returns
payload is WeakSet<any>
Defined in
location
AnyQueryParams
Ƭ AnyQueryParams: undefined
| null
| Record
<string
| number
, unknown
>
Defined in
buildUrlQueryString
▸ buildUrlQueryString<T
>(params
): string
Get clean query string for URL
It returns the query string with the initial ?
TODO: at some point replace with URLSearchParams
,
Type parameters
Name | Type |
---|---|
T | extends AnyQueryParams |
Parameters
Name | Type |
---|---|
params | T |
Returns
string
See
Defined in
changeUrlPath
▸ changeUrlPath(pathname
, state?
, replace?
): string
Change URL path, ensures initial and ending slashes and normalise eventual
consecutive slashes, it uses history
.
Parameters
Name | Type | Description |
---|---|---|
pathname | string | - |
state? | object | - |
replace? | boolean | Replace URL instead of pushing it in the history stack. By default it pushes it. |
Returns
string
The new cleaned pathname
Defined in
getParamAmong
▸ getParamAmong<T
>(raw?
, allowedValues?
): null
| T
[number
]
Get query parameter as string
treating the ParsedUrlQuery
result of
querystring
(used in next.js
router and elsewhere)
Type parameters
Name | Type |
---|---|
T | extends string [] |
Parameters
Name | Type | Description |
---|---|---|
raw? | string | string [] | The raw query parameter |
allowedValues | T | The list of values (as strings) that the parameter can have, if not one of them null is returned |
Returns
null
| T
[number
]
Defined in
getParamAsInt
▸ getParamAsInt<TFallback
>(raw?
, fallback?
): number
| TFallback
Get query parameter as int
eger treating the ParsedUrlQuery
result of
querystring
(used in next.js
router and elsewhere)
Type parameters
Name | Type |
---|---|
TFallback | extends undefined | null | number |
Parameters
Name | Type | Description |
---|---|---|
raw? | string | string [] | The raw query parameter |
fallback | TFallback | Fallback number, we return null if not provided |
Returns
number
| TFallback
Defined in
getParamAsString
▸ getParamAsString(raw?
): string
Get query parameter as string
treating the ParsedUrlQuery
result of
querystring
(used in next.js
router and elsewhere)
Parameters
Name | Type | Description |
---|---|---|
raw? | string | string [] | The raw query parameter |
Returns
string
Defined in
getUrlHashParams
▸ getUrlHashParams<T
>(hash?
): T
It returns the "query params" as an object extracting it from the given hash
string or, if not provided, failling back reading the location.hash
Type parameters
Name | Type |
---|---|
T | extends Record <string | number , unknown > |
Parameters
Name | Type | Default value |
---|---|---|
hash | string | "" |
Returns
T
Defined in
getUrlHashPathname
▸ getUrlHashPathname(hash?
): string
It returns the "pathname" cleaned up from the #
and the initial slashes
extracting it from the given hash
string or, if not provided, failling
back reading the location.hash
Parameters
Name | Type | Default value |
---|---|---|
hash | string | "" |
Returns
string
Defined in
getUrlPathnameParts
▸ getUrlPathnameParts(pathname?
): string
[]
Get pathname parts
First clean the pathname from the first slash if any then split the pathname
in parts,
Given a pathname like: "/en/{prefix}/{collection}/{slug}"
we obtain
[locale, prefix, collection, slug]
Parameters
Name | Type | Default value |
---|---|---|
pathname | string | "" |
Returns
string
[]
Defined in
getUrlQueryParams
▸ getUrlQueryParams<T
>(url?
): T
Get parsed query parameters as object dictionary (from URL or given query string)
Type parameters
Name | Type |
---|---|
T | extends Record <string | number , unknown > |
Parameters
Name | Type | Description |
---|---|---|
url? | string | A URL which contains a ? , e.g. ?myparam=x or https://a.com?myparams=x . If not provided it defaults reading the current URL query string with location.search . Through this argument you can use this same function to parse, for instance, the query params of the href of a <a href="..."> HTML tag. |
Returns
T
Defined in
isExternalUrl
▸ isExternalUrl(url
, currentUrl?
): boolean
Is external url compared to the given current URL (if not provided it falls
back to location.href
)
Parameters
Name | Type |
---|---|
url | string |
currentUrl? | string |
Returns
boolean
Defined in
mergeUrlQueryParams
▸ mergeUrlQueryParams<T
>(oldParams?
, newParams?
): T
Merge query parameters objects, it mutates the first given object argument
Type parameters
Name | Type |
---|---|
T | extends AnyQueryParams |
Parameters
Name | Type |
---|---|
oldParams | Record <string | number , unknown > |
newParams | Record <string | number , unknown > |
Returns
T
Defined in
normaliseUrl
▸ normaliseUrl(absoluteUrl?
): string
Normalise URL, it works both for absolute and relative URLs
- replaces too many consecutive slashes (except
http{s}://
) - removes the trailing slash
Parameters
Name | Type | Default value |
---|---|---|
absoluteUrl | string | "" |
Returns
string
See
https://stackoverflow.com/a/40649435/1938970
Defined in
normaliseUrlPathname
▸ normaliseUrlPathname(pathname?
): string
Normalise URL pathname (relative URL)
- replaces too many consecutive slashes
- removes the trailing slash
Parameters
Name | Type | Default value |
---|---|---|
pathname | string | "" |
Returns
string
Defined in
parseURL
▸ parseURL(url
): null
| { hash
: string
; host
: string
; hostname
: string
; href
: string
= url; pathname
: string
; port
: string
; protocol
: string
; search
: string
}
Solution without DOM or specific env native methods
Parameters
Name | Type |
---|---|
url | string |
Returns
null
| { hash
: string
; host
: string
; hostname
: string
; href
: string
= url; pathname
: string
; port
: string
; protocol
: string
; search
: string
}
See
https://stackoverflow.com/a/21553982/1938970
Defined in
removeTralingSlash
▸ removeTralingSlash(urlLike?
): string
Strips out the trailing slash
Parameters
Name | Type | Default value |
---|---|---|
urlLike | string | "" |
Returns
string
Defined in
removeUrlQueryParams
▸ removeUrlQueryParams(url
, paramsToRemove?
): string
Remove the given keys from the given URL query parameters
Parameters
Name | Type | Default value |
---|---|---|
url | string | undefined |
paramsToRemove | string [] | [] |
Returns
string
Defined in
transformToUrlPathname
▸ transformToUrlPathname(toPathname?
): string
Transform string in a URL pathname (relative URL)
- adds an initial slash
- encode the string
- replaces whitespaces with dashes
Parameters
Name | Type |
---|---|
toPathname? | string |
Returns
string
Defined in
updateLinkParams
▸ updateLinkParams($anchor
, newParams
): string
Update link <a href="">
merging the given new query parameters.
it returns the newly created href
URL value
Parameters
Name | Type |
---|---|
$anchor | HTMLAnchorElement |
newParams | Record <string | number , unknown > |
Returns
string
Pure
Defined in
updateUrlQueryParams
▸ updateUrlQueryParams(url
, newParams?
): string
Update a URL string query parameters merging the given new query parameters
Parameters
Name | Type |
---|---|
url | string |
newParams | Record <string | number , unknown > |
Returns
string
Defined in
math
arraySum
▸ arraySum(numbers
): number
Sum array of numbers
Parameters
Name | Type |
---|---|
numbers | number [] |
Returns
number
Defined in
clamp
▸ clamp(num
, min
, max
): number
Returns a number whose value is limited to the given range.
Parameters
Name | Type |
---|---|
num | number |
min | number |
max | number |
Returns
number
See
https://stackoverflow.com/a/11409944/1938970
Defined in
convertRange
▸ convertRange(num
, r1
, r2
): number
Convert range of a number
e.g. converting number 5 in a scale/range from 0 10 to a scale/range from 50 to 100 would return 75
Parameters
Name | Type |
---|---|
num | number |
r1 | number [] |
r2 | number [] |
Returns
number
Example
convertRange(5, [0, 10], [50, 100]);
See
https://stackoverflow.com/a/14224813
Defined in
randomInt
▸ randomInt(min
, max
): number
Get random int (min and max included)
Parameters
Name | Type |
---|---|
min | number |
max | number |
Returns
number
Defined in
roundTo
▸ roundTo(num
, decimals?
): string
Round to given number of the given number of decimals
Parameters
Name | Type | Default value |
---|---|---|
num | number | undefined |
decimals | number | 2 |
Returns
string
See
https://stackoverflow.com/a/15762794/1938970
Defined in
misc
randomKey
▸ randomKey<T
>(obj
): keyof T
Get random key from given object
Type parameters
Name | Type |
---|---|
T | extends Record <string | number , unknown > |
Parameters
Name | Type |
---|---|
obj | T |
Returns
keyof T
See
https://stackoverflow.com/a/15106541/1938970
Defined in
native
forin
▸ forin<T
>(object
, cb
): void
To easily get typed native for in
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
object | T |
cb | <K>(key : K , value : T [K ]) => void |
Returns
void
Defined in
getKeys
▸ getKeys<T
>(obj
): keyof T
[]
Type safe replacement for Object.keys(myObject)
to iterate over a record
without loosing the key's types in simple string
s.
Type parameters
Name | Type |
---|---|
T | extends object |
Parameters
Name | Type |
---|---|
obj | T |
Returns
keyof T
[]
See
https://stackoverflow.com/a/59459000/1938970
Defined in
lowercase
▸ lowercase<T
>(str?
): Lowercase
<T
>
Replacement for native toLowercase
tyescript ready (type narrowing ready)
Type parameters
Name | Type |
---|---|
T | extends string |
Parameters
Name | Type |
---|---|
str? | null | T |
Returns
Lowercase
<T
>
Defined in
noop
▸ noop(): undefined
| void
No operation function
Returns
undefined
| void
Defined in
uppercase
▸ uppercase<T
>(str?
): Uppercase
<T
>
Replacement for native toUpperCase
tyescript ready (type narrowing ready)
Type parameters
Name | Type |
---|---|
T | extends string |
Parameters
Name | Type |
---|---|
str? | null | T |
Returns
Uppercase
<T
>
Defined in
object
areEqual
▸ areEqual(a
, b?
): boolean
A simple and quick deep equal objects utility. This is meant to be used
solely to deduplicate requests payload and perform comparison on JSON ready
objects made of primitives string
, number
and boolean
s.
It support nested object
s and array
s only.
NB: undefined
and null
values do not count in the comparison as they are
usually meant to be ignored in JSON requestBody payloads.
According to very rudimentary tests this function takes on average between 0.15 ms and 2ms to compare two averaged sizes requet body payloads.
Parameters
Name | Type |
---|---|
a | Comparable |
b? | Comparable |
Returns
boolean
Defined in
forin
▸ forin<T
>(object
, cb
): void
To easily get typed native for in
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
object | T |
cb | <K>(key : K , value : T [K ]) => void |
Returns
void
Defined in
getKeys
▸ getKeys<T
>(obj
): keyof T
[]
Type safe replacement for Object.keys(myObject)
to iterate over a record
without loosing the key's types in simple string
s.
Type parameters
Name | Type |
---|---|
T | extends object |
Parameters
Name | Type |
---|---|
obj | T |
Returns
keyof T
[]
See
https://stackoverflow.com/a/59459000/1938970
Defined in
mergeObjects
▸ mergeObjects<T
>(target
, ...sources
): T
Merge two or more objects together. It mutates the target object.
Type parameters
Name | Type |
---|---|
T | extends object = object |
Parameters
Name | Type |
---|---|
target | T |
...sources | Partial <T >[] |
Returns
T
See
https://stackoverflow.com/a/46973278/1938970
Defined in
objectFlip
▸ objectFlip<T
, U
>(input
, keyTransformer?
): Record
<U
, T
>
Type parameters
Name | Type |
---|---|
T | extends PropertyKey |
U | extends PropertyKey |
Parameters
Name | Type |
---|---|
input | Record <T , U > |
keyTransformer? | (key : string ) => T |
Returns
Record
<U
, T
>
Borrows
Defined in
objectOmit
▸ objectOmit<T
, Keys
>(object
, keys
): Omit
<T
, Keys
[number
]>
Omit object properties by removing the given keys, it returns a new object.
NOTE: most of the time using a normal destructuring assignment is enough, use this utility only when it makes sense.
Type parameters
Name | Type |
---|---|
T | extends object |
Keys | extends keyof T [] |
Parameters
Name | Type |
---|---|
object | T |
keys | Keys |
Returns
Omit
<T
, Keys
[number
]>
Defined in
objectPick
▸ objectPick<T
, Keys
>(object
, keys
): Pick
<T
, Keys
[number
]>
Pick object properties by selecting only the given keys, it returns a new object.
Type parameters
Name | Type |
---|---|
T | extends object |
Keys | extends keyof T [] |
Parameters
Name | Type |
---|---|
object | T |
keys | Keys |
Returns
Pick
<T
, Keys
[number
]>
Defined in
swapMap
▸ swapMap<T
>(map?
): Record
<T
[keyof T
], keyof T
>
Swap object map key/value
Type parameters
Name | Type |
---|---|
T | extends Record <string , string | number | symbol > = Record <string , string | number | symbol > |
Parameters
Name | Type |
---|---|
map | T |
Returns
Record
<T
[keyof T
], keyof T
>
Defined in
responsive
GetMediaQueryWidthResolversBreakpoints
Ƭ GetMediaQueryWidthResolversBreakpoints: Record
<string
, number
>
Defined in
getMediaQueryWidthResolvers.ts:4
createPalette
▸ createPalette<TName
, TShades
, TColor
, TMap
>(name
, shades
): readonly [TMap
, Record
<`${TName}-${TShades[number][0]}`, string
>, TColor
[]]
Create palette, this is primarily thought to improve the reuse of a palette definition between TailwindCSS and straight ES imports
Type parameters
Name | Type |
---|---|
TName | extends string |
TShades | extends PaletteShades |
TColor | TShades [number ][``1``] |
TMap | PaletteMap <TShades > |
Parameters
Name | Type |
---|---|
name | TName |
shades | TShades |
Returns
readonly [TMap
, Record
<`${TName}-${TShades[number][0]}`, string
>, TColor
[]]
An array with: 1) A flat palette map 2) A TailwindCSS ready palette
object 3) A flat array of colors (no special sorting, same order as the shades
given as argument)
Defined in
getMediaQueryWidthResolvers
▸ getMediaQueryWidthResolvers<TBreakpointsConfig
>(customBreakpoints
): Object
Type parameters
Name | Type |
---|---|
TBreakpointsConfig | extends GetMediaQueryWidthResolversBreakpoints |
Parameters
Name | Type |
---|---|
customBreakpoints | TBreakpointsConfig |
Returns
Object
Name | Type |
---|---|
between | (br1 : Extract <keyof TBreakpointsConfig , string >, br2? : Extract <keyof TBreakpointsConfig , string >) => string |
down | (br : Extract <keyof TBreakpointsConfig , string >) => string |
max | (br : Extract <keyof TBreakpointsConfig , string >) => string |
min | (br : Extract <keyof TBreakpointsConfig , string >) => string |
only | (br : Extract <keyof TBreakpointsConfig , string >) => string |
up | (br : Extract <keyof TBreakpointsConfig , string >) => string |
Defined in
getMediaQueryWidthResolvers.ts:9
getMediaQueryWidthTailwindScreens
▸ getMediaQueryWidthTailwindScreens(breakpoints
): Record
<string
, { raw
: string
}>
Parameters
Name | Type |
---|---|
breakpoints | GetMediaQueryWidthResolversBreakpoints |
Returns
Record
<string
, { raw
: string
}>
Defined in
getMediaQueryWidthTailwindScreens.ts:10
security
decode
▸ decode<TReturn
>(str
): TReturn
Type parameters
Name | Type |
---|---|
TReturn | extends string |
Parameters
Name | Type |
---|---|
str | string |
Returns
TReturn
See
https://stackoverflow.com/a/22405578/9122820
Defined in
encode
▸ encode<TReturn
>(str
): TReturn
Type parameters
Name | Type |
---|---|
TReturn | extends string |
Parameters
Name | Type |
---|---|
str | string |
Returns
TReturn
See
https://stackoverflow.com/a/22405578/9122820
Defined in
getNonce
▸ getNonce(): null
| string
Returns
null
| string
See
Defined in
ssr
isBrowser
• Const
isBrowser: boolean
Defined in
isServer
• Const
isServer: boolean
= !isBrowser
Defined in
isBrowserNow
▸ isBrowserNow(): boolean
Returns
boolean
Defined in
isServerNow
▸ isServerNow(): boolean
Returns
boolean
Defined in
tailwind
createPalette
▸ createPalette<TName
, TShades
, TColor
, TMap
>(name
, shades
): readonly [TMap
, Record
<`${TName}-${TShades[number][0]}`, string
>, TColor
[]]
Create palette, this is primarily thought to improve the reuse of a palette definition between TailwindCSS and straight ES imports
Type parameters
Name | Type |
---|---|
TName | extends string |
TShades | extends PaletteShades |
TColor | TShades [number ][``1``] |
TMap | PaletteMap <TShades > |
Parameters
Name | Type |
---|---|
name | TName |
shades | TShades |
Returns
readonly [TMap
, Record
<`${TName}-${TShades[number][0]}`, string
>, TColor
[]]
An array with: 1) A flat palette map 2) A TailwindCSS ready palette
object 3) A flat array of colors (no special sorting, same order as the shades
given as argument)
Defined in
getMediaQueryWidthTailwindScreens
▸ getMediaQueryWidthTailwindScreens(breakpoints
): Record
<string
, { raw
: string
}>
Parameters
Name | Type |
---|---|
breakpoints | GetMediaQueryWidthResolversBreakpoints |
Returns
Record
<string
, { raw
: string
}>
Defined in
getMediaQueryWidthTailwindScreens.ts:10
text
AccentsSet
Ƭ AccentsSet: [string
, string
]
First value is the to
, second is from
, from which chars do we translates to
Defined in
accentsSets
• Const
accentsSets: AccentsSet
[]
Accent sets
Resources
- https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
- https://gist.github.com/eek/9c4887e80b3ede05c0e39fee4dce3747 for usage of normalize
Defined in
capitalize
▸ capitalize<T
>(string?
): Capitalize
<T
>
Capitalize first letter of the given string.
Type parameters
Name | Type |
---|---|
T | extends string |
Parameters
Name | Type |
---|---|
string? | null | T |
Returns
Capitalize
<T
>
Resources
Defined in
removeAccents
▸ removeAccents(text?
, sets?
): string
Parameters
Name | Type | Default value |
---|---|---|
text | string | "" |
sets | AccentsSet [] | accentsSets |
Returns
string
Defined in
slugify
▸ slugify(text
, separator?
): string
Slugify a text
- replaces the accented letters
- replaces the punctuation with dashes
Parameters
Name | Type | Default value |
---|---|---|
text | string | undefined |
separator | string | "-" |
Returns
string
Borrows
Defined in
titleCase
▸ titleCase(input?
): string
Parameters
Name | Type |
---|---|
input? | null | string |
Returns
string
Borrows
License
Blake Embrey (hello@blakeembrey.com)
Defined in
truncate
▸ truncate(input
, length
): string
Truncate string
Parameters
Name | Type |
---|---|
input | undefined | null | string |
length | number |
Returns
string
Defined in
uppercase
▸ uppercase<T
>(str?
): Uppercase
<T
>
Replacement for native toUpperCase
tyescript ready (type narrowing ready)
Type parameters
Name | Type |
---|---|
T | extends string |
Parameters
Name | Type |
---|---|
str? | null | T |
Returns
Uppercase
<T
>
Defined in
uid
uid
▸ uid(prefix?
): string
Super basic UID increment-based generator
Parameters
Name | Type | Default value |
---|---|---|
prefix | string | "id" |
Returns
string
Defined in
uuid
▸ uuid(): string
Uuid, tiny custom helper instead of node's uuid/v4
Returns
string
See
https://stackoverflow.com/a/2117523/1938970
Defined in
uuidNumeric
▸ uuidNumeric(): number
Returns
number
See
https://stackoverflow.com/a/18048162/1938970