Helper functions for arrays on NodeJS. The functions are pure and curried with Ramda.
$ npm install alien-node-list-utils --save
Run the specs
$ npm test
Given a list and an item, returns a copy of the list absent said item.
var listUtils = require('alien-node-list-utils'),
list = ['a', 'b', 'c', 'd'];
listUtils.filterOutItem('b', list); // ['a', 'c', 'd']
Given a key, value, and list, returns a copy of the list absent the object(s) which match said k/v pair.
var listUtils = require('alien-node-list-utils'),
list = [{ foo : 'bar'}, {baz : 'bat'}, {buz : 'but'}];
listUtils.filterOutObject('baz', 'bat', list); // [{ foo : 'bar'}, {buz : 'but'}]
Given a qualifying drop length and a list, returns a new list who's last item is dropped if the list length exceeds or equals provided drop length
var listUtils = require('alien-node-list-utils'),
list1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],
list2 = ['x', 'y', 'z'];
listUtils.maybeDropLastItem(5, list1); // ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
listUtils.maybeDropLastItem(5, list2); // ['x', 'y', 'z']
Simple ascending sorter function
var listUtils = require('alien-node-list-utils'),
list = ['b', 'd', 'a', 'c'];
listUtils.sortAsc(list1); // ['a', 'b', 'c', 'd']
Simple descending sorter function
var listUtils = require('alien-node-list-utils'),
list = ['b', 'd', 'a', 'c'];
listUtils.sortDesc(list1); // ['d', 'c', 'b', 'a']