Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ndhoule/curry
Wrap a function in a function that will repeatedly return a new wrapper function until all expected arguments have been provided.
https://github.com/ndhoule/curry
Last synced: 13 days ago
JSON representation
Wrap a function in a function that will repeatedly return a new wrapper function until all expected arguments have been provided.
- Host: GitHub
- URL: https://github.com/ndhoule/curry
- Owner: ndhoule
- License: mit
- Created: 2015-02-26T08:30:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-02T20:03:41.000Z (over 8 years ago)
- Last Synced: 2024-10-02T22:36:00.190Z (about 2 months ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE.md
Awesome Lists containing this project
README
# curry [![CI][ci-badge]][ci-link]
Wrap a function in a function that will repeatedly return a new wrapper function until all expected arguments have been provided.
## Installation
```sh
$ component install ndhoule/curry
$ npm install @ndhoule/curry
```## API
### `curry(func : Function, arity : number)`
Accepts a function `func` and returns a new function that, when invoked, will repeatedly return a new wrapper function until all expected arguments have been provided.
```javascript
var addThreeItems = function(a, b, c) { return a + b + c; };
var curriedAddThreeItems = curry(addThreeItems);
curriedAddThreeItems(2)(3)(4);
//=> 9var curriedReduce = curry(reduce);
var add = function(a, b) { return a + b; };
var sumArray = curriedReduce(add, 0);
sumArray([1, 2, 3]);
//=> 6
```## License
Released under the [MIT license](LICENSE.md).
[ci-link]: https://travis-ci.org/ndhoule/curry
[ci-badge]: https://travis-ci.org/ndhoule/curry.svg?branch=master