npm.io
0.2.0 • Published 8 months ago

help-curry

Licence
MIT
Version
0.2.0
Deps
0
Size
7 kB
Vulns
0
Weekly
0

help-curry

A tiny curry helper for fixed-arity functions

CI npm version npm downloads

Install

npm install help-curry
pnpm add help-curry
bun add help-curry

Usage

import curry from 'help-curry';

const sum = (a, b, c) => a + b + c;
const curriedSum = curry(sum);

curriedSum(1, 2, 3); // 6
curriedSum(1)(2, 3); // 6
curriedSum(1)(2)(3); // 6

API

curry(fn)

Creates a curried version of fn that can be called with any number of arguments until the original function arity is satisfied. The arity is taken from fn.length.

  • Preserves the this context when calling the original function
  • Works well with fixed-arity functions
  • Ships with TypeScript types

Development

bun install
bun test
bun run lint
bun run build

License

MIT Paul Nodet

Keywords