Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

sift

Package Overview
Dependencies
Maintainers
2
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 4.0.0 to 5.0.0

2

package.json
{
"name": "sift",
"description": "mongodb query style array filtering",
"version": "4.0.0",
"version": "5.0.0",
"repository": "crcn/sift.js",

@@ -6,0 +6,0 @@ "author": {

@@ -77,4 +77,4 @@ /*

function validate(validator, b) {
return validator.v(validator.a, b);
function validate(validator, b, k, o) {
return validator.v(validator.a, b, k, o);
}

@@ -171,3 +171,3 @@

var validator = createRootValidator(get(a, i), undefined);
var result = validate(validator, b);
var result = validate(validator, b, i, a);
if ((result) && (String(result) !== '[object Object]') && (String(b) !== '[object Object]')) {

@@ -187,4 +187,4 @@ return true;

$nin: function(a, b) {
return !OPERATORS.$in(a, b);
$nin: function(a, b, k, o) {
return !OPERATORS.$in(a, b, k, o);
},

@@ -195,4 +195,4 @@

$not: function(a, b) {
return !validate(a, b);
$not: function(a, b, k, o) {
return !validate(a, b, k, o);
},

@@ -210,4 +210,4 @@

$all: function(a, b) {
return OPERATORS.$and(a, b);
$all: function(a, b, k, o) {
return OPERATORS.$and(a, b, k, o);
},

@@ -225,4 +225,4 @@

$or: function(a, b) {
for (var i = 0, n = a.length; i < n; i++) if (validate(get(a, i), b)) return true;
$or: function(a, b, k, o) {
for (var i = 0, n = a.length; i < n; i++) if (validate(get(a, i), b, k, o)) return true;
return false;

@@ -234,4 +234,4 @@ },

$nor: function(a, b) {
return !OPERATORS.$or(a, b);
$nor: function(a, b, k, o) {
return !OPERATORS.$or(a, b, k, o);
},

@@ -242,5 +242,5 @@

$and: function(a, b) {
$and: function(a, b, k, o) {
for (var i = 0, n = a.length; i < n; i++) {
if (!validate(get(a, i), b)) {
if (!validate(get(a, i), b, k, o)) {
return false;

@@ -262,4 +262,4 @@ }

$where: function(a, b) {
return a.call(b, b);
$where: function(a, b, k, o) {
return a.call(b, b, k, o);
},

@@ -270,7 +270,7 @@

$elemMatch: function(a, b) {
$elemMatch: function(a, b, k, o) {
if (isArray(b)) {
return !!~search(b, a);
}
return validate(a, b);
return validate(a, b, k, o);
},

@@ -281,4 +281,4 @@

$exists: function(a, b) {
return (b != void 0) === a;
$exists: function(a, b, k, o) {
return o.hasOwnProperty(k) === a;
}

@@ -397,2 +397,3 @@ };

for (var i = 0; i < array.length; i++) {
var result = get(array, i);
if (validate(validator, get(array, i))) {

@@ -418,9 +419,17 @@ return i;

var values = [];
findValues(b, a.k, 0, values);
findValues(b, a.k, 0, b, values);
if (values.length === 1) {
return validate(a.nv, values[0]);
var first = values[0];
return validate(a.nv, first[0], first[1], first[2]);
}
return !!~search(values, a.nv);
for (var i = 0; i < values.length; i++) {
var result = values[i];
if (validate(a.nv, result[0], result[1], result[2])) {
return true;
}
}
return false;
}

@@ -431,6 +440,6 @@

function findValues(current, keypath, index, values) {
function findValues(current, keypath, index, object, values) {
if (index === keypath.length || current == void 0) {
values.push(current);
values.push([current, keypath[index - 1], object]);
return;

@@ -446,6 +455,6 @@ }

for (var i = 0, n = current.length; i < n; i++) {
findValues(get(current, i), keypath, index, values);
findValues(get(current, i), keypath, index, current, values);
}
} else {
findValues(get(current, k), keypath, index + 1, values);
findValues(get(current, k), keypath, index + 1, current, values);
}

@@ -509,4 +518,4 @@ }

a: validator,
v: function(a, b) {
return validate(a, getter(b));
v: function(a, b, k, o) {
return validate(a, getter(b), k, o);
}

@@ -530,4 +539,4 @@ };

function filter(b) {
return validate(validator, b);
function filter(b, k, o) {
return validate(validator, b, k, o);
}

@@ -534,0 +543,0 @@

@@ -10,3 +10,2 @@ var assert = require('assert');

[
// $eq

@@ -62,5 +61,6 @@ [{$eq:5}, [5,'5', 6], [5]],

// $exists
[{$exists:false}, [0,false,void 0, null],[void 0, void 0]],
[{$exists:true}, [0,false,void 0, 1, {}],[0, false, 1, {}]],
[{$exists:false}, [0,false,void 0, null],[]],
[{$exists:true}, [0,false,void 0, 1, {}],[0, false, void 0, 1, {}]],
[{"a.b": {$exists: true}}, [{a: {b: "exists"}}, {a: {c: "does not exist"}}], [{a: {b: "exists"}}]],
[{field: { $exists: false }}, [{a: 1}, {a: 2, field: 5}, {a: 3, field: 0}, {a: 4, field: undefined}, {a: 5}],[{a: 1}, {a: 5}]],

@@ -117,2 +117,3 @@ // $in

[{$and:[{$gt:1},{$lt:4}]},[1,2,3,4],[2,3]],
[{$and: [{field: {$not: {$type: String}}}, {field: {$ne: null}}]}, [{a: 1, field: 1}, {a: 2, field: '2'}], [{a: 1, field: 1}]],

@@ -119,0 +120,0 @@ // $regex

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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