Comparing version 0.2.2 to 0.3.0
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
var _, indexify; | ||
var _, indexify, | ||
slice = [].slice; | ||
@@ -46,4 +47,15 @@ _ = require('lodash'); | ||
return [ | ||
index.key, function(key) { | ||
return data[index.key][key]; | ||
index.key, function() { | ||
var keys, start; | ||
keys = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
if (keys.length === 0) { | ||
throw new Error('Expecting at least one value to search for'); | ||
} else { | ||
start = data[index.key][keys[0]]; | ||
return _.reduce(_.tail(keys), function(acc, key) { | ||
return _.filter(acc, function(obj) { | ||
return _.contains(index.extract(obj), key); | ||
}); | ||
}, start); | ||
} | ||
} | ||
@@ -50,0 +62,0 @@ ]; |
{ | ||
"name": "indexify", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "A simple collection that will automatically update multiple indexes.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -36,2 +36,7 @@ # README | ||
### 0.3 | ||
* Add the ability to search for multiple values: `posts.by.tags('pet', 'house')`. | ||
### 0.2 | ||
@@ -38,0 +43,0 @@ |
3712
64
48