clctr
Event emitting collections with iterators (like Backbone.Collection).
Warning: Developer preview release. Lots of broken stuff, I'm sure.
Events
var co = ;var c = ; c; c;// [ { name: 'bar', value: 'baz', previousValue: undefined } ]
contains(list, value):Boolean
Checks if collection contains value.
; // true; // false
every(list, callback, [thisObj]):Boolean
Tests whether all values in the collection pass the test implemented by the provided callback.
var obj = a: 1 b: 2 c: 3 d: 'string'; ; // false
filter(list, callback, [thisObj]):Object
Filter collection properties.
find(list, callback, [thisObj]):*
Loops through all the values in the collection and returns the first one that passes a truth test (callback).
Important: loop order over objects properties isn't guaranteed to be the same on all environments.
; // 'foo'; // 12
forEach(list, callback, [thisObj])
Loop through all values of the collection.
map(list, callback, [thisObj]):Object
Returns a new collection where the properties values are the result of calling the callback for each property in the original collection.
max(list, [iterator]):*
Returns maximum value inside collection or use a custom iterator to define how items should be compared.
; // 200; // 'lorem'
min(list, [iterator]):*
Returns minimum value inside collection or use a custom iterator to define how items should be compared.
; // 2; // 'foo'
pluck(list, propName):Array
Extract a list of property values.
var users = [
{
name : 'John',
age : 21
},
{
name : 'Jane',
age : 27
}
];
pluck(users, 'name'); // ["John", "Jane"]
pluck(users, 'age'); // [21, 27]
users = {
first: {
name : 'John',
age : 21
},
second: {
name : 'Mary',
age : 25
}
};
pluck(users, 'name'); // ['John', 'Mary']
reduce(list, callback, initial, [thisObj]):*
Apply a function against an accumulator and each value in the collection as to reduce it to a single value.
var obj = a: 1 b: 2 c: 3 d: 4; { return prev + cur;} ; // 10
reject(obj, callback, thisObj):Object
Returns a new object containing all properties where callback returns true, similar to Array/reject. It does not use properties from the object's prototype. Opposite of filter().
var obj = a: 1 b: 2 c: 3 d: 4 e: 5;; // {b: 2, d: 4}
size(list):Number
Returns the number of values in the collection.
var obj = foo : 1 bar : 2 lorem : 3;; // 3; // 3; // 0
some(list, callback, [thisObj]):Boolean
Tests whether any values in the collection pass the test implemented by the provided callback.
var obj = a: 1 b: 2 c: 3 d: 'string'; ; // true; // true