Ufunc
Ufunc is a set of JavaScript functional methods.
NOTE: No longer depends on Ramda;
Installation
$ npm install ufunc
Usage
Add the module to the script via ES5 or ES6
ES6
import ufunc from 'ufunc';
ES5
var ufunc = require('ufunc');
Functions
clean
Revome all null and undefined items from array.
clean;//=> [0, 1, 2, 3]
cleanAll
Revome all null and undefined items from list.
utils.cleanAll;//=> [1, 2, 3]
cleanObj
Revome all null, undefined and 0 Key/value pairs from object.
cleanObj;//=> {a: 1, d: 'otis', e:0}
cleanObjAll
Revome all null, undefined and 0 Key/value pairs from object.
cleanObjAll;//=> {a: 1, d: 'otis'}
filterObjetsInList
Filters a list of objects by using another list of objects as the criteria.
var fn = =>
fmap
Maps a function over a container and returns a new container.
fmap
either
Executes left if any of the condition are true, else right if false.
either,//=> 'left' //=> 'left' either;//=> 'right' //=> 'right' either;//=> 'left' either
maybe
Returns if value is truthy, else null.
An optional second argument can be passed to be used as the return value if false.
//=> 'Jack Bower' //=> null maybe;//=> []
maybeIf
Returns if value is condition is truthy, else null.
An optional second argument can be passed to be used as the return value if false.
maybeIf;//=> 'Jack Bower' //=> null maybeIf,;//=> []
pickPairsFromList
Picks keys/values out of an array of objects.
var fixtures = [ {user: 'user1', id: 'id1', email: 'user1@test.com', status: 'online', name: 'Bill'}, {user: 'user2', id: 'id2', email: 'user2@test.com', status: 'online', name: 'Jane'}, {user: 'user3', id: 'id3', email: 'user3@test.com', status: 'offline', name: 'Marry'}, {user: 'user4', id: 'id4', email: 'user4@test.com', status: 'offline', name: 'Larry'}]; pickKeyValuesFromList;//=>// [// {id: 'id1', email: 'user1@test.com', status: 'online'},// {id: 'id2', email: 'user2@test.com', status: 'online'},// {id: 'id3', email: 'user3@test.com', status: 'offline'},// {id: 'id4', email: 'user4@test.com', status: 'offline'}// ]
License
MIT