Utils Reference
⚒️ Lou’s TypeScript curried functional utils.
Usage
📦 Node
Install @lou.codes/utils
as a dependency:
Import it and use it:
🦕 Deno
Import @lou.codes/utils
using the npm:
prefix, and use it directly:
🌎 Browser
Import @lou.codes/utils
using esm.sh, and use it directly:
Useful links
- 📝 Documentation: TypeDoc generated documentation.
- ⏳ Changelog: List of changes between versions.
- ✅ Tests Coverage: Coveralls page with tests coverage.
Classes
bind
▸ bind<Context
>(context
): <Method>(method
: Method
) => Method
Bounds the given context to the given method.
Type parameters
Name |
---|
Context |
Parameters
Name | Type |
---|---|
context | Context |
Returns
fn
Curried function with context
in context.
▸ <Method
>(method
): Method
Type parameters
Name | Type |
---|---|
Method | extends Function |
Parameters
Name | Type |
---|---|
method | Method |
Returns
Method
Example
construct
▸ construct<Constructor
>(constructor
): (…constructorArguments
:
ConstructorParameters
<Constructor
>) =>
Unbound
<InstanceType
<Constructor
>>
Creates a new instance of the given constructor with the given arguments. This also binds all functions to the instance.
Type parameters
Name | Type |
---|---|
Constructor | extends Class <never > |
Parameters
Name | Type |
---|---|
constructor | Constructor |
Returns
fn
Curried function with constructor
in context.
▸ (...constructorArguments
): Unbound
<InstanceType
<Constructor
>>
Parameters
Name | Type |
---|---|
...constructorArguments | ConstructorParameters <Constructor > |
Returns
Unbound
<InstanceType
<Constructor
>>
Example
constructArray
▸ constructArray<Item
>(length
): Object
Functional alias for new Array()
.
Type parameters
Name |
---|
Item |
Parameters
Name | Type |
---|---|
length | number |
Returns
Object
Name | Type | Description |
---|---|---|
[unscopables] | { [unscopables]? : boolean ; length? : boolean ; [iterator]? : { valueOf : () => boolean } ; at? : { valueOf : () => boolean } ; concat? : { valueOf : () => boolean } ; entries? : { valueOf : () => boolean } ; every? : { valueOf : () => boolean } ; filter? : { valueOf : () => boolean } ; find? : { valueOf : () => boolean } ; findIndex? : { valueOf : () => boolean } ; findLast? : { valueOf : () => boolean } ; findLastIndex? : { valueOf : () => boolean } ; flat? : { valueOf : () => boolean } ; flatMap? : { valueOf : () => boolean } ; forEach? : { valueOf : () => boolean } ; includes? : { valueOf : () => boolean } ; indexOf? : { valueOf : () => boolean } ; join? : { valueOf : () => boolean } ; keys? : { valueOf : () => boolean } ; lastIndexOf? : { valueOf : () => boolean } ; map? : { valueOf : () => boolean } ; reduce? : { valueOf : () => boolean } ; reduceRight? : { valueOf : () => boolean } ; slice? : { valueOf : () => boolean } ; some? : { valueOf : () => boolean } ; toLocaleString? : { valueOf : () => boolean } ; toReversed? : { valueOf : () => boolean } ; toSorted? : { valueOf : () => boolean } ; toSpliced? : { valueOf : () => boolean } ; toString? : { valueOf : () => boolean } ; values? : { valueOf : () => boolean } ; with? : { valueOf : () => boolean } } | Is an object whose properties have the value ‘true’ when they will be absent when used in a ‘with’ statement. |
[unscopables].[unscopables] (optional) | boolean | Is an object whose properties have the value ‘true’ when they will be absent when used in a ‘with’ statement. |
[unscopables].length (optional) | boolean | Gets the length of the array. This is a number one higher than the highest element defined in an array. |
[unscopables].[iterator] (optional) | [object Object] | - |
[unscopables].at (optional) | [object Object] | - |
[unscopables].concat (optional) | [object Object] | - |
[unscopables].entries (optional) | [object Object] | - |
[unscopables].every (optional) | [object Object] | - |
[unscopables].filter (optional) | [object Object] | - |
[unscopables].find (optional) | [object Object] | - |
[unscopables].findIndex (optional) | [object Object] | - |
[unscopables].findLast (optional) | [object Object] | - |
[unscopables].findLastIndex (optional) | [object Object] | - |
[unscopables].flat (optional) | [object Object] | - |
[unscopables].flatMap (optional) | [object Object] | - |
[unscopables].forEach (optional) | [object Object] | - |
[unscopables].includes (optional) | [object Object] | - |
[unscopables].indexOf (optional) | [object Object] | - |
[unscopables].join (optional) | [object Object] | - |
[unscopables].keys (optional) | [object Object] | - |
[unscopables].lastIndexOf (optional) | [object Object] | - |
[unscopables].map (optional) | [object Object] | - |
[unscopables].reduce (optional) | [object Object] | - |
[unscopables].reduceRight (optional) | [object Object] | - |
[unscopables].slice (optional) | [object Object] | - |
[unscopables].some (optional) | [object Object] | - |
[unscopables].toLocaleString (optional) | [object Object] | - |
[unscopables].toReversed (optional) | [object Object] | - |
[unscopables].toSorted (optional) | [object Object] | - |
[unscopables].toSpliced (optional) | [object Object] | - |
[unscopables].toString (optional) | [object Object] | - |
[unscopables].values (optional) | [object Object] | - |
[unscopables].with (optional) | [object Object] | - |
length | number | Gets the length of the array. This is a number one higher than the highest element defined in an array. |
[iterator] | (this : void , …methodArguments : []) => IterableIterator <Item > | - |
at | (this : void , …methodArguments : [index: number]) => undefined | Item | - |
concat | (this : void , …methodArguments : (Item | ConcatArray <Item >)[]) => Item [] | - |
entries | (this : void , …methodArguments : []) => IterableIterator <[number , Item ]> | - |
every | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => boolean | - |
filter | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => Item [] | - |
find | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => undefined | Item | - |
findIndex | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => number | - |
findLast | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => undefined | Item | - |
findLastIndex | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => number | - |
flat | (this : void , …methodArguments : [depth?: number]) => unknown [] | - |
flatMap | (this : void , …methodArguments : [callback: Function, thisArg?: unknown]) => unknown [] | - |
forEach | (this : void , …methodArguments : [callbackfn: Function, thisArg?: any]) => void | - |
includes | (this : void , …methodArguments : [searchElement: Item, fromIndex?: number]) => boolean | - |
indexOf | (this : void , …methodArguments : [searchElement: Item, fromIndex?: number]) => number | - |
join | (this : void , …methodArguments : [separator?: string]) => string | - |
keys | (this : void , …methodArguments : []) => IterableIterator <number > | - |
lastIndexOf | (this : void , …methodArguments : [searchElement: Item, fromIndex?: number]) => number | - |
map | (this : void , …methodArguments : [callbackfn: Function, thisArg?: any]) => unknown [] | - |
reduce | (this : void , …methodArguments : [callbackfn: Function, initialValue: unknown]) => unknown | - |
reduceRight | (this : void , …methodArguments : [callbackfn: Function, initialValue: unknown]) => unknown | - |
slice | (this : void , …methodArguments : [start?: number, end?: number]) => Item [] | - |
some | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => boolean | - |
toLocaleString | (this : void , …methodArguments : []) => string | - |
toReversed | (this : void , …methodArguments : []) => Item [] | - |
toSorted | (this : void , …methodArguments : [compareFn?: Function]) => Item [] | - |
toSpliced | (this : void , …methodArguments : [start: number, deleteCount?: number]) => Item [] | - |
toString | (this : void , …methodArguments : []) => string | - |
values | (this : void , …methodArguments : []) => IterableIterator <Item > | - |
with | (this : void , …methodArguments : [index: number, value: Item]) => Item [] | - |
▸ constructArray<Items
>(...items
): Object
Functional alias for new Array()
.
Type parameters
Name | Type |
---|---|
Items | extends ReadOnlyArray |
Parameters
Name | Type |
---|---|
...items | Items |
Returns
Object
Name | Type | Description |
---|---|---|
[unscopables] | { [unscopables]? : boolean ; length? : boolean ; [iterator]? : { valueOf : () => boolean } ; at? : { valueOf : () => boolean } ; concat? : { valueOf : () => boolean } ; entries? : { valueOf : () => boolean } ; every? : { valueOf : () => boolean } ; filter? : { valueOf : () => boolean } ; find? : { valueOf : () => boolean } ; findIndex? : { valueOf : () => boolean } ; findLast? : { valueOf : () => boolean } ; findLastIndex? : { valueOf : () => boolean } ; flat? : { valueOf : () => boolean } ; flatMap? : { valueOf : () => boolean } ; forEach? : { valueOf : () => boolean } ; includes? : { valueOf : () => boolean } ; indexOf? : { valueOf : () => boolean } ; join? : { valueOf : () => boolean } ; keys? : { valueOf : () => boolean } ; lastIndexOf? : { valueOf : () => boolean } ; map? : { valueOf : () => boolean } ; reduce? : { valueOf : () => boolean } ; reduceRight? : { valueOf : () => boolean } ; slice? : { valueOf : () => boolean } ; some? : { valueOf : () => boolean } ; toLocaleString? : { valueOf : () => boolean } ; toReversed? : { valueOf : () => boolean } ; toSorted? : { valueOf : () => boolean } ; toSpliced? : { valueOf : () => boolean } ; toString? : { valueOf : () => boolean } ; values? : { valueOf : () => boolean } ; with? : { valueOf : () => boolean } } | Is an object whose properties have the value ‘true’ when they will be absent when used in a ‘with’ statement. |
[unscopables].[unscopables] (optional) | boolean | Is an object whose properties have the value ‘true’ when they will be absent when used in a ‘with’ statement. |
[unscopables].length (optional) | boolean | Gets the length of the array. This is a number one higher than the highest element defined in an array. |
[unscopables].[iterator] (optional) | [object Object] | - |
[unscopables].at (optional) | [object Object] | - |
[unscopables].concat (optional) | [object Object] | - |
[unscopables].entries (optional) | [object Object] | - |
[unscopables].every (optional) | [object Object] | - |
[unscopables].filter (optional) | [object Object] | - |
[unscopables].find (optional) | [object Object] | - |
[unscopables].findIndex (optional) | [object Object] | - |
[unscopables].findLast (optional) | [object Object] | - |
[unscopables].findLastIndex (optional) | [object Object] | - |
[unscopables].flat (optional) | [object Object] | - |
[unscopables].flatMap (optional) | [object Object] | - |
[unscopables].forEach (optional) | [object Object] | - |
[unscopables].includes (optional) | [object Object] | - |
[unscopables].indexOf (optional) | [object Object] | - |
[unscopables].join (optional) | [object Object] | - |
[unscopables].keys (optional) | [object Object] | - |
[unscopables].lastIndexOf (optional) | [object Object] | - |
[unscopables].map (optional) | [object Object] | - |
[unscopables].reduce (optional) | [object Object] | - |
[unscopables].reduceRight (optional) | [object Object] | - |
[unscopables].slice (optional) | [object Object] | - |
[unscopables].some (optional) | [object Object] | - |
[unscopables].toLocaleString (optional) | [object Object] | - |
[unscopables].toReversed (optional) | [object Object] | - |
[unscopables].toSorted (optional) | [object Object] | - |
[unscopables].toSpliced (optional) | [object Object] | - |
[unscopables].toString (optional) | [object Object] | - |
[unscopables].values (optional) | [object Object] | - |
[unscopables].with (optional) | [object Object] | - |
length | number | Gets the length of the array. This is a number one higher than the highest element defined in an array. |
[iterator] | (this : void , …methodArguments : []) => IterableIterator <Items [number ]> | - |
at | (this : void , …methodArguments : [index: number]) => undefined | Items [number ] | - |
concat | (this : void , …methodArguments : (Items [number ] | ConcatArray <Items [number ]>)[]) => Items [number ][] | - |
entries | (this : void , …methodArguments : []) => IterableIterator <[number , Items [number ]]> | - |
every | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => boolean | - |
filter | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => Items [number ][] | - |
find | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => undefined | Items [number ] | - |
findIndex | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => number | - |
findLast | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => undefined | Items [number ] | - |
findLastIndex | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => number | - |
flat | (this : void , …methodArguments : [depth?: number]) => unknown [] | - |
flatMap | (this : void , …methodArguments : [callback: Function, thisArg?: unknown]) => unknown [] | - |
forEach | (this : void , …methodArguments : [callbackfn: Function, thisArg?: any]) => void | - |
includes | (this : void , …methodArguments : [searchElement: Items[number], fromIndex?: number]) => boolean | - |
indexOf | (this : void , …methodArguments : [searchElement: Items[number], fromIndex?: number]) => number | - |
join | (this : void , …methodArguments : [separator?: string]) => string | - |
keys | (this : void , …methodArguments : []) => IterableIterator <number > | - |
lastIndexOf | (this : void , …methodArguments : [searchElement: Items[number], fromIndex?: number]) => number | - |
map | (this : void , …methodArguments : [callbackfn: Function, thisArg?: any]) => unknown [] | - |
reduce | (this : void , …methodArguments : [callbackfn: Function, initialValue: unknown]) => unknown | - |
reduceRight | (this : void , …methodArguments : [callbackfn: Function, initialValue: unknown]) => unknown | - |
slice | (this : void , …methodArguments : [start?: number, end?: number]) => Items [number ][] | - |
some | (this : void , …methodArguments : [predicate: Function, thisArg?: any]) => boolean | - |
toLocaleString | (this : void , …methodArguments : []) => string | - |
toReversed | (this : void , …methodArguments : []) => Items [number ][] | - |
toSorted | (this : void , …methodArguments : [compareFn?: Function]) => Items [number ][] | - |
toSpliced | (this : void , …methodArguments : [start: number, deleteCount?: number]) => Items [number ][] | - |
toString | (this : void , …methodArguments : []) => string | - |
values | (this : void , …methodArguments : []) => IterableIterator <Items [number ]> | - |
with | (this : void , …methodArguments : [index: number, value: Items[number]]) => Items [number ][] | - |
constructDataView
▸ constructDataView(...constructorArguments
): Object
Functional alias for new DataView()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [buffer: ArrayBufferLike & Object, byteOffset?: number, byteLength?: number] |
Returns
Object
Name | Type |
---|---|
[toStringTag] | string |
buffer | ArrayBuffer |
byteLength | number |
byteOffset | number |
getBigInt64 | (this : void , …methodArguments : [byteOffset: number, littleEndian?: boolean]) => bigint |
getBigUint64 | (this : void , …methodArguments : [byteOffset: number, littleEndian?: boolean]) => bigint |
getFloat32 | (this : void , …methodArguments : [byteOffset: number, littleEndian?: boolean]) => number |
getFloat64 | (this : void , …methodArguments : [byteOffset: number, littleEndian?: boolean]) => number |
getInt16 | (this : void , …methodArguments : [byteOffset: number, littleEndian?: boolean]) => number |
getInt32 | (this : void , …methodArguments : [byteOffset: number, littleEndian?: boolean]) => number |
getInt8 | (this : void , …methodArguments : [byteOffset: number]) => number |
getUint16 | (this : void , …methodArguments : [byteOffset: number, littleEndian?: boolean]) => number |
getUint32 | (this : void , …methodArguments : [byteOffset: number, littleEndian?: boolean]) => number |
getUint8 | (this : void , …methodArguments : [byteOffset: number]) => number |
setBigInt64 | (this : void , …methodArguments : [byteOffset: number, value: bigint, littleEndian?: boolean]) => void |
setBigUint64 | (this : void , …methodArguments : [byteOffset: number, value: bigint, littleEndian?: boolean]) => void |
setFloat32 | (this : void , …methodArguments : [byteOffset: number, value: number, littleEndian?: boolean]) => void |
setFloat64 | (this : void , …methodArguments : [byteOffset: number, value: number, littleEndian?: boolean]) => void |
setInt16 | (this : void , …methodArguments : [byteOffset: number, value: number, littleEndian?: boolean]) => void |
setInt32 | (this : void , …methodArguments : [byteOffset: number, value: number, littleEndian?: boolean]) => void |
setInt8 | (this : void , …methodArguments : [byteOffset: number, value: number]) => void |
setUint16 | (this : void , …methodArguments : [byteOffset: number, value: number, littleEndian?: boolean]) => void |
setUint32 | (this : void , …methodArguments : [byteOffset: number, value: number, littleEndian?: boolean]) => void |
setUint8 | (this : void , …methodArguments : [byteOffset: number, value: number]) => void |
constructDate
▸ constructDate(date?
): Object
Functional alias for new Date()
.
Parameters
Name | Type |
---|---|
date (optional) | string | number | Readonly <Date > |
Returns
Object
Name | Type |
---|---|
getVarDate | (this : void , …methodArguments : []) => VarDate |
[toPrimitive] | (this : void , …methodArguments : [hint: string]) => string | number |
getDate | (this : void , …methodArguments : []) => number |
getDay | (this : void , …methodArguments : []) => number |
getFullYear | (this : void , …methodArguments : []) => number |
getHours | (this : void , …methodArguments : []) => number |
getMilliseconds | (this : void , …methodArguments : []) => number |
getMinutes | (this : void , …methodArguments : []) => number |
getMonth | (this : void , …methodArguments : []) => number |
getSeconds | (this : void , …methodArguments : []) => number |
getTime | (this : void , …methodArguments : []) => number |
getTimezoneOffset | (this : void , …methodArguments : []) => number |
getUTCDate | (this : void , …methodArguments : []) => number |
getUTCDay | (this : void , …methodArguments : []) => number |
getUTCFullYear | (this : void , …methodArguments : []) => number |
getUTCHours | (this : void , …methodArguments : []) => number |
getUTCMilliseconds | (this : void , …methodArguments : []) => number |
getUTCMinutes | (this : void , …methodArguments : []) => number |
getUTCMonth | (this : void , …methodArguments : []) => number |
getUTCSeconds | (this : void , …methodArguments : []) => number |
setDate | (this : void , …methodArguments : [date: number]) => number |
setFullYear | (this : void , …methodArguments : [year: number, month?: number, date?: number]) => number |
setHours | (this : void , …methodArguments : [hours: number, min?: number, sec?: number, ms?: number]) => number |
setMilliseconds | (this : void , …methodArguments : [ms: number]) => number |
setMinutes | (this : void , …methodArguments : [min: number, sec?: number, ms?: number]) => number |
setMonth | (this : void , …methodArguments : [month: number, date?: number]) => number |
setSeconds | (this : void , …methodArguments : [sec: number, ms?: number]) => number |
setTime | (this : void , …methodArguments : [time: number]) => number |
setUTCDate | (this : void , …methodArguments : [date: number]) => number |
setUTCFullYear | (this : void , …methodArguments : [year: number, month?: number, date?: number]) => number |
setUTCHours | (this : void , …methodArguments : [hours: number, min?: number, sec?: number, ms?: number]) => number |
setUTCMilliseconds | (this : void , …methodArguments : [ms: number]) => number |
setUTCMinutes | (this : void , …methodArguments : [min: number, sec?: number, ms?: number]) => number |
setUTCMonth | (this : void , …methodArguments : [month: number, date?: number]) => number |
setUTCSeconds | (this : void , …methodArguments : [sec: number, ms?: number]) => number |
toDateString | (this : void , …methodArguments : []) => string |
toISOString | (this : void , …methodArguments : []) => string |
toJSON | (this : void , …methodArguments : [key?: any]) => string |
toLocaleDateString | (this : void , …methodArguments : [locales?: LocalesArgument, options?: DateTimeFormatOptions]) => string |
toLocaleString | (this : void , …methodArguments : [locales?: LocalesArgument, options?: DateTimeFormatOptions]) => string |
toLocaleTimeString | (this : void , …methodArguments : [locales?: LocalesArgument, options?: DateTimeFormatOptions]) => string |
toString | (this : void , …methodArguments : []) => string |
toTimeString | (this : void , …methodArguments : []) => string |
toUTCString | (this : void , …methodArguments : []) => string |
valueOf | (this : void , …methodArguments : []) => number |
constructError
▸ constructError(...constructorArguments
): Object
Functional alias for new Error()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [message?: string, options?: ErrorOptions] |
Returns
Object
Name | Type |
---|---|
cause (optional) | unknown |
message | string |
name | string |
stack (optional) | string |
constructIntlCollator
▸ constructIntlCollator(...constructorArguments
): Object
Functional alias for new Intl.Collator()
, which enables language-sensitive
string comparison.
Parameters
Name | Type |
---|---|
...constructorArguments | [locales?: LocalesArgument, options?: CollatorOptions] |
Returns
Object
Name | Type |
---|---|
compare | (this : void , …methodArguments : [x: string, y: string]) => number |
resolvedOptions | (this : void , …methodArguments : []) => ResolvedCollatorOptions |
See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator
constructIntlDateTimeFormat
▸ constructIntlDateTimeFormat(...constructorArguments
): Object
Functional alias for new Intl.DateTimeFormat()
, which enables
language-sensitive date and time formatting.
Parameters
Name | Type |
---|---|
...constructorArguments | [locales?: LocalesArgument, options?: DateTimeFormatOptions] |
Returns
Object
Name | Type |
---|---|
format | (this : void , …methodArguments : [date?: number | Date]) => string |
formatRange | (this : void , …methodArguments : [startDate: number | bigint | Date, endDate: number | bigint | Date]) => string |
formatRangeToParts | (this : void , …methodArguments : [startDate: number | bigint | Date, endDate: number | bigint | Date]) => DateTimeRangeFormatPart [] |
formatToParts | (this : void , …methodArguments : [date?: number | Date]) => DateTimeFormatPart [] |
resolvedOptions | (this : void , …methodArguments : []) => ResolvedDateTimeFormatOptions |
See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
constructIntlLocale
▸ constructIntlLocale(tag
, options?
): Object
Functional alias for new Intl.Locale()
, which represents a Unicode locale
identifier.
Parameters
Name | Type |
---|---|
tag | Readonly <Locale | LocaleIdentifier > |
options (optional) | Readonly <LocaleOptions > |
Returns
Object
Name | Type | Description |
---|---|---|
baseName | string | A string containing the language, and the script and region if available. |
calendar (optional) | string | The part of the Locale that indicates the locale’s calendar era. |
caseFirst (optional) | LocaleCollationCaseFirst | Flag that defines whether case is taken into account for the locale’s collation rules. |
collation (optional) | string | The collation type used for sorting |
hourCycle (optional) | LocaleHourCycleKey | The time keeping format convention used by the locale. |
language | string | The primary language subtag associated with the locale. |
numberingSystem (optional) | string | The numeral system used by the locale. |
numeric (optional) | boolean | Flag that defines whether the locale has special collation handling for numeric characters. |
region (optional) | string | The region of the world (usually a country) associated with the locale. Possible values are region codes as defined by ISO 3166-1. |
script (optional) | string | The script used for writing the particular language used in the locale. Possible values are script codes as defined by ISO 15924. |
maximize | (this : void , …methodArguments : []) => Locale | - |
minimize | (this : void , …methodArguments : []) => Locale | - |
toString | (this : void , …methodArguments : []) => string | - |
See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale
constructIntlNumberFormat
▸ constructIntlNumberFormat(...constructorArguments
): Object
Functional alias for new Intl.NumberFormat()
, which enables language-sensitive
number formatting.
Parameters
Name | Type |
---|---|
...constructorArguments | [locales?: LocalesArgument, options?: NumberFormatOptions] |
Returns
Object
Name | Type |
---|---|
format | (this : void , …methodArguments : [value: number | bigint]) => string |
formatRange | (this : void , …methodArguments : [start: number | bigint, end: number | bigint]) => string |
formatRangeToParts | (this : void , …methodArguments : [start: number | bigint, end: number | bigint]) => NumberRangeFormatPart [] |
formatToParts | (this : void , …methodArguments : [number?: number | bigint]) => NumberFormatPart [] |
resolvedOptions | (this : void , …methodArguments : []) => ResolvedNumberFormatOptions |
See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
constructIntlPluralRules
▸ constructIntlPluralRules(...constructorArguments
): Object
Functional alias for new Intl.PluralRules()
, which enables plural-sensitive
formatting and plural-related language rules.
Parameters
Name | Type |
---|---|
...constructorArguments | [locales?: LocalesArgument, options?: PluralRulesOptions] |
Returns
Object
Name | Type |
---|---|
resolvedOptions | (this : void , …methodArguments : []) => ResolvedPluralRulesOptions |
select | (this : void , …methodArguments : [n: number]) => LDMLPluralRule |
See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules
constructIntlRelativeTimeFormat
▸ constructIntlRelativeTimeFormat(...constructorArguments
): Object
Functional alias for new Intl.RelativeTimeFormat()
, which enables
language-sensitive relative time formatting.
Parameters
Name | Type |
---|---|
...constructorArguments | [locales?: LocalesArgument, options?: RelativeTimeFormatOptions] |
Returns
Object
Name | Type |
---|---|
format | (this : void , …methodArguments : [value: number, unit: RelativeTimeFormatUnit]) => string |
formatToParts | (this : void , …methodArguments : [value: number, unit: RelativeTimeFormatUnit]) => RelativeTimeFormatPart [] |
resolvedOptions | (this : void , …methodArguments : []) => ResolvedRelativeTimeFormatOptions |
See
constructMap
▸ constructMap<Key
, Value
>(iterable?
): Object
Functional alias for new Map()
.
Type parameters
Name |
---|
Key |
Value |
Parameters
Name | Type |
---|---|
iterable (optional) | Iterable <readonly [Key , Value ]> |
Returns
Object
Name | Type | Description |
---|---|---|
[toStringTag] | string | - |
size | number | |
[iterator] | (this : void , …methodArguments : []) => IterableIterator <[Key , Value ]> | - |
clear | (this : void , …methodArguments : []) => void | - |
delete | (this : void , …methodArguments : [key: Key]) => boolean | - |
entries | (this : void , …methodArguments : []) => IterableIterator <[Key , Value ]> | - |
forEach | (this : void , …methodArguments : [callbackfn: Function, thisArg?: any]) => void | - |
get | (this : void , …methodArguments : [key: Key]) => undefined | Value | - |
has | (this : void , …methodArguments : [key: Key]) => boolean | - |
keys | (this : void , …methodArguments : []) => IterableIterator <Key > | - |
set | (this : void , …methodArguments : [key: Key, value: Value]) => Map <Key , Value > | - |
values | (this : void , …methodArguments : []) => IterableIterator <Value > | - |
constructPromise
▸ constructPromise<Value
>(executor
): Object
Functional alias for new Promise()
.
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
executor | (resolve : (value : Value ) => void , reject : (reason? : unknown ) => void ) => void |
Returns
Object
Name | Type | Description |
---|---|---|
catch | <RejectedValue>(this : void , onrejected? : Unary <unknown , RejectedValue | PromiseLike <RejectedValue >>) => Promise <Value | RejectedValue > | - |
then | <ResolvedValue, RejectedValue>(this : void , onResolved? : Unary <Value , ResolvedValue | PromiseLike <ResolvedValue >>, onRejected? : Unary <unknown , RejectedValue | PromiseLike <RejectedValue >>) => Promise <ResolvedValue | RejectedValue > | - |
constructProxy
▸ constructProxy<Target
>(target
, handler
): Unbound
<Target
>
Functional alias for new Proxy()
.
Type parameters
Name | Type |
---|---|
Target | extends object |
Parameters
Name | Type |
---|---|
target | Target |
handler | ProxyHandler <Target > |
Returns
Unbound
<Target
>
constructRangeError
▸ constructRangeError(...constructorArguments
): Object
Functional alias for new RangeError()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [message?: string, options?: ErrorOptions] |
Returns
Object
Name | Type |
---|---|
cause (optional) | unknown |
message | string |
name | string |
stack (optional) | string |
constructReferenceError
▸ constructReferenceError(...constructorArguments
): Object
Functional alias for new ReferenceError()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [message?: string, options?: ErrorOptions] |
Returns
Object
Name | Type |
---|---|
cause (optional) | unknown |
message | string |
name | string |
stack (optional) | string |
constructRegExp
▸ constructRegExp(...constructorArguments
): Object
Functional alias for new RegExp()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [pattern: string | RegExp, flags?: string] |
Returns
Object
Name | Type | Description |
---|---|---|
dotAll | boolean | Returns a Boolean value indicating the state of the dotAll flag (s) used with a regular expression. Default is false. Read-only. |
flags | string | Returns a string indicating the flags of the regular expression in question. This field is read-only. The characters in this string are sequenced and concatenated in the following order: - “g” for global - “i” for ignoreCase - “m” for multiline - “u” for unicode - “y” for sticky If no flags are set, the value is the empty string. |
global | boolean | Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. |
hasIndices | boolean | Returns a Boolean value indicating the state of the hasIndices flag (d) used with with a regular expression. Default is false. Read-only. |
ignoreCase | boolean | Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. |
lastIndex | number | - |
multiline | boolean | Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. |
source | string | Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. |
sticky | boolean | Returns a Boolean value indicating the state of the sticky flag (y) used with a regular expression. Default is false. Read-only. |
unicode | boolean | Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular expression. Default is false. Read-only. |
[matchAll] | (this : void , …methodArguments : [str: string]) => IterableIterator <RegExpMatchArray > | - |
[match] | (this : void , …methodArguments : [string: string]) => null | RegExpMatchArray | - |
[replace] | (this : void , …methodArguments : [string: string, replacer: Function]) => string | - |
[search] | (this : void , …methodArguments : [string: string]) => number | - |
[split] | (this : void , …methodArguments : [string: string, limit?: number]) => string [] | - |
compile | (this : void , …methodArguments : [pattern: string, flags?: string]) => RegExp | - |
exec | (this : void , …methodArguments : [string: string]) => null | RegExpExecArray | - |
test | (this : void , …methodArguments : [string: string]) => boolean | - |
constructSet
▸ constructSet<Value
>(iterable?
): Object
Functional alias for new Set()
.
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
iterable (optional) | Iterable <Value > |
Returns
Object
Name | Type | Description |
---|---|---|
[toStringTag] | string | - |
size | number | |
[iterator] | (this : void , …methodArguments : []) => IterableIterator <Value > | - |
add | (this : void , …methodArguments : [value: Value]) => Set <Value > | - |
clear | (this : void , …methodArguments : []) => void | - |
delete | (this : void , …methodArguments : [value: Value]) => boolean | - |
entries | (this : void , …methodArguments : []) => IterableIterator <[Value , Value ]> | - |
forEach | (this : void , …methodArguments : [callbackfn: Function, thisArg?: any]) => void | - |
has | (this : void , …methodArguments : [value: Value]) => boolean | - |
keys | (this : void , …methodArguments : []) => IterableIterator <Value > | - |
values | (this : void , …methodArguments : []) => IterableIterator <Value > | - |
constructSyntaxError
▸ constructSyntaxError(...constructorArguments
): Object
Functional alias for new SyntaxError()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [message?: string, options?: ErrorOptions] |
Returns
Object
Name | Type |
---|---|
cause (optional) | unknown |
message | string |
name | string |
stack (optional) | string |
constructTextEncoder
▸ constructTextEncoder(...constructorArguments
): Object
Functional alias for new TextEncoder()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [] |
Returns
Object
Name | Type | Description |
---|---|---|
encoding | string | Returns “utf-8”. MDN Reference |
encode | (this : void , …methodArguments : [input?: string]) => Uint8Array | - |
encodeInto | (this : void , …methodArguments : [source: string, destination: Uint8Array]) => TextEncoderEncodeIntoResult | - |
constructTypeError
▸ constructTypeError(...constructorArguments
): Object
Functional alias for new TypeError()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [message?: string, options?: ErrorOptions] |
Returns
Object
Name | Type |
---|---|
cause (optional) | unknown |
message | string |
name | string |
stack (optional) | string |
constructURIError
▸ constructURIError(...constructorArguments
): Object
Functional alias for new URIError()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [message?: string, options?: ErrorOptions] |
Returns
Object
Name | Type |
---|---|
cause (optional) | unknown |
message | string |
name | string |
stack (optional) | string |
constructWeakMap
▸ constructWeakMap<Key
, Value
>(iterable?
): Object
Functional alias for new WeakMap()
.
Type parameters
Name | Type |
---|---|
Key | extends object |
Value | Value |
Parameters
Name | Type |
---|---|
iterable (optional) | Iterable <readonly [Key , Value ]> |
Returns
Object
Name | Type |
---|---|
[toStringTag] | string |
delete | (this : void , …methodArguments : [key: Key]) => boolean |
get | (this : void , …methodArguments : [key: Key]) => undefined | Value |
has | (this : void , …methodArguments : [key: Key]) => boolean |
set | (this : void , …methodArguments : [key: Key, value: Value]) => WeakMap <Key , Value > |
constructWeakSet
▸ constructWeakSet<Value
>(iterable?
): Object
Functional alias for new WeakSet()
.
Type parameters
Name | Type |
---|---|
Value | extends object |
Parameters
Name | Type |
---|---|
iterable (optional) | Iterable <Value > |
Returns
Object
Name | Type |
---|---|
[toStringTag] | string |
add | (this : void , …methodArguments : [value: Value]) => WeakSet <Value > |
delete | (this : void , …methodArguments : [value: Value]) => boolean |
has | (this : void , …methodArguments : [value: Value]) => boolean |
Common
toString
▸ toString<Input
>(input
): Input
extends Strigifiable
?
`${Input<Input>}` : Input
extends { toString
: () => string
} ?
ReturnType
<Input
<Input
>["toString"
]> : string
Parses given value to string.
Type parameters
Name | Type |
---|---|
Input | extends Strigifiable | { toString : () => string } |
Parameters
Name | Type |
---|---|
input | Input |
Returns
Input
extends Strigifiable
? `${Input<Input>}` : Input
extends {
toString
: () => string
} ?
ReturnType
<Input
<Input
>["toString"
]> : string
stringified value.
Example
Conditions
when
▸ when<Value
, Predicated
>(predicate
):
<TrueOutput>(truthyHandler
: Unary
<Predicated
& Value
, TrueOutput
>)
=> <FalseInput, FalseOutput>(falsyHandler
: Unary
<FalseInput
,
FalseOutput
>) => (value
: Value
) => TrueOutput
| FalseOutput
Curried conditional (like a functional ternary).
Type parameters
Name | Type |
---|---|
Value | Value |
Predicated | never |
Parameters
Name | Type | Description |
---|---|---|
predicate | Single <Predicated > extends Single <never > ? Filter <Value > : Predicate <Value , Predicated > | Predicate to check value against. |
Returns
fn
Curried function with predicate
in context.
▸ <TrueOutput
>(truthyHandler
): <FalseInput, FalseOutput>(falsyHandler
:
Unary
<FalseInput
, FalseOutput
>) => (value
: Value
) => TrueOutput
|
FalseOutput
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <Predicated & Value , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: Value
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | Value extends Predicated ? Value <Value > : Predicated |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | Value |
Returns
TrueOutput
| FalseOutput
Example
whenFalsy
▸ whenFalsy<Value
, Predicated
>(predicate
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: Value
) => Predicated
& Value
| FalseOutput
Like when
, but when is falsy the value is returned as is.
Type parameters
Name | Type |
---|---|
Value | Value |
Predicated | never |
Parameters
Name | Type | Description |
---|---|---|
predicate | Single <Predicated > extends Single <never > ? Filter <Value > : Predicate <Value , Predicated > | Predicate to check value against. |
Returns
fn
Curried function with predicate
in context.
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: Value
) =>
Predicated
& Value
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | Value extends Predicated ? Value <Value > : Predicated |
FalseOutput | Predicated & Value |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): Predicated
& Value
| FalseOutput
Parameters
Name | Type |
---|---|
value | Value |
Returns
Predicated
& Value
| FalseOutput
Example
whenIsArray
▸ whenIsArray<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is an Array
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <ReadOnlyArray <unknown >, TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | ReadOnlyArray <unknown > |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsAsyncIterable
▸ whenIsAsyncIterable<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is an AsyncIterable
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <Readonly <AsyncIterable <unknown >>, TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | Readonly <AsyncIterable <unknown >> |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsBigInt
▸ whenIsBigInt<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is a BigInt
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <bigint , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | bigint |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsBoolean
▸ whenIsBoolean<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is a Boolean
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <boolean , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | boolean |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsDate
▸ whenIsDate<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is a Date
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <Date , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | Date |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsFalsy
▸ whenIsFalsy<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is a Falsy
value.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <Falsy , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | Falsy |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsFunction
▸ whenIsFunction<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is a Function
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <Function , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | Function |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsIsomorphicIterable
▸ whenIsIsomorphicIterable<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is an AsynchronousIterable
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <IsomorphicIterable <unknown >, TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | IsomorphicIterable <unknown > |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsIterable
▸ whenIsIterable<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is an Iterable
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <Readonly <Iterable <unknown >>, TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | Readonly <Iterable <unknown >> |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsNull
▸ whenIsNull<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is null
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <null , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | null |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsNullish
▸ whenIsNullish<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is a Nullish
value.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <Nullish , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | Nullish |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsNumber
▸ whenIsNumber<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is a Number
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <number , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | number |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsObject
▸ whenIsObject<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is an Object
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <object , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | object |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsPromise
▸ whenIsPromise<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is a Promise
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <Promise <unknown >, TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | Promise <unknown > |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsPropertyKey
▸ whenIsPropertyKey<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is a PropertyKey
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <PropertyKey , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | PropertyKey |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsPrototypeOfObject
▸ whenIsPrototypeOfObject<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: object
) => TrueOutput
| FalseOutput
Conditional handler for when something has an Object
prototype.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <never , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: object
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | never |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | object |
Returns
TrueOutput
| FalseOutput
whenIsRegExp
▸ whenIsRegExp<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is a RegExp
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <RegExp , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | RegExp |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsSafeInteger
▸ whenIsSafeInteger<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: number
) => TrueOutput
| FalseOutput
Conditional handler for when a number is a SafeInteger
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <never , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: number
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | never |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | number |
Returns
TrueOutput
| FalseOutput
whenIsString
▸ whenIsString<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is a String
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <string , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | string |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsSymbol
▸ whenIsSymbol<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is a Symbol
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <symbol , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | symbol |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsTruthy
▸ whenIsTruthy<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is a Truthy
value.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <Readonly <unknown >, TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | Readonly <unknown > |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenIsUndefined
▸ whenIsUndefined<TrueOutput
>(truthyHandler
): <FalseInput,
FalseOutput>(falsyHandler
: Unary
<FalseInput
, FalseOutput
>) =>
(value
: unknown
) => TrueOutput
| FalseOutput
Conditional handler for when something is undefined
.
Type parameters
Name |
---|
TrueOutput |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <undefined , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | undefined |
FalseOutput | TrueOutput |
Parameters
Name | Type |
---|---|
falsyHandler | Unary <FalseInput , FalseOutput > |
Returns
fn
▸ (value
): TrueOutput
| FalseOutput
Parameters
Name | Type |
---|---|
value | unknown |
Returns
TrueOutput
| FalseOutput
whenTruthy
▸ whenTruthy<Value
, Predicated
>(predicate
):
<Output>(truthyHandler
: Unary
<Predicated
& Value
, Output
>) =>
(value
: Value
) => Value
| Output
Like when
, but when is falsy the value is returned as is.
Type parameters
Name | Type |
---|---|
Value | Value |
Predicated | never |
Parameters
Name | Type | Description |
---|---|---|
predicate | Single <Predicated > extends Single <never > ? Filter <Value > : Predicate <Value , Predicated > | Predicate to check value against. |
Returns
fn
Curried function with predicate
in context.
▸ <Output
>(truthyHandler
): (value
: Value
) => Value
| Output
Type parameters
Name |
---|
Output |
Parameters
Name | Type |
---|---|
truthyHandler | Unary <Predicated & Value , Output > |
Returns
fn
▸ (value
): Value
| Output
Parameters
Name | Type |
---|---|
value | Value |
Returns
Value
| Output
Example
Functions
always
▸ always<Input
>(input
): () => Input
Returns a function that always returns the same value.
Type parameters
Name |
---|
Input |
Parameters
Name | Type |
---|---|
input | Input |
Returns
fn
Function that always return the given value.
▸ (): Input
Returns
Input
Example
applyTo
▸ applyTo<Input
>(input
): <Output>(unary
: Unary
<Input
,
Output
>) => Output
Takes a value and applies a function to it.
Type parameters
Name |
---|
Input |
Parameters
Name | Type |
---|---|
input | Input |
Returns
fn
Function that expects a function that will receive the input
.
▸ <Output
>(unary
): Output
Type parameters
Name |
---|
Output |
Parameters
Name | Type |
---|---|
unary | Unary <Input , Output > |
Returns
Output
Example
entryKey
▸ entryKey<InputEntry
>(entry
): EntryKey
<InputEntry
>
Get key of an Entry
.
Type parameters
Name | Type |
---|---|
InputEntry | extends Entry |
Parameters
Name | Type | Description |
---|---|---|
entry | InputEntry | Entry to get key from. |
Returns
EntryKey
<InputEntry
>
Key of an Entry
.
Example
entryValue
▸ entryValue<InputEntry
>(entry
): EntryValue
<InputEntry
>
Get value of an Entry
.
Type parameters
Name | Type |
---|---|
InputEntry | extends Entry |
Parameters
Name | Type | Description |
---|---|---|
entry | InputEntry | Entry to get vale from. |
Returns
EntryValue
<InputEntry
>
Value of an Entry
.
Example
flip
▸ flip<UnaryToFlip
>(unary
): (…secondArgument
:
Parameters
<UnaryOutput
<UnaryToFlip
>>) => (…firstArgument
:
Parameters
<UnaryToFlip
>) =>
UnaryOutput
<UnaryOutput
<UnaryToFlip
>>
Flips arguments of a curried function.
Type parameters
Name | Type |
---|---|
UnaryToFlip | extends Unary <never , Unary <never , unknown >> |
Parameters
Name | Type |
---|---|
unary | UnaryToFlip |
Returns
fn
Curried function with unary
in context.
▸ (...secondArgument
): (…firstArgument
: Parameters
<UnaryToFlip
>) =>
UnaryOutput
<UnaryOutput
<UnaryToFlip
>>
Parameters
Name | Type |
---|---|
...secondArgument | Parameters <UnaryOutput <UnaryToFlip >> |
Returns
fn
▸ (...firstArgument
): UnaryOutput
<UnaryOutput
<UnaryToFlip
>>
Parameters
Name | Type |
---|---|
...firstArgument | Parameters <UnaryToFlip > |
Returns
UnaryOutput
<UnaryOutput
<UnaryToFlip
>>
Example
identity
▸ identity<Input
>(input
): Input
Identity function.
Type parameters
Name |
---|
Input |
Parameters
Name | Type |
---|---|
input | Input |
Returns
Input
Same value given.
Example
memoize
▸ memoize<MemoizedFunction
>(unary
): MemoizedFunction
Memoize function return values for expensive operations.
Type parameters
Name | Type |
---|---|
MemoizedFunction | extends Unary <never , unknown > |
Parameters
Name | Type | Description |
---|---|---|
unary | MemoizedFunction | Function to memoize. |
Returns
MemoizedFunction
Curried function with unary
in context.
Example
negate
▸ negate<Item
, Predicated
>(predicate
): Single
<Predicated
>
extends Single
<never
> ? Unary
<Item
, boolean
> :
Predicate
<Item
, Exclude
<Item
, Predicated
>>
Takes a function and returns a copy with negated output.
Type parameters
Name | Type |
---|---|
Item | Item |
Predicated | never |
Parameters
Name | Type | Description |
---|---|---|
predicate | Single <Predicated > extends Single <never > ? Filter <Item > : Predicate <Item , Predicated > | Function to be negated. |
Returns
Single
<Predicated
> extends Single
<never
> ? Unary
<Item
,
boolean
> : Predicate
<Item
, Exclude
<Item
, Predicated
>>
Source function with negated output.
Example
once
▸ once<OnceFunction
>(unary
): (value
: UnaryInput
<OnceFunction
>)
=> UnaryOutput
<OnceFunction
> | UnaryOutput
<OnceFunction
>
Runs a function once, and after that returns always the same value.
Type parameters
Name | Type |
---|---|
OnceFunction | extends Unary <never , unknown > |
Parameters
Name | Type | Description |
---|---|---|
unary | OnceFunction | Function to run once. |
Returns
fn
Curried function with unary
in context.
▸ (value
): UnaryOutput
<OnceFunction
> | UnaryOutput
<OnceFunction
>
Parameters
Name | Type |
---|---|
value | UnaryInput <OnceFunction > |
Returns
UnaryOutput
<OnceFunction
> | UnaryOutput
<OnceFunction
>
Example
tap
▸ tap<Input
>(tapper
): <Tapped>(tapped
: Tapped
) => Tapped
Tap into a value before calling a function.
Type parameters
Name |
---|
Input |
Parameters
Name | Type | Description |
---|---|---|
tapper | Unary <Input , unknown > | Tapper function to be called with the value. |
Returns
fn
Curried function with tapper
in context.
▸ <Tapped
>(tapped
): Tapped
Type parameters
Name | Type |
---|---|
Tapped | extends Unary <Input , unknown > |
Parameters
Name | Type |
---|---|
tapped | Tapped |
Returns
Tapped
Example
thunk
▸ thunk<Input
, Output
>(unary
): (input
: Input
) => () => Output
Delayed evaluation function.
Type parameters
Name |
---|
Input |
Output |
Parameters
Name | Type |
---|---|
unary | Unary <Input , Output > |
Returns
fn
Function that will run the given function when called.
▸ (input
): () => Output
Parameters
Name | Type |
---|---|
input | Input |
Returns
fn
▸ (): Output
Returns
Output
Example
Numbers
cryptoNumber
▸ cryptoNumber(seed
): Promise
<number
>
Generates number
using SubtleCrypto#digest
and the given seed.
⚠️ IMPORTANT: This only works in secure contexts (HTTPS/Node).
Parameters
Name | Type | Description |
---|---|---|
seed | string | Numeric | Seed to be used to generate random numbers. |
Returns
Promise
<number
>
Pseudo-random number from seed.
Example
See
Objects
awaitableHandler
▸ awaitableHandler<Value
, Output
>(handler
):
<AwaitableValue>(awaitable
: AwaitableValue
) => AwaitableValue
extends
Promise
<Value
> ? Promise
<Output
> : Output
If the given value is a promise, the handler
is called when is resolved,
otherwise the handler is called directly with the value.
Type parameters
Name |
---|
Value |
Output |
Parameters
Name | Type | Description |
---|---|---|
handler | (awaitable : Value ) => Output | Handler function to be called with the value. |
Returns
fn
Curried function with handler
in context.
▸ <AwaitableValue
>(awaitable
): AwaitableValue
extends
Promise
<Value
> ? Promise
<Output
> : Output
Type parameters
Name |
---|
AwaitableValue |
Parameters
Name | Type |
---|---|
awaitable | AwaitableValue |
Returns
AwaitableValue
extends Promise
<Value
> ? Promise
<Output
> : Output
Example
get
▸ get<Key
>(key
): <Source>(object
: Source
) => Source
[Key
&
keyof Source
]
Get the value of a property in an object.
Type parameters
Name | Type |
---|---|
Key | extends PropertyKey |
Parameters
Name | Type |
---|---|
key | Key |
Returns
fn
Curried function with key
in context.
▸ <Source
>(object
): Source
[Key
& keyof Source
]
Type parameters
Name | Type |
---|---|
Source | extends Readonly <Record <Key , unknown >> |
Parameters
Name | Type |
---|---|
object | Source |
Returns
Source
[Key
& keyof Source
]
Example
intercept
▸ intercept<Interceptions
>(interceptions
): <Target>(target
:
Target
) => keyof Target
extends keyof Interceptions
? Omit
<Target
,
keyof Interceptions
> : Target
& { readonly [Property in string | number
| symbol]: ReturnType<Interceptions[Property]> }
Function that takes a dictionary property -> getter
and uses said getter in
the matching property of the object by returning a proxy to it.
Type parameters
Name | Type |
---|---|
Interceptions | extends Readonly <Record <PropertyKey , <ProxiedObject>(target : ProxiedObject ) => unknown >> |
Parameters
Name | Type | Description |
---|---|---|
interceptions | Interceptions | Dictionary property -> handler . |
Returns
fn
Curried function with interceptions
in context.
▸ <Target
>(target
): keyof Target
extends keyof Interceptions
?
Omit
<Target
, keyof Interceptions
> : Target
& { readonly [Property in
string | number | symbol]: ReturnType<Interceptions[Property]> }
Type parameters
Name | Type |
---|---|
Target | extends object |
Parameters
Name | Type |
---|---|
target | Target |
Returns
keyof Target
extends keyof Interceptions
? Omit
<Target
, keyof
Interceptions
> : Target
& { readonly [Property in string | number |
symbol]: ReturnType<Interceptions[Property]> }
Example
mutate
▸ mutate<Update
>(update
): <Target>(target
: Target
) => Target
&
Update
Function to encapsulate object mutations.
⚠️ IMPORTANT: Try to avoid this util, use intercept instead.
Type parameters
Name | Type |
---|---|
Update | extends object |
Parameters
Name | Type | Description |
---|---|---|
update | Update | Update to apply to given target. |
Returns
fn
Curried function with update
in context.
▸ <Target
>(target
): Target
& Update
Type parameters
Name | Type |
---|---|
Target | extends object |
Parameters
Name | Type |
---|---|
target | Target |
Returns
Target
& Update
Example
omit
▸ omit<Properties
>(...properties
): <Source>(object
: Source
) =>
Omit
<Source
, Properties
[number
]>
Omits given properties from an object.
Type parameters
Name | Type |
---|---|
Properties | extends ReadOnlyArray <PropertyKey > |
Parameters
Name | Type | Description |
---|---|---|
...properties | Properties | Properties to omit. |
Returns
fn
Curried function with properties
in context.
▸ <Source
>(object
): Omit
<Source
, Properties
[number
]>
Type parameters
Name | Type |
---|---|
Source | extends Readonly <Record <PropertyKey , unknown >> |
Parameters
Name | Type |
---|---|
object | Source |
Returns
Omit
<Source
, Properties
[number
]>
Example
pick
▸ pick<Properties
>(...properties
): <Source>(object
: Source
) =>
Pick
<Source
, Properties
[number
]>
Picks given properties from an object.
Type parameters
Name | Type |
---|---|
Properties | extends ReadOnlyArray <PropertyKey > |
Parameters
Name | Type | Description |
---|---|---|
...properties | Properties | Properties to pick. |
Returns
fn
Curried function with properties
in context.
▸ <Source
>(object
): Pick
<Source
, Properties
[number
]>
Type parameters
Name | Type |
---|---|
Source | extends Readonly <Record <PropertyKey , unknown >> |
Parameters
Name | Type |
---|---|
object | Source |
Returns
Pick
<Source
, Properties
[number
]>
Example
set
▸ set<Key
>(key
): <Value>(value
: Value
) => <Source>(object
:
Source
) => Omit
<Source
, Key
> & Readonly
<Record
<Key
,
Value
>>
Set the value of a property in an object (read only).
Type parameters
Name | Type |
---|---|
Key | extends PropertyKey |
Parameters
Name | Type |
---|---|
key | Key |
Returns
fn
Curried function with key
in context.
▸ <Value
>(value
): <Source>(object
: Source
) => Omit
<Source
,
Key
> & Readonly
<Record
<Key
, Value
>>
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
value | Value |
Returns
fn
▸ <Source
>(object
): Omit
<Source
, Key
> &
Readonly
<Record
<Key
, Value
>>
Type parameters
Name | Type |
---|---|
Source | extends object |
Parameters
Name | Type |
---|---|
object | Source |
Returns
Omit
<Source
, Key
> & Readonly
<Record
<Key
, Value
>>
Example
Promises
otherwise
▸ otherwise<Output
>(handler
): <PromisedValue>(promise
:
Promise
<PromisedValue
>) => Promise
<Output
| PromisedValue
>
Sets a promise catch
handler.
Type parameters
Name |
---|
Output |
Parameters
Name | Type |
---|---|
handler | Unary <unknown , Output | PromiseLike <Output >> |
Returns
fn
Curried function with handler
set in context.
▸ <PromisedValue
>(promise
): Promise
<Output
| PromisedValue
>
Type parameters
Name |
---|
PromisedValue |
Parameters
Name | Type |
---|---|
promise | Promise <PromisedValue > |
Returns
Promise
<Output
| PromisedValue
>
Example
then
▸ then<HandlerInput
, Output
>(handler
):
<PromiseInstance>(promise
: PromiseInstance
) => Promise
<Output
>
Sets a promise then
handler.
Type parameters
Name |
---|
HandlerInput |
Output |
Parameters
Name | Type |
---|---|
handler | Unary <HandlerInput , Output | PromiseLike <Output >> |
Returns
fn
Curried function with handler
set in context.
▸ <PromiseInstance
>(promise
): Promise
<Output
>
Type parameters
Name | Type |
---|---|
PromiseInstance | extends Promise <HandlerInput > |
Parameters
Name | Type |
---|---|
promise | PromiseInstance |
Returns
Promise
<Output
>
Example