@blakek/curry
Advanced tools
Comparing version 2.0.1 to 2.0.2
{ | ||
"name": "@blakek/curry", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"main": "dist/curry.cjs.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/curry.esm.js", |
@@ -5,4 +5,8 @@ # curry | ||
A simple helper to help apply arguments to a function over time. | ||
A simple helper to wrap a function and gradually accept (i.e. partially apply) | ||
arguments. | ||
This package is technically a helper partial application, but `curry` is much | ||
easier to remember and a nicer package function name than `partiallyApply`. | ||
## Install | ||
@@ -43,2 +47,21 @@ | ||
### TypeScript | ||
The types of many functions are inferred. However, some functions, such as | ||
variadic functions, need an explicit type: | ||
```ts | ||
const add = (...args: number[]) => args.reduce((a, b) => a + b, 0); | ||
const addFourItems = curry(add, 4) as VariadicCurry< | ||
// argument types | ||
[number, number, number, number], | ||
// return type | ||
number | ||
>; | ||
// Includes helpers for functions accepting <=5 args | ||
const addTwo = curry(add, 2) as Curry2<number, number, number>; | ||
``` | ||
## API | ||
@@ -52,4 +75,4 @@ | ||
Returns functions that take in the arguments of another function until all have | ||
been provided. | ||
Returns functions that take in the arguments of a function until all have been | ||
provided. | ||
@@ -64,4 +87,6 @@ ### `curryRight` | ||
Provided for the common use-case of needing to supply context-specific arguments | ||
before providing the first arguments. For example: | ||
before providing the first arguments. | ||
For example: | ||
```js | ||
@@ -68,0 +93,0 @@ import { curryRight } from '@blakek/curry'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110354
128