unary
v0.0.2
Published
Creates a unary function wrapper which extracts a specific argument by index and applies the argument to the original unary function.
Downloads
18
Maintainers
Readme
unary
Creates a unary function wrapper which extracts a specific argument by index and applies the argument to the original unary function.
npm install unary --save
npm stats
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.