The Wayback Machine - https://web.archive.org/web/20150925011322/https://www.npmjs.com/package/collection.js

collection.js

Minimalistic JavaScript library for working with collections of data.

Collection

Collection — minimalistic JavaScript library for working with collections of data.

Demo (threads)

Documentation

  • Universal interface for multiple data types: arrays, typed arrays, tables, Map, Set, generators and @@iterator protocol;
  • A rich set of iterators;
  • Built-in self JIT compilation of requests provides a very high speed of execution, which is comparable to the native cycles JavaScript;
  • Support lightweight threads based on generators;
  • Transparent support for the data storage: LocalStorage, SessionStorage, IndexedDB;
  • Work in browsers, as well as on the server (node.js);
  • The engine is written in pure JavaScript and does not have any dependencies;
  • The source code is designed to work with Google Closure Compiler in advanced mode;
  • 3 basic types of the library:
    1. full (min + gzip ~ 22kb);
    2. light (only base iterators, min + gzip ~ 13kb);
    3. core (only forEach, min + gzip ~ 11kb).
  • The modular architecture allows to build your library;
  • Good code coverage;
  • Detailed documentation with examples.
// Iterate over the elements in reverse order starting with the 5th 
$C(document.querySelectorAll('.foo')).forEach(function (el) {
    ...
}, {
    reverse: true,
    startIndex: 5
});
 
// Return an array of all the even elements of the original array 
$C([1, 2, 3, 4]).get(function (el) { return el % 2 === 0; });
 
// Create a new object based on the source, 
// {a: 2, b: 4} 
$C({a: 4, b: 16}).map(Math.sqrt);
 
// Upload a collection from the indexedDB 
$C().load({lib: 'indexedDB', id: 'foo'});
 
// Iterate very large object in the thread 
$C(new Array(1e8)).forEach(function () {
    ...
}, {thread: true});

License

The MIT License.