collectionjs
0.3.4 • Public • Published collectionjs
How to use?
var CL = new Collection('Collection Name');
var a = {x: 1};
var b = {x: 2};
CL.add(a);
CL.add(a);
CL.remove(a);
CL.remove(b);
CL.exists(b);
CL.add(b);
CL.exists(b);
var CL1 = new Collection('Collection 1 Name');
var CL2 = new Collection('Collection 2 Name');
CL1.add(a);
CL1.add(b);
CL2.add(b);
CL1.list();
CL2.list();
Methods
- indexed(key): return array of objects indexed by key
- each(callback): for each object
- add(object): add object to collection, return boolean
- remove(object): remove object from collection, return deleted object
- get(): get some object from collection
- exists(object): check object existing in collection
- contains(object): alias for exists method
- list(): return array of objects
- count(): return count of collection objects
- on(eventName, callback): add event listner
Events
- Event add (obj)
- Event remove (obj)
- Event change (obj, boolean isAdd)
CL.on('add', function (obj) {
console.log(obj);
});
Readme
Keywords
nonePackage Sidebar
Install
Weekly Downloads