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
>) => InstanceType
<Constructor
>
Creates a new instance of the given constructor with the given arguments.
Type parameters
Name | Type |
---|---|
Constructor | extends Class <never > |
Parameters
Name | Type |
---|---|
constructor | Constructor |
Returns
fn
Curried function with constructor
in context.
▸ (...constructorArguments
): InstanceType
<Constructor
>
Parameters
Name | Type |
---|---|
...constructorArguments | ConstructorParameters <Constructor > |
Returns
InstanceType
<Constructor
>
Example
constructArray
▸ constructArray<Item
>(length
): Item
[]
Functional alias for new Array()
.
Type parameters
Name |
---|
Item |
Parameters
Name | Type |
---|---|
length | number |
Returns
Item
[]
▸ constructArray<Items
>(...items
): Items
[number
][]
Functional alias for new Array()
.
Type parameters
Name | Type |
---|---|
Items | extends ReadOnlyArray |
Parameters
Name | Type |
---|---|
...items | Items |
Returns
Items
[number
][]
constructDate
▸ constructDate(date?
): Date
Functional alias for new Date()
.
Parameters
Name | Type |
---|---|
date (optional) | string | number | { getVarDate : () => VarDate ; [toPrimitive] : (hint : "default" ) => string (hint : "string" ) => string (hint : "number" ) => number (hint : string ) => string | number ; getDate : () => number ; getDay : () => number ; getFullYear : () => number ; getHours : () => number ; getMilliseconds : () => number ; getMinutes : () => number ; getMonth : () => number ; getSeconds : () => number ; getTime : () => number ; getTimezoneOffset : () => number ; getUTCDate : () => number ; getUTCDay : () => number ; getUTCFullYear : () => number ; getUTCHours : () => number ; getUTCMilliseconds : () => number ; getUTCMinutes : () => number ; getUTCMonth : () => number ; getUTCSeconds : () => number ; setDate : (date : number ) => number ; setFullYear : (year : number , month? : number , date? : number ) => number ; setHours : (hours : number , min? : number , sec? : number , ms? : number ) => number ; setMilliseconds : (ms : number ) => number ; setMinutes : (min : number , sec? : number , ms? : number ) => number ; setMonth : (month : number , date? : number ) => number ; setSeconds : (sec : number , ms? : number ) => number ; setTime : (time : number ) => number ; setUTCDate : (date : number ) => number ; setUTCFullYear : (year : number , month? : number , date? : number ) => number ; setUTCHours : (hours : number , min? : number , sec? : number , ms? : number ) => number ; setUTCMilliseconds : (ms : number ) => number ; setUTCMinutes : (min : number , sec? : number , ms? : number ) => number ; setUTCMonth : (month : number , date? : number ) => number ; setUTCSeconds : (sec : number , ms? : number ) => number ; toDateString : () => string ; toISOString : () => string ; toJSON : (key? : any ) => string ; toLocaleDateString : () => string (locales? : string | string [], options? : DateTimeFormatOptions ) => string (locales? : LocalesArgument , options? : DateTimeFormatOptions ) => string ; toLocaleString : () => string (locales? : string | string [], options? : DateTimeFormatOptions ) => string (locales? : LocalesArgument , options? : DateTimeFormatOptions ) => string ; toLocaleTimeString : () => string (locales? : string | string [], options? : DateTimeFormatOptions ) => string (locales? : LocalesArgument , options? : DateTimeFormatOptions ) => string ; toString : () => string ; toTimeString : () => string ; toUTCString : () => string ; valueOf : () => number } |
Returns
Date
constructError
▸ constructError(...constructorArguments
): Error
Functional alias for new Error()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [message?: string, options?: ErrorOptions] |
Returns
Error
constructIntlCollator
▸ constructIntlCollator(...constructorArguments
): Collator
Functional alias for new Intl.Collator()
, which enables language-sensitive
string comparison.
Parameters
Name | Type |
---|---|
...constructorArguments | [locales?: LocalesArgument, options?: CollatorOptions] |
Returns
Collator
See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator
constructIntlDateTimeFormat
▸ constructIntlDateTimeFormat(...constructorArguments
): DateTimeFormat
Functional alias for new Intl.DateTimeFormat()
, which enables
language-sensitive date and time formatting.
Parameters
Name | Type |
---|---|
...constructorArguments | [locales?: LocalesArgument, options?: DateTimeFormatOptions] |
Returns
DateTimeFormat
See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
constructIntlLocale
▸ constructIntlLocale(tag
, options?
): Locale
Functional alias for new Intl.Locale()
, which represents a Unicode locale
identifier.
Parameters
Name | Type | Description |
---|---|---|
tag | ReadOnly <Locale | LocaleIdentifier > | - |
options (optional) | Object | - |
options.baseName (optional) | string | A string containing the language, and the script and region if available. |
options.calendar (optional) | string | The part of the Locale that indicates the locale’s calendar era. |
options.caseFirst (optional) | LocaleCollationCaseFirst | Flag that defines whether case is taken into account for the locale’s collation rules. |
options.collation (optional) | string | The collation type used for sorting |
options.hourCycle (optional) | LocaleHourCycleKey | The time keeping format convention used by the locale. |
options.language (optional) | string | The primary language subtag associated with the locale. |
options.numberingSystem (optional) | string | The numeral system used by the locale. |
options.numeric (optional) | boolean | Flag that defines whether the locale has special collation handling for numeric characters. |
options.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. |
options.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. |
Returns
Locale
See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale
constructIntlNumberFormat
▸ constructIntlNumberFormat(...constructorArguments
): NumberFormat
Functional alias for new Intl.NumberFormat()
, which enables language-sensitive
number formatting.
Parameters
Name | Type |
---|---|
...constructorArguments | [locales?: LocalesArgument, options?: NumberFormatOptions] |
Returns
NumberFormat
See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
constructIntlPluralRules
▸ constructIntlPluralRules(...constructorArguments
): PluralRules
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
PluralRules
See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules
constructIntlRelativeTimeFormat
▸ constructIntlRelativeTimeFormat(...constructorArguments
):
RelativeTimeFormat
Functional alias for new Intl.RelativeTimeFormat()
, which enables
language-sensitive relative time formatting.
Parameters
Name | Type |
---|---|
...constructorArguments | [locales?: LocalesArgument, options?: RelativeTimeFormatOptions] |
Returns
RelativeTimeFormat
See
constructMap
▸ constructMap<Key
, Value
>(iterable?
): Map
<Key
, Value
>
Functional alias for new Map()
.
Type parameters
Name |
---|
Key |
Value |
Parameters
Name | Type |
---|---|
iterable (optional) | Iterable <readonly [Key , Value ]> |
Returns
Map
<Key
, Value
>
constructPromise
▸ constructPromise<Value
>(executor
): Promise
<Value
>
Functional alias for new Promise()
.
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
executor | (resolve : (value : Value ) => void , reject : (reason? : unknown ) => void ) => void |
Returns
Promise
<Value
>
constructProxy
▸ constructProxy<Target
>(target
, handler
): Target
Functional alias for new Proxy()
.
Type parameters
Name | Type |
---|---|
Target | extends object |
Parameters
Name | Type |
---|---|
target | Target |
handler | ProxyHandler <Target > |
Returns
Target
constructRangeError
▸ constructRangeError(...constructorArguments
): Error
Functional alias for new RangeError()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [message?: string, options?: ErrorOptions] |
Returns
Error
constructReferenceError
▸ constructReferenceError(...constructorArguments
): Error
Functional alias for new ReferenceError()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [message?: string, options?: ErrorOptions] |
Returns
Error
constructRegExp
▸ constructRegExp(...constructorArguments
): RegExp
Functional alias for new RegExp()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [pattern: string | RegExp, flags?: string] |
Returns
RegExp
constructSet
▸ constructSet<Value
>(iterable?
): Set
<Value
>
Functional alias for new Set()
.
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
iterable (optional) | Iterable <Value > |
Returns
Set
<Value
>
constructSyntaxError
▸ constructSyntaxError(...constructorArguments
): Error
Functional alias for new SyntaxError()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [message?: string, options?: ErrorOptions] |
Returns
Error
constructTypeError
▸ constructTypeError(...constructorArguments
): Error
Functional alias for new TypeError()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [message?: string, options?: ErrorOptions] |
Returns
Error
constructURIError
▸ constructURIError(...constructorArguments
): Error
Functional alias for new URIError()
.
Parameters
Name | Type |
---|---|
...constructorArguments | [message?: string, options?: ErrorOptions] |
Returns
Error
constructWeakMap
▸ constructWeakMap<Key
, Value
>(iterable?
): WeakMap
<Key
,
Value
>
Functional alias for new WeakMap()
.
Type parameters
Name | Type |
---|---|
Key | extends object |
Value | Value |
Parameters
Name | Type |
---|---|
iterable (optional) | Iterable <readonly [Key , Value ]> |
Returns
WeakMap
<Key
, Value
>
constructWeakSet
▸ constructWeakSet<Value
>(iterable?
): WeakSet
<Value
>
Functional alias for new WeakSet()
.
Type parameters
Name | Type |
---|---|
Value | extends object |
Parameters
Name | Type |
---|---|
iterable (optional) | Iterable <Value > |
Returns
WeakSet
<Value
>
Common
toString
▸ toString<Input
>(input
): Input
extends Strigifiable
?
`${Input}` : Input
extends { toString
: () => string
} ?
ReturnType
<Input
["toString"
]> : string
Parses given value to string, if number is given, then that’s used as a radix and a function is returned expecting an actual value.
Type parameters
Name | Type |
---|---|
Input | extends Strigifiable | { toString : () => string } |
Parameters
Name | Type |
---|---|
input | Input |
Returns
Input
extends Strigifiable
? `${Input}` : Input
extends { toString
:
() => string
} ? ReturnType
<Input
["toString"
]> : string
string or function expecting a 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 : 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 : 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 <{ [asyncIterator] : () => AsyncIterator <unknown , any , undefined > }, TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | { [asyncIterator] : () => AsyncIterator <unknown , any , undefined > } |
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 <ReadOnlyArray , unknown >, TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | Function <ReadOnlyArray , unknown > |
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 <{ [iterator] : () => Iterator <unknown , any , undefined > }, TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | { [iterator] : () => Iterator <unknown , any , undefined > } |
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 <unknown , TrueOutput > |
Returns
fn
▸ <FalseInput
, FalseOutput
>(falsyHandler
): (value
: unknown
) =>
TrueOutput
| FalseOutput
Type parameters
Name | Type |
---|---|
FalseInput | 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
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 [] | readonly [unknown , unknown ] | Record <Key , unknown > | Readonly <ReadonlyMap <unknown , unknown >> | Readonly <ReadonlySet <unknown >> | readonly unknown [] | Function & Record <Key , unknown > | { readonly [Property in PropertyKey]: ReadOnly<Record<Key, unknown>[Property]> } |
Parameters
Name | Type |
---|---|
object | Source |
Returns
Source
[Key
& keyof Source
]
Example
mutate
▸ mutate<Update
>(update
): <Target>(target
: Target
) => Target
&
Update
Function to encapsulate object mutations.
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 Object |
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 Object |
Parameters
Name | Type |
---|---|
object | Source |
Returns
Pick
<Source
, Properties
[number
]>
Example
set
▸ set<Key
>(key
): <Value>(value
: Value
) => <Source>(object
:
Source
) => Omit
<Source
, Key
> & ReadOnlyRecord
<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
> & ReadOnlyRecord
<Key
, Value
>
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
value | Value |
Returns
fn
▸ <Source
>(object
): Omit
<Source
, Key
> & ReadOnlyRecord
<Key
,
Value
>
Type parameters
Name | Type |
---|---|
Source | extends object |
Parameters
Name | Type |
---|---|
object | Source |
Returns
Omit
<Source
, Key
> & ReadOnlyRecord
<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