npm.io
0.1.0 • Published 13 years ago

tower-collection

Licence
Version
0.1.0
Deps
3
Vulns
0
Weekly
0
Stars
1

Tower Collection

Arrays that automatically update your UI.

Installation

$ component install tower/collection

Example

var collection = require('tower-collection');

Create a blank collection:

collection(); // []
collection([]); // []

API

push
collection.push(item);
collection.push(item1, item2);
pop
collection.pop();
shift

Remove first item in array.

collection.shift();
unshift

Add item(s) to beginning of array.

collection.unshift(item);
collection.unshift(item1, item2);
splice(index, length, item)

Modify the original array.

collection.splice(1, 2, item);
length
collection.length;

Notes

The collection is only necessary to bind lists of data (such as queries) to the DOM. It just makes it easier to listen for changes to an array. In most other cases you can just use plain arrays and don't need the power of dirty tracking.

Licence

MIT