Socket
Socket
Sign inDemoInstall

sift

Package Overview
Dependencies
Maintainers
1
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sift - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

10

package.json
{
"name": "sift",
"description": "mongodb query style array filtering",
"version": "2.0.4",
"repository": {},
"version": "2.0.5",
"repository": "crcn/sift.js",
"author": {
"name": "Craig Condon",
"email": "craig.j.condon@gmail.com",
"url": "http://crcn.io"
},
"license": "MIT",
"engines": {},

@@ -7,0 +13,0 @@ "dependencies": {},

1

README.md

@@ -310,2 +310,3 @@ ## validate objects & filter arrays with mongodb queries

sift({ $regex: /^f/i, $nin: ["frank"] }, ["frank", "fred", "sam", "frost"]); // ["fred", "frost"]
sift({ $regex: "^f", $options: "i", $nin: ["frank"] }, ["frank", "fred", "sam", "frost"]); // ["fred", "frost"]
```

@@ -312,0 +313,0 @@

@@ -203,3 +203,3 @@ /*

$regex: function(a, b) {
return a.test(b);
return b && a.test(b);
},

@@ -291,4 +291,4 @@

$regex: function(a) {
return new RegExp(a);
$regex: function(a, options) {
return new RegExp(a, options);
},

@@ -384,3 +384,2 @@

function parse(query) {
query = comparable(query);

@@ -393,2 +392,6 @@

var options = query.$options;
delete query.$options;
var validators = [];

@@ -399,5 +402,4 @@

if (operator[key]) {
if (prepare[key]) a = prepare[key](a);
if (prepare[key]) a = key === '$regex' ? prepare[key](a, options): prepare[key](a);
validators.push(createValidator(comparable(a), operator[key]));

@@ -404,0 +406,0 @@ } else {

@@ -185,2 +185,27 @@ var sift = require(".."),

});
it("$regex for nested object (one missing key)", function () {
var persons = [{
id: 1,
prof: 'Mr. Moriarty'
}, {
id: 2,
prof: 'Mycroft Holmes'
}, {
id: 3,
name: 'Dr. Watson',
prof: 'Doctor'
}, {
id: 4,
name: 'Mr. Holmes',
prof: 'Detective'
}];
var q = { "name": { "$regex": "n" } };
var sifted = sift(q, persons);
assert.deepEqual(sifted, [{
id: 3,
name: 'Dr. Watson',
prof: 'Doctor'
}]);
});
});

@@ -187,0 +212,0 @@

@@ -112,2 +112,6 @@ var assert = require("assert");

[{$regex:"^a"},["a","ab","abc","bc","bcd"],["a","ab","abc"]],
// $options
[{$regex:"^a", $options: 'i'},["a","Ab","abc","bc","bcd"],["a","Ab","abc"]],
// undefined
[{$regex:"a"},[undefined, null, true, false, 0, "aa"],["aa"]],

@@ -114,0 +118,0 @@ // $where

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc