Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
JavaScript CSS HTML
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
README.md
mozart_brocchini_collection.js

README.md

A JavaScript Collection implementation without external dependencies


Usage

// Create some data
var obj1 = {name:'Ana', age:19, camera:'AE1'};
var obj2 = {name:'Rod', age:76, camera: 'Rolleiflex'};
var obj3 = {name:'Sandy', age:69, camera: 'EOS'};

// Create a collection instance
var col = new Collection();

// Add data to collection object
col.add(obj1)   
   .add(obj2)
   .add(obj3);

// Iterate to next item
alert(col.next()['name']);

// Sort by property
col.sortBy('name');

// Call a function on each collection item 
col.each( 
  function(it){
    alert('Camera is '+ it.camera+ ', age=' +it.age);
  });

alert(col.flatten(' : ', 'camera'));

// Remove an item based on a property value
col.removeByPredicate(
 function(it){ return it['name']=='Rod';}
);
Something went wrong with that request. Please try again.