cu

Copper - collection utilities

Cu

Copper - collection utilities

Copper's API aims to be properly extensible using functions, not magic string parameters

var Cu = require('cu')

Returns a Comparator: (itemA: Value, itemB: Value) => Boolean - a function which compares two values for equality. For example, if you want to consider two objects equal if their _id properties are stringwise equal, you could create a Comparator with:

var idComparator = Cu.comparator(function (obj) {
  return obj._id.toString()
})

Returns true if a collection contains a thing

Returns true if a collection is a superset of a second collection

Returns true if a collection intersects with a second collection

type Predicate: (Value) => Boolean

Splits by a predicate, then applies them to a function for the true and false subsets. It returns a 2-tuple of the return value of the trueFn and falseFn, respectively.

Splits by a predicate, then applies them to a function for the true and false subsets. It returns a 2-tuple of the return value of the trueFn and falseFn, respectively. Flattens the result by 1 level.

Returns the compacted Array with all null or elements removed

Returns a dictionary with keys generated by scalarFn and the original object as the value.

Returns a scalar function mapping an object to a named property.

Flattens an array by one level

Returns the Cartesian square (binary Cartesian product) of two arrays

eg

Cu.cartesianSquare([1,2],[3,4])
// => [ 
//      [1,3], 
//      [1,4], 
//      [2,3], 
//      [2,4] 
//    ] 
$ npm install cu

From package root:

$ npm install
$ npm test

MIT. (c) 2013 AgileMD opensource@agilemd.com. See LICENSE.md