Socket
Socket
Sign inDemoInstall

sift

Package Overview
Dependencies
0
Maintainers
2
Versions
155
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 16.0.0 to 16.0.1

11

lib/core.d.ts

@@ -14,3 +14,3 @@ import { Key, Comparator } from "./utils";

export declare type OperationCreator<TItem> = (params: any, parentQuery: any, options: Options, name: string) => Operation<TItem>;
declare type BasicValueQuery<TValue> = {
export declare type BasicValueQuery<TValue> = {
$eq?: TValue;

@@ -37,13 +37,14 @@ $ne?: TValue;

};
declare type ArrayValueQuery<TValue> = {
export declare type ArrayValueQuery<TValue> = {
$elemMatch?: Query<TValue>;
} & BasicValueQuery<TValue>;
declare type Unpacked<T> = T extends (infer U)[] ? U : T;
declare type ValueQuery<TValue> = TValue extends Array<any> ? ArrayValueQuery<Unpacked<TValue>> : BasicValueQuery<TValue>;
export declare type ValueQuery<TValue> = TValue extends Array<any> ? ArrayValueQuery<Unpacked<TValue>> : BasicValueQuery<TValue>;
declare type NotObject = string | number | Date | boolean | Array<any>;
declare type ShapeQuery<TItemSchema> = TItemSchema extends NotObject ? {} : {
export declare type ShapeQuery<TItemSchema> = TItemSchema extends NotObject ? {} : {
[k in keyof TItemSchema]?: TItemSchema[k] | ValueQuery<TItemSchema[k]>;
};
declare type NestedQuery<TItemSchema> = ValueQuery<TItemSchema> & ShapeQuery<TItemSchema>;
export declare type NestedQuery<TItemSchema> = ValueQuery<TItemSchema> & ShapeQuery<TItemSchema>;
export declare type Query<TItemSchema> = TItemSchema | RegExp | NestedQuery<TItemSchema>;
export declare type QueryOperators<TValue = any> = keyof ValueQuery<TValue>;
export declare abstract class BaseOperation<TParams, TItem = any> implements Operation<TItem> {

@@ -50,0 +51,0 @@ readonly params: TParams;

@@ -1,6 +0,6 @@

import { Query, Options, createQueryTester, EqualsOperation, createQueryOperation, createEqualsOperation, createOperationTester } from "./core";
import { Query, QueryOperators, BasicValueQuery, ArrayValueQuery, ValueQuery, NestedQuery, ShapeQuery, Options, createQueryTester, EqualsOperation, createQueryOperation, createEqualsOperation, createOperationTester } from "./core";
declare const createDefaultQueryOperation: <TItem, TSchema extends TItem = TItem>(query: Query<TSchema>, ownerQuery: any, { compare, operations }?: Partial<Options>) => import("./core").QueryOperation<unknown>;
declare const createDefaultQueryTester: <TItem, TSchema extends TItem = TItem>(query: Query<TSchema>, options?: Partial<Options>) => (item: unknown, key?: import("./utils").Key, owner?: any) => boolean;
export { Query, EqualsOperation, createQueryTester, createOperationTester, createDefaultQueryOperation, createEqualsOperation, createQueryOperation };
export { Query, QueryOperators, BasicValueQuery, ArrayValueQuery, ValueQuery, NestedQuery, ShapeQuery, EqualsOperation, createQueryTester, createOperationTester, createDefaultQueryOperation, createEqualsOperation, createQueryOperation };
export * from "./operations";
export default createDefaultQueryTester;
{
"name": "sift",
"description": "MongoDB query filtering in JavaScript",
"version": "16.0.0",
"version": "16.0.1",
"repository": "crcn/sift.js",

@@ -6,0 +6,0 @@ "sideEffects": false,

@@ -7,5 +7,5 @@ import { Key, Comparator } from "./utils";

reset(): any;
next(item: TItem, key?: Key, owner?: any): any;
next(item: TItem, key?: Key, owner?: any, root?: boolean): any;
}
export declare type Tester = (item: any, key?: Key, owner?: any) => boolean;
export declare type Tester = (item: any, key?: Key, owner?: any, root?: boolean) => boolean;
export interface NamedOperation {

@@ -15,3 +15,3 @@ name: string;

export declare type OperationCreator<TItem> = (params: any, parentQuery: any, options: Options, name: string) => Operation<TItem>;
declare type BasicValueQuery<TValue> = {
export declare type BasicValueQuery<TValue> = {
$eq?: TValue;

@@ -38,30 +38,27 @@ $ne?: TValue;

};
declare type ArrayValueQuery<TValue> = {
export declare type ArrayValueQuery<TValue> = {
$elemMatch?: Query<TValue>;
} & BasicValueQuery<TValue>;
declare type Unpacked<T> = T extends (infer U)[] ? U : T;
declare type ValueQuery<TValue> = TValue extends Array<any> ? ArrayValueQuery<Unpacked<TValue>> : BasicValueQuery<TValue>;
export declare type ValueQuery<TValue> = TValue extends Array<any> ? ArrayValueQuery<Unpacked<TValue>> : BasicValueQuery<TValue>;
declare type NotObject = string | number | Date | boolean | Array<any>;
declare type ShapeQuery<TItemSchema> = TItemSchema extends NotObject ? {} : {
export declare type ShapeQuery<TItemSchema> = TItemSchema extends NotObject ? {} : {
[k in keyof TItemSchema]?: TItemSchema[k] | ValueQuery<TItemSchema[k]>;
};
declare type NestedQuery<TItemSchema> = ValueQuery<TItemSchema> & ShapeQuery<TItemSchema>;
export declare type NestedQuery<TItemSchema> = ValueQuery<TItemSchema> & ShapeQuery<TItemSchema>;
export declare type Query<TItemSchema> = TItemSchema | RegExp | NestedQuery<TItemSchema>;
declare abstract class BaseOperation<TParams, TItem = any> implements Operation<TItem> {
export declare type QueryOperators<TValue = any> = keyof ValueQuery<TValue>;
export declare abstract class BaseOperation<TParams, TItem = any> implements Operation<TItem> {
readonly params: TParams;
readonly owneryQuery: any;
readonly options: Options;
readonly name?: string;
keep: boolean;
done: boolean;
abstract propop: boolean;
constructor(params: TParams, owneryQuery: any, options: Options);
constructor(params: TParams, owneryQuery: any, options: Options, name?: string);
protected init(): void;
reset(): void;
abstract next(item: any, key: Key, parent: any): any;
abstract next(item: any, key: Key, parent: any, root: boolean): any;
}
export declare abstract class NamedBaseOperation<TParams, TItem = any> extends BaseOperation<TParams, TItem> implements NamedOperation {
readonly name: string;
abstract propop: boolean;
constructor(params: TParams, owneryQuery: any, options: Options, name: string);
}
declare abstract class GroupOperation extends BaseOperation<any> {

@@ -75,6 +72,6 @@ readonly children: Operation<any>[];

reset(): void;
abstract next(item: any, key: Key, owner: any): any;
abstract next(item: any, key: Key, owner: any, root: boolean): any;
/**
*/
protected childrenNext(item: any, key: Key, owner: any): void;
protected childrenNext(item: any, key: Key, owner: any, root: boolean): void;
}

@@ -90,3 +87,3 @@ export declare abstract class NamedGroupOperation extends GroupOperation implements NamedOperation {

*/
next(item: TItem, key: Key, parent: any): void;
next(item: TItem, key: Key, parent: any, root: boolean): void;
}

@@ -116,4 +113,4 @@ export declare class NestedOperation extends GroupOperation {

}
export declare const numericalOperationCreator: (createNumericalOperation: OperationCreator<any>) => (params: any, owneryQuery: any, options: Options, name: string) => Operation<any>;
export declare const numericalOperation: (createTester: (any: any) => Tester) => (params: any, owneryQuery: any, options: Options, name: string) => Operation<any>;
export declare const numericalOperationCreator: (createNumericalOperation: OperationCreator<any>) => (params: any, owneryQuery: any, options: Options, name: string) => Operation<any> | NopeOperation<any>;
export declare const numericalOperation: (createTester: (any: any) => Tester) => (params: any, owneryQuery: any, options: Options, name: string) => Operation<any> | NopeOperation<any>;
export declare type Options = {

@@ -120,0 +117,0 @@ operations: {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createQueryTester = exports.createOperationTester = exports.createQueryOperation = exports.containsOperation = exports.numericalOperation = exports.numericalOperationCreator = exports.NopeOperation = exports.createEqualsOperation = exports.EqualsOperation = exports.createTester = exports.NestedOperation = exports.QueryOperation = exports.NamedGroupOperation = exports.NamedBaseOperation = void 0;
exports.createQueryTester = exports.createOperationTester = exports.createQueryOperation = exports.containsOperation = exports.numericalOperation = exports.numericalOperationCreator = exports.NopeOperation = exports.createEqualsOperation = exports.EqualsOperation = exports.createTester = exports.NestedOperation = exports.QueryOperation = exports.NamedGroupOperation = exports.BaseOperation = void 0;
const utils_1 = require("./utils");

@@ -13,3 +13,3 @@ /**

// { $eq: [1, 2, 3] }, [ 1, 2, 3 ].
if (utils_1.isArray(item) && isNaN(Number(currentKey))) {
if ((0, utils_1.isArray)(item) && isNaN(Number(currentKey))) {
for (let i = 0, { length } = item; i < length; i++) {

@@ -24,3 +24,3 @@ // if FALSE is returned, then terminate walker. For operations, this simply

if (depth === keyPath.length || item == null) {
return next(item, key, owner);
return next(item, key, owner, depth === 0);
}

@@ -30,6 +30,7 @@ return walkKeyPathValues(item[currentKey], keyPath, next, depth + 1, currentKey, item);

class BaseOperation {
constructor(params, owneryQuery, options) {
constructor(params, owneryQuery, options, name) {
this.params = params;
this.owneryQuery = owneryQuery;
this.options = options;
this.name = name;
this.init();

@@ -43,9 +44,3 @@ }

}
class NamedBaseOperation extends BaseOperation {
constructor(params, owneryQuery, options, name) {
super(params, owneryQuery, options);
this.name = name;
}
}
exports.NamedBaseOperation = NamedBaseOperation;
exports.BaseOperation = BaseOperation;
class GroupOperation extends BaseOperation {

@@ -67,3 +62,3 @@ constructor(params, owneryQuery, options, children) {

*/
childrenNext(item, key, owner) {
childrenNext(item, key, owner, root) {
let done = true;

@@ -73,3 +68,5 @@ let keep = true;

const childOperation = this.children[i];
childOperation.next(item, key, owner);
if (!childOperation.done) {
childOperation.next(item, key, owner, root);
}
if (!childOperation.keep) {

@@ -105,4 +102,4 @@ keep = false;

*/
next(item, key, parent) {
this.childrenNext(item, key, parent);
next(item, key, parent, root) {
this.childrenNext(item, key, parent, root);
}

@@ -118,4 +115,4 @@ }

*/
this._nextNestedValue = (value, key, owner) => {
this.childrenNext(value, key, owner);
this._nextNestedValue = (value, key, owner, root) => {
this.childrenNext(value, key, owner, root);
return !this.done;

@@ -142,4 +139,4 @@ };

}
const comparableA = utils_1.comparable(a);
return b => compare(comparableA, utils_1.comparable(b));
const comparableA = (0, utils_1.comparable)(a);
return b => compare(comparableA, (0, utils_1.comparable)(b));
};

@@ -153,3 +150,3 @@ exports.createTester = createTester;

init() {
this._test = exports.createTester(this.params, this.options.compare);
this._test = (0, exports.createTester)(this.params, this.options.compare);
}

@@ -181,3 +178,3 @@ next(item, key, parent) {

if (params == null) {
return new NopeOperation(params, owneryQuery, options);
return new NopeOperation(params, owneryQuery, options, name);
}

@@ -187,8 +184,8 @@ return createNumericalOperation(params, owneryQuery, options, name);

exports.numericalOperationCreator = numericalOperationCreator;
const numericalOperation = (createTester) => exports.numericalOperationCreator((params, owneryQuery, options) => {
const typeofParams = typeof utils_1.comparable(params);
const numericalOperation = (createTester) => (0, exports.numericalOperationCreator)((params, owneryQuery, options, name) => {
const typeofParams = typeof (0, utils_1.comparable)(params);
const test = createTester(params);
return new EqualsOperation(b => {
return typeof utils_1.comparable(b) === typeofParams && test(b);
}, owneryQuery, options);
return typeof (0, utils_1.comparable)(b) === typeofParams && test(b);
}, owneryQuery, options, name);
});

@@ -215,3 +212,3 @@ exports.numericalOperation = numericalOperation;

const createNestedOperation = (keyPath, nestedQuery, parentKey, owneryQuery, options) => {
if (exports.containsOperation(nestedQuery, options)) {
if ((0, exports.containsOperation)(nestedQuery, options)) {
const [selfOperations, nestedOperations] = createQueryOperations(nestedQuery, parentKey, options);

@@ -247,3 +244,3 @@ if (nestedOperations.length) {

const nestedOperations = [];
if (!utils_1.isVanillaObject(query)) {
if (!(0, utils_1.isVanillaObject)(query)) {
selfOperations.push(new EqualsOperation(query, query, options));

@@ -281,5 +278,5 @@ return [selfOperations, nestedOperations];

const createQueryTester = (query, options = {}) => {
return exports.createOperationTester(exports.createQueryOperation(query, null, options));
return (0, exports.createOperationTester)((0, exports.createQueryOperation)(query, null, options));
};
exports.createQueryTester = createQueryTester;
//# sourceMappingURL=core.js.map

@@ -36,3 +36,3 @@ import {

type BasicValueQuery<TValue> = {
export type BasicValueQuery<TValue> = {
$eq?: TValue;

@@ -60,3 +60,3 @@ $ne?: TValue;

type ArrayValueQuery<TValue> = {
export type ArrayValueQuery<TValue> = {
$elemMatch?: Query<TValue>;

@@ -66,3 +66,3 @@ } & BasicValueQuery<TValue>;

type ValueQuery<TValue> = TValue extends Array<any>
export type ValueQuery<TValue> = TValue extends Array<any>
? ArrayValueQuery<Unpacked<TValue>>

@@ -72,7 +72,7 @@ : BasicValueQuery<TValue>;

type NotObject = string | number | Date | boolean | Array<any>;
type ShapeQuery<TItemSchema> = TItemSchema extends NotObject
export type ShapeQuery<TItemSchema> = TItemSchema extends NotObject
? {}
: { [k in keyof TItemSchema]?: TItemSchema[k] | ValueQuery<TItemSchema[k]> };
type NestedQuery<TItemSchema> = ValueQuery<TItemSchema> &
export type NestedQuery<TItemSchema> = ValueQuery<TItemSchema> &
ShapeQuery<TItemSchema>;

@@ -84,2 +84,4 @@ export type Query<TItemSchema> =

export type QueryOperators<TValue = any> = keyof ValueQuery<TValue>;
/**

@@ -86,0 +88,0 @@ * Walks through each value given the context - used for nested operations. E.g:

@@ -1,6 +0,6 @@

import { Query, Options, createQueryTester, EqualsOperation, createQueryOperation, createEqualsOperation, createOperationTester } from "./core";
import { Query, QueryOperators, BasicValueQuery, ArrayValueQuery, ValueQuery, NestedQuery, ShapeQuery, Options, createQueryTester, EqualsOperation, createQueryOperation, createEqualsOperation, createOperationTester } from "./core";
declare const createDefaultQueryOperation: <TItem, TSchema extends TItem = TItem>(query: Query<TSchema>, ownerQuery: any, { compare, operations }?: Partial<Options>) => import("./core").QueryOperation<unknown>;
declare const createDefaultQueryTester: <TItem, TSchema extends TItem = TItem>(query: Query<TSchema>, options?: Partial<Options>) => (item: unknown, key?: import("./utils").Key, owner?: any) => boolean;
export { Query, EqualsOperation, createQueryTester, createOperationTester, createDefaultQueryOperation, createEqualsOperation, createQueryOperation };
export { Query, QueryOperators, BasicValueQuery, ArrayValueQuery, ValueQuery, NestedQuery, ShapeQuery, EqualsOperation, createQueryTester, createOperationTester, createDefaultQueryOperation, createEqualsOperation, createQueryOperation };
export * from "./operations";
export default createDefaultQueryTester;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -22,3 +26,3 @@ if (k2 === undefined) k2 = k;

const createDefaultQueryOperation = (query, ownerQuery, { compare, operations } = {}) => {
return core_1.createQueryOperation(query, ownerQuery, {
return (0, core_1.createQueryOperation)(query, ownerQuery, {
compare,

@@ -30,5 +34,4 @@ operations: Object.assign({}, defaultOperations, operations || {})

const createDefaultQueryTester = (query, options = {}) => {
console.log("Q", query);
const op = createDefaultQueryOperation(query, null, options);
return core_1.createOperationTester(op);
return (0, core_1.createOperationTester)(op);
};

@@ -35,0 +38,0 @@ __exportStar(require("./operations"), exports);

import * as defaultOperations from "./operations";
import {
Query,
QueryOperators,
BasicValueQuery,
ArrayValueQuery,
ValueQuery,
NestedQuery,
ShapeQuery,
Options,

@@ -33,2 +39,8 @@ createQueryTester,

Query,
QueryOperators,
BasicValueQuery,
ArrayValueQuery,
ValueQuery,
NestedQuery,
ShapeQuery,
EqualsOperation,

@@ -35,0 +47,0 @@ createQueryTester,

@@ -1,4 +0,4 @@

import { NamedBaseOperation, EqualsOperation, Options, Operation, Query, NamedGroupOperation } from "./core";
import { BaseOperation, EqualsOperation, Options, Operation, Query, NamedGroupOperation } from "./core";
import { Key } from "./utils";
declare class $Ne extends NamedBaseOperation<any> {
declare class $Ne extends BaseOperation<any> {
readonly propop = true;

@@ -10,3 +10,3 @@ private _test;

}
declare class $ElemMatch extends NamedBaseOperation<Query<any>> {
declare class $ElemMatch extends BaseOperation<Query<any>> {
readonly propop = true;

@@ -18,3 +18,3 @@ private _queryOperation;

}
declare class $Not extends NamedBaseOperation<Query<any>> {
declare class $Not extends BaseOperation<Query<any>> {
readonly propop = true;

@@ -24,5 +24,5 @@ private _queryOperation;

reset(): void;
next(item: any, key: Key, owner: any): void;
next(item: any, key: Key, owner: any, root: boolean): void;
}
export declare class $Size extends NamedBaseOperation<any> {
export declare class $Size extends BaseOperation<any> {
readonly propop = true;

@@ -32,3 +32,3 @@ init(): void;

}
declare class $Or extends NamedBaseOperation<any> {
declare class $Or extends BaseOperation<any> {
readonly propop = false;

@@ -44,3 +44,3 @@ private _ops;

}
declare class $In extends NamedBaseOperation<any> {
declare class $In extends BaseOperation<any> {
readonly propop = true;

@@ -51,7 +51,10 @@ private _testers;

}
declare class $Nin extends $In {
declare class $Nin extends BaseOperation<any> {
readonly propop = true;
next(item: any, key: Key, owner: any): void;
private _in;
constructor(params: any, ownerQuery: any, options: Options, name: string);
next(item: any, key: Key, owner: any, root: boolean): void;
reset(): void;
}
declare class $Exists extends NamedBaseOperation<boolean> {
declare class $Exists extends BaseOperation<boolean> {
readonly propop = true;

@@ -63,3 +66,3 @@ next(item: any, key: Key, owner: any): void;

constructor(params: Query<any>[], owneryQuery: Query<any>, options: Options, name: string);
next(item: any, key: Key, owner: any): void;
next(item: any, key: Key, owner: any, root: boolean): void;
}

@@ -69,3 +72,3 @@ declare class $All extends NamedGroupOperation {

constructor(params: Query<any>[], owneryQuery: Query<any>, options: Options, name: string);
next(item: any, key: Key, owner: any): void;
next(item: any, key: Key, owner: any, root: boolean): void;
}

@@ -79,6 +82,6 @@ export declare const $eq: (params: any, owneryQuery: Query<any>, options: Options) => EqualsOperation<any>;

export declare const $in: (params: any, owneryQuery: Query<any>, options: Options, name: string) => $In;
export declare const $lt: (params: any, owneryQuery: any, options: Options, name: string) => Operation<any>;
export declare const $lte: (params: any, owneryQuery: any, options: Options, name: string) => Operation<any>;
export declare const $gt: (params: any, owneryQuery: any, options: Options, name: string) => Operation<any>;
export declare const $gte: (params: any, owneryQuery: any, options: Options, name: string) => Operation<any>;
export declare const $lt: (params: any, owneryQuery: any, options: Options, name: string) => Operation<any> | import("./core").NopeOperation<any>;
export declare const $lte: (params: any, owneryQuery: any, options: Options, name: string) => Operation<any> | import("./core").NopeOperation<any>;
export declare const $gt: (params: any, owneryQuery: any, options: Options, name: string) => Operation<any> | import("./core").NopeOperation<any>;
export declare const $gte: (params: any, owneryQuery: any, options: Options, name: string) => Operation<any> | import("./core").NopeOperation<any>;
export declare const $mod: ([mod, equalsValue]: number[], owneryQuery: Query<any>, options: Options) => EqualsOperation<(b: any) => boolean>;

@@ -85,0 +88,0 @@ export declare const $exists: (params: boolean, owneryQuery: Query<any>, options: Options, name: string) => $Exists;

@@ -6,3 +6,3 @@ "use strict";

const utils_1 = require("./utils");
class $Ne extends core_1.NamedBaseOperation {
class $Ne extends core_1.BaseOperation {
constructor() {

@@ -13,3 +13,3 @@ super(...arguments);

init() {
this._test = core_1.createTester(this.params, this.options.compare);
this._test = (0, core_1.createTester)(this.params, this.options.compare);
}

@@ -28,3 +28,3 @@ reset() {

// https://docs.mongodb.com/manual/reference/operator/query/elemMatch/
class $ElemMatch extends core_1.NamedBaseOperation {
class $ElemMatch extends core_1.BaseOperation {
constructor() {

@@ -38,3 +38,3 @@ super(...arguments);

}
this._queryOperation = core_1.createQueryOperation(this.params, this.owneryQuery, this.options);
this._queryOperation = (0, core_1.createQueryOperation)(this.params, this.owneryQuery, this.options);
}

@@ -46,3 +46,3 @@ reset() {

next(item) {
if (utils_1.isArray(item)) {
if ((0, utils_1.isArray)(item)) {
for (let i = 0, { length } = item; i < length; i++) {

@@ -53,3 +53,3 @@ // reset query operation since item being tested needs to pass _all_ query

const child = item[i];
this._queryOperation.next(child, i, item);
this._queryOperation.next(child, i, item, false);
this.keep = this.keep || this._queryOperation.keep;

@@ -65,3 +65,3 @@ }

}
class $Not extends core_1.NamedBaseOperation {
class $Not extends core_1.BaseOperation {
constructor() {

@@ -72,9 +72,10 @@ super(...arguments);

init() {
this._queryOperation = core_1.createQueryOperation(this.params, this.owneryQuery, this.options);
this._queryOperation = (0, core_1.createQueryOperation)(this.params, this.owneryQuery, this.options);
}
reset() {
super.reset();
this._queryOperation.reset();
}
next(item, key, owner) {
this._queryOperation.next(item, key, owner);
next(item, key, owner, root) {
this._queryOperation.next(item, key, owner, root);
this.done = this._queryOperation.done;

@@ -84,3 +85,3 @@ this.keep = !this._queryOperation.keep;

}
class $Size extends core_1.NamedBaseOperation {
class $Size extends core_1.BaseOperation {
constructor() {

@@ -92,3 +93,3 @@ super(...arguments);

next(item) {
if (utils_1.isArray(item) && item.length === this.params) {
if ((0, utils_1.isArray)(item) && item.length === this.params) {
this.done = true;

@@ -109,3 +110,3 @@ this.keep = true;

};
class $Or extends core_1.NamedBaseOperation {
class $Or extends core_1.BaseOperation {
constructor() {

@@ -117,3 +118,3 @@ super(...arguments);

assertGroupNotEmpty(this.params);
this._ops = this.params.map(op => core_1.createQueryOperation(op, null, this.options));
this._ops = this.params.map(op => (0, core_1.createQueryOperation)(op, null, this.options));
}

@@ -153,3 +154,3 @@ reset() {

}
class $In extends core_1.NamedBaseOperation {
class $In extends core_1.BaseOperation {
constructor() {

@@ -161,6 +162,6 @@ super(...arguments);

this._testers = this.params.map(value => {
if (core_1.containsOperation(value, this.options)) {
throw new Error(`cannot nest $ under ${this.constructor.name.toLowerCase()}`);
if ((0, core_1.containsOperation)(value, this.options)) {
throw new Error(`cannot nest $ under ${this.name.toLowerCase()}`);
}
return core_1.createTester(value, this.options.compare);
return (0, core_1.createTester)(value, this.options.compare);
});

@@ -183,13 +184,31 @@ }

}
class $Nin extends $In {
constructor() {
super(...arguments);
class $Nin extends core_1.BaseOperation {
constructor(params, ownerQuery, options, name) {
super(params, ownerQuery, options, name);
this.propop = true;
this._in = new $In(params, ownerQuery, options, name);
}
next(item, key, owner) {
super.next(item, key, owner);
this.keep = !this.keep;
next(item, key, owner, root) {
this._in.next(item, key, owner);
if ((0, utils_1.isArray)(owner) && !root) {
if (this._in.keep) {
this.keep = false;
this.done = true;
}
else if (key == owner.length - 1) {
this.keep = true;
this.done = true;
}
}
else {
this.keep = !this._in.keep;
this.done = true;
}
}
reset() {
super.reset();
this._in.reset();
}
}
class $Exists extends core_1.NamedBaseOperation {
class $Exists extends core_1.BaseOperation {
constructor() {

@@ -208,8 +227,8 @@ super(...arguments);

constructor(params, owneryQuery, options, name) {
super(params, owneryQuery, options, params.map(query => core_1.createQueryOperation(query, owneryQuery, options)), name);
super(params, owneryQuery, options, params.map(query => (0, core_1.createQueryOperation)(query, owneryQuery, options)), name);
this.propop = false;
assertGroupNotEmpty(params);
}
next(item, key, owner) {
this.childrenNext(item, key, owner);
next(item, key, owner, root) {
this.childrenNext(item, key, owner, root);
}

@@ -219,7 +238,7 @@ }

constructor(params, owneryQuery, options, name) {
super(params, owneryQuery, options, params.map(query => core_1.createQueryOperation(query, owneryQuery, options)), name);
super(params, owneryQuery, options, params.map(query => (0, core_1.createQueryOperation)(query, owneryQuery, options)), name);
this.propop = true;
}
next(item, key, owner) {
this.childrenNext(item, key, owner);
next(item, key, owner, root) {
this.childrenNext(item, key, owner, root);
}

@@ -239,9 +258,11 @@ }

exports.$nin = $nin;
const $in = (params, owneryQuery, options, name) => new $In(params, owneryQuery, options, name);
const $in = (params, owneryQuery, options, name) => {
return new $In(params, owneryQuery, options, name);
};
exports.$in = $in;
exports.$lt = core_1.numericalOperation(params => b => b < params);
exports.$lte = core_1.numericalOperation(params => b => b <= params);
exports.$gt = core_1.numericalOperation(params => b => b > params);
exports.$gte = core_1.numericalOperation(params => b => b >= params);
const $mod = ([mod, equalsValue], owneryQuery, options) => new core_1.EqualsOperation(b => utils_1.comparable(b) % mod === equalsValue, owneryQuery, options);
exports.$lt = (0, core_1.numericalOperation)(params => b => b < params);
exports.$lte = (0, core_1.numericalOperation)(params => b => b <= params);
exports.$gt = (0, core_1.numericalOperation)(params => b => b > params);
exports.$gte = (0, core_1.numericalOperation)(params => b => b >= params);
const $mod = ([mod, equalsValue], owneryQuery, options) => new core_1.EqualsOperation(b => (0, utils_1.comparable)(b) % mod === equalsValue, owneryQuery, options);
exports.$mod = $mod;

@@ -282,3 +303,3 @@ const $exists = (params, owneryQuery, options, name) => new $Exists(params, owneryQuery, options, name);

let test;
if (utils_1.isFunction(params)) {
if ((0, utils_1.isFunction)(params)) {
test = params;

@@ -285,0 +306,0 @@ }

@@ -16,3 +16,3 @@ "use strict";

}
else if (exports.isArray(value)) {
else if ((0, exports.isArray)(value)) {
return value.map(exports.comparable);

@@ -26,5 +26,5 @@ }

exports.comparable = comparable;
exports.isArray = exports.typeChecker("Array");
exports.isObject = exports.typeChecker("Object");
exports.isFunction = exports.typeChecker("Function");
exports.isArray = (0, exports.typeChecker)("Array");
exports.isObject = (0, exports.typeChecker)("Object");
exports.isFunction = (0, exports.typeChecker)("Function");
const isVanillaObject = value => {

@@ -49,3 +49,3 @@ return (value &&

}
if (exports.isArray(a)) {
if ((0, exports.isArray)(a)) {
if (a.length !== b.length) {

@@ -55,3 +55,3 @@ return false;

for (let i = 0, { length } = a; i < length; i++) {
if (!exports.equals(a[i], b[i]))
if (!(0, exports.equals)(a[i], b[i]))
return false;

@@ -61,3 +61,3 @@ }

}
else if (exports.isObject(a)) {
else if ((0, exports.isObject)(a)) {
if (Object.keys(a).length !== Object.keys(b).length) {

@@ -67,3 +67,3 @@ return false;

for (const key in a) {
if (!exports.equals(a[key], b[key]))
if (!(0, exports.equals)(a[key], b[key]))
return false;

@@ -70,0 +70,0 @@ }

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc