xs

A collections library with one interface to rule them.

npm install xs
1 downloads in the last month

xs.js | Never Too Many Collections

xs is a JavaScript library that lets you treat most everything like a collection that just does what you mean with via a unified, consistent interface.

// Objects...
var o = xs({ a:1, b:2, c:3, 3:'d' });
o.keys();
// --> [ 'a', 'b', 'c', '3' ]
o.values();
// --> [ 1, 2, 3, 'd' ]
o.attr(3);
// --> 'd'

// Arrays...
var a = xs([ 1, 2, 3, 'd' ]);
a.keys();
// --> [ 0, 1, 2, 3 ]
a.values();
// --> [ 1, 2, 3, 'd' ]
a.attr(3);
// --> 'd'

var inc = function(x){ return x+1; };
o.map(inc);
// --> xs({ a:2, b:3, c:4, 3:'d1' })
a.map(inc);
// --> xs([ 2, 3, 4, 'd1' ])
  • Supports both Object-oriented and Functional styles.
  • Plays nice with other libraries (like jQuery).
  • Extensible via simple plugins.
npm loves you