Skip to content

fx-flow v0.7.0 / pipe/strict / curry

Function: curry()

curry<A, B>(fn, args): (args) => ReturnType<A>

Curry for single arg function

Type parameters

A extends SingleArgFunction

B extends Partial<Parameters<A>[0]>

Parameters

fn: A

args: B

Returns

Function

Parameters

args: Omit<Parameters<A>[0], keyof B>

Returns

ReturnType<A>

Example

typescript
const add = (args: { a: number; b: number }) => args.a + args.b
const curriedAdd = curry(add, { a: 1 })
console.log(curriedAdd({ b: 2 }) // 3

More examples

Source

packages/core/src/pipe/strict/curry.ts:15

Released under the MIT License.