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
| Name | Type |
|---|---|
Function | extends VariadicFunction |
Length | extends 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
| Name | Type |
|---|---|
Args | extends Gradual<Parameters<Function>> |
Parameters
| Name | Type |
|---|---|
...args | Args |
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
| Name | Type |
|---|---|
Function | extends VariadicFunction |
Length | extends number = Parameters<Function>["length"] |
Parameters
| Name | Type |
|---|---|
fn | Function |
length | Length |
Returns
Curry<Function, Length>