0.0.2 • Published 8 years ago

unary v0.0.2

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

unary

Creates a unary function wrapper which extracts a specific argument by index and applies the argument to the original unary function.

Build Status Code Climate js-standard-style

npm install unary --save
npm stats

npm NPM downloads Dependency Status

Examples

require
var unary = require('unary')
full application
var odds = unary(odd, 1)
var fruit = [ 'apple', 'pear', 'pineapple', 'strawberry', 'orange', 'grapefruit' ]

fruit.filter(odds)
//=> [ 'apple', 'pineapple', 'orange' ]
functor (+ partial application)
var evens = unary(even)
var fruit = [ 'apple', 'pear', 'pineapple', 'strawberry', 'orange', 'grapefruit' ]

fruit.filter(evens(1))
//=> [ 'pear', 'strawberry', 'grapefruit' ]

API

unary(fun, idx)

arguments
  • fun: (Function) Unary function to wrap.
  • idx: (Number) Index of argument to extract.
returns
  • (Function) Wrapped unary function.

License

GitHub license