Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Latest commit

 

History

History
49 lines (27 loc) · 839 Bytes

README.md

File metadata and controls

49 lines (27 loc) · 839 Bytes

Collection.js

A basic JavaScript collection.

Installation

Server-side (Node.js):

$ npm install shannonmoeller/collection.js

Client-side (component(1)):

$ component install shannonmoeller/collection.js

API

Collection(array)

Create a new model which wraps around object.

var Collection = require('collection');
var foo = Collection([{ a: 1 }, { a: 2 }, { a: 3 }]);

.model

.filter(filterer)

.map(mapper)

.pluck(key):Array.<*>
.pluck(array):Array.&lt;Object&gt;

.sort(sorter)

.toJSON()

Returns the current state of the internal data as a plain object.

var foo = Collection([{ a: 1 }, { a: 2 }, { a: 3 }]);

foo.toJSON(); // [{ a: 1 }, { a: 2 }, { a: 3 }]

License

MIT