Skip to content

gunar/ncurry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ncurry

Curry for named arguments.

Usage

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

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

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

License

MIT http://gunar.mit-license.org

About

Curry for named arguments

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published