README
Sometimes you want to keep track of a collection of objects, but have that collection indexed by
different properties. This is where indexify might be useful:
indexify = require('indexify');
var persons = indexify([
{ key: 'id', extract: function(obj) { return obj.id; }, unique: true },
{ key: 'age', extract: function(obj) { return obj.age; }, unique: false }
]);
persons.add({
id: '09707', age: 37
});
persons.add({
id: '08227', age: 37
});
persons.by.age(37);
persons.by.id('09707');
That's basically it. The only other thing you're currently able to do is remove objects from the
collection:
persons.remove({
id: '09707', age: 37
});