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

mingo

Package Overview
Dependencies
Maintainers
1
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mingo - npm Package Compare versions

Comparing version 4.1.2 to 4.1.3

types.d.ts

3

aggregator.d.ts

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

import { Collection, Options } from "./core";
import { Options } from "./core";
import { Iterator, Source } from "./lazy";
import { Collection } from "./types";
/**

@@ -4,0 +5,0 @@ * Provides functionality for the mongoDB aggregation pipeline

# Changelog
## 4.1.3 / 2021-07-12
* Add stronger type definitions for custom operators.
* Convert unit tests to Typescript.
* Update Typedocs.
## 4.1.2 / 2021-02-17

@@ -4,0 +10,0 @@

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

import { AnyVal, Callback, HashFunction, RawObject } from "./util";
/** Represents an array of documents */
export declare type Collection = Array<RawObject>;
import { Iterator } from "./lazy";
import { AnyVal, Callback, Collection, RawObject } from "./types";
import { HashFunction, resolve } from "./util";
/**

@@ -25,3 +25,3 @@ * Resolves the given string to a Collection.

export interface Options extends RawObject {
readonly idKey: string;
readonly idKey?: string;
readonly collation?: CollationSpec;

@@ -31,4 +31,5 @@ readonly hashFunction?: HashFunction;

}
/** Map of operator functions */
export declare type OperatorMap = Record<string, Callback<AnyVal>>;
export interface ComputeOptions extends Options {
readonly root?: RawObject;
}
/**

@@ -49,2 +50,12 @@ * Creates an Option from another required keys are initialized

}
export declare type AccumulatorOperator = (collection: Collection, expr: AnyVal, options?: Options) => AnyVal;
export declare type ExpressionOperator = (obj: RawObject, expr: AnyVal, options?: Options) => AnyVal;
export declare type PipelineOperator = (collection: Iterator, expr: AnyVal, options?: Options) => Iterator;
export declare type ProjectionOperator = (obj: RawObject, expr: AnyVal, field: string, options?: Options) => AnyVal;
export declare type QueryOperator = (selector: string, value: AnyVal, options?: Options) => (obj: RawObject) => boolean;
/** Map of operator functions */
export declare type OperatorMap = Record<string, AccumulatorOperator | ExpressionOperator | PipelineOperator | ProjectionOperator | QueryOperator>;
/** Spec for Query and Project operators where the value of the selector is resolved. */
declare type SelectorOperator<R> = (selector: string, lhs: AnyVal, rhs: AnyVal, options?: Options) => R;
export declare type AddOperatorsMap = Record<string, AccumulatorOperator | ExpressionOperator | PipelineOperator | SelectorOperator<AnyVal>>;
/**

@@ -63,12 +74,14 @@ * Register fully specified operators for the given operator class.

export declare function getOperator(cls: OperatorType, operator: string): Callback<AnyVal> | null;
/** Context used for creating new operators */
export interface OperatorContext {
readonly computeValue: typeof computeValue;
readonly resolve: typeof resolve;
}
/**
* Add new operators
*
* @param cls the operator class to extend
* @param operatorFn a callback that accepts internal object state and returns an object of new operators.
* @param operatorType the operator class to extend
* @param operatorFactory a callback that accepts internal object state and returns an object of new operators.
*/
export declare function addOperators(cls: OperatorType, operatorFn: Callback<OperatorMap>): void;
interface ComputeOptions extends Options {
root?: RawObject;
}
export declare function addOperators(operatorType: OperatorType, operatorFactory: (context: OperatorContext) => AddOperatorsMap): void;
/**

@@ -75,0 +88,0 @@ * Computes the value of the expression on the object for the given operator

"use strict";
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
var _a;

@@ -36,3 +41,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

*/
function validateOperators(operators) {
function validateOperatorMap(operators) {
for (var _i = 0, _a = Object.entries(operators); _i < _a.length; _i++) {

@@ -50,3 +55,3 @@ var _b = _a[_i], k = _b[0], v = _b[1];

function useOperators(cls, operators) {
validateOperators(operators);
validateOperatorMap(operators);
util_1.into(OPERATORS[cls], operators);

@@ -67,26 +72,29 @@ }

*
* @param cls the operator class to extend
* @param operatorFn a callback that accepts internal object state and returns an object of new operators.
* @param operatorType the operator class to extend
* @param operatorFactory a callback that accepts internal object state and returns an object of new operators.
*/
function addOperators(cls, operatorFn) {
var newOperators = operatorFn({ computeValue: computeValue, resolve: util_1.resolve });
validateOperators(newOperators);
function addOperators(operatorType, operatorFactory) {
var customOperators = operatorFactory({ computeValue: computeValue, resolve: util_1.resolve });
validateOperatorMap(customOperators);
// check for existing operators
for (var _i = 0, _a = Object.entries(newOperators); _i < _a.length; _i++) {
var _b = _a[_i], op = _b[0], _ = _b[1];
var call = getOperator(cls, op);
util_1.assert(!call, op + " already exists for '" + cls + "' operators");
for (var _i = 0, _a = Object.entries(customOperators); _i < _a.length; _i++) {
var _b = _a[_i], op = _b[0], _1 = _b[1];
var call = getOperator(operatorType, op);
util_1.assert(!call, op + " already exists for '" + operatorType + "' operators");
}
var wrapped = {};
switch (cls) {
var normalizedOperators = {};
switch (operatorType) {
case OperatorType.QUERY:
var _loop_1 = function (op, f) {
var fn = f.bind(newOperators);
wrapped[op] = function (selector, value, options) { return function (obj) {
// value of field must be fully resolved.
var lhs = util_1.resolve(obj, selector, { unwrapArray: true });
return fn(selector, lhs, value, options);
}; };
var fn = f;
normalizedOperators[op] =
function (selector, value, options) {
return function (obj) {
// value of field must be fully resolved.
var lhs = util_1.resolve(obj, selector, { unwrapArray: true });
return fn(selector, lhs, value, options);
};
};
};
for (var _c = 0, _d = Object.entries(newOperators); _c < _d.length; _c++) {
for (var _c = 0, _d = Object.entries(customOperators); _c < _d.length; _c++) {
var _e = _d[_c], op = _e[0], f = _e[1];

@@ -98,4 +106,4 @@ _loop_1(op, f);

var _loop_2 = function (op, f) {
var fn = f.bind(newOperators);
wrapped[op] = function (obj, expr, selector, options) {
var fn = f;
normalizedOperators[op] = function (obj, expr, selector, options) {
var lhs = util_1.resolve(obj, selector);

@@ -105,3 +113,3 @@ return fn(selector, lhs, expr, options);

};
for (var _f = 0, _g = Object.entries(newOperators); _f < _g.length; _f++) {
for (var _f = 0, _g = Object.entries(customOperators); _f < _g.length; _f++) {
var _h = _g[_f], op = _h[0], f = _h[1];

@@ -113,3 +121,3 @@ _loop_2(op, f);

var _loop_3 = function (op, fn) {
wrapped[op] = function () {
normalizedOperators[op] = function () {
var args = [];

@@ -119,6 +127,6 @@ for (var _i = 0; _i < arguments.length; _i++) {

}
return fn.apply(newOperators, args);
return fn.call.apply(fn, __spreadArray([null], args));
};
};
for (var _j = 0, _k = Object.entries(newOperators); _j < _k.length; _j++) {
for (var _j = 0, _k = Object.entries(customOperators); _j < _k.length; _j++) {
var _l = _k[_j], op = _l[0], fn = _l[1];

@@ -129,3 +137,3 @@ _loop_3(op, fn);

// toss the operator salad :)
useOperators(cls, wrapped);
useOperators(operatorType, normalizedOperators);
}

@@ -199,2 +207,3 @@ exports.addOperators = addOperators;

};
/* eslint-enable unused-imports/no-unused-vars-ts */
/**

@@ -201,0 +210,0 @@ * Computes the value of the expression on the object for the given operator

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

import { CollationSpec, Collection, Options } from "./core";
import { CollationSpec, Options } from "./core";
import { Iterator, Source } from "./lazy";
import { AnyVal, Callback, Predicate, RawArray, RawObject } from "./util";
import { AnyVal, Collection, RawArray, RawObject } from "./types";
import { Callback, Predicate } from "./util";
/**

@@ -78,2 +79,3 @@ * Cursor to iterate and perform filtering on matched objects.

forEach(callback: Callback<AnyVal>): void;
[Symbol.iterator](): Iterator;
}

@@ -31,4 +31,5 @@ "use strict";

// add projection operator
if (util_1.isObject(this.__projection))
if (util_1.isObject(this.__projection)) {
this.__operators.push({ $project: this.__projection });
}
// filter collection

@@ -95,6 +96,9 @@ this.__result = lazy_1.Lazy(this.__source).filter(this.__predicateFn);

Cursor.prototype.next = function () {
// empty stack means processing is done
if (!this.__stack)
return; // done
if (this.__stack.length > 0)
return this.__stack.pop(); // yield value obtains in hasNext()
return;
// yield value obtains in hasNext()
if (this.__stack.length > 0) {
return this.__stack.pop();
}
var o = this._fetch().next();

@@ -113,10 +117,11 @@ if (!o.done)

return false; // done
// there is a value on stack
if (this.__stack.length > 0)
return true; // there is a value on stack
return true;
var o = this._fetch().next();
if (!o.done) {
this.__stack.push(o.value);
if (o.done) {
this.__stack = null;
}
else {
this.__stack = null;
this.__stack.push(o.value);
}

@@ -140,14 +145,7 @@ return !!this.__stack;

};
Cursor.prototype[Symbol.iterator] = function () {
return this._fetch(); /* eslint-disable-line */
};
return Cursor;
}());
exports.Cursor = Cursor;
if (typeof Symbol === "function") {
/**
* Applies an [ES2015 Iteration protocol][] compatible implementation
* [ES2015 Iteration protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
* @returns {Object}
*/
Cursor.prototype[Symbol.iterator] = function () {
return this._fetch(); /* eslint-disable-line */
};
}
import "./init/basic";
import { Aggregator } from "./aggregator";
import { Collection, Options } from "./core";
import { Options } from "./core";
import { Cursor } from "./cursor";
import { Source } from "./lazy";
import { Query } from "./query";
import { RawArray, RawObject } from "./util";
import { Collection, RawArray, RawObject } from "./types";
export { Aggregator } from "./aggregator";

@@ -9,0 +9,0 @@ export { Query } from "./query";

"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]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -8,7 +27,7 @@ /**

var core_1 = require("../core");
var booleanOperators = require("../operators/expression/boolean");
var comparisonOperators = require("../operators/expression/comparison");
var booleanOperators = __importStar(require("../operators/expression/boolean"));
var comparisonOperators = __importStar(require("../operators/expression/comparison"));
var pipeline_1 = require("../operators/pipeline");
var projectionOperators = require("../operators/projection");
var queryOperators = require("../operators/query");
var projectionOperators = __importStar(require("../operators/projection"));
var queryOperators = __importStar(require("../operators/query"));
var util_1 = require("../util");

@@ -15,0 +34,0 @@ /**

"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]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,7 +25,7 @@ // all system operators

var core_1 = require("../core");
var accumulatorOperators = require("../operators/accumulator");
var expressionOperators = require("../operators/expression");
var pipelineOperators = require("../operators/pipeline");
var projectionOperators = require("../operators/projection");
var queryOperators = require("../operators/query");
var accumulatorOperators = __importStar(require("../operators/accumulator"));
var expressionOperators = __importStar(require("../operators/expression"));
var pipelineOperators = __importStar(require("../operators/pipeline"));
var projectionOperators = __importStar(require("../operators/projection"));
var queryOperators = __importStar(require("../operators/query"));
/**

@@ -13,0 +32,0 @@ * Enable all supported MongoDB operators

@@ -1,16 +0,16 @@

import { AnyVal, Callback, Predicate, RawArray } from "./util";
import { AnyVal, Callback, Predicate, RawArray } from "./types";
/**
* Simplified generator interface
* A value produced by a generator
*/
interface Generator<T> {
next: Callback<T>;
interface IteratorResult {
readonly value?: AnyVal;
readonly done: boolean;
}
/**
* A value produced by a generator
* Simplified generator interface
*/
interface Value {
value?: AnyVal;
done: boolean;
interface Generator<T> {
next: () => T;
}
export declare type Source = Generator<AnyVal> | Callback<AnyVal> | RawArray;
export declare type Source = Generator<IteratorResult> | Callback<IteratorResult> | RawArray;
/**

@@ -44,3 +44,3 @@ * Returns an iterator

private _push;
next(): Value;
next(): IteratorResult;
/**

@@ -47,0 +47,0 @@ * Transform each item in the sequence to a new value

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

else if (!(source instanceof Function)) {
throw new Error("Source is not iterable. Must be Array, Function, or Generator");
throw new Error("Source is of type '" + typeof source + "'. Must be Array, Function, or Generator");
}

@@ -133,0 +133,0 @@ // create next function

/**
* Predicates used for Query and Expression operators.
*/
import { Options } from "../core";
import { AnyVal, Callback, Predicate, RawArray, RawObject } from "../util";
import { ExpressionOperator, Options, QueryOperator } from "../core";
import { AnyVal, RawArray, RawObject } from "../types";
import { Predicate } from "../util";
/**
* Returns a query operator created from the predicate
*
* @param pred Predicate function
* @param predicate Predicate function
*/
export declare function createQueryOperator(pred: Predicate<AnyVal>): Callback<Callback<boolean>>;
export declare function createQueryOperator(predicate: Predicate<AnyVal>): QueryOperator;
/**
* Returns an expression operator created from the predicate
*
* @param f Predicate function
* @param predicate Predicate function
*/
export declare function createExpressionOperator(f: Predicate<AnyVal>): Callback<AnyVal>;
export declare function createExpressionOperator(predicate: Predicate<AnyVal>): ExpressionOperator;
/**

@@ -136,2 +137,2 @@ * Checks that two values are equal.

*/
export declare function $type(a: AnyVal, b: number | string, options?: Options): boolean;
export declare function $type(a: AnyVal, b: number | string | Array<number | string>, options?: Options): boolean;

@@ -13,5 +13,5 @@ "use strict";

*
* @param pred Predicate function
* @param predicate Predicate function
*/
function createQueryOperator(pred) {
function createQueryOperator(predicate) {
return function (selector, value, options) {

@@ -22,3 +22,3 @@ var opts = { unwrapArray: true };

var lhs = util_1.resolve(obj, selector, opts);
return pred(lhs, value, options);
return predicate(lhs, value, options);
};

@@ -31,8 +31,8 @@ };

*
* @param f Predicate function
* @param predicate Predicate function
*/
function createExpressionOperator(f) {
function createExpressionOperator(predicate) {
return function (obj, expr, options) {
var args = core_1.computeValue(obj, expr, null, options);
return f.apply(void 0, args);
return predicate.apply(void 0, args);
};

@@ -251,3 +251,3 @@ }

*/
function $type(a, b, options) {
function compareType(a, b, options) {
switch (b) {

@@ -301,2 +301,14 @@ case 1:

}
/**
* Selects documents if a field is of the specified type.
*
* @param a
* @param b
* @returns {boolean}
*/
function $type(a, b, options) {
return Array.isArray(b)
? b.findIndex(function (t) { return compareType(a, t, options); }) >= 0
: compareType(a, b, options);
}
exports.$type = $type;

@@ -303,0 +315,0 @@ function compare(a, b, f) {

@@ -1,3 +0,3 @@

import { Collection, Options } from "../../core";
import { AnyVal } from "../../util";
import { Options } from "../../core";
import { AnyVal, Collection } from "../../types";
/**

@@ -4,0 +4,0 @@ * Returns an array of all the unique values for the selected field among for each document in that group.

@@ -1,3 +0,3 @@

import { Collection, Options } from "../../core";
import { AnyVal } from "../../util";
import { Options } from "../../core";
import { AnyVal, Collection } from "../../types";
/**

@@ -4,0 +4,0 @@ * Returns an average of all the values in a group.

@@ -1,3 +0,3 @@

import { Collection, Options } from "../../core";
import { AnyVal } from "../../util";
import { Options } from "../../core";
import { AnyVal, Collection } from "../../types";
/**

@@ -4,0 +4,0 @@ * Returns the first value in a group.

@@ -1,3 +0,3 @@

import { Collection, Options } from "../../core";
import { AnyVal } from "../../util";
import { Options } from "../../core";
import { AnyVal, Collection } from "../../types";
/**

@@ -4,0 +4,0 @@ * Returns the last value in the collection.

@@ -1,3 +0,3 @@

import { Collection, Options } from "../../core";
import { AnyVal } from "../../util";
import { Options } from "../../core";
import { AnyVal, Collection } from "../../types";
/**

@@ -4,0 +4,0 @@ * Returns the highest value in a group.

@@ -1,3 +0,3 @@

import { Collection, Options } from "../../core";
import { AnyVal } from "../../util";
import { Options } from "../../core";
import { AnyVal, Collection } from "../../types";
/**

@@ -4,0 +4,0 @@ * Returns the lowest value in a group.

@@ -1,3 +0,3 @@

import { Collection, Options } from "../../core";
import { AnyVal, RawArray } from "../../util";
import { Options } from "../../core";
import { AnyVal, Collection, RawArray } from "../../types";
/**

@@ -4,0 +4,0 @@ * Returns an array of all values for the selected field among for each document in that group.

@@ -1,3 +0,3 @@

import { Collection, Options } from "../../core";
import { AnyVal } from "../../util";
import { Options } from "../../core";
import { AnyVal, Collection } from "../../types";
/**

@@ -4,0 +4,0 @@ * Returns the population standard deviation of the input values.

@@ -1,3 +0,3 @@

import { Collection, Options } from "../../core";
import { AnyVal } from "../../util";
import { Options } from "../../core";
import { AnyVal, Collection } from "../../types";
/**

@@ -4,0 +4,0 @@ * Returns the sample standard deviation of the input values.

@@ -1,3 +0,3 @@

import { Collection, Options } from "../../core";
import { AnyVal } from "../../util";
import { Options } from "../../core";
import { AnyVal, Collection } from "../../types";
/**

@@ -4,0 +4,0 @@ * Returns the sum of all the values in a group.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the absolute value of a number.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Computes the sum of an array of numbers.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the smallest integer greater than or equal to the specified number.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Takes two numbers and divides the first number by the second.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Raises Euler’s number (i.e. e ) to the specified exponent and returns the result.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the largest integer less than or equal to the specified number.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Calculates the natural logarithm ln (i.e loge) of a number and returns the result as a double.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Calculates the log of a number in the specified base and returns the result as a double.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Calculates the log base 10 of a number and returns the result as a double.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Takes two numbers and calculates the modulo of the first number divided by the second.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Computes the product of an array of numbers.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Raises a number to the specified exponent and returns the result.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Rounds a number to to a whole integer or to a specified decimal place.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Calculates the square root of a positive number and returns the result as a double.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Takes an array that contains two numbers or two dates and subtracts the second value from the first.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Truncates a number to a whole integer or to a specified decimal place.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the element at the specified array index.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Converts an array of key value pairs to a document.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Concatenates arrays to return the concatenated array.

import { Options } from "../../../core";
import { AnyVal, RawArray, RawObject } from "../../../util";
import { AnyVal, RawArray, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Selects a subset of the array to return an array with only the elements that match the filter condition.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns a boolean indicating whether a specified value is in an array.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Searches an array for an occurrence of a specified value and returns the array index of the first occurrence.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Determines if the operand is an array. Returns a boolean.

import { Options } from "../../../core";
import { AnyVal, RawArray, RawObject } from "../../../util";
import { AnyVal, RawArray, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Applies a sub-expression to each element of an array and returns the array of resulting values in order.

@@ -8,2 +8,2 @@ /**

*/
export declare const $nin: import("../../../util").Callback<unknown>;
export declare const $nin: import("../../../core").ExpressionOperator;
import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns an array whose elements are a generated sequence of numbers.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Applies an expression to each element in an array and combines them into a single value.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns an array with the elements in reverse order.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Counts and returns the total the number of items in an array.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns a subset of an array.

import { Options } from "../../../core";
import { AnyVal, RawArray, RawObject } from "../../../util";
import { AnyVal, RawArray, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Merge two lists together.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns true only when all its expressions evaluate to true. Accepts any number of argument expressions.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the boolean value that is the opposite of its argument expression. Accepts a single argument expression.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns true when any of its expressions evaluates to true. Accepts any number of argument expressions.

import { Options } from "../../core";
import { AnyVal, RawObject } from "../../util";
export declare const $eq: import("../../util").Callback<unknown>;
export declare const $gt: import("../../util").Callback<unknown>;
export declare const $gte: import("../../util").Callback<unknown>;
export declare const $lt: import("../../util").Callback<unknown>;
export declare const $lte: import("../../util").Callback<unknown>;
export declare const $ne: import("../../util").Callback<unknown>;
import { AnyVal, RawObject } from "../../types";
export declare const $eq: import("../../core").ExpressionOperator;
export declare const $gt: import("../../core").ExpressionOperator;
export declare const $gte: import("../../core").ExpressionOperator;
export declare const $lt: import("../../core").ExpressionOperator;
export declare const $lte: import("../../core").ExpressionOperator;
export declare const $ne: import("../../core").ExpressionOperator;
/**

@@ -10,0 +10,0 @@ * Compares two values and returns the result of the comparison as an integer.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, Container, RawObject } from "../../../util";
import { AnyVal, ArrayOrObject, RawObject } from "../../../types";
/**

@@ -14,2 +14,2 @@ * A ternary operator that evaluates one expression,

*/
export declare function $cond(obj: RawObject, expr: Container, options?: Options): AnyVal;
export declare function $cond(obj: RawObject, expr: ArrayOrObject, options?: Options): AnyVal;

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawArray, RawObject } from "../../../util";
import { AnyVal, RawArray, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Evaluates an expression and returns the first expression if it evaluates to a non-null value.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * An operator that evaluates a series of case expressions. When it finds an expression which

import { Options } from "../../../core";
import { AnyVal } from "../../../util";
import { AnyVal } from "../../../types";
export declare const MILLIS_PER_DAY: number;

@@ -4,0 +4,0 @@ export declare const MINUTES_PER_HOUR = 60;

@@ -38,2 +38,3 @@ "use strict";

"%Z": { name: "minuteOffset", padding: 3, re: /([+-][0-9]{3})/ },
// "%%": "%",
};

@@ -40,0 +41,0 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Constructs and returns a Date object given the date’s constituent properties.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Converts a date/time string to a date object.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns a document that contains the constituent parts of a given Date value as individual properties.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the date as a formatted string.

@@ -29,2 +29,5 @@ "use strict";

"%V": week_1.$week,
// "%z": null,
// "%Z": null,
// "%%": "%",
};

@@ -31,0 +34,0 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the day of the month for a date as a number between 1 and 31.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday).

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the day of the year for a date as a number between 1 and 366 (leap year).

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the hour for a date as a number between 0 and 23.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the milliseconds of a date as a number between 0 and 999.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the minute for a date as a number between 0 and 59.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the month for a date as a number between 1 (January) and 12 (December).

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the seconds for a date as a number between 0 and 60 (leap seconds).

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the week number for a date as a number between 0

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Returns the year for a date as a number (e.g. 2014).

import { Options } from "../../core";
import { AnyVal, RawObject } from "../../util";
import { AnyVal, RawObject } from "../../types";
/**

@@ -4,0 +4,0 @@ * Return a value without parsing.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Combines multiple documents into a single document.

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Converts a document to an array of documents representing key-value pairs.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Returns true if all elements of a set evaluate to true, and false otherwise.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Returns true if any elements of a set evaluate to true, and false otherwise.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Returns elements of a set that do not appear in a second set.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Returns true if two sets have the same elements.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Returns the common elements of the input sets.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Returns true if all elements of a set appear in a second set.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Returns a set that holds all elements of the input sets.

import { Options } from "../../../core";
import { AnyVal, RawArray, RawObject } from "../../../util";
import { AnyVal, RawArray, RawObject } from "../../../types";
/**

@@ -4,0 +4,0 @@ * Trims the resolved string

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

0x2009,
0x200a,
0x200a, // Hair space
];

@@ -29,0 +29,0 @@ /**

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Concatenates two strings.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Searches a string for an occurrence of a substring and returns the UTF-8 code point index of the first occurence.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Removes whitespace characters, including null, or the specified characters from the beginning of a string.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Applies a regular expression (regex) to a string and returns information on the first matched substring.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Applies a regular expression (regex) to a string and returns information on the all matched substrings.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Applies a regular expression (regex) to a string and returns a boolean that indicates if a match is found or not.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Removes whitespace characters, including null, or the specified characters from the end of a string.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Splits a string into substrings based on a delimiter.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Compares two strings and returns an integer that reflects the comparison.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Returns the number of UTF-8 encoded bytes in the specified string.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Returns the number of UTF-8 code points in the specified string.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Returns a substring of a string, starting at a specified index position and including the specified number of characters.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Returns a substring of a string, starting at a specified index position and including the specified number of characters.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
export declare function $substrCP(obj: RawObject, expr: AnyVal, options?: Options): AnyVal;

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Converts a string to lowercase.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Converts a string to uppercase.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Removes whitespace characters, including null, or the specified characters from the beginning and end of a string.

import { Options } from "../../core";
import { AnyVal, Callback, RawObject } from "../../util";
import { AnyVal, RawObject } from "../../types";
import { Callback } from "../../util";
/** Returns the sine of a value that is measured in radians. */

@@ -4,0 +5,0 @@ export declare const $sin: Callback<number>;

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
export declare class TypeConvertError extends Error {

@@ -4,0 +4,0 @@ constructor(message: string);

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -12,0 +14,0 @@ function __() { this.constructor = d; }

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Converts a value to a specified type.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Checks if the specified expression resolves to a numeric value

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Converts a value to a boolean.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Converts a value to a date. If the value cannot be converted to a date, $toDate errors. If the value is null or missing, $toDate returns null.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Converts a value to a double. If the value cannot be converted to an double, $toDouble errors. If the value is null or missing, $toDouble returns null.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Converts a value to an integer. If the value cannot be converted to an integer, $toInt errors. If the value is null or missing, $toInt returns null.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Converts a value to a long. If the value cannot be converted to a long, $toLong errors. If the value is null or missing, $toLong returns null.

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
export declare function $toString(obj: RawObject, expr: AnyVal, options?: Options): string | null;

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
export declare function $type(obj: RawObject, expr: AnyVal, options?: Options): string;

@@ -5,3 +5,3 @@ /**

import { Options } from "../../../core";
import { AnyVal, RawObject } from "../../../util";
import { AnyVal, RawObject } from "../../../types";
/**

@@ -8,0 +8,0 @@ * Defines variables for use within the scope of a sub-expression and returns the result of the sub-expression.

import { Options } from "../../core";
import { Iterator } from "../../lazy";
import { RawObject } from "../../util";
import { RawObject } from "../../types";
/**

@@ -5,0 +5,0 @@ * Adds new fields to documents.

import { Options } from "../../core";
import { Iterator } from "../../lazy";
import { AnyVal, RawArray, RawObject } from "../../util";
import { AnyVal, RawArray, RawObject } from "../../types";
/**

@@ -5,0 +5,0 @@ * Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries.

"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};

@@ -23,3 +21,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

function $bucket(collection, expr, options) {
var boundaries = __spreadArrays(expr.boundaries);
var boundaries = __spreadArray([], expr.boundaries);
var defaultKey = expr.default;

@@ -26,0 +24,0 @@ var lower = boundaries[0]; // inclusive

import { Options } from "../../core";
import { Iterator } from "../../lazy";
import { AnyVal, RawObject } from "../../util";
import { AnyVal, RawObject } from "../../types";
/**

@@ -5,0 +5,0 @@ * Categorizes incoming documents into a specific number of groups, called buckets,

@@ -69,3 +69,4 @@ "use strict";

if (result.length > 0) {
result[result.length - 1][ID_KEY].max = computeValueOptimized(sorted[sorted.length - 1], groupByExpr, null, options);
result[result.length - 1][ID_KEY].max =
computeValueOptimized(sorted[sorted.length - 1], groupByExpr, null, options);
}

@@ -72,0 +73,0 @@ return result;

import { Options } from "../../core";
import { Iterator } from "../../lazy";
import { RawObject } from "../../util";
import { RawObject } from "../../types";
/**

@@ -5,0 +5,0 @@ * Processes multiple aggregation pipelines within a single stage on the same set of input documents.

import { Options } from "../../core";
import { Iterator } from "../../lazy";
import { RawObject } from "../../util";
import { RawObject } from "../../types";
/**

@@ -5,0 +5,0 @@ * Groups documents together for the purpose of calculating aggregate values based on a collection of documents.

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

import { Collection, Options } from "../../core";
import { Options } from "../../core";
import { Iterator } from "../../lazy";
import { Collection } from "../../types";
/**

@@ -4,0 +5,0 @@ * Performs a left outer join to another collection in the same database to filter in documents from the “joined” collection for processing.

@@ -14,3 +14,4 @@ "use strict";

var joinColl = util_1.isString(expr.from)
? options === null || options === void 0 ? void 0 : options.collectionResolver(expr.from) : expr.from;
? options === null || options === void 0 ? void 0 : options.collectionResolver(expr.from)
: expr.from;
util_1.assert(joinColl instanceof Array, "'from' field must resolve to an array");

@@ -17,0 +18,0 @@ var hash = {};

import { Options } from "../../core";
import { Iterator } from "../../lazy";
import { RawObject } from "../../util";
import { RawObject } from "../../types";
/**

@@ -5,0 +5,0 @@ * Filters the document stream, and only allows matching documents to pass into the next pipeline stage.

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

import { Collection, Options } from "../../core";
import { Options } from "../../core";
import { Iterator } from "../../lazy";
import { Collection } from "../../types";
/**

@@ -4,0 +5,0 @@ * Takes the documents returned by the aggregation pipeline and writes them to a specified collection.

@@ -18,3 +18,4 @@ "use strict";

var outputColl = util_1.isString(expr)
? options === null || options === void 0 ? void 0 : options.collectionResolver(expr) : expr;
? options === null || options === void 0 ? void 0 : options.collectionResolver(expr)
: expr;
util_1.assert(outputColl instanceof Array, "expression must resolve to an array");

@@ -21,0 +22,0 @@ return collection.map(function (o) {

import { Options } from "../../core";
import { Iterator } from "../../lazy";
import { RawObject } from "../../util";
import { RawObject } from "../../types";
/**

@@ -5,0 +5,0 @@ * Reshapes a document stream.

import { Options } from "../../core";
import { Iterator } from "../../lazy";
import { RawObject } from "../../util";
import { RawObject } from "../../types";
/**

@@ -5,0 +5,0 @@ * Restricts the contents of the documents based on information stored in the documents themselves.

import { Options } from "../../core";
import { Iterator } from "../../lazy";
import { RawObject } from "../../util";
import { RawObject } from "../../types";
/**

@@ -5,0 +5,0 @@ * Replaces a document with the specified embedded document or new one.

@@ -35,4 +35,4 @@ "use strict";

coll = [];
for (var _i = 0, indexKeys_1 = indexKeys; _i < indexKeys_1.length; _i++) {
var k = indexKeys_1[_i];
for (var _b = 0, indexKeys_1 = indexKeys; _b < indexKeys_1.length; _b++) {
var k = indexKeys_1[_b];
util_1.into(coll, grouped.groups[sortedIndex[k]]);

@@ -60,2 +60,3 @@ }

3: "variant",
// case - Only strings that differ in base letters or case compare as unequal. Examples: a ≠ b, a = á, a ≠ A.
};

@@ -62,0 +63,0 @@ /**

import { Options } from "../../core";
import { Iterator } from "../../lazy";
import { AnyVal } from "../../util";
import { AnyVal } from "../../types";
/**

@@ -5,0 +5,0 @@ * Groups incoming documents based on the value of a specified expression,

import { Options } from "../../core";
import { AnyVal, RawObject } from "../../util";
import { AnyVal, RawObject } from "../../types";
/**

@@ -4,0 +4,0 @@ * Projects only the first element from an array that matches the specified $elemMatch condition.

import { Options } from "../../core";
import { AnyVal, RawObject } from "../../util";
import { AnyVal, RawObject } from "../../types";
/**

@@ -4,0 +4,0 @@ * Limits the number of elements projected from an array. Supports skip and limit slices.

"use strict";
// $slice operator. https://docs.mongodb.com/manual/reference/operator/projection/slice/#proj._S_slice
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};

@@ -26,4 +24,4 @@ Object.defineProperty(exports, "__esModule", { value: true });

return xs;
return slice_1.$slice(obj, expr instanceof Array ? __spreadArrays([xs], exprAsArray) : [xs, expr], options);
return slice_1.$slice(obj, expr instanceof Array ? __spreadArray([xs], exprAsArray) : [xs, expr], options);
}
exports.$slice = $slice;
/**
* Matches arrays that contain all elements specified in the query.
*/
export declare const $all: import("../../../util").Callback<import("../../../util").Callback<boolean>>;
export declare const $all: import("../../../core").QueryOperator;
/**
* Selects documents if element in the array field matches all the specified $elemMatch conditions.
*/
export declare const $elemMatch: import("../../../util").Callback<import("../../../util").Callback<boolean>>;
export declare const $elemMatch: import("../../../core").QueryOperator;
/**
* Selects documents if the array field is a specified size.
*/
export declare const $size: import("../../../util").Callback<import("../../../util").Callback<boolean>>;
export declare const $size: import("../../../core").QueryOperator;
/**
* Matches values that are equal to a specified value.
*/
export declare const $eq: import("../../util").Callback<import("../../util").Callback<boolean>>;
export declare const $eq: import("../../core").QueryOperator;
/**
* Matches values that are greater than a specified value.
*/
export declare const $gt: import("../../util").Callback<import("../../util").Callback<boolean>>;
export declare const $gt: import("../../core").QueryOperator;
/**
* Matches values that are greater than or equal to a specified value.
*/
export declare const $gte: import("../../util").Callback<import("../../util").Callback<boolean>>;
export declare const $gte: import("../../core").QueryOperator;
/**
* Matches any of the values that exist in an array specified in the query.
*/
export declare const $in: import("../../util").Callback<import("../../util").Callback<boolean>>;
export declare const $in: import("../../core").QueryOperator;
/**
* Matches values that are less than the value specified in the query.
*/
export declare const $lt: import("../../util").Callback<import("../../util").Callback<boolean>>;
export declare const $lt: import("../../core").QueryOperator;
/**
* Matches values that are less than or equal to the value specified in the query.
*/
export declare const $lte: import("../../util").Callback<import("../../util").Callback<boolean>>;
export declare const $lte: import("../../core").QueryOperator;
/**
* Matches all values that are not equal to the value specified in the query.
*/
export declare const $ne: import("../../util").Callback<import("../../util").Callback<boolean>>;
export declare const $ne: import("../../core").QueryOperator;
/**
* Matches values that do not exist in an array specified to the query.
*/
export declare const $nin: import("../../util").Callback<import("../../util").Callback<boolean>>;
export declare const $nin: import("../../core").QueryOperator;
/**
* Matches documents that have the specified field.
*/
export declare const $exists: import("../../../util").Callback<import("../../../util").Callback<boolean>>;
export declare const $exists: import("../../../core").QueryOperator;
/**
* Selects documents if a field is of the specified type.
*/
export declare const $type: import("../../../util").Callback<import("../../../util").Callback<boolean>>;
export declare const $type: import("../../../core").QueryOperator;
import { Options } from "../../../core";
import { AnyVal, Callback } from "../../../util";
import { AnyVal } from "../../../types";
import { Callback } from "../../../util";
/**

@@ -4,0 +5,0 @@ * Allows the use of aggregation expressions within the query language.

/**
* Performs a modulo operation on the value of a field and selects documents with a specified result.
*/
export declare const $mod: import("../../../util").Callback<import("../../../util").Callback<boolean>>;
export declare const $mod: import("../../../core").QueryOperator;
/**
* Selects documents where values match a specified regular expression.
*/
export declare const $regex: import("../../../util").Callback<import("../../../util").Callback<boolean>>;
export declare const $regex: import("../../../core").QueryOperator;
import { Options } from "../../../core";
import { AnyVal, Callback } from "../../../util";
import { AnyVal } from "../../../types";
import { Callback } from "../../../util";
/**

@@ -4,0 +5,0 @@ * Matches documents that satisfy a JavaScript expression.

import { Options } from "../../../core";
import { Callback, RawObject } from "../../../util";
import { RawObject } from "../../../types";
import { Callback } from "../../../util";
/**

@@ -4,0 +5,0 @@ * Joins query clauses with a logical AND returns all documents that match the conditions of both clauses.

import { Options } from "../../../core";
import { Callback, RawObject } from "../../../util";
import { RawObject } from "../../../types";
import { Callback } from "../../../util";
/**

@@ -4,0 +5,0 @@ * Joins query clauses with a logical NOR returns all documents that fail to match both clauses.

import { Options } from "../../../core";
import { AnyVal, Callback } from "../../../util";
import { AnyVal } from "../../../types";
import { Callback } from "../../../util";
/**

@@ -4,0 +5,0 @@ * Inverts the effect of a query expression and returns documents that do not match the query expression.

import { Options } from "../../../core";
import { Callback, RawObject } from "../../../util";
import { RawObject } from "../../../types";
import { Callback } from "../../../util";
/**

@@ -4,0 +5,0 @@ * Joins query clauses with a logical OR returns all documents that match the conditions of either clause.

{
"name": "mingo",
"version": "4.1.2",
"version": "4.1.3",
"description": "MongoDB query language for in-memory objects",
"main": "index.js",
"module": "index.js",
"typings": "index.d.ts",
"scripts": {},

@@ -40,3 +39,4 @@ "repository": {

"url": "https://github.com/kofrasa/mingo/issues"
}
},
"typings": "index.d.ts"
}

@@ -1,5 +0,5 @@

import { Collection, Options } from "./core";
import { Options } from "./core";
import { Cursor } from "./cursor";
import { Source } from "./lazy";
import { AnyVal, RawObject } from "./util";
import { AnyVal, Collection, RawObject } from "./types";
/**

@@ -6,0 +6,0 @@ * An object used to filter input documents

@@ -5,8 +5,10 @@ # mingo

[![version](https://img.shields.io/npm/v/mingo.svg)](https://www.npmjs.org/package/mingo)
[![build status](https://img.shields.io/travis/kofrasa/mingo.svg)](http://travis-ci.org/kofrasa/mingo)
[![npm](https://img.shields.io/npm/dm/mingo.svg)](https://www.npmjs.org/package/mingo)
[![Codecov](https://img.shields.io/codecov/c/github/kofrasa/mingo.svg)](https://codecov.io/gh/kofrasa/mingo)
[![Code Quality: Javascript](https://img.shields.io/lgtm/grade/javascript/g/kofrasa/mingo.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/kofrasa/mingo/context:javascript)
[![Total Alerts](https://img.shields.io/lgtm/alerts/g/kofrasa/mingo.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/kofrasa/mingo/alerts)
![license](https://img.shields.io/github/license/kofrasa/mingo)
[![version](https://img.shields.io/npm/v/mingo)](https://www.npmjs.org/package/mingo)
[![build status](https://img.shields.io/travis/com/kofrasa/mingo)](http://travis-ci.com/kofrasa/mingo)
![issues](https://img.shields.io/github/issues/kofrasa/mingo)
[![codecov](https://img.shields.io/codecov/c/github/kofrasa/mingo)](https://codecov.io/gh/kofrasa/mingo)
[![quality: Javascript](https://img.shields.io/lgtm/grade/javascript/github/kofrasa/mingo)](https://lgtm.com/projects/g/kofrasa/mingo/context:javascript)
[![alerts](https://img.shields.io/lgtm/alerts/github/kofrasa/mingo)](https://lgtm.com/projects/g/kofrasa/mingo/alerts)
[![npm downloads](https://img.shields.io/npm/dm/mingo)](https://www.npmjs.org/package/mingo)

@@ -153,7 +155,7 @@ ## Install

```js
import mingo from 'mingo'
import { Query } from 'mingo'
// create a query with criteria
// find all grades for homework with score >= 50
let query = new mingo.Query({
let query = new Query({
type: "homework",

@@ -170,3 +172,3 @@ score: { $gte: 50 }

```js
import mingo from 'mingo'
import { Query } from 'mingo'

@@ -176,3 +178,3 @@ // input is either an Array or any iterable source (i.e Object{next:Function}) including ES6 generators.

let query = new mingo.Query(criteria)
let query = new Query(criteria)

@@ -179,0 +181,0 @@ // filter collection with find()

/**
* Utility constants and functions
*/
export declare type AnyVal = unknown;
export declare type RawObject = Record<string, AnyVal>;
export declare type RawArray = Array<AnyVal>;
export declare type Container = RawObject | RawArray;
/**
* Custom function to hash values to improve faster comparaisons
*/
export declare type HashFunction = (v: AnyVal) => string;
import { AnyVal, ArrayOrObject, Callback, RawArray, RawObject } from "./types";
export { AnyVal, ArrayOrObject, Callback, Predicate, RawArray, RawObject, } from "./types";
export declare const MAX_INT = 2147483647;

@@ -16,2 +10,6 @@ export declare const MIN_INT = -2147483648;

export declare const MIN_LONG: number;
/**
* Custom function to hash values to improve faster comparaisons
*/
export declare type HashFunction = Callback<string>;
export declare enum JsType {

@@ -37,8 +35,2 @@ NULL = "null",

}
export interface Callback<T> {
(...args: AnyVal[]): T;
}
export interface Predicate<T> {
(...args: T[]): boolean;
}
declare type CompareResult = -1 | 0 | 1;

@@ -99,3 +91,3 @@ export interface Comparator<T> {

*/
export declare function merge(target: Container, obj: Container, options?: MergeOptions): Container;
export declare function merge(target: ArrayOrObject, obj: ArrayOrObject, options?: MergeOptions): ArrayOrObject;
/**

@@ -182,3 +174,3 @@ * Returns the intersection between two arrays

*/
export declare function into(target: Container, ...rest: Array<Container>): Container;
export declare function into(target: ArrayOrObject, ...rest: Array<ArrayOrObject>): ArrayOrObject;
/**

@@ -199,3 +191,3 @@ * This is a generic memoization function

*/
export declare function resolve(obj: Container, selector: string, options?: ResolveOptions): AnyVal;
export declare function resolve(obj: ArrayOrObject, selector: string, options?: ResolveOptions): AnyVal;
/**

@@ -208,3 +200,3 @@ * Returns the full object to the resolved value given by the selector.

*/
export declare function resolveGraph(obj: Container, selector: string, options?: ResolveOptions): Container;
export declare function resolveGraph(obj: ArrayOrObject, selector: string, options?: ResolveOptions): ArrayOrObject;
/**

@@ -215,3 +207,3 @@ * Filter out all MISSING values from the object in-place

*/
export declare function filterMissing(obj: Container): void;
export declare function filterMissing(obj: ArrayOrObject): void;
/**

@@ -226,3 +218,3 @@ * Walk the object graph and execute the given transform function

*/
export declare function traverse(obj: Container, selector: string, fn: Callback<void>, force?: boolean): void;
export declare function traverse(obj: ArrayOrObject, selector: string, fn: Callback<void>, force?: boolean): void;
/**

@@ -241,6 +233,6 @@ * Set the value of the given object field

*
* @param obj {Container} object or array
* @param obj {ArrayOrObject} object or array
* @param selector {String} dot separated path to element to remove
*/
export declare function removeValue(obj: Container, selector: string): void;
export declare function removeValue(obj: ArrayOrObject, selector: string): void;
/**

@@ -258,2 +250,1 @@ * Check whether the given name passes for an operator. We assume AnyVal field name starting with '$' is an operator.

export declare function normalize(expr: AnyVal): AnyVal;
export {};

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

*
* @param obj {Container} object or array
* @param obj {ArrayOrObject} object or array
* @param selector {String} dot separated path to element to remove

@@ -800,0 +800,0 @@ */

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