Skip to main content

Module: Curry

Type Aliases​

Curry​

Ƭ Curry<Function, Length>: <Args>(...args: Args) => Args["length"] extends Length ? ReturnType<Function> : Curry<(...args: Slice<Parameters<Function>, Args["length"]>) => ReturnType<Function>>

Type parameters​

NameType
Functionextends VariadicFunction
Lengthextends number = Parameters<Function>["length"]

Type declaration​

▸ <Args>(...args): Args["length"] extends Length ? ReturnType<Function> : Curry<(...args: Slice<Parameters<Function>, Args["length"]>) => ReturnType<Function>>

Creates a type for an auto-curried function.

Type parameters​
NameType
Argsextends Gradual<Parameters<Function>>
Parameters​
NameType
...argsArgs
Returns​

Args["length"] extends Length ? ReturnType<Function> : Curry<(...args: Slice<Parameters<Function>, Args["length"]>) => ReturnType<Function>>

Functions​

curry​

▸ curry<Function, Length>(fn, length?): Curry<Function, Length>

Creates an auto-curried function from the one provided. Until the curried function receives an expected number of arguments, defined by either its length property or the length argument of curry, it will return new function which receives from one to the remaining amount of arguments. Any excess arguments will not be applied.

Type parameters​

NameType
Functionextends VariadicFunction
Lengthextends number = Parameters<Function>["length"]

Parameters​

NameType
fnFunction
lengthLength

Returns​

Curry<Function, Length>