This commit is contained in:
Jonasz Bigda
2023-03-25 21:51:42 +01:00
parent 0db1d5117e
commit b332e9ceb0
1044 changed files with 37502 additions and 63938 deletions

3
node_modules/sift/.babelrc generated vendored
View File

@@ -1,3 +0,0 @@
{
"presets": ["es2015"]
}

1
node_modules/sift/.coveralls.yml generated vendored
View File

@@ -1 +0,0 @@
repo_token: dYtQuNe9CVSGoA5LVadgT3lomowKzEgav

13
node_modules/sift/.travis.yml generated vendored
View File

@@ -1,13 +0,0 @@
language: node_js
node_js:
- 0.10
script: npm run test-coveralls
notifications:
email:
- craig.j.condon@gmail.com
branches:
only:
- master

466
node_modules/sift/README.md generated vendored Normal file → Executable file
View File

@@ -1,5 +1,9 @@
## validate objects & filter arrays with mongodb queries
[![Build Status](https://secure.travis-ci.org/crcn/sift.js.png)](https://secure.travis-ci.org/crcn/sift.js)
**Installation**: `npm install sift`, or `yarn add sift`
## Sift is a tiny library for using MongoDB queries in Javascript
[![Build Status](https://secure.travis-ci.org/crcn/sift.js.png)](https://secure.travis-ci.org/crcn/sift.js)
<!-- [![Coverage Status](https://coveralls.io/repos/crcn/sift.js/badge.svg)](https://coveralls.io/r/crcn/sift.js) -->
<!-- [![Join the chat at https://gitter.im/crcn/sift.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/crcn/sift.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -->
@@ -7,411 +11,455 @@
## Features:
- Supported operators: [$in](#in), [$nin](#nin), [$exists](#exists), [$gte](#gte), [$gt](#gt), [$lte](#lte), [$lt](#lt), [$eq](#eq), [$ne](#ne), [$mod](#mod), [$all](#all), [$and](#and), [$or](#or), [$nor](#nor), [$not](#not), [$size](#size), [$type](#type), [$regex](#regex), [$where](#where), [$elemMatch](#elemmatch)
- Supported operators: [\$in](#in), [\$nin](#nin), [\$exists](#exists), [\$gte](#gte), [\$gt](#gt), [\$lte](#lte), [\$lt](#lt), [\$eq](#eq), [\$ne](#ne), [\$mod](#mod), [\$all](#all), [\$and](#and), [\$or](#or), [\$nor](#nor), [\$not](#not), [\$size](#size), [\$type](#type), [\$regex](#regex), [\$where](#where), [\$elemMatch](#elemmatch)
- Regexp searches
- Function filtering
- sub object searching
- dot notation searching
- Supports node.js, and web
- Small (2 kb minified) library
- Custom Expressions
- filtering of immutable datastructures
- Custom Operations
- Tree-shaking (omitting functionality from web app bundles)
## Node.js Examples
## Examples
```javascript
import sift from 'sift';
import sift from "sift";
//intersecting arrays
var sifted = sift({ $in: ['hello','world'] }, ['hello','sifted','array!']); //['hello']
const result1 = ["hello", "sifted", "array!"].filter(
sift({ $in: ["hello", "world"] })
); //['hello']
//regexp filter
var sifted = sift(/^j/, ['craig','john','jake']); //['john','jake']
const result2 = ["craig", "john", "jake"].filter(sift(/^j/)); //['john','jake']
//A *sifter* is returned if the second parameter is omitted
var testQuery = sift({
//you can also filter against functions
name: function(value) {
return value.length == 5;
}
// function filter
const testFilter = sift({
//you can also filter against functions
name: function(value) {
return value.length == 5;
}
});
//filtered: [{ name: 'craig' }]
[{
name: 'craig',
},
{
name: 'john'
},
{
name: 'jake'
}].filter(testQuery);
const result3 = [
{
name: "craig"
},
{
name: "john"
},
{
name: "jake"
}
].filter(testFilter); // filtered: [{ name: 'craig' }]
//you can test *single values* against your custom sifter
testQuery({ name: 'sarah' }); //true
testQuery({ name: 'tim' }); //false\
```
## Browser Examples
```html
<html>
<head>
<script src="https://raw.github.com/crcn/sift.js/master/sift.min.js" type="text/javascript"></script>
<script type="text/javascript">
//regexp filter
var sifted = sift(/^j/, ['craig','john','jake']); //['john','jake']
</script>
</head>
<body>
</body>
</html>
testFilter({ name: "sarah" }); //true
testFilter({ name: "tim" }); //false
```
## API
### .sift(filter[, array][, selectorFn])
### sift(query: MongoQuery, options?: Options): Function
- `filter` - the filter to use against the target array
- `array` - sifts against target array. Without this, a function is returned
- `selectorFn` - selector for the values within the array.
Creates a filter with all of the built-in MongoDB query operations.
With an array:
- `query` - the filter to use against the target array
- `options`
- `operations` - [custom operations](#custom-operations)
- `compare` - compares difference between two values
Example:
```javascript
sift({$exists:true}, ['craig',null]); //['craig']
import sift from "sift";
const test = sift({ $gt: 5 }));
console.log(test(6)); // true
console.log(test(4)); // false
[3, 4, 5, 6, 7].filter(sift({ $exists: true })); // [6, 7]
```
Without an array, a sifter is returned:
### createQueryTester(query: Query, options?: Options): Function
Creates a filter function **without** built-in MongoDB query operations. This is useful
if you're looking to omit certain operations from application bundles. See [Omitting built-in operations](#omitting-built-in-operations) for more info.
```javascript
var siftExists = sift({$exists:true});
siftExists('craig'); //true
siftExists(null); //false
['craig',null].filter(siftExists); //['craig']
import { createQueryTester, $eq, $in } from "sift";
const filter = createQueryTester({ $eq: 5 }, { operations: { $eq, $in } });
```
With a selector:
### createEqualsOperation(params: any, ownerQuery: Query, options: Options): Operation
Used for [custom operations](#custom-operations).
```javascript
var sifter = sift({$exists:true}, function(user) {
return !!user.name;
});
sifter([
{
name: "Craig"
},
{
name: null
}
])
import { createQueryTester, createEqualsOperation, $eq, $in } from "sift";
const filter = createQueryTester(
{ $mod: 5 },
{
operations: {
$something(mod, ownerQuery, options) {
return createEqualsOperation(
value => value % mod === 0,
ownerQuery,
options
);
}
}
}
);
filter(10); // true
filter(11); // false
```
With your sifter, you can also **test** values:
```javascript
siftExists(null); //false
siftExists('craig'); //true
```
## Supported Operators:
## Supported Operators
See MongoDB's [advanced queries](http://www.mongodb.org/display/DOCS/Advanced+Queries) for more info.
### $in
### \$in
array value must be *$in* the given query:
array value must be _\$in_ the given query:
Intersecting two arrays:
```javascript
//filtered: ['Brazil']
sift({ $in: ['Costa Rica','Brazil'] }, ['Brazil','Haiti','Peru','Chile']);
["Brazil", "Haiti", "Peru", "Chile"].filter(
sift({ $in: ["Costa Rica", "Brazil"] })
);
```
Here's another example. This acts more like the $or operator:
Here's another example. This acts more like the \$or operator:
```javascript
sift({ location: { $in: ['Costa Rica','Brazil'] } }, [ { name: 'Craig', location: 'Brazil' } ]);
[{ name: "Craig", location: "Brazil" }].filter(
sift({ location: { $in: ["Costa Rica", "Brazil"] } })
);
```
### $nin
### \$nin
Opposite of $in:
Opposite of \$in:
```javascript
//filtered: ['Haiti','Peru','Chile']
sift({ $nin: ['Costa Rica','Brazil'] }, ['Brazil','Haiti','Peru','Chile']);
["Brazil", "Haiti", "Peru", "Chile"].filter(
sift({ $nin: ["Costa Rica", "Brazil"] })
);
```
### $exists
### \$exists
Checks if whether a value exists:
```javascript
//filtered: ['Craig','Tim']
sift({ $exists: true }, ['Craig',null,'Tim']);
sift({ $exists: true })(["Craig", null, "Tim"]);
```
You can also filter out values that don't exist
```javascript
//filtered: [{ name: 'Craig', city: 'Minneapolis' }]
sift({ city: { $exists: false } }, [ { name: 'Craig', city: 'Minneapolis' }, { name: 'Tim' }]);
//filtered: [{ name: "Tim" }]
[{ name: "Craig", city: "Minneapolis" }, { name: "Tim" }].filter(
sift({ city: { $exists: false } })
);
```
### $gte
### \$gte
Checks if a number is >= value:
```javascript
//filtered: [2, 3]
sift({ $gte: 2 }, [0, 1, 2, 3]);
[0, 1, 2, 3].filter(sift({ $gte: 2 }));
```
### $gt
### \$gt
Checks if a number is > value:
```javascript
//filtered: [3]
sift({ $gt: 2 }, [0, 1, 2, 3]);
[0, 1, 2, 3].filter(sift({ $gt: 2 }));
```
### $lte
### \$lte
Checks if a number is <= value.
```javascript
//filtered: [0, 1, 2]
sift({ $lte: 2 }, [0, 1, 2, 3]);
[0, 1, 2, 3].filter(sift({ $lte: 2 }));
```
### $lt
### \$lt
Checks if number is < value.
```javascript
//filtered: [0, 1]
sift({ $lt: 2 }, [0, 1, 2, 3]);
[0, 1, 2, 3].filter(sift({ $lt: 2 }));
```
### $eq
### \$eq
Checks if `query === value`. Note that **$eq can be omitted**. For **$eq**, and **$ne**
Checks if `query === value`. Note that **\$eq can be omitted**. For **\$eq**, and **\$ne**
```javascript
//filtered: [{ state: 'MN' }]
sift({ state: {$eq: 'MN' }}, [{ state: 'MN' }, { state: 'CA' }, { state: 'WI' }]);
[{ state: "MN" }, { state: "CA" }, { state: "WI" }].filter(
sift({ state: { $eq: "MN" } })
);
```
Or:
```javascript
//filtered: [{ state: 'MN' }]
sift({ state: 'MN' }, [{ state: 'MN' }, { state: 'CA' }, { state: 'WI' }]);
[{ state: "MN" }, { state: "CA" }, { state: "WI" }].filter(
sift({ state: "MN" })
);
```
### $ne
### \$ne
Checks if `query !== value`.
```javascript
//filtered: [{ state: 'CA' }, { state: 'WI'}]
sift({ state: {$ne: 'MN' }}, [{ state: 'MN' }, { state: 'CA' }, { state: 'WI' }]);
[{ state: "MN" }, { state: "CA" }, { state: "WI" }].filter(
sift({ state: { $ne: "MN" } })
);
```
### $mod
### \$mod
Modulus:
```javascript
//filtered: [300, 600]
sift({ $mod: [3, 0] }, [100, 200, 300, 400, 500, 600]);
[100, 200, 300, 400, 500, 600].filter(sift({ $mod: [3, 0] }));
```
### $all
### \$all
values must match **everything** in array:
```javascript
//filtered: [ { tags: ['books','programming','travel' ]} ]
sift({ tags: {$all: ['books','programming'] }}, [
{ tags: ['books','programming','travel' ] },
{ tags: ['travel','cooking'] } ]);
[
{ tags: ["books", "programming", "travel"] },
{ tags: ["travel", "cooking"] }
].filter(sift({ tags: { $all: ["books", "programming"] } }));
```
### $and
### \$and
ability to use an array of expressions. All expressions must test true.
```javascript
//filtered: [ { name: 'Craig', state: 'MN' }]
sift({ $and: [ { name: 'Craig' }, { state: 'MN' } ] }, [
{ name: 'Craig', state: 'MN' },
{ name: 'Tim', state: 'MN' },
{ name: 'Joe', state: 'CA' } ]);
[
{ name: "Craig", state: "MN" },
{ name: "Tim", state: "MN" },
{ name: "Joe", state: "CA" }
].filter(sift({ $and: [{ name: "Craig" }, { state: "MN" }] }));
```
### $or
### \$or
OR array of expressions.
```javascript
//filtered: [ { name: 'Craig', state: 'MN' }, { name: 'Tim', state: 'MN' }]
sift({ $or: [ { name: 'Craig' }, { state: 'MN' } ] }, [
{ name: 'Craig', state: 'MN' },
{ name: 'Tim', state: 'MN' },
{ name: 'Joe', state: 'CA' } ]);
[
{ name: "Craig", state: "MN" },
{ name: "Tim", state: "MN" },
{ name: "Joe", state: "CA" }
].filter(sift({ $or: [{ name: "Craig" }, { state: "MN" }] }));
```
### $nor
### \$nor
opposite of or:
```javascript
//filtered: [ { name: 'Tim', state: 'MN' }, { name: 'Joe', state: 'CA' }]
sift({ $nor: [ { name: 'Craig' }, { state: 'MN' } ] }, [
{ name: 'Craig', state: 'MN' },
{ name: 'Tim', state: 'MN' },
{ name: 'Joe', state: 'CA' } ]);
[
{ name: "Craig", state: "MN" },
{ name: "Tim", state: "MN" },
{ name: "Joe", state: "CA" }
].filter(sift({ $nor: [{ name: "Craig" }, { state: "MN" }] }));
```
### $size
### \$size
Matches an array - must match given size:
```javascript
//filtered: ['food','cooking']
sift({ tags: { $size: 2 } }, [ { tags: ['food','cooking'] }, { tags: ['traveling'] }]);
[{ tags: ["food", "cooking"] }, { tags: ["traveling"] }].filter(
sift({ tags: { $size: 2 } })
);
```
### $type
### \$type
Matches a values based on the type
```javascript
sift({ $type: Date }, [new Date(), 4342, 'hello world']); //returns single date
sift({ $type: String }, [new Date(), 4342, 'hello world']); //returns ['hello world']
[new Date(), 4342, "hello world"].filter(sift({ $type: Date })); //returns single date
[new Date(), 4342, "hello world"].filter(sift({ $type: String })); //returns ['hello world']
```
### $regex
### \$regex
Matches values based on the given regular expression
```javascript
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"]
["frank", "fred", "sam", "frost"].filter(
sift({ $regex: /^f/i, $nin: ["frank"] })
); // ["fred", "frost"]
["frank", "fred", "sam", "frost"].filter(
sift({ $regex: "^f", $options: "i", $nin: ["frank"] })
); // ["fred", "frost"]
```
### $where
### \$where
Matches based on some javascript comparison
```javascript
sift({ $where: "this.name === 'frank'" }, [{name:'frank'},{name:'joe'}]); // ["frank"]
sift({
$where: function() {
return this.name === "frank"
}
}, [{name:'frank'},{name:'joe'}]); // ["frank"]
[{ name: "frank" }, { name: "joe" }].filter(
sift({ $where: "this.name === 'frank'" })
); // ["frank"]
[{ name: "frank" }, { name: "joe" }].filter(
sift({
$where: function() {
return this.name === "frank";
}
})
); // ["frank"]
```
### $elemMatch
### \$elemMatch
Matches elements of array
```javascript
var bills = [{
month: 'july',
casts: [{
var bills = [
{
month: "july",
casts: [
{
id: 1,
value: 200
},{
},
{
id: 2,
value: 1000
}]
},
{
month: 'august',
casts: [{
}
]
},
{
month: "august",
casts: [
{
id: 3,
value: 1000,
}, {
value: 1000
},
{
id: 4,
value: 4000
}]
}];
}
]
}
];
var result = sift({
casts: {$elemMatch:{
value: {$gt: 1000}
}}
}, bills); // {month:'august', casts:[{id:3, value: 1000},{id: 4, value: 4000}]}
var result = bills.filter(
sift({
casts: {
$elemMatch: {
value: { $gt: 1000 }
}
}
})
); // {month:'august', casts:[{id:3, value: 1000},{id: 4, value: 4000}]}
```
### $not
### \$not
Not expression:
```javascript
sift({$not:{$in:['craig','tim']}}, ['craig','tim','jake']); //['jake']
sift({$not:{$size:5}}, ['craig','tim','jake']); //['tim','jake']
["craig", "tim", "jake"].filter(sift({ $not: { $in: ["craig", "tim"] } })); //['jake']
["craig", "tim", "jake"].filter(sift({ $not: { $size: 5 } })); //['tim','jake']
```
## sub object Searching
### Date comparison
Mongodb allows you to do date comparisons like so:
```javascript
var people = [{
name: 'craig',
address: {
city: 'Minneapolis'
}
},
{
name: 'tim',
address: {
city: 'St. Paul'
}
}];
var sifted = sift({ address: { city: 'Minneapolis' }}, people); // count = 1
//or
var sifted = sift({'address.city': 'minneapolis'}, people);//count = 1
db.collection.find({ createdAt: { $gte: "2018-03-22T06:00:00Z" } });
```
## Get index of first matching element
Get the index (0-based) of first matching element in target array. Returns `-1` if no match is found.
In Sift, you'll need to specify a Date object:
```javascript
import {indexOf as siftIndexOf} from 'sift';
var people = [{
name: 'craig',
address: {
city: 'Minneapolis'
}
},
{
name: 'tim',
address: {
city: 'St. Paul'
}
}];
var index = siftIndexOf({ address: { city: 'Minneapolis' }}, people); // index = 0
collection.find(
sift({ createdAt: { $gte: new Date("2018-03-22T06:00:00Z") } })
);
```
## Custom behavior
Sift works like MongoDB out of the box, but you're also able to modify the behavior to suite your needs.
#### Custom operations
You can register your own custom operations. Here's an example:
```javascript
import sift, { createEqualsOperation } from "sift";
var filter = sift(
{
$customMod: 2
},
{
operations: {
$customMod(params, ownerQuery, options) {
return createEqualsOperation(
value => value % params !== 0,
ownerQuery,
options
);
}
}
}
);
[1, 2, 3, 4, 5].filter(filter); // 1, 3, 5
```
#### Omitting built-in operations
You can create a filter function that omits the built-in operations like so:
```javascript
import { createQueryTester, $in, $all, $nin, $lt } from "sift";
const test = createQueryTester(
{
$eq: 10
},
{ $in, $all, $nin, $lt }
);
[1, 2, 3, 4, 10].filter(test);
```
For bundlers like `Webpack` and `Rollup`, operations that aren't used are omitted from application bundles via tree-shaking.

21
node_modules/sift/bower.json generated vendored
View File

@@ -1,21 +0,0 @@
{
"name": "sift",
"version": "3.2.0",
"authors": [
"Craig Condon <craig.j.condon@gmail.com>"
],
"description": "mongodb query style array filtering",
"main": "sift.min.js",
"moduleType": [],
"license": "MIT",
"homepage": "https://github.com/crcn/sift.js",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"benchmark",
"webpack.js",
"package.json"
]
}

54
node_modules/sift/changelog.md generated vendored
View File

@@ -1,3 +1,55 @@
## 13.1.0
- Added stronger types for queries: https://github.com/crcn/sift.js/issues/197
## 13.0.0
- Fix behavior discrepancy with Mongo: https://github.com/crcn/sift.js/issues/196
## 12.0.0
- Fix bug where \$elemMatch tested objects: e.g: `sift({a: {$elemMatch: 1}})({ a: { b: 1}})`. \$elemMatch now expects arrays based on Mongodb syntax. E.g: `sift({a: {$elemMatch: 1}})({ a: { b: 1}})`
## 11.0.0
- new custom operations syntax (see API readme)
- null & undefined are not treated equally (change has been added to keep spec as functionality as possible to MongoDB)
- `select` option has been removed
- `compare` option now expects `boolean` return value instead of an integer
- nested queries are no-longer supported
- `expressions` option is now `operations`
- `operations` parameter now expects new operations API
- ImmutableJS support removed for now
- Remove bower support
## 9.0.0
- (behavior change) toJSON works for vanilla objects.
## 8.5.1
- Fix dependency vulnerability
- Fix #158
## 8.5.0
- Added `comparable` option (fix https://github.com/crcn/sift.js/issues/156)
## 8.4.0
- Added `compare` option (fix https://github.com/crcn/sift.js/issues/155)
## 8.3.2
- Query _properties_ now excpect exact object shape (based on https://github.com/crcn/sift.js/issues/152). E.g: `[{a: { b: 1}}, {a: { b: 1, c: 2}}]].filter(sift({ a: { b: 1} })) === [{a: {b: 1}]`, and `[{a: 1, b: 1}, {a: 1}]].filter(sift({ a: 1 })) === [{a: 1, b: 1}, {a: 1}]`.
## 8.0.0
- DEPRECATED `indexOf` in favor of `array.findIndex(sift(query))`
- second param is now `options` instead of select function. E.g: `sift(query, { expressions: customExpressions, select: selectValue })`
- DEPRECATED `sift(query, array)`. You must now use `array.filter(sift(query))`
- Queries now expect exact object shape (based on https://github.com/crcn/sift.js/issues/117). E.g: `[{a: 1, b: 1}, {a: 1}]].filter(sift({ a: 1 })) === [{a: 1}]`
### 7.0.0
- Remove global `*.use()` function.
@@ -18,7 +70,7 @@ sift.use({
// compare here
};
}
})
});
```
- all operators are traversable now

File diff suppressed because one or more lines are too long

446
node_modules/sift/coverage/lcov.info generated vendored
View File

@@ -1,446 +0,0 @@
TN:
SF:/Users/crcn/Developer/public/sift.js/sift.js
FN:10,(anonymous_1)
FN:17,isFunction
FN:24,isArray
FN:31,comparable
FN:43,get
FN:50,or
FN:51,(anonymous_7)
FN:65,and
FN:66,(anonymous_9)
FN:77,validate
FN:86,(anonymous_11)
FN:93,(anonymous_12)
FN:100,(anonymous_13)
FN:107,(anonymous_14)
FN:114,(anonymous_15)
FN:121,(anonymous_16)
FN:128,(anonymous_17)
FN:135,(anonymous_18)
FN:185,(anonymous_19)
FN:192,(anonymous_20)
FN:199,(anonymous_21)
FN:206,(anonymous_22)
FN:213,(anonymous_23)
FN:220,(anonymous_24)
FN:228,(anonymous_25)
FN:235,(anonymous_26)
FN:247,(anonymous_27)
FN:254,(anonymous_28)
FN:261,(anonymous_29)
FN:271,(anonymous_30)
FN:284,(anonymous_31)
FN:287,(anonymous_32)
FN:294,(anonymous_33)
FN:298,(anonymous_34)
FN:304,(anonymous_35)
FN:312,(anonymous_36)
FN:319,(anonymous_37)
FN:326,(anonymous_38)
FN:333,(anonymous_39)
FN:340,(anonymous_40)
FN:347,(anonymous_41)
FN:354,(anonymous_42)
FN:361,(anonymous_43)
FN:368,(anonymous_44)
FN:375,(anonymous_45)
FN:383,search
FN:398,createValidator
FN:405,nestedValidator
FN:432,findValues
FN:457,createNestedValidator
FN:465,isVanillaObject
FN:469,parse
FN:503,createRootValidator
FN:508,(anonymous_54)
FN:519,sift
FN:528,filter
FN:542,(anonymous_57)
FN:555,(anonymous_58)
FN:562,(anonymous_59)
FNF:59
FNH:59
FNDA:1,(anonymous_1)
FNDA:1480,isFunction
FNDA:3068,isArray
FNDA:1895,comparable
FNDA:1341,get
FNDA:7,or
FNDA:509,(anonymous_7)
FNDA:1,and
FNDA:57,(anonymous_9)
FNDA:1076,validate
FNDA:399,(anonymous_11)
FNDA:59,(anonymous_12)
FNDA:34,(anonymous_13)
FNDA:15,(anonymous_14)
FNDA:24,(anonymous_15)
FNDA:10,(anonymous_16)
FNDA:10,(anonymous_17)
FNDA:99,(anonymous_18)
FNDA:22,(anonymous_19)
FNDA:15,(anonymous_20)
FNDA:13,(anonymous_21)
FNDA:18,(anonymous_22)
FNDA:7,(anonymous_23)
FNDA:32,(anonymous_24)
FNDA:10,(anonymous_25)
FNDA:58,(anonymous_26)
FNDA:41,(anonymous_27)
FNDA:6,(anonymous_28)
FNDA:11,(anonymous_29)
FNDA:25,(anonymous_30)
FNDA:236,(anonymous_31)
FNDA:41,(anonymous_32)
FNDA:3,(anonymous_33)
FNDA:5,(anonymous_34)
FNDA:406,(anonymous_35)
FNDA:18,(anonymous_36)
FNDA:10,(anonymous_37)
FNDA:6,(anonymous_38)
FNDA:4,(anonymous_39)
FNDA:2,(anonymous_40)
FNDA:4,(anonymous_41)
FNDA:21,(anonymous_42)
FNDA:3,(anonymous_43)
FNDA:5,(anonymous_44)
FNDA:8,(anonymous_45)
FNDA:8,search
FNDA:378,createValidator
FNDA:215,nestedValidator
FNDA:706,findValues
FNDA:92,createNestedValidator
FNDA:413,isVanillaObject
FNDA:443,parse
FNDA:306,createRootValidator
FNDA:4,(anonymous_54)
FNDA:135,sift
FNDA:413,filter
FNDA:4,(anonymous_57)
FNDA:2,(anonymous_58)
FNDA:489,(anonymous_59)
DA:10,1
DA:17,1
DA:18,1480
DA:24,1
DA:25,3068
DA:31,1
DA:32,1895
DA:33,36
DA:34,1859
DA:35,45
DA:36,1814
DA:37,27
DA:39,1787
DA:43,1
DA:44,1341
DA:50,1
DA:51,7
DA:52,509
DA:53,474
DA:55,35
DA:56,59
DA:58,12
DA:65,1
DA:66,1
DA:67,57
DA:68,53
DA:70,4
DA:71,6
DA:73,2
DA:77,1
DA:78,1076
DA:81,1
DA:87,399
DA:94,59
DA:101,34
DA:108,15
DA:115,24
DA:122,10
DA:129,10
DA:137,99
DA:138,10
DA:139,11
DA:140,8
DA:144,89
DA:145,89
DA:146,8
DA:147,12
DA:148,1
DA:157,88
DA:158,22
DA:159,24
DA:160,1
DA:168,87
DA:169,169
DA:170,169
DA:171,169
DA:172,34
DA:176,53
DA:179,2
DA:186,22
DA:193,15
DA:200,13
DA:207,18
DA:214,7
DA:221,64
DA:222,11
DA:229,10
DA:236,58
DA:237,98
DA:238,27
DA:241,31
DA:248,41
DA:255,6
DA:262,11
DA:263,6
DA:265,5
DA:272,25
DA:279,1
DA:286,236
DA:287,19
DA:288,41
DA:290,217
DA:291,1
DA:292,216
DA:294,1
DA:295,3
DA:297,215
DA:298,4
DA:300,5
DA:304,211
DA:305,406
DA:313,18
DA:320,10
DA:327,6
DA:334,4
DA:341,2
DA:348,4
DA:355,21
DA:362,3
DA:369,5
DA:376,8
DA:383,1
DA:385,8
DA:386,15
DA:387,15
DA:388,5
DA:392,3
DA:398,1
DA:399,378
DA:405,1
DA:406,215
DA:407,215
DA:409,215
DA:410,179
DA:411,179
DA:415,36
DA:416,36
DA:417,36
DA:418,114
DA:419,114
DA:420,114
DA:421,8
DA:423,106
DA:426,36
DA:432,1
DA:434,706
DA:436,293
DA:437,293
DA:440,413
DA:445,413
DA:446,41
DA:447,119
DA:450,372
DA:457,1
DA:458,92
DA:465,1
DA:466,413
DA:469,1
DA:470,443
DA:472,443
DA:473,215
DA:476,443
DA:478,443
DA:479,458
DA:481,458
DA:482,2
DA:485,456
DA:486,363
DA:487,363
DA:490,93
DA:491,1
DA:493,92
DA:497,442
DA:503,1
DA:504,306
DA:505,305
DA:506,3
DA:509,4
DA:513,305
DA:519,1
DA:521,135
DA:522,1
DA:523,1
DA:526,135
DA:528,1
DA:529,413
DA:532,134
DA:533,33
DA:536,101
DA:542,1
DA:543,4
DA:544,3
DA:546,3
DA:547,3
DA:555,1
DA:556,2
DA:562,1
DA:563,489
DA:564,363
DA:565,284
DA:566,151
DA:568,133
DA:569,133
DA:575,1
DA:576,1
DA:580,1
DA:581,1
DA:585,1
DA:586,1
LF:189
LH:189
BRDA:32,1,0,36
BRDA:32,1,1,1859
BRDA:34,2,0,45
BRDA:34,2,1,1814
BRDA:36,3,0,27
BRDA:36,3,1,1787
BRDA:36,4,0,1814
BRDA:36,4,1,1628
BRDA:44,5,0,12
BRDA:44,5,1,1329
BRDA:52,6,0,474
BRDA:52,6,1,35
BRDA:52,7,0,509
BRDA:52,7,1,36
BRDA:56,8,0,23
BRDA:56,8,1,36
BRDA:67,9,0,53
BRDA:67,9,1,4
BRDA:67,10,0,57
BRDA:67,10,1,4
BRDA:71,11,0,2
BRDA:71,11,1,4
BRDA:137,12,0,10
BRDA:137,12,1,89
BRDA:139,13,0,8
BRDA:139,13,1,3
BRDA:145,14,0,8
BRDA:145,14,1,81
BRDA:145,15,0,89
BRDA:145,15,1,85
BRDA:147,16,0,1
BRDA:147,16,1,11
BRDA:147,17,0,12
BRDA:147,17,1,7
BRDA:157,18,0,22
BRDA:157,18,1,66
BRDA:159,19,0,1
BRDA:159,19,1,23
BRDA:171,20,0,34
BRDA:171,20,1,135
BRDA:171,21,0,169
BRDA:171,21,1,37
BRDA:171,21,2,36
BRDA:200,22,0,12
BRDA:200,22,1,1
BRDA:200,23,0,12
BRDA:200,23,1,11
BRDA:214,24,0,6
BRDA:214,24,1,1
BRDA:221,25,0,21
BRDA:221,25,1,43
BRDA:237,26,0,27
BRDA:237,26,1,71
BRDA:248,27,0,41
BRDA:248,27,1,30
BRDA:262,28,0,6
BRDA:262,28,1,5
BRDA:286,29,0,19
BRDA:286,29,1,217
BRDA:288,30,0,41
BRDA:288,30,1,25
BRDA:290,31,0,1
BRDA:290,31,1,216
BRDA:292,32,0,1
BRDA:292,32,1,215
BRDA:292,33,0,216
BRDA:292,33,1,1
BRDA:295,34,0,3
BRDA:295,34,1,1
BRDA:297,35,0,4
BRDA:297,35,1,211
BRDA:362,36,0,2
BRDA:362,36,1,1
BRDA:387,37,0,5
BRDA:387,37,1,10
BRDA:409,38,0,179
BRDA:409,38,1,36
BRDA:415,39,0,36
BRDA:415,39,1,36
BRDA:415,39,2,36
BRDA:420,40,0,8
BRDA:420,40,1,106
BRDA:434,41,0,293
BRDA:434,41,1,413
BRDA:434,42,0,706
BRDA:434,42,1,414
BRDA:445,43,0,41
BRDA:445,43,1,372
BRDA:445,44,0,413
BRDA:445,44,1,45
BRDA:466,45,0,413
BRDA:466,45,1,413
BRDA:472,46,0,215
BRDA:472,46,1,228
BRDA:472,47,0,443
BRDA:472,47,1,413
BRDA:481,48,0,2
BRDA:481,48,1,456
BRDA:485,49,0,363
BRDA:485,49,1,93
BRDA:486,50,0,294
BRDA:486,50,1,69
BRDA:490,51,0,1
BRDA:490,51,1,92
BRDA:497,52,0,427
BRDA:497,52,1,15
BRDA:505,53,0,3
BRDA:505,53,1,302
BRDA:521,54,0,1
BRDA:521,54,1,134
BRDA:532,55,0,33
BRDA:532,55,1,101
BRDA:543,56,0,1
BRDA:543,56,1,3
BRDA:546,57,0,3
BRDA:546,57,1,0
BRDA:563,58,0,126
BRDA:563,58,1,363
BRDA:564,59,0,284
BRDA:564,59,1,79
BRDA:565,60,0,151
BRDA:565,60,1,133
BRDA:568,61,0,133
BRDA:568,61,1,0
BRDA:575,62,0,1
BRDA:575,62,1,0
BRDA:575,63,0,1
BRDA:575,63,1,1
BRDA:585,64,0,0
BRDA:585,64,1,1
BRF:130
BRH:129
end_of_record

154
node_modules/sift/gulpfile.js generated vendored
View File

@@ -1,154 +0,0 @@
var gulp = require("gulp");
var istanbul = require("gulp-istanbul");
var mocha = require("gulp-mocha");
var plumber = require("gulp-plumber");
var jshint = require("gulp-jshint");
var uglify = require("gulp-uglify");
var jscs = require("gulp-jscs");
var coveralls = require("gulp-coveralls");
var rename = require("gulp-rename");
var options = require("yargs").argv;
var pkg = require("./package");
/**
*/
var paths = {
testFiles : ["test/**/*-test.js"],
appFiles : ["sift.js"],
allFiles : ["test/**/*-test.js", "sift.js"]
};
/**
*/
var mochaOptions = {
bail : options.bail !== 'false',
reporter : options.reporter || 'dot',
grep : options.grep || options.only,
timeout : 500
}
/**
*/
gulp.task("test-coverage", function (complete) {
gulp.
src(paths.appFiles).
pipe(istanbul()).
pipe(istanbul.hookRequire()).
on("finish", function () {
gulp.
src(paths.testFiles).
pipe(plumber()).
pipe(mocha(mochaOptions)).
pipe(istanbul.writeReports({
reporters: ["text","text-summary", "lcov"]
})).
on("end", complete);
});
});
/**
*/
gulp.task("test-coveralls", ["test-coverage"], function () {
return gulp.
src("coverage/**/lcov.info").
pipe(coveralls());
});
/**
*/
gulp.task("minify", function() {
return gulp.
src("./" + pkg.name + ".js").
pipe(uglify()).
pipe(rename(function(path) {
path.basename += ".min";
})).
pipe(gulp.dest("./"));
});
/**
*/
gulp.task("lint", function() {
return gulp.run(["jshint", "jscs"]);
});
/**
*/
gulp.task("jscs", function() {
return gulp.
src(paths.allFiles).
pipe(jscs({
"preset": "google",
"requireParenthesesAroundIIFE": true,
"maximumLineLength": 200,
"validateLineBreaks": "LF",
"validateIndentation": 2,
"validateQuoteMarks": "\"",
"disallowKeywords": ["with"],
"disallowSpacesInsideObjectBrackets": null,
"disallowImplicitTypeConversion": ["string"],
"requireCurlyBraces": [],
"safeContextKeyword": "self"
}));
});
/**
*/
gulp.task("jshint", function() {
return gulp.
src(paths.allFiles).
pipe(jshint({
es3: true,
evil: true
})).
pipe(jshint.reporter('default'));
});
/**
*/
gulp.task("test", function (complete) {
gulp.
src(paths.testFiles, { read: false }).
pipe(plumber()).
pipe(mocha(mochaOptions)).
on("error", complete).
on("end", complete);
});
var iofwatch = process.argv.indexOf("watch");
/**
* runs previous tasks (1 or more)
*/
gulp.task("watch", function () {
gulp.watch(paths.allFiles, process.argv.slice(2, iofwatch));
});
/**
*/
gulp.task("default", function () {
return gulp.run("test-coverage");
});
/**
*/
gulp.doneCallback = function (err) {
// a bit hacky, but fixes issue with testing where process
// doesn't exist process. Also fixes case where timeout / interval are set (CC)
if (!~iofwatch) process.exit(err ? 1 : 0);
};

64
node_modules/sift/index.d.ts generated vendored
View File

@@ -1,62 +1,4 @@
export type SupportedTypes = Array<string | { [index: string]: any } | number | null | any>;
export type KeyOrValue<T extends SupportedTypes> = T & T[0];
import sift from "./lib";
export type ElemMatch<T extends { [index: string]: any[] }> = {
[P in keyof T]?: SiftQuery<T[P]>;
}
export type Query<T extends SupportedTypes> = {
$eq?: T[0];
$ne?: T[0];
$or?: Array<Partial<T[0]>>;
$gt?: T[0];
$gte?: T[0];
$lt?: T[0];
$lte?: T[0];
$mod?: number[];
$in?: Array<Partial<T[0]>>;
$nin?: Array<Partial<T[0]>>;
$not?: SiftQuery<T>;
$type?: any;
$all?: Array<Partial<T[0]>>;
$size?: number;
$nor?: Array<Partial<T[0]>>;
$and?: Array<Partial<T[0]>>;
$regex?: RegExp | string;
$elemMatch?: ExternalQuery<T>;
$exists?: boolean;
$where?: string | WhereFn<T>;
$options?: "i" | "g" | "m" | "u";
}
export interface InternalQuery<T extends SupportedTypes> extends Query<T> {
}
export type ExternalQuery<T extends SupportedTypes> = ElemMatch<T[0]>;
export type WhereFn<T extends SupportedTypes> = (this: T[0], value: T[0], index: number, array: T) => boolean;
export type FilterFn = <T>(value: T, index?: number, array?: T[]) => boolean;
export type SiftQuery<T extends SupportedTypes> = ExternalQuery<T> & InternalQuery<T>;
export type PluginDefinition<T> = {
[index: string]: (a: T, b: T) => boolean | number;
}
export type PluginFunction<T> = (sift: Sift) => PluginDefinition<T>;
export type Exec = <T extends SupportedTypes>(array: T) => T;
export interface Sift {
<T extends SupportedTypes>(query: RegExp, target: T, rawSelector?: any): T;
<T>(query: SiftQuery<any>, rawSelector: (item: T) => boolean): Exec;
<T extends SupportedTypes[]>(query: SiftQuery<T>): FilterFn;
<T extends SupportedTypes>(query: SiftQuery<T>, target: T, rawSelector?: any): T;
indexOf<T extends SupportedTypes>(query: SiftQuery<T>, target: T, rawSelector?: any): number;
compare<T, K>(a: T, b: K): 0 | -1 | 1;
}
declare const Sift: Sift
export default Sift
export default sift;
export * from "./lib";

1219
node_modules/sift/lib/index.js generated vendored

File diff suppressed because it is too large Load Diff

77
node_modules/sift/package.json generated vendored
View File

@@ -1,38 +1,61 @@
{
"name": "sift",
"description": "mongodb query style array filtering",
"version": "7.0.1",
"description": "MongoDB query filtering in JavaScript",
"version": "13.5.2",
"repository": "crcn/sift.js",
"sideEffects": false,
"author": {
"name": "Craig Condon",
"email": "craig.j.condon@gmail.com",
"url": "http://crcn.io"
"email": "craig.j.condon@gmail.com"
},
"license": "MIT",
"engines": {},
"dependencies": {},
"typings": "./index.d.ts",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-preset-es2015": "^6.24.1",
"babel-preset-es2015-loose": "^8.0.0",
"bson": "^3.0.2",
"immutable": "^3.7.6",
"mocha": "^5.2.0",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2",
"yargs": "^3.15.0"
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
},
"main": "./lib/index.js",
"module": "./src/index.js",
"es2015": "./src/index.js",
"devDependencies": {
"@rollup/plugin-replace": "^2.3.2",
"@rollup/plugin-typescript": "^4.1.1",
"@types/node": "^13.7.0",
"bson": "^4.0.3",
"eval": "^0.1.4",
"husky": "^1.2.1",
"immutable": "^3.7.6",
"mocha": "8.3.2",
"mongodb": "^3.6.6",
"prettier": "1.15.3",
"pretty-quick": "^1.11.1",
"rimraf": "^3.0.2",
"rollup": "^2.7.2",
"rollup-plugin-terser": "^7.0.2",
"tslib": "^2.0.0",
"typescript": "^3.8.3"
},
"main": "./index.js",
"module": "./es5m/index.js",
"es2015": "./es/index.js",
"scripts": {
"build": "mkdir -p lib; babel src/index.js > lib/index.js; webpack",
"test": "mocha ./test -R spec --compilers js:babel-core/register"
}
,"_resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz"
,"_integrity": "sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g=="
,"_from": "sift@7.0.1"
}
"clean": "rimraf lib es5m es",
"prebuild": "npm run clean && npm run build:types",
"build": "rollup -c",
"build:types": "tsc -p tsconfig.json --emitDeclarationOnly --outDir lib",
"test": "npm run test:spec && npm run test:types",
"test:spec": "mocha ./test -R spec",
"test:types": "cd test && tsc types.ts --noEmit",
"prepublishOnly": "npm run build && npm run test"
},
"files": [
"es",
"es5m",
"lib",
"*.d.ts",
"*.js.map",
"index.js",
"sift.csp.min.js",
"sift.min.js",
"MIT-LICENSE.txt"
]
}

17
node_modules/sift/sift.min.js generated vendored

File diff suppressed because one or more lines are too long

554
node_modules/sift/src/index.js generated vendored
View File

@@ -1,554 +0,0 @@
/*
*
* Copryright 2018, Craig Condon
* Licensed under MIT
*
* Filter JavaScript objects with mongodb queries
*/
/**
*/
function isFunction(value) {
return typeof value === 'function';
}
/**
*/
function isArray(value) {
return Object.prototype.toString.call(value) === '[object Array]';
}
/**
*/
function comparable(value) {
if (value instanceof Date) {
return value.getTime();
} else if (isArray(value)) {
return value.map(comparable);
} else if (value && typeof value.toJSON === 'function') {
return value.toJSON();
} else {
return value;
}
}
function get(obj, key) {
return isFunction(obj.get) ? obj.get(key) : obj[key];
}
/**
*/
function or(validator) {
return function(a, b) {
if (!isArray(b) || !b.length) {
return validator(a, b);
}
for (var i = 0, n = b.length; i < n; i++) {
if (validator(a, get(b,i))) return true;
}
return false;
}
}
/**
*/
function and(validator) {
return function(a, b) {
if (!isArray(b) || !b.length) {
return validator(a, b);
}
for (var i = 0, n = b.length; i < n; i++) {
if (!validator(a, get(b, i))) return false;
}
return true;
};
}
function validate(validator, b, k, o) {
return validator.v(validator.a, b, k, o);
}
var OPERATORS = {
/**
*/
$eq: or(function(a, b) {
return a(b);
}),
/**
*/
$ne: and(function(a, b) {
return !a(b);
}),
/**
*/
$gt: or(function(a, b) {
return compare(comparable(b), a) > 0;
}),
/**
*/
$gte: or(function(a, b) {
return compare(comparable(b), a) >= 0;
}),
/**
*/
$lt: or(function(a, b) {
return compare(comparable(b), a) < 0;
}),
/**
*/
$lte: or(function(a, b) {
return compare(comparable(b), a) <= 0;
}),
/**
*/
$mod: or(function(a, b) {
return b % a[0] == a[1];
}),
/**
*/
$in: function(a, b) {
if (b instanceof Array) {
for (var i = b.length; i--;) {
if (~a.indexOf(comparable(get(b, i)))) {
return true;
}
}
} else {
var comparableB = comparable(b);
if (comparableB === b && typeof b === 'object') {
for (var i = a.length; i--;) {
if (String(a[i]) === String(b) && String(b) !== '[object Object]') {
return true;
}
}
}
/*
Handles documents that are undefined, whilst also
having a 'null' element in the parameters to $in.
*/
if (typeof comparableB == 'undefined') {
for (var i = a.length; i--;) {
if (a[i] == null) {
return true;
}
}
}
/*
Handles the case of {'field': {$in: [/regexp1/, /regexp2/, ...]}}
*/
for (var i = a.length; i--;) {
var validator = createRootValidator(get(a, i), undefined);
var result = validate(validator, b, i, a);
if ((result) && (String(result) !== '[object Object]') && (String(b) !== '[object Object]')) {
return true;
}
}
return !!~a.indexOf(comparableB);
}
return false;
},
/**
*/
$nin: function(a, b, k, o) {
return !OPERATORS.$in(a, b, k, o);
},
/**
*/
$not: function(a, b, k, o) {
return !validate(a, b, k, o);
},
/**
*/
$type: function(a, b) {
return b != void 0 ? b instanceof a || b.constructor == a : false;
},
/**
*/
$all: function(a, b, k, o) {
return OPERATORS.$and(a, b, k, o);
},
/**
*/
$size: function(a, b) {
return b ? a === b.length : false;
},
/**
*/
$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;
},
/**
*/
$nor: function(a, b, k, o) {
return !OPERATORS.$or(a, b, k, o);
},
/**
*/
$and: function(a, b, k, o) {
for (var i = 0, n = a.length; i < n; i++) {
if (!validate(get(a, i), b, k, o)) {
return false;
}
}
return true;
},
/**
*/
$regex: or(function(a, b) {
return typeof b === 'string' && a.test(b);
}),
/**
*/
$where: function(a, b, k, o) {
return a.call(b, b, k, o);
},
/**
*/
$elemMatch: function(a, b, k, o) {
if (isArray(b)) {
return !!~search(b, a);
}
return validate(a, b, k, o);
},
/**
*/
$exists: function(a, b, k, o) {
return o.hasOwnProperty(k) === a;
}
};
/**
*/
var prepare = {
/**
*/
$eq: function(a) {
if (a instanceof RegExp) {
return function(b) {
return typeof b === 'string' && a.test(b);
};
} else if (a instanceof Function) {
return a;
} else if (isArray(a) && !a.length) {
// Special case of a == []
return function(b) {
return (isArray(b) && !b.length);
};
} else if (a === null){
return function(b){
//will match both null and undefined
return b == null;
}
}
return function(b) {
return compare(comparable(b), comparable(a)) === 0;
};
},
/**
*/
$ne: function(a) {
return prepare.$eq(a);
},
/**
*/
$and: function(a) {
return a.map(parse);
},
/**
*/
$all: function(a) {
return prepare.$and(a);
},
/**
*/
$or: function(a) {
return a.map(parse);
},
/**
*/
$nor: function(a) {
return a.map(parse);
},
/**
*/
$not: function(a) {
return parse(a);
},
/**
*/
$regex: function(a, query) {
return new RegExp(a, query.$options);
},
/**
*/
$where: function(a) {
return typeof a === 'string' ? new Function('obj', 'return ' + a) : a;
},
/**
*/
$elemMatch: function(a) {
return parse(a);
},
/**
*/
$exists: function(a) {
return !!a;
}
};
/**
*/
function search(array, validator) {
for (var i = 0; i < array.length; i++) {
var result = get(array, i);
if (validate(validator, get(array, i))) {
return i;
}
}
return -1;
}
/**
*/
function createValidator(a, validate) {
return { a: a, v: validate };
}
/**
*/
function nestedValidator(a, b) {
var values = [];
findValues(b, a.k, 0, b, values);
if (values.length === 1) {
var first = values[0];
return validate(a.nv, first[0], first[1], first[2]);
}
// If the query contains $ne, need to test all elements ANDed together
var inclusive = a && a.q && typeof a.q.$ne !== 'undefined';
var allValid = inclusive;
for (var i = 0; i < values.length; i++) {
var result = values[i];
var isValid = validate(a.nv, result[0], result[1], result[2]);
if (inclusive) {
allValid &= isValid;
} else {
allValid |= isValid;
}
}
return allValid;
}
/**
*/
function findValues(current, keypath, index, object, values) {
if (index === keypath.length || current == void 0) {
values.push([current, keypath[index - 1], object]);
return;
}
var k = get(keypath, index);
// ensure that if current is an array, that the current key
// is NOT an array index. This sort of thing needs to work:
// sift({'foo.0':42}, [{foo: [42]}]);
if (isArray(current) && isNaN(Number(k))) {
for (var i = 0, n = current.length; i < n; i++) {
findValues(get(current, i), keypath, index, current, values);
}
} else {
findValues(get(current, k), keypath, index + 1, current, values);
}
}
/**
*/
function createNestedValidator(keypath, a, q) {
return { a: { k: keypath, nv: a, q: q }, v: nestedValidator };
}
/**
* flatten the query
*/
function isVanillaObject(value) {
return value && value.constructor === Object;
}
function parse(query) {
query = comparable(query);
if (!query || !isVanillaObject(query)) { // cross browser support
query = { $eq: query };
}
var validators = [];
for (var key in query) {
var a = query[key];
if (key === '$options') {
continue;
}
if (OPERATORS[key]) {
if (prepare[key]) a = prepare[key](a, query);
validators.push(createValidator(comparable(a), OPERATORS[key]));
} else {
if (key.charCodeAt(0) === 36) {
throw new Error('Unknown operation ' + key);
}
validators.push(createNestedValidator(key.split('.'), parse(a), a));
}
}
return validators.length === 1 ? validators[0] : createValidator(validators, OPERATORS.$and);
}
/**
*/
function createRootValidator(query, getter) {
var validator = parse(query);
if (getter) {
validator = {
a: validator,
v: function(a, b, k, o) {
return validate(a, getter(b), k, o);
}
};
}
return validator;
}
/**
*/
export default function sift(query, array, getter) {
if (isFunction(array)) {
getter = array;
array = void 0;
}
var validator = createRootValidator(query, getter);
function filter(b, k, o) {
return validate(validator, b, k, o);
}
if (array) {
return array.filter(filter);
}
return filter;
}
/**
*/
export function indexOf(query, array, getter) {
return search(array, createRootValidator(query, getter));
};
/**
*/
export function compare(a, b) {
if(a===b) return 0;
if(typeof a === typeof b) {
if (a > b) {
return 1;
}
if (a < b) {
return -1;
}
}
};

237
node_modules/sift/test/basic-test.js generated vendored
View File

@@ -1,237 +0,0 @@
import * as assert from 'assert';
import sift, {indexOf as siftIndexOf} from '..';
describe(__filename + '#', function() {
it('doesn\'t sort arrays', function () {
var values = sift({
$or: [3, 2, 1]
}, [9,8,7,6,5,4,3,2,1]);
assert.equal(values.length, 3);
assert.equal(values[0], 3);
assert.equal(values[1], 2);
assert.equal(values[2], 1);
});
it('can create a custom selector, and use it', function () {
var sifter = sift({ age: { $gt: 5}}, function (item) {
return item.person;
});
var people = [{ person: { age: 6 }}],
filtered = people.filter(sifter);
assert.equal(filtered.length, 1);
assert.equal(filtered[0], people[0]);
});
it('throws an error if the operation is invalid', function () {
var err;
try {
sift({$aaa:1})('b');
} catch (e) {
err = e;
}
assert.equal(err.message, 'Unknown operation $aaa');
});
it('can use a custom selector as the 3rd param', function () {
var people = [{ person: { age: 6 }}];
var filtered = sift({ age: { $gt: 5}}, people, function (item) {
return item.person;
});
assert.equal(filtered.length, 1);
assert.equal(filtered[0], people[0]);
});
it('can get the first index of a matching element', function () {
var index = siftIndexOf({ val: { $gt: 5}}, [{val: 4}, {val: 3}, {val: 6}, {val: 7}]);
assert.equal(index, 2);
});
it('returns -1 as index if no matching element is found', function () {
var index = siftIndexOf({ val: { $gt: 7}}, [{val: 4}, {val: 3}, {val: 6}, {val: 7}]);
assert.equal(index, -1);
});
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);
});
it('$ne: null does not hit when field is present', function(){
var sifter = sift({age: {$ne: null}});
var people = [
{age: 'matched'},
{missed: 1}
];
var filtered = people.filter(sifter);
assert.equal(filtered.length, 1);
assert.equal(filtered[0].age, 'matched');
});
it('$ne does not hit when field is different', function () {
var sifter = sift({ age: { $ne: 5 }});
var people = [{ age: 5 }],
filtered = people.filter(sifter);
assert.equal(filtered.length, 0);
});
it('$ne does hit when field exists with different value', function () {
var sifter = sift({ age: { $ne: 4 }});
var people = [{ age: 5 }],
filtered = people.filter(sifter);
assert.equal(filtered.length, 1);
});
it('$ne does hit when field does not exist', function(){
var sifter = sift({ age: { $ne: 5 }});
var people = [{}],
filtered = people.filter(sifter);
assert.equal(filtered.length, 1);
});
it('$eq matches objects that serialize to the same value', function() {
var counter = 0;
function Book(name) {
this.name = name;
this.copyNumber = counter;
this.toJSON = function() {
return this.name; // discard the copy when serializing.
};
counter += 1;
}
var warAndPeace = new Book('War and Peace');
var sifter = sift({ $eq: warAndPeace});
var books = [ new Book('War and Peace')];
var filtered = books.filter(sifter);
assert.equal(filtered.length, 1);
});
it('$neq does not match objects that serialize to the same value', function() {
var counter = 0;
function Book(name) {
this.name = name;
this.copyNumber = counter;
this.toJSON = function() {
return this.name; // discard the copy when serializing.
};
counter += 1;
}
var warAndPeace = new Book('War and Peace');
var sifter = sift({ $ne: warAndPeace});
var books = [ new Book('War and Peace')];
var filtered = books.filter(sifter);
assert.equal(filtered.length, 0);
});
// https://gist.github.com/jdnichollsc/00ea8cf1204b17d9fb9a991fbd1dfee6
it('returns a period between start and end dates', function() {
var product = {
'productTypeCode': 'productTypeEnergy',
'quantities': [
{
'period': {
'startDate': new Date('2017-01-13T05:00:00.000Z'),
'endDate': new Date('2017-01-31T05:00:00.000Z'),
'dayType': {
'normal': true,
'holiday': true
},
'specificDays': [
'monday',
'wednesday',
'friday'
],
'loadType': {
'high': true,
'medium': false,
'low': false
}
},
'type': 'DemandPercentage',
'quantityValue': '44'
},
{
'period': {
'startDate': new Date('2017-01-13T05:00:00.000Z'),
'endDate': new Date('2017-01-31T05:00:00.000Z'),
'dayType': {
'normal': true,
'holiday': true
},
'loadType': {
'high': false,
'medium': true,
'low': false
}
},
'type': 'Value',
'quantityValue': '22'
}
]
};
var period = {
'startDate': new Date('2017-01-08T05:00:00.000Z'),
'endDate': new Date('2017-01-29T05:00:00.000Z'),
'dayType': {
'normal': true,
'holiday': true
},
'loadType': {
'high': true,
'medium': false,
'low': true
},
specificPeriods : ['3', '4', '5-10']
};
var results = sift({
$and: [
{ 'period.startDate': { $lte : period.endDate } },
{ 'period.endDate': { $gte : period.startDate } }
]
}, product.quantities);
assert.equal(results.length, 2);
});
});

View File

@@ -1,20 +0,0 @@
import * as assert from 'assert';
import * as Immutable from 'immutable';
import sift from '..';
const ObjectID = require('bson').ObjectID;
describe(__filename + '#', function() {
var topic = Immutable.List([1, 2, 3, 4, 5, 6, 6, 4, 3]);
var persons = Immutable.fromJS([{ person: {age: 3} }, { person: {age: 5} }, { person: {age: 8} }]);
it('works with Immutable.Map in a Immutable.List', function() {
assert.equal(sift({ 'person.age' : { $gt: 4 } }, persons).size, 2);
assert.equal(persons.filter(sift({ 'person.age' : { $gt: 4 } })).size, 2);
});
});

View File

@@ -1,409 +0,0 @@
import assert from 'assert';
import sift from '..';
describe(__filename + '#', function () {
var topic = [
{
name: 'craig',
age: 90001,
tags: ['coder', 'programmer', 'traveler', 'photographer'],
address: {
city: 'Minneapolis',
state: 'MN',
phone: '9999999999'
},
tags: ['photos', 'cook'],
hobbies: [
{
name: 'programming',
description: 'some desc'
},
{
name: 'cooking'
},
{
name: 'photography',
places: ['haiti', 'brazil', 'costa rica']
},
{
name: 'backpacking'
}
]
},
{
name: 'tim',
age: 90001,
tags: ['traveler', 'photographer'],
address: {
city: 'St. Paul',
state: 'MN',
phone: '765765756765'
},
tags: ['dj'],
hobbies: [
{
name: 'biking',
description: 'some desc'
},
{
name: 'DJ'
},
{
name: 'photography',
places: ['costa rica']
}
]
}
];
xit('throws error if $not is incorrect', function () {
assert.throws(function () {
sift({
$not: ['abc']
}, topic);
}, Error);
});
it('has sifted through photography in brazil count of 1', function () {
var sifted = sift({
hobbies: {
name: 'photography',
places: {
$in: ['brazil']
}
}
}, topic);
assert.equal(sifted.length, 1);
});
it('has sifted through photography in brazil, haiti, and costa rica count of 1', function () {
var sifted = sift({
hobbies: {
name: 'photography',
places: {
$all: ['brazil', 'haiti', 'costa rica']
}
}
}, topic);
assert.equal(sifted.length, 1);
assert.equal(sifted[0], topic[0]);
});
it('has a sifted hobbies of photography, cooking, or biking count of 2', function () {
var sifted = sift({
hobbies: {
name: {
$in: ['photography', 'cooking', 'biking']
}
}
}, topic);
assert.equal(sifted.length, 2);
});
it('has sifted to complex count of 2', function () {
var sifted = sift({
hobbies: {
name: 'photography',
places: {
$in: ['costa rica']
}
},
address: {
state: 'MN',
phone: {
$exists: true
}
}
}, topic);
assert.equal(sifted.length, 2);
});
it('has sifted to complex count of 0', function () {
var sifted = sift({
hobbies: {
name: 'photos',
places: {
$in: ['costa rica']
}
}
}, topic);
assert.equal(sifted.length, 0);
});
it('has sifted subobject hobbies count of 3', function () {
var sifted = sift({
'hobbies.name': 'photography'
}, topic);
assert.equal(sifted.length, 2);
});
it('has sifted dot-notation hobbies of photography, cooking, and biking count of 3', function () {
var sifted = sift({
'hobbies.name': {
$in: ['photography', 'cooking', 'biking']
}
}, topic);
assert.equal(sifted.length, 2);
});
it('has sifted to complex dot-search count of 2', function () {
var sifted = sift({
'hobbies.name': 'photography',
'hobbies.places': {
$in: ['costa rica']
},
'address.state': 'MN',
'address.phone': {
$exists: true
}
}, topic);
assert.equal(sifted.length, 2);
});
it('has sifted with selector function count of 2', function () {
var sifted = sift({
'name': 'photography',
'places': {
$in: ['costa rica']
}
}, topic, function (item) {
return item.hobbies;
});
assert.equal(sifted.length, 2);
});
describe('nesting', function () {
it('$eq for nested object', function () {
var sifted = sift({'sub.num': {'$eq': 10}}, loremArr);
assert(sifted.length > 0);
sifted.forEach(function (v) {
assert.equal(10, v.sub.num);
});
});
it('$ne for nested object', function () {
var sifted = sift({'sub.num': {'$ne': 10}}, loremArr);
assert(sifted.length > 0);
sifted.forEach(function (v) {
assert.notEqual(10, v.sub.num);
});
});
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'
}]);
});
});
describe('arrays of objects', function () {
var objects = [
{
things: [
{
id: 123
}, {
id: 456
}
]
}, {
things: [
{
id: 123
},
{
id: 789
}
]
}
];
it('$eq for array of objects, matches if at least one exists', function () {
let q = {
'things.id': 123
}
var sifted = sift(q, objects)
assert.deepEqual(sifted, objects)
let q2 = {
'things.id': 789
}
var sifted2 = sift(q2, objects)
assert.deepEqual(sifted2, [objects[1]])
})
it('$ne for array of objects, returns if none of the array elements match the query', function () {
let q = {
'things.id': {
$ne: 123
}
}
var sifted = sift(q, objects)
assert.deepEqual(sifted, [])
let q2 = {
'things.id': {
$ne: 789
}
}
var sifted2 = sift(q2, objects)
assert.deepEqual(sifted2, [objects[0]])
})
})
describe('$where', function() {
var couples = [{
name: 'SMITH',
person: [{
firstName: 'craig',
gender: 'female',
age: 29
}, {
firstName: 'tim',
gender: 'male',
age: 32
}
]
}, {
name: 'JOHNSON',
person: [{
firstName: 'emily',
gender: 'female',
age: 35
}, {
firstName: 'jacob',
gender: 'male',
age: 32
}
]
}];
it('can filter people', function() {
var results = sift({'person': {$elemMatch: { 'gender': 'female', 'age': {'$lt': 30}}}}, couples);
assert.equal(results[0].name, 'SMITH');
var results = sift({'person': {$elemMatch: { 'gender': 'male', 'age': {'$lt': 30}}}}, [couples[0]]);
assert.equal(results.length, 0);
});
});
describe('keypath', function () {
var arr = [
{
a: {
b: {
c: 1,
c2: 1
}
}
}
]
it('can be used', function () {
assert.equal(sift({'a.b.c':1})(arr[0]), true);
});
});
});
var loremArr = [
{
'num': 1,
'pum': 1,
'sub': {
'num': 1,
'pum': 1
}
},
{
'num': 2,
'pum': 2,
'sub': {
'num': 2,
'pum': 2
}
},
{
'num': 3,
'pum': 3,
'sub': {
'num': 3,
'pum': 3
}
},
{
'num': 4,
'pum': 4,
'sub': {
'num': 4,
'pum': 4
}
},
{
'num': 5,
'pum': 5,
'sub': {
'num': 5,
'pum': 5
}
},
{
'num': 6,
'pum': 6,
'sub': {
'num': 6,
'pum': 6
}
},
{
'num': 7,
'pum': 7,
'sub': {
'num': 7,
'pum': 7
}
},
{
'num': 8,
'pum': 8,
'sub': {
'num': 8,
'pum': 8
}
},
{
'num': 9,
'pum': 9,
'sub': {
'num': 9,
'pum': 9
}
},
{
'num': 10,
'pum': 10,
'sub': {
'num': 10,
'pum': 10
}
},
{
'num': 11,
'pum': 11,
'sub': {
'num': 10,
'pum': 10
}
}
];

View File

@@ -1,203 +0,0 @@
import * as assert from 'assert';
import sift from '..';
var ObjectID = require('bson').ObjectID;
describe(__filename + '#', function () {
[
// $eq
[{$eq:5}, [5,'5', 6], [5]],
['5', [5,'5', 6], ['5']],
[false, [false,'false', true], [false]],
[true, [1, true], [true]],
[0, [0,'0'], [0]],
[null, [null], [null]],
[void 0, [void 0, null], [void 0]],
[1, [2,3,4,5], []],
[1, [[1]], [[1]]],
[new Date(1), [new Date(), new Date(1), new Date(2), new Date(3)], [new Date(1)]],
[/^a/, ['a','ab','abc','b','bc'], ['a','ab','abc']],
[function(b) { return b === 1; }, [1,2,3],[1]],
[ObjectID('54dd5546b1d296a54d152e84'),[ObjectID(),ObjectID('54dd5546b1d296a54d152e84')],[ObjectID('54dd5546b1d296a54d152e84')]],
// $ne
[{$ne:5}, [5, '5', 6], ['5', 6]],
[{$ne:'5'}, ['5', 6], [6]],
[{$ne:false}, [false], []],
[{$ne:void 0}, [false, 0, '0', void 0], [false, 0, '0']],
[{$ne:/^a/}, ['a','ab','abc','b','bc'], ['b','bc']],
[{$ne:1}, [[2],[1]], [[2]]],
[{groups:{$ne:111}}, [{groups:[111,222,333,444]},{groups:[222,333,444]}],[{groups:[222,333,444]}]],
// $lt
[{$lt:5}, [3,4,5,6],[3,4]],
[{$lt:'c'}, ['a','b','c'],['a','b']],
[{$lt:null}, [-3,-4], []],
[{$lt:new Date(3)}, [new Date(1), new Date(2), new Date(3)],[new Date(1), new Date(2)]],
// $lte
[{$lte:5}, [3,4,5,6],[3,4,5]],
[{groups:{$lt:5}}, [{groups:[1,2,3,4]}, {groups:[7,8]}], [{groups:[1,2,3,4]}]],
// $gt
[{$gt:5}, [3,4,5,6],[6]],
[{$gt:null}, [3,4], []],
[{groups:{$gt:5}}, [{groups:[1,2,3,4]}, {groups:[7,8]}], [{groups:[7,8]}]],
// $gte
[{$gte:5}, [3,4,5,6],[5, 6]],
[{groups:{$gte:5}}, [{groups:[1,2,3,4]}, {groups:[7,8]}], [{groups:[7,8]}]],
// $mod
[{$mod:[2,1]}, [1,2,3,4,5,6],[1,3,5]],
[{groups:{$mod:[2,0]}}, [{groups:[1,2,3,4]}, {groups:[7,9]}], [{groups:[1,2,3,4]}]],
// $exists
[{$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}]],
// $in
// TODO - {$in:[Date]} doesn't work - make it work?
[{$in:[0,false,1,'1']},[0,1,2,3,4,false],[0,1,false]],
[{$in:[1,'1','2']},['1','2','3'],['1','2']],
[{$in:[new Date(1)]},[new Date(1), new Date(2)],[new Date(1)]],
[{'a.b.status':{'$in': [0]}}, [{'a':{'b':[{'status':0}]}},{'a':{'b':[{'status':2}]}}],[{'a':{'b':[{'status':0}]}}]],
[{'a.b.status':{'$in': [0, 2]}}, [{'a':{'b':[{'status':0}]}},{'a':{'b':[{'status':2}]}}], [{'a':{'b':[{'status':0}]}},{'a':{'b':[{'status':2}]}}]],
[{'x': {$in: [{$regex: '.*aaa.*'}, {$regex: '.*bbb.*'}]}}, [{'x': {'b': 'aaa'}}, {'x': 'bbb'}, {'x': 'ccc'}, {'x': 'aaa'}], [{'x': 'bbb'}, {'x': 'aaa'}]],
[{'x': {$in: [/.*aaa.*/, /.*bbb.*/]}}, [{'x': {'b': 'aaa'}}, {'x': 'bbb'}, {'x': 'ccc'}, {'x': 'aaa'}], [{'x': 'bbb'}, {'x': 'aaa'}]],
// $nin
[{$nin:[0,false,1,'1']},[0,1,2,3,4,false],[2,3,4]],
[{$nin:[1,'1','2']},['1','2','3'],['3']],
[{$nin:[new Date(1)]},[new Date(1), new Date(2)],[new Date(2)]],
[{'root.notDefined': {$nin: [1, 2, 3]}}, [{'root': {'defined': 1337}}], [{'root': {'defined': 1337}}]],
[{'root.notDefined': {$nin: [1, 2, 3, null]}}, [{'root': {'defined': 1337}}], []],
[{'x': {$nin: [{$regex: '.*aaa.*'}, {$regex: '.*bbb.*'}]}}, [{'x': {'b': 'aaa'}}, {'x': 'bbb'}, {'x': 'ccc'}, {'x': 'aaa'}], [{'x': {'b': 'aaa'}},{'x': 'ccc'}]],
[{'x': {$nin: [/.*aaa.*/, /.*bbb.*/]}}, [{'x': {'b': 'aaa'}}, {'x': 'bbb'}, {'x': 'ccc'}, {'x': 'aaa'}], [{'x': {'b': 'aaa'}},{'x': 'ccc'}]],
// $not
[{$not:false},[0,false],[0]],
[{$not:0},[0, false, 1, 2, 3],[false, 1, 2, 3]],
[{$not:{$in:[1,2,3]}},[1,2,3,4,5,6],[4,5,6]], // with expressions
// $type
[{$type:Date}, [0,new Date(1)],[new Date(1)]],
[{$type:Number}, [0,false,1],[0,1]],
[{$type:Boolean}, [0,false, void 0],[false]],
[{$type:String}, ['1',1,false],['1']],
// $all
[{$all:[1,2,3]},[[1,2,3,4],[1,2,4]],[[1,2,3,4]]],
[{$all:[0,false]},[[0,1,2],[0,false],['0','false'],void 0],[[0,false]]],
[{$all:['1']},[[1]],[]],
[{$all:[new Date(1),new Date(2)]},[[new Date(1), new Date(2)],[new Date(1)]],[[new Date(1), new Date(2)]]],
// $size
[{$size:3},['123',[1,2,3],'1'],['123',[1,2,3]]],
[{$size:1},['123',[1,2,3],'1', void 0],['1']],
// $or
[{$or:[1,2,3]},[1,2,3,4],[1,2,3]],
[{$or:[{$ne:1},2]},[1,2,3,4,5,6],[2,3,4,5,6]],
// $nor
[{$nor:[1,2,3]},[1,2,3,4],[4]],
[{$nor:[{$ne:1},2]},[1,2,3,4,5,6],[1]],
// $and
[{$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}]],
// $regex
[{$regex:'^a'},['a','ab','abc','bc','bcd'],['a','ab','abc']],
[{a:{$regex:'b|c'}}, [{a:['b']},{a:['c']},{a:'c'},{a:'d'}], [{a:['b']},{a:['c']},{a:'c'}]],
[{ folder: { $regex:'^[0-9]{4}$' }}, [{ folder:['1234','3212'] }], [{ folder:['1234','3212'] }]],
// $options
[{$regex:'^a', $options: 'i'},['a','Ab','abc','bc','bcd'],['a','Ab','abc']],
[{'text':{'$regex':'.*lis.*','$options':'i'}}, [{text:['Bob','Melissa','Joe','Sherry']}], [{text:['Bob','Melissa','Joe','Sherry']}]],
// undefined
[{$regex:'a'},[undefined, null, true, false, 0, 'aa'],['aa']],
[/a/,[undefined, null, true, false, 0, 'aa'],['aa']],
[/.+/,[undefined, null, true, false, 0, 'aa', {}],['aa']],
// Multiple conditions on an undefined root
[{'a.b': {$exists: true, $nin: [null]}}, [{a: {b: 'exists'}}, {a: {c: 'does not exist'}}], [{a: {b: 'exists'}}]],
// $where
[{$where:function () { return this.v === 1 }}, [{v:1},{v:2}],[{v:1}]],
[{$where:'this.v === 1'}, [{v:1},{v:2}],[{v:1}]],
[{$where:'obj.v === 1'}, [{v:1},{v:2}],[{v:1}]],
// $elemMatch
//{'person': {'$elemMatch': {'gender': 'male', 'age': {'$lt': 30}}}}
[
{a:{$elemMatch:{b:1,c:2}}},
[{a:{b:1,c:2}},{a:[{b:1,c:2,d:3}]},{a:{b:2,c:3}}], [{a:{b:1,c:2}},{a:[{b:1,c:2,d:3}]}]
],
[{a:{$elemMatch:{b:2,c:{$gt:2}}}}, [{a:{b:1,c:2}},{a:{b:1,c:2,d:3}},[{a:{b:2,c:3}}]], [[{a:{b:2,c:3}}]]],
[
{tags: {$all: [{$elemMatch: {a: 1}}]}},
[{tags: [{a: 1}]}, {tags: [{a: 1}, {b: 1}]}], [{tags: [{a: 1}]}, {tags: [{a: 1}, {b: 1}]}]
],
// dot-notation
[
{'a.b': /c/ },
[{a:{b:'c'}}, {a:{b:'cd'}}, {'a.b':'c'},{a:{b:'e'}}],
[{a:{b:'c'}}, {a:{b:'cd'}}]
],
[
{'foo.0': 'baz' },
[{foo:['bar', 'baz']}, {foo:['baz', 'bar']}],
[{foo:['baz', 'bar']}]
],
[
{'foo.0.name': 'baz' },
[{foo:[{ name: 'bar' }, { name: 'baz' }]}, {foo:[{ name: 'baz' }, { name: 'bar' }]}],
[{foo:[{ name: 'baz' }, { name: 'bar' }]}]
],
// object.toString() tests
[
{ $in: [{ toString: function(){ return 'a'; }}]},
[{toString: function(){ return 'a'; }}, {toString: function(){ return 'b' }}],
[{toString: function(){ return 'a'; }}]
],
[
{ $in: [{}]},
[{}, {}],
[]
],
// various comparisons
[
{ c: { d: 'd' }},
[{ a: 'b', b: 'c', c: { d: 'd', e: 'e' }}, { c: { d: 'e' }}],
[{ a: 'b', b: 'c', c: { d: 'd', e: 'e' }}]
],
// based on https://gist.github.com/jdnichollsc/00ea8cf1204b17d9fb9a991fbd1dfee6
[
{ $and: [{ 'a.s': { $lte: new Date('2017-01-29T05:00:00.000Z') }}, {'a.e': { $gte: new Date('2017-01-08T05:00:00.000Z') }}]},
[{ a: { s: new Date('2017-01-13T05:00:00.000Z'), e: new Date('2017-01-31T05:00:00.000Z') }}],
[{ a: { s: new Date('2017-01-13T05:00:00.000Z'), e: new Date('2017-01-31T05:00:00.000Z') }}]
],
].forEach(function (operation, i) {
var filter = operation[0];
var array = operation[1];
var matchArray = operation[2];
it(i + ': ' + JSON.stringify(filter), function() {
assert.equal(JSON.stringify(array.filter(sift(filter))), JSON.stringify(matchArray));
});
});
});

8
node_modules/sift/tsconfig.json generated vendored
View File

@@ -1,8 +0,0 @@
{
"compilerOptions": {
"target": "es6",
"moduleResolution": "node",
"module": "commonjs",
"allowSyntheticDefaultImports": true
}
}

23
node_modules/sift/webpack.config.js generated vendored
View File

@@ -1,23 +0,0 @@
const {resolve} = require('path');
const fs = require('fs');
module.exports = {
devtool: 'none',
mode: 'production',
entry: {
index: [__dirname + '/lib/index.js']
},
output: {
path: __dirname,
library: 'sift',
libraryTarget: 'umd',
filename: 'sift.min.js'
},
resolve: {
extensions: ['.js']
},
module: {
rules: [
]
}
};

4016
node_modules/sift/yarn.lock generated vendored

File diff suppressed because it is too large Load Diff