Comparing version 2.0.6 to 2.0.7
{ | ||
"name": "sift", | ||
"description": "mongodb query style array filtering", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"repository": "crcn/sift.js", | ||
@@ -26,2 +26,3 @@ "author": { | ||
"gulp-uglify": "^1.2.0", | ||
"nodangel": "^1.3.8", | ||
"yargs": "^3.15.0" | ||
@@ -31,4 +32,5 @@ }, | ||
"scripts": { | ||
"test": "gulp test-coveralls" | ||
"test": "gulp test-coveralls", | ||
"tdd": "nodangel --ignore node_modules --watch test --watch sift.js --exec 'npm run test'" | ||
} | ||
} |
@@ -46,3 +46,3 @@ /* | ||
return function(a, b) { | ||
if (!isArray(b)) return validator(a, b); | ||
if (!isArray(b) || !b.length) return validator(a, b); | ||
for (var i = 0, n = b.length; i < n; i++) if (validator(a, b[i])) return true; | ||
@@ -246,2 +246,7 @@ return false; | ||
return a; | ||
} else if (isArray(a) && !a.length) { | ||
// Special case of a == [] | ||
return function(b) { | ||
return (isArray(b) && !b.length); | ||
}; | ||
} | ||
@@ -248,0 +253,0 @@ |
@@ -67,2 +67,16 @@ var assert = require("assert"), | ||
}); | ||
it("can match empty arrays", function () { | ||
var statusQuery = {$or: [{status: {$exists: false}}, | ||
{status: []}, | ||
{status: {$in: ["urgent", "completed", "today"]}} | ||
]}; | ||
var filtered = sift(statusQuery, [{ status: [] }, | ||
{ status: ["urgent"] }, | ||
{ status: ["nope"] } | ||
]); | ||
assert.equal(filtered.length, 2); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
147794
1524
13