Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gunar/ncurry
Curry for named arguments
https://github.com/gunar/ncurry
Last synced: about 2 months ago
JSON representation
Curry for named arguments
- Host: GitHub
- URL: https://github.com/gunar/ncurry
- Owner: gunar
- Created: 2017-07-17T20:02:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-31T15:00:39.000Z (over 7 years ago)
- Last Synced: 2024-10-12T21:36:06.337Z (2 months ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ncurry
Curry for named arguments.
## Usage
```js
var ncurry = require('ncurry')const foo = ncurry(
['a', 'b', 'c'],
({a, b, c}) =>
a + b + c)foo({ a: 1 })({ b: 2, c: 3 }) // 6
```### Accepts optional arguments
```js
var ncurry = require('ncurry')const foo = ncurry(
['a', 'c'],
({a, b, c}) =>
a + b + c)foo({ a: 1 })({ b: 2, c: 3 }) // 6
foo({ a: 1 })({ c: 3 }) // 4
```### Partial application works too
```js
const ncurry = require('ncurry')
const { partial } = require('lodash/fp')const foo = ncurry(
['a', 'c'],
({a, b, c}) =>
a + b + c)const fooabc = partial(foo)([{ a: 1, b: 2, c: 3 }])
fooabc() // 7
```## Inspiration
- [Gist and discussion](https://gist.github.com/gunar/1268c997ca66343f060dbca07aee67bd)
- [named-curry](https://github.com/rjmk/named-curry)## License
MIT [http://gunar.mit-license.org]()