diff --git a/.bithoundrc b/.bithoundrc index 9f021cd..5b50a56 100644 --- a/.bithoundrc +++ b/.bithoundrc @@ -13,16 +13,15 @@ }, "dependencies": { "mute": [ - "tsdoc", - "gulp-tsdoc", - "istanbul", - "semver", - "gulp", - "coveralls", + "chai", + "chai-as-promised", + "chalk", "codeclimate-test-reporter", - "del", - "gulp-bump", - "gulp-istanbul" + "concurrently", + "istanbul", + "mocha" + "tslint", + "typedoc" ] } } \ No newline at end of file diff --git a/.gitignore b/.gitignore index 88c66cf..c4bf72a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,4 @@ -Properties/ -bin/ -obj/ -*.suo -*.user -*.sublime* -node_modules/ -.vs -*.dat -.idea -*.tmp +dist +node_modules coverage/ -.tscache doc \ No newline at end of file diff --git a/.npmignore b/.npmignore index d8b6019..5d19764 100644 --- a/.npmignore +++ b/.npmignore @@ -1,22 +1,8 @@ -.idea -.vs -.vscode -benchmarks -build -coverage -doc -example -obj -test -typings -.bithoundrc -.gitattributes -.gitignore -.gitmodules -.jshintrc -.travis.yml -gulpfile.js -Iridium.njsproj -Iridium.sln -Iridium.sublime-* -tslint.json \ No newline at end of file +* +!dist/** +!package.json +!LICENSE +!CHANGELOG.md +!CONTRIBUTING.md +!README.md +!tsconfig.json \ No newline at end of file diff --git a/Iridium.njsproj b/Iridium.njsproj deleted file mode 100644 index e8711c9..0000000 --- a/Iridium.njsproj +++ /dev/null @@ -1,187 +0,0 @@ - - - - Debug - 2.0 - {e9a19872-d84f-418a-8332-3ded543fb1fa} - - ShowAllFiles - node_modules\mocha\bin\mocha - . - . - {3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{349c5851-65df-11da-9384-00065b846f21};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD} - true - CommonJS - true - 11.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - C:\Program Files\iojs\iojs.exe - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - Mocha - - - Code - Mocha - - - Code - Mocha - - - Code - Mocha - - - Mocha - - - Code - Mocha - - - Mocha - - - Code - Mocha - - - Mocha - - - - Mocha - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - False - - - - - - - - False - True - 0 - / - http://localhost:48022/ - False - True - http://localhost:1337 - False - - - - - - - CurrentPage - True - False - False - False - - - - - - - - - False - False - - - - - \ No newline at end of file diff --git a/Iridium.sln b/Iridium.sln deleted file mode 100644 index 3e496f8..0000000 --- a/Iridium.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.22609.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "Iridium", "Iridium.njsproj", "{E9A19872-D84F-418A-8332-3DED543FB1FA}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E9A19872-D84F-418A-8332-3DED543FB1FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E9A19872-D84F-418A-8332-3DED543FB1FA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E9A19872-D84F-418A-8332-3DED543FB1FA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E9A19872-D84F-418A-8332-3DED543FB1FA}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/benchmarks/mongodb.ts b/benchmarks/mongodb.ts index 1faa12e..1b1c361 100644 --- a/benchmarks/mongodb.ts +++ b/benchmarks/mongodb.ts @@ -1,8 +1,8 @@ -import Iridium = require("../iridium"); -import Bluebird = require("bluebird"); -import MongoDB = require("mongodb"); -import _ = require("lodash"); -import crypto = require("crypto"); +import * as Iridium from "../iridium"; +import * as Bluebird from "bluebird"; +import * as MongoDB from "mongodb"; +import * as _ from "lodash"; +import * as crypto from "crypto"; var intensity = 1000; var samples = 3; @@ -38,7 +38,7 @@ class IridiumDB extends Iridium.Core { console.log("Running benchmark with intensity of %d, %d samples", intensity, samples); var results: { [name: string]: number } = {}; -function benchmark(name: string, prepare: (objects: UserDocument[]) => Bluebird, run: (objects: UserDocument[]) => Bluebird, compareTo?: string) { +function benchmark(name: string, prepare: (objects: UserDocument[]) => Bluebird|null, run: (objects: UserDocument[]) => Bluebird, compareTo?: string) { return Bluebird.resolve(new Array(samples)).map(() => { var objects: UserDocument[] = new Array(intensity); for (var i = 0; i < objects.length; i++) @@ -80,7 +80,7 @@ iDB.connect() return new Bluebird((resolve, reject) => { iDB.connection.collection("mongodb").deleteMany({},(err) => { if (err) return reject(err); - return resolve(null); + return resolve({}); }); }); },(objects) => { diff --git a/build/bundle.js b/build/bundle.js deleted file mode 100644 index 3209811..0000000 --- a/build/bundle.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -var typings = require('typings-core'), - path = require('path'), - chalk = require('chalk'); - -typings.bundle({ - cwd: path.dirname(__dirname), - out: path.resolve(__dirname, "../dist/main.d.ts") -}).then(() => { - console.log(chalk.green("bundled type definitions")); -}, err => { - console.error(chalk.red("failed to bundle type definitions")); - console.error(chalk.gray(chalk.red("ERROR"), ": %s\n%s"), err.message, err.stack); -}); \ No newline at end of file diff --git a/circle.yml b/circle.yml deleted file mode 100644 index ddd6ef1..0000000 --- a/circle.yml +++ /dev/null @@ -1,32 +0,0 @@ -general: - branches: - ignore: - - gh-pages - artifacts: - - dist - -machine: - node: - version: 6 - environment: - CI_SERVER: 1 - -dependencies: - override: - - sudo apt-get purge mongodb-org* - - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 - - echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list - - sudo apt-get update - - sudo apt-get install -y mongodb-org - - sudo service mongod restart - - npm install --progress=false - - npm install mocha-junit-reporter --progress=false - -test: - pre: - - mongo --version - - mongo --eval 'db.hostInfo()' - override: - - npm run test -- --reporter mocha-junit-reporter: - environment: - MOCHA_FILE: $CIRCLE_TEST_REPORTS/junit/test-results.xml \ No newline at end of file diff --git a/dist/.gitignore b/dist/.gitignore deleted file mode 100644 index acdb84d..0000000 --- a/dist/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -benchmarks -example -test -*.d.ts -*.map \ No newline at end of file diff --git a/dist/.npmignore b/dist/.npmignore deleted file mode 100644 index 82a5e6f..0000000 --- a/dist/.npmignore +++ /dev/null @@ -1,6 +0,0 @@ -benchmarks -example -lib/*.d.ts -lib/*/**.d.ts -browser.d.ts -test \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 050d14d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; -function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} -__export(require("./lib/Core")); -__export(require("./lib/Model")); -__export(require("./lib/Instance")); -__export(require("./lib/Decorators")); -__export(require("./lib/Transforms")); -__export(require("./lib/caches/MemoryCache")); -__export(require("./lib/caches/NoOpCache")); -__export(require("./lib/cacheControllers/IDDirector")); -__export(require("./lib/utils/ObjectID")); -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 6890c05..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;AAAA,iBAAc,YAAY,CAAC,EAAA;AAC3B,iBAAc,aAAa,CAAC,EAAA;AAC5B,iBAAc,gBAAgB,CAAC,EAAA;AAE/B,iBAAc,kBAAkB,CAAC,EAAA;AASjC,iBAAc,kBAAkB,CAAC,EAAA;AAEjC,iBAAc,0BAA0B,CAAC,EAAA;AACzC,iBAAc,wBAAwB,CAAC,EAAA;AAEvC,iBAAc,mCAAmC,CAAC,EAAA;AAElD,iBAAc,sBAAsB,CAAC,EAAA"} \ No newline at end of file diff --git a/dist/iridium.d.ts b/dist/iridium.d.ts deleted file mode 100644 index 1c0ce3e..0000000 --- a/dist/iridium.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -export * from "./lib/Core"; -export * from "./lib/Model"; -export * from "./lib/Instance"; -export * from "./lib/Decorators"; -export * from "./lib/Plugins"; -export * from "./lib/Schema"; -export * from "./lib/Cache"; -export * from "./lib/CacheDirector"; -export * from "./lib/ModelOptions"; -export * from "./lib/Configuration"; -export * from "./lib/Hooks"; -export * from "./lib/Transforms"; -export * from "./lib/caches/MemoryCache"; -export * from "./lib/caches/NoOpCache"; -export * from "./lib/cacheControllers/IDDirector"; -export * from "./lib/utils/ObjectID"; diff --git a/dist/iridium.js b/dist/iridium.js deleted file mode 100644 index eace17d..0000000 --- a/dist/iridium.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; -function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} -__export(require("./lib/Core")); -__export(require("./lib/Model")); -__export(require("./lib/Instance")); -__export(require("./lib/Decorators")); -__export(require("./lib/Transforms")); -__export(require("./lib/caches/MemoryCache")); -__export(require("./lib/caches/NoOpCache")); -__export(require("./lib/cacheControllers/IDDirector")); -__export(require("./lib/utils/ObjectID")); -//# sourceMappingURL=iridium.js.map \ No newline at end of file diff --git a/dist/iridium.js.map b/dist/iridium.js.map deleted file mode 100644 index 62af329..0000000 --- a/dist/iridium.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"iridium.js","sourceRoot":"","sources":["../iridium.ts"],"names":[],"mappings":";;;;AAAA,iBAAc,YAAY,CAAC,EAAA;AAC3B,iBAAc,aAAa,CAAC,EAAA;AAC5B,iBAAc,gBAAgB,CAAC,EAAA;AAE/B,iBAAc,kBAAkB,CAAC,EAAA;AASjC,iBAAc,kBAAkB,CAAC,EAAA;AAEjC,iBAAc,0BAA0B,CAAC,EAAA;AACzC,iBAAc,wBAAwB,CAAC,EAAA;AAEvC,iBAAc,mCAAmC,CAAC,EAAA;AAElD,iBAAc,sBAAsB,CAAC,EAAA"} \ No newline at end of file diff --git a/dist/lib/Aggregate.js b/dist/lib/Aggregate.js deleted file mode 100644 index fb36ff5..0000000 --- a/dist/lib/Aggregate.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=Aggregate.js.map \ No newline at end of file diff --git a/dist/lib/Aggregate.js.map b/dist/lib/Aggregate.js.map deleted file mode 100644 index e8ab70c..0000000 --- a/dist/lib/Aggregate.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Aggregate.js","sourceRoot":"","sources":["../../lib/Aggregate.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/BSON.js b/dist/lib/BSON.js deleted file mode 100644 index 888ea9b..0000000 --- a/dist/lib/BSON.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; -var mongodb_1 = require("mongodb"); -exports.ObjectID = mongodb_1.ObjectID; -exports.Binary = mongodb_1.Binary; -//# sourceMappingURL=BSON.js.map \ No newline at end of file diff --git a/dist/lib/BSON.js.map b/dist/lib/BSON.js.map deleted file mode 100644 index 0a05db8..0000000 --- a/dist/lib/BSON.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"BSON.js","sourceRoot":"","sources":["../../lib/BSON.ts"],"names":[],"mappings":";AAAA,wBAAiC,SAAS,CAAC;AAAlC,sCAAQ;AAAE,kCAAwB"} \ No newline at end of file diff --git a/dist/lib/Cache.js b/dist/lib/Cache.js deleted file mode 100644 index e36eaeb..0000000 --- a/dist/lib/Cache.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=Cache.js.map \ No newline at end of file diff --git a/dist/lib/Cache.js.map b/dist/lib/Cache.js.map deleted file mode 100644 index a7f5bfe..0000000 --- a/dist/lib/Cache.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../lib/Cache.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/CacheDirector.js b/dist/lib/CacheDirector.js deleted file mode 100644 index 37a2cf2..0000000 --- a/dist/lib/CacheDirector.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=CacheDirector.js.map \ No newline at end of file diff --git a/dist/lib/CacheDirector.js.map b/dist/lib/CacheDirector.js.map deleted file mode 100644 index 449cadb..0000000 --- a/dist/lib/CacheDirector.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"CacheDirector.js","sourceRoot":"","sources":["../../lib/CacheDirector.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/Configuration.js b/dist/lib/Configuration.js deleted file mode 100644 index e382fd7..0000000 --- a/dist/lib/Configuration.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=Configuration.js.map \ No newline at end of file diff --git a/dist/lib/Configuration.js.map b/dist/lib/Configuration.js.map deleted file mode 100644 index 0865480..0000000 --- a/dist/lib/Configuration.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../lib/Configuration.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/Core.js b/dist/lib/Core.js deleted file mode 100644 index b20811c..0000000 --- a/dist/lib/Core.js +++ /dev/null @@ -1,188 +0,0 @@ -"use strict"; -const Bluebird = require("bluebird"); -const MongoDB = require("mongodb"); -const _ = require("lodash"); -const Express_1 = require("./middleware/Express"); -const NoOpCache_1 = require("./caches/NoOpCache"); -/** - * The Iridium Core, responsible for managing the connection to the database as well - * as any plugins you are making use of. - * - * Generally you will subclass this to provide your own custom core with the models you - * make use of within your application. - */ -class Core { - constructor(uri, config) { - this.mongoConnectAsyc = Bluebird.promisify(MongoDB.MongoClient.connect); - this._plugins = []; - this._cache = new NoOpCache_1.NoOpCache(); - let args = Array.prototype.slice.call(arguments, 0); - uri = config = null; - for (let i = 0; i < args.length; i++) { - if (typeof args[i] == "string") - uri = args[i]; - else if (typeof args[i] == "object") - config = args[i]; - } - if (!uri && !config) - throw new Error("Expected either a URI or config object to be supplied when initializing Iridium"); - this._url = uri; - this._config = config; - } - /** - * Gets the plugins registered with this Iridium Core - * @returns {[Iridium.Plugin]} - */ - get plugins() { - return this._plugins; - } - /** - * Gets the configuration specified in the construction of this - * Iridium Core. - * @returns {Iridium.Configuration} - */ - get settings() { - return this._config; - } - /** - * Gets the currently active database connection for this Iridium - * Core. - * @returns {MongoDB.Db} - */ - get connection() { - return this._connection; - } - /** - * Gets the URL used to connect to MongoDB - * @returns {String} - */ - get url() { - if (this._url) - return this._url; - let url = "mongodb://"; - if (this._config.username) { - url += this._config.username; - if (this._config.password) - url += ":" + this._config.password; - url += "@"; - } - let hosts = []; - if (this._config.host) { - if (this._config.port) - hosts.push(this._config.host + ":" + this._config.port); - else - hosts.push(this._config.host); - } - if (this._config.hosts) { - _.each(this._config.hosts, (host) => { - if (host.port) - hosts.push(host.address + ":" + host.port); - else if (this._config.port) - hosts.push(host.address + ":" + this._config.port); - else - hosts.push(host.address); - }); - } - if (hosts.length) - url += _.uniq(hosts).join(","); - else - url += "localhost"; - url += "/" + this._config.database; - return url; - } - /** - * Gets the cache used to store objects retrieved from the database for performance reasons - * @returns {cache} - */ - get cache() { - return this._cache; - } - set cache(value) { - this._cache = value; - } - /** - * Registers a new plugin with this Iridium Core - * @param {Iridium.Plugin} plugin The plugin to register with this Iridium Core - * @returns {Iridium.Core} - */ - register(plugin) { - this.plugins.push(plugin); - return this; - } - /** - * Connects to the database server specified in the provided configuration - * @param {function(Error, Iridium.Core)} [callback] A callback to be triggered once the connection is established. - * @returns {Promise} - */ - connect(callback) { - return Bluebird.resolve().then(() => { - if (this._connection) - return this._connection; - if (this._connectPromise) - return this._connectPromise; - return this._connectPromise = this.mongoConnectAsyc(this.url, this._config && this._config.options); - }).then((db) => { - return this.onConnecting(db); - }).then(db => { - this._connection = db; - this._connectPromise = null; - return this.onConnected(); - }).then(() => { - return this; - }, (err) => { - if (this._connection) - this._connection.close(); - this._connection = null; - this._connectPromise = null; - return Bluebird.reject(err); - }).nodeify(callback); - } - /** - * Closes the active database connection - * @type {Promise} - */ - close() { - return Bluebird.resolve().then(() => { - if (!this._connection) - return this; - let conn = this._connection; - this._connection = null; - conn.close(); - return this; - }); - } - /** - * Provides an express middleware which can be used to set the req.db property - * to the current Iridium instance. - * @returns {Iridium.ExpressMiddleware} - */ - express() { - return Express_1.ExpressMiddlewareFactory(this); - } - /** - * A method which is called whenever a new connection is made to the database. - * - * @param connection The underlying MongoDB connection which was created, you can modify or replace this if you wish. - * @returns A promise for the connection, allowing you to perform any asynchronous initialization required by your application. - * - * In subclassed Iridium Cores this method can be overridden to manipulate the properties - * of the underlying MongoDB connection object, such as authenticating. Until this method - * resolves a connection object, Iridium will be unable to execute any queries. If you wish - * to run Iridium queries then look at the onConnected method. - */ - onConnecting(connection) { - return Bluebird.resolve(connection); - } - /** - * A method which is called once a database connection has been established and accepted by Iridium - * - * In subclassed Iridium cores this method can be overridden to perform tasks whenever a - * connection to the database has been established - such as setting up indexes for your - * collections or seeding the database. - */ - onConnected() { - return Bluebird.resolve(); - } -} -exports.Core = Core; -//# sourceMappingURL=Core.js.map \ No newline at end of file diff --git a/dist/lib/Core.js.map b/dist/lib/Core.js.map deleted file mode 100644 index c312a44..0000000 --- a/dist/lib/Core.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Core.js","sourceRoot":"","sources":["../../lib/Core.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/dist/lib/Cursor.js b/dist/lib/Cursor.js deleted file mode 100644 index 06e84c6..0000000 --- a/dist/lib/Cursor.js +++ /dev/null @@ -1,179 +0,0 @@ -"use strict"; -const Bluebird = require("bluebird"); -/** - * An Iridium collection cursor which allows the itteration through documents - * in the collection, automatically wrapping them in the correct instance type. - * - * @param TDocument The interface representing the collection's documents - * @param TInstance The interface or class used to represent the wrapped documents. - */ -class Cursor { - /** - * Creates a new Iridium cursor which wraps a MongoDB cursor object - * @param {Model} model The Iridium model that this cursor belongs to - * @param {Object} conditions The conditions that resulte in this cursor being created - * @param {MongoDB.Cursor} cursor The MongoDB native cursor object to be wrapped - * @constructor - */ - constructor(model, conditions, cursor) { - this.model = model; - this.conditions = conditions; - this.cursor = cursor; - } - /** - * Counts the number of documents which are matched by this cursor - * @param {function(Error, Number)} callback A callback which is triggered when the result is available - * @return {Promise} A promise which will resolve with the number of documents matched by this cursor - */ - count(callback) { - return new Bluebird((resolve, reject) => { - this.cursor.count(true, (err, count) => { - if (err) - return reject(err); - return resolve(count); - }); - }).nodeify(callback); - } - /** - * Runs the specified handler over each instance in the query results - * @param {function(Instance)} handler The handler which is triggered for each element in the query - * @param {function(Error)} callback A callback which is triggered when all operations have been dispatched - * @return {Promise} A promise which is resolved when all operations have been dispatched - */ - forEach(handler, callback) { - let helpers = this.model.helpers; - return new Bluebird((resolve, reject) => { - this.cursor.forEach((item) => { - this.model.handlers.documentReceived(this.conditions, item, function () { return helpers.wrapDocument.apply(helpers, arguments); }).then(handler); - }, (err) => { - if (err) - return reject(err); - return resolve(null); - }); - }).nodeify(callback); - } - /** - * Runs the specified transform over each instance in the query results and returns the resulting transformed objects - * @param {function(Instance): TResult} transform A handler which is used to transform the result objects - * @param {function(Error, TResult[])} callback A callback which is triggered when the transformations are completed - * @return {Promise} A promise which is fulfilled with the results of the transformations - */ - map(transform, callback) { - let helpers = this.model.helpers; - return new Bluebird((resolve, reject) => { - let promises = []; - this.cursor.forEach((item) => { - promises.push(this.model.handlers.documentReceived(this.conditions, item, function () { return helpers.wrapDocument.apply(helpers, arguments); }) - .then(transform)); - }, (err) => { - if (err) - return reject(err); - return resolve(Bluebird.all(promises)); - }); - }).nodeify(callback); - } - /** - * Retrieves all matching instances and returns them in an array - * @param {function(Error, TInstance[])} callback A callback which is triggered with the resulting instances - * @return {Promise} A promise which resolves with the instances returned by the query - */ - toArray(callback) { - let helpers = this.model.helpers; - return new Bluebird((resolve, reject) => { - this.cursor.toArray((err, results) => { - if (err) - return reject(err); - return resolve(results); - }); - }).map((document) => { - return this.model.handlers.documentReceived(this.conditions, document, function () { return helpers.wrapDocument.apply(helpers, arguments); }); - }).nodeify(callback); - } - /** - * Retrieves the next item in the results list - * @param {function(Error, TInstance)} callback A callback which is triggered when the next item becomes available - * @return {Promise} A promise which is resolved with the next item - */ - next(callback) { - return new Bluebird((resolve, reject) => { - this.cursor.next((err, result) => { - if (err) - return reject(err); - return resolve(result); - }); - }).then((document) => { - if (!document) - return Bluebird.resolve(null); - return this.model.handlers.documentReceived(this.conditions, document, (document, isNew, isPartial) => this.model.helpers.wrapDocument(document, isNew, isPartial)); - }).nodeify(callback); - } - /** - * Retrieves the next item in the result list and then closes the cursor - * @param {function(Error, TInstance)} callback A callback which is triggered when the next item becomes available - * @return {Promise} A promise which is resolved once the item becomes available and the cursor has been closed. - */ - one(callback) { - return new Bluebird((resolve, reject) => { - this.cursor.next((err, result) => { - if (err) - return reject(err); - return resolve(result); - }); - }).then((document) => { - return new Bluebird((resolve, reject) => { - this.cursor.close((err) => { - if (err) - return reject(err); - return resolve(document); - }); - }); - }).then((document) => { - if (!document) - return Bluebird.resolve(null); - return this.model.handlers.documentReceived(this.conditions, document, (document, isNew, isPartial) => this.model.helpers.wrapDocument(document, isNew, isPartial)); - }).nodeify(callback); - } - /** - * Returns a new cursor which behaves the same as this one did before any results were retrieved - * @return {Cursor} The new cursor which starts at the beginning of the results - */ - rewind() { - this.cursor.rewind(); - return this; - } - /** - * Returns a new cursor which sorts its results by the given index expression - * @param {model.IndexSpecification} sortExpression The index expression dictating the sort order and direction to use - * @return {Cursor} The new cursor which sorts its results by the sortExpression - */ - sort(sortExpression) { - return new Cursor(this.model, this.conditions, this.cursor.sort(sortExpression)); - } - /** - * Returns a new cursor which limits the number of returned results - * @param {Number} limit The maximum number of results to return - * @return {Cursor} The new cursor which will return a maximum number of results - */ - limit(limit) { - return new Cursor(this.model, this.conditions, this.cursor.limit(limit)); - } - /** - * Returns a new cursor which skips a number of results before it begins - * returning any. - * @param {Number} skip The number of results to skip before the cursor beings returning - * @return {Cursor} The new cursor which skips a number of results - */ - skip(skip) { - return new Cursor(this.model, this.conditions, this.cursor.skip(skip)); - } - /** - * Returns a new cursor which will read from the specified node type. - * @param {String} type The type of node to read from - see https://docs.mongodb.org/manual/core/read-preference/ - * @return {Cursor} The new cursor which reads from the specified node type - */ - readFrom(type) { - return new Cursor(this.model, this.conditions, this.cursor.setReadPreference(type)); - } -} -exports.Cursor = Cursor; -//# sourceMappingURL=Cursor.js.map \ No newline at end of file diff --git a/dist/lib/Cursor.js.map b/dist/lib/Cursor.js.map deleted file mode 100644 index f85f39e..0000000 --- a/dist/lib/Cursor.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Cursor.js","sourceRoot":"","sources":["../../lib/Cursor.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/dist/lib/Decorators.js b/dist/lib/Decorators.js deleted file mode 100644 index a0e39c3..0000000 --- a/dist/lib/Decorators.js +++ /dev/null @@ -1,125 +0,0 @@ -"use strict"; -const MongoDB = require("mongodb"); -const _ = require("lodash"); -const Skmatc = require("skmatc"); -const Transforms_1 = require("./Transforms"); -/** - * Specifies the name of the collection to which this instance's documents should be sent. - * @param name The name of the MongoDB collection to store the documents in. - * - * This decorator replaces the use of the static collection property on instance implementation - * classes. If your transpiler does not support decorators then you are free to make use of the - * property instead. - */ -function Collection(name) { - return function (target) { - target.collection = name; - }; -} -exports.Collection = Collection; -/** - * Specifies a MongoDB collection level index to be managed by Iridium for this instance type. - * More than one instance of this decorator may be used if you wish to specify multiple indexes. - * @param spec The formal index specification which defines the properties and ordering used in the index. - * @param options The options dictating the way in which the index behaves. - * - * This decorator replaces the use of the static indexes property on instance implementation - * classes. If your transpiler does not support decorators then you are free to make use of the - * property instead. - */ -function Index(spec, options) { - return function (target) { - target.indexes = (target.indexes || []).concat({ spec: spec, options: options || {} }); - }; -} -exports.Index = Index; -/** - * Specifies a custom validator to be made available for this collection's schema. - * More than one instance of this decorator may be used if you wish to specify multiple validators. - * @param forType The value in the schema which will be delegated to this function for validation. - * @param validate A function which calls this.assert(condition) to determine whether a schema node is valid or not. - * - * This decorator replaces the use of the static validators property on instance implementation - * classes. If your transpiler does not support decorators then you are free to make use of the - * property instead. - */ -function Validate(forType, validate) { - return function (target) { - target.validators = (target.validators || []).concat(Skmatc.create(schema => schema === forType, validate)); - }; -} -exports.Validate = Validate; -function Property(...args) { - let name = null, asType = false, required = true; - if (args.length > 1 && typeof args[args.length - 1] === "boolean") - required = args.pop(); - return function (target, property) { - let staticTarget = target; - if (!property) - name = args.shift(); - else { - name = property; - staticTarget = target.constructor; - } - asType = args.pop() || false; - staticTarget.schema = _.clone(staticTarget.schema || { _id: false }); - if (!required && typeof asType !== "boolean") - staticTarget.schema[name] = { $required: required, $type: asType }; - else - staticTarget.schema[name] = asType; - }; -} -exports.Property = Property; -/** - * Specifies a custom transform to be applied to the property this decorator is applied to. - * - * @param fromDB The function used to convert values from the database for the application. - * @param toDB The function used to convert values from the application to the form used in the database. - * - * This decorator can either compliment or replace the static transforms property on your instance - * class, however only one transform can be applied to any property at a time. - * If your transpiler does not support decorators then you are free to make use of the - * property instead. - * - * If this decorator is applied to the instance class itself, as opposed to a property, then - * it will be treated as a $document transformer - and will receive the full document as opposed - * to individual property values. Similarly, it is expected to return a full document when either - * fromDB or toDB is called. - */ -function Transform(fromDB, toDB) { - return function (target, property = "$document") { - let staticTarget = (target.constructor || target); - staticTarget.transforms = _.clone(staticTarget.transforms || {}); - staticTarget.transforms[property] = { - fromDB: fromDB, - toDB: toDB - }; - }; -} -exports.Transform = Transform; -/** - * Specifies that this property should be treated as an ObjectID, with the requisite validator and transforms. - * - * This decorator applies an ObjectID validator to the property, which ensures that values sent to the database - * are instances of the MongoDB ObjectID type, as well as applying a transform operation which converts ObjectIDs - * to strings for your application, and then converts strings back to ObjectIDs for the database. - */ -function ObjectID(target, name) { - Property(MongoDB.ObjectID)(target, name); - Transform(Transforms_1.DefaultTransforms.ObjectID.fromDB, Transforms_1.DefaultTransforms.ObjectID.toDB)(target, name); -} -exports.ObjectID = ObjectID; -/** - * Specifies that this property should be stored using the MongoDB binary type and represented as a Buffer. - * - * This decorator applies a Buffer validator to the property, which ensures that values you send to the database - * are well formatted Buffer objects represented using the BSON Binary datatype. In addition to this, it will - * apply a transform which ensures you only work with Buffer objects and that data is always stored in Binary - * format. - */ -function Binary(target, name) { - Property(Buffer)(target, name); - Transform(Transforms_1.DefaultTransforms.Binary.fromDB, Transforms_1.DefaultTransforms.Binary.toDB)(target, name); -} -exports.Binary = Binary; -//# sourceMappingURL=Decorators.js.map \ No newline at end of file diff --git a/dist/lib/Decorators.js.map b/dist/lib/Decorators.js.map deleted file mode 100644 index e6dc2cc..0000000 --- a/dist/lib/Decorators.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Decorators.js","sourceRoot":"","sources":["../../lib/Decorators.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/dist/lib/General.js b/dist/lib/General.js deleted file mode 100644 index 0b2164e..0000000 --- a/dist/lib/General.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=General.js.map \ No newline at end of file diff --git a/dist/lib/General.js.map b/dist/lib/General.js.map deleted file mode 100644 index 5b3f975..0000000 --- a/dist/lib/General.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"General.js","sourceRoot":"","sources":["../../lib/General.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/Hooks.js b/dist/lib/Hooks.js deleted file mode 100644 index 42f41b7..0000000 --- a/dist/lib/Hooks.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=Hooks.js.map \ No newline at end of file diff --git a/dist/lib/Hooks.js.map b/dist/lib/Hooks.js.map deleted file mode 100644 index 5b77db3..0000000 --- a/dist/lib/Hooks.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Hooks.js","sourceRoot":"","sources":["../../lib/Hooks.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/Index.js b/dist/lib/Index.js deleted file mode 100644 index 3a3a9b2..0000000 --- a/dist/lib/Index.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=Index.js.map \ No newline at end of file diff --git a/dist/lib/Index.js.map b/dist/lib/Index.js.map deleted file mode 100644 index 5c062a6..0000000 --- a/dist/lib/Index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Index.js","sourceRoot":"","sources":["../../lib/Index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/Instance.js b/dist/lib/Instance.js deleted file mode 100644 index 75cbf57..0000000 --- a/dist/lib/Instance.js +++ /dev/null @@ -1,262 +0,0 @@ -"use strict"; -const Validators_1 = require("./Validators"); -const _ = require("lodash"); -const Bluebird = require("bluebird"); -/** - * The default Iridium Instance implementation which provides methods for saving, refreshing and - * removing the wrapped document from the collection, as well as integrating with Omnom, our - * built in document diff processor which allows clean, atomic, document updates to be performed - * without needing to write the update queries yourself. - * - * @param TDocument The interface representing the structure of the documents in the collection. - * @param TInstance The type of instance which wraps the documents, generally the subclass of this class. - * - * This class will be subclassed automatically by Iridium to create a model specific instance - * which takes advantage of some of v8's optimizations to boost performance significantly. - * The instance returned by the model, and all of this instance's methods, will be of type - * TInstance - which should represent the merger of TSchema and IInstance for best results. - */ -class Instance { - /** - * Creates a new instance which represents the given document as a type of model - * @param model The model that dictates the collection the document originated from as well as how validations are performed. - * @param document The document which should be wrapped by this instance - * @param isNew Whether the document is new (doesn't exist in the database) or not - * @param isPartial Whether the document has only a subset of its fields populated - * - */ - constructor(model, document, isNew = true, isPartial = false) { - this._model = model; - this._isNew = !!isNew; - this._isPartial = isPartial; - this._original = document; - this._modified = model.helpers.cloneDocument(document); - _.each(model.core.plugins, (plugin) => { - if (plugin.newInstance) - plugin.newInstance(this, model); - }); - } - /** - * Gets the underlying document representation of this instance - */ - get document() { - return this._modified; - } - save(...args) { - let callback = null; - let changes = null; - let conditions = {}; - Array.prototype.slice.call(args, 0).reverse().forEach((arg) => { - if (typeof arg == "function") - callback = arg; - else if (typeof arg == "object") { - if (!changes) - changes = arg; - else - conditions = arg; - } - }); - return Bluebird.resolve().then(() => { - conditions = this._model.helpers.cloneConditions(conditions); - _.merge(conditions, { _id: this._modified._id }); - if (!changes) { - let validation = this._model.helpers.validate(this._modified); - if (validation.failed) - return Bluebird.reject(validation.error).bind(this).nodeify(callback); - let original = this._model.helpers.cloneDocument(this._original); - let modified = this._model.helpers.cloneDocument(this._modified); - modified = this._model.helpers.transformToDB(modified, { document: true }); - changes = this._model.helpers.diff(original, modified); - } - if (!_.keys(changes).length) - return null; - return changes; - }).then((changes) => { - if (!changes && !this._isNew) - return changes; - return this._model.handlers.savingDocument(this, changes).then(() => changes); - }).then((changes) => { - if (!changes && !this._isNew) - return false; - if (this._isNew) { - return new Bluebird((resolve, reject) => { - this._model.collection.insertOne(this._modified, { w: "majority" }, (err, doc) => { - if (err) - return reject(err); - return resolve(!!doc); - }); - }); - } - else { - return new Bluebird((resolve, reject) => { - this._model.collection.updateOne(conditions, changes, { w: "majority" }, (err, changed) => { - if (err) { - err["conditions"] = conditions; - err["changes"] = changes; - return reject(err); - } - return resolve(!!changed.modifiedCount); - }); - }); - } - }).catch(err => { - err["original"] = this._original; - err["modified"] = this._modified; - return Bluebird.reject(err); - }).then((changed) => { - conditions = { _id: this._modified._id }; - if (!changed) - return this._modified; - return new Bluebird((resolve, reject) => { - this._model.collection.find(conditions).limit(1).next((err, latest) => { - if (err) - return reject(err); - return resolve(latest); - }); - }); - }).then((latest) => { - if (!latest) { - this._isNew = true; - this._original = this._model.helpers.cloneDocument(this._modified); - return Bluebird.resolve(this); - } - return this._model.handlers.documentReceived(conditions, latest, (value) => { - this._isPartial = false; - this._isNew = false; - this._modified = value; - this._original = this._model.helpers.cloneDocument(value); - return this; - }); - }).nodeify(callback); - } - /** - * Updates this instance to match the latest document available in the backing collection - * @param {function(Error, IInstance)} callback A callback which is triggered when the update completes - * @returns {Promise} - */ - update(callback) { - return this.refresh(callback); - } - /** - * Updates this instance to match the latest document available in the backing collection - * @param {function(Error, IInstance)} callback A callback which is triggered when the update completes - * @returns {Promise} - */ - refresh(callback) { - let conditions = { _id: this._original._id }; - return Bluebird.resolve().then(() => { - return new Bluebird((resolve, reject) => { - this._model.collection.find(conditions).limit(1).next((err, doc) => { - if (err) - return reject(err); - return resolve(doc); - }); - }); - }).then((newDocument) => { - if (!newDocument) { - this._isPartial = true; - this._isNew = true; - this._original = this._model.helpers.cloneDocument(this._modified); - return this; - } - return this._model.handlers.documentReceived(conditions, newDocument, (doc) => { - this._isNew = false; - this._isPartial = false; - this._original = doc; - this._modified = this._model.helpers.cloneDocument(doc); - return this; - }); - }).nodeify(callback); - } - /** - * Removes this instance's document from the backing collection - * @param {function(Error, IInstance)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - delete(callback) { - return this.remove(callback); - } - /** - * Removes this instance's document from the backing collection - * @param {function(Error, IInstance)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - remove(callback) { - let conditions = { _id: this._original._id }; - return Bluebird.resolve().then(() => { - if (this._isNew) - return 0; - return new Bluebird((resolve, reject) => { - this._model.collection.deleteOne(conditions, { w: "majority" }, (err, removed) => { - if (err) - return reject(err); - return resolve(removed); - }); - }); - }).then((removed) => { - if (removed) - return this._model.cache.clear(conditions); - return false; - }).then(() => { - this._isNew = true; - return this; - }).nodeify(callback); - } - first(collection, predicate) { - let result = null; - _.each(collection, (value, key) => { - if (predicate.call(this, value, key)) { - result = value; - return false; - } - }); - return result; - } - select(collection, predicate) { - let isArray = Array.isArray(collection); - let results = isArray ? [] : {}; - _.each(collection, (value, key) => { - if (predicate.call(this, value, key)) { - if (isArray) - results.push(value); - else - results[key] = value; - } - }); - return results; - } - /** - * Gets the JSON representation of this instance - * @returns {TDocument} - */ - toJSON() { - return this.document; - } - /** - * Gets a string representation of this instance - * @returns {String} - */ - toString() { - return JSON.stringify(this.document, null, 2); - } -} -/** - * The schema used to validate documents of this type before being stored in the database. - */ -Instance.schema = { - _id: false -}; -/** - * Additional which should be made available for use in the schema definition for this instance. - */ -Instance.validators = Validators_1.DefaultValidators(); -/** - * The transformations which should be applied to properties of documents of this type. - */ -Instance.transforms = {}; -/** - * The indexes which should be managed by Iridium for the collection used by this type. - */ -Instance.indexes = []; -exports.Instance = Instance; -//# sourceMappingURL=Instance.js.map \ No newline at end of file diff --git a/dist/lib/Instance.js.map b/dist/lib/Instance.js.map deleted file mode 100644 index c953f16..0000000 --- a/dist/lib/Instance.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Instance.js","sourceRoot":"","sources":["../../lib/Instance.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/dist/lib/InstanceInterface.js b/dist/lib/InstanceInterface.js deleted file mode 100644 index 4b6c0d7..0000000 --- a/dist/lib/InstanceInterface.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=InstanceInterface.js.map \ No newline at end of file diff --git a/dist/lib/InstanceInterface.js.map b/dist/lib/InstanceInterface.js.map deleted file mode 100644 index eb36d1f..0000000 --- a/dist/lib/InstanceInterface.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"InstanceInterface.js","sourceRoot":"","sources":["../../lib/InstanceInterface.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/Middleware.js b/dist/lib/Middleware.js deleted file mode 100644 index b652e4e..0000000 --- a/dist/lib/Middleware.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=Middleware.js.map \ No newline at end of file diff --git a/dist/lib/Middleware.js.map b/dist/lib/Middleware.js.map deleted file mode 100644 index 9030c34..0000000 --- a/dist/lib/Middleware.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Middleware.js","sourceRoot":"","sources":["../../lib/Middleware.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/Model.js b/dist/lib/Model.js deleted file mode 100644 index 6136dbe..0000000 --- a/dist/lib/Model.js +++ /dev/null @@ -1,469 +0,0 @@ -"use strict"; -const MongoDB = require("mongodb"); -const Bluebird = require("bluebird"); -const _ = require("lodash"); -const Core_1 = require("./Core"); -const Instance_1 = require("./Instance"); -const Cursor_1 = require("./Cursor"); -const ModelCache_1 = require("./ModelCache"); -const ModelHelpers_1 = require("./ModelHelpers"); -const ModelHandlers_1 = require("./ModelHandlers"); -const ModelSpecificInstance_1 = require("./ModelSpecificInstance"); -const Transforms_1 = require("./Transforms"); -/** - * An Iridium Model which represents a structured MongoDB collection. - * Models expose the methods you will generally use to query those collections, and ensure that - * the results of those queries are returned as {TInstance} instances. - * - * @param TDocument The interface used to determine the schema of documents in the collection. - * @param TInstance The interface or class used to represent collection documents in the JS world. - * - * @class - */ -class Model { - /** - * Creates a new Iridium model representing a given ISchema and backed by a collection whose name is specified - * @param core The Iridium core that this model should use for database access - * @param instanceType The class which will be instantiated for each document retrieved from the database - * @constructor - */ - constructor(core, instanceType) { - this._hooks = {}; - if (!(core instanceof Core_1.Core)) - throw new Error("You failed to provide a valid Iridium core for this model"); - if (typeof instanceType !== "function") - throw new Error("You failed to provide a valid instance constructor for this model"); - if (typeof instanceType.collection !== "string" || !instanceType.collection) - throw new Error("You failed to provide a valid collection name for this model"); - if (!_.isPlainObject(instanceType.schema) || instanceType.schema._id === undefined) - throw new Error("You failed to provide a valid schema for this model"); - this._core = core; - this.loadExternal(instanceType); - this.onNewModel(); - this.loadInternal(); - } - /** - * Loads any externally available properties (generally accessed using public getters/setters). - */ - loadExternal(instanceType) { - this._collection = instanceType.collection; - this._schema = instanceType.schema; - this._hooks = instanceType; - this._cacheDirector = instanceType.cache; - this._transforms = instanceType.transforms || {}; - this._validators = instanceType.validators || []; - this._indexes = instanceType.indexes || []; - if (!this._schema._id) - this._schema._id = MongoDB.ObjectID; - if (this._schema._id === MongoDB.ObjectID && !this._transforms._id) - this._transforms._id = Transforms_1.DefaultTransforms.ObjectID; - if (instanceType.prototype instanceof Instance_1.Instance) - this._Instance = ModelSpecificInstance_1.ModelSpecificInstance(this, instanceType); - else - this._Instance = instanceType.bind(undefined, this); - } - /** - * Loads any internally (protected/private) properties and helpers only used within Iridium itself. - */ - loadInternal() { - this._cache = new ModelCache_1.ModelCache(this); - this._helpers = new ModelHelpers_1.ModelHelpers(this); - this._handlers = new ModelHandlers_1.ModelHandlers(this); - } - /** - * Process any callbacks and plugin delegation for the creation of this model. - * It will generally be called whenever a new Iridium Core is created, however is - * more specifically tied to the lifespan of the models themselves. - */ - onNewModel() { - this._core.plugins.forEach(plugin => plugin.newModel && plugin.newModel(this)); - } - /** - * Provides helper methods used by Iridium for common tasks - * @returns A set of helper methods which are used within Iridium for common tasks - */ - get helpers() { - return this._helpers; - } - /** - * Provides helper methods used by Iridium for hook delegation and common processes - * @returns A set of helper methods which perform common event and response handling tasks within Iridium. - */ - get handlers() { - return this._handlers; - } - /** - * Gets the even hooks subscribed on this model for a number of different state changes. - * These hooks are primarily intended to allow lifecycle manipulation logic to be added - * in the user's model definition, allowing tasks such as the setting of default values - * or automatic client-side joins to take place. - */ - get hooks() { - return this._hooks; - } - /** - * Gets the schema dictating the data structure represented by this model. - * The schema is used by skmatc to validate documents before saving to the database, however - * until MongoDB 3.1 becomes widely available (with server side validation support) we are - * limited in our ability to validate certain types of updates. As such, these validations - * act more as a data-integrity check than anything else, unless you purely make use of Omnom - * updates within instances. - * @public - * @returns The defined validation schema for this model - */ - get schema() { - return this._schema; - } - /** - * Gets the Iridium core that this model is associated with. - * @public - * @returns The Iridium core that this model is bound to - */ - get core() { - return this._core; - } - /** - * Gets the underlying MongoDB collection from which this model's documents are retrieved. - * You can make use of this object if you require any low level access to the MongoDB collection, - * however we recommend you make use of the Iridium methods whereever possible, as we cannot - * guarantee the accuracy of the type definitions for the underlying MongoDB driver. - * @public - * @returns {Collection} - */ - get collection() { - if (!this.core.connection) - throw new Error("Iridium Core not connected to a database."); - return this.core.connection.collection(this._collection); - } - /** - * Gets the name of the underlying MongoDB collection from which this model's documents are retrieved - * @public - */ - get collectionName() { - return this._collection; - } - /** - * Sets the name of the underlying MongoDB collection from which this model's documents are retrieved - * @public - */ - set collectionName(value) { - this._collection = value; - } - /** - * Gets the cache controller which dictates which queries will be cached, and under which key - * @public - * @returns {CacheDirector} - */ - get cacheDirector() { - return this._cacheDirector; - } - /** - * Gets the cache responsible for storing objects for quick retrieval under certain conditions - * @public - * @returns {ModelCache} - */ - get cache() { - return this._cache; - } - /** - * Gets the constructor responsible for creating instances for this model - */ - get Instance() { - return this._Instance; - } - /** - * Gets the transforms which are applied whenever a document is received from the database, or - * prior to storing a document in the database. Tasks such as converting an ObjectID to a string - * and vice versa are all listed in this object. - */ - get transforms() { - return this._transforms; - } - /** - * Gets the custom validation types available for this model. These validators are added to the - * default skmatc validators, as well as those available through plugins, for use when checking - * your instances. - */ - get validators() { - return this._validators; - } - /** - * Gets the indexes which Iridium will manage on this model's database collection. - */ - get indexes() { - return this._indexes; - } - find(conditions, fields) { - conditions = conditions || {}; - if (!_.isPlainObject(conditions)) - conditions = { _id: conditions }; - conditions = this._helpers.convertToDB(conditions); - let cursor = this.collection.find(conditions); - if (fields) - cursor = cursor.project(fields); - return new Cursor_1.Cursor(this, conditions, cursor); - } - get(...args) { - return this.findOne.apply(this, args); - } - findOne(...args) { - let conditions = null; - let options = null; - let callback = null; - for (let argI = 0; argI < args.length; argI++) { - if (typeof args[argI] === "function") - callback = callback || args[argI]; - else if (_.isPlainObject(args[argI])) { - if (conditions) - options = args[argI]; - else - conditions = args[argI]; - } - else - conditions = { _id: args[argI] }; - } - conditions = conditions || {}; - options = options || {}; - _.defaults(options, { - cache: true - }); - return Bluebird.resolve().bind(this).then(() => { - conditions = this._helpers.convertToDB(conditions); - return this._cache.get(conditions); - }).then((cachedDocument) => { - if (cachedDocument) - return cachedDocument; - return new Bluebird((resolve, reject) => { - let cursor = this.collection.find(conditions); - if (options.sort) - cursor = cursor.sort(options.sort); - if (typeof options.skip === "number") - cursor = cursor.skip(options.skip); - cursor = cursor.limit(1); - if (options.fields) - cursor = cursor.project(options.fields); - return cursor.next((err, result) => { - if (err) - return reject(err); - return resolve(result); - }); - }); - }).then((document) => { - if (!document) - return null; - return this._handlers.documentReceived(conditions, document, (document, isNew, isPartial) => this._helpers.wrapDocument(document, isNew, isPartial), options); - }).nodeify(callback); - } - create(...args) { - return this.insert.apply(this, args); - } - insert(objs, ...args) { - let objects; - let options = {}; - let callback = null; - if (typeof args[0] === "function") - callback = args[0]; - else { - options = args[0]; - callback = args[1]; - } - if (Array.isArray(objs)) - objects = objs; - else - objects = [objs]; - options = options || {}; - _.defaults(options, { - w: "majority", - forceServerObjectId: true - }); - return Bluebird.resolve().then(() => { - let queryOptions = { w: options.w, upsert: options.upsert, new: true }; - if (options.upsert) { - let docs = this._handlers.creatingDocuments(objects); - return docs.map((object) => { - return new Bluebird((resolve, reject) => { - this.collection.findOneAndUpdate({ _id: object._id }, object, { - upsert: options.upsert, - returnOriginal: false - }, (err, result) => { - if (err) - return reject(err); - return resolve(result.value); - }); - }); - }); - } - else - return this._handlers.creatingDocuments(objects).then(objects => _.chunk(objects, 1000)).map((objects) => { - return new Bluebird((resolve, reject) => { - this.collection.insertMany(objects, queryOptions, (err, result) => { - if (err) - return reject(err); - return resolve(result.ops); - }); - }); - }).then(results => _.flatten(results)); - }).map((inserted) => { - return this._handlers.documentReceived(null, inserted, (document, isNew, isPartial) => this._helpers.wrapDocument(document, isNew, isPartial), { cache: options.cache }); - }).then((results) => { - if (Array.isArray(objs)) - return results; - return results[0]; - }).nodeify(callback); - } - update(conditions, changes, options, callback) { - if (typeof options === "function") { - callback = options; - options = {}; - } - options = options || {}; - if (!_.isPlainObject(conditions)) - conditions = { - _id: conditions - }; - _.defaults(options, { - w: "majority", - multi: true - }); - return Bluebird.resolve().then(() => { - conditions = this._helpers.convertToDB(conditions); - return new Bluebird((resolve, reject) => { - this.collection.updateMany(conditions, changes, options, (err, response) => { - if (err) - return reject(err); - // New MongoDB 2.6+ response type - if (response.result && response.result.nModified !== undefined) - return resolve(response.result.nModified); - // Legacy response type - return resolve(response.result.n); - }); - }); - }).nodeify(callback); - } - count(conds, callback) { - let conditions = conds; - if (typeof conds === "function") { - callback = conds; - conditions = {}; - } - conditions = conditions || {}; - if (!_.isPlainObject(conditions)) - conditions = { - _id: conditions - }; - return Bluebird.resolve().then(() => { - conditions = this._helpers.convertToDB(conditions); - return new Bluebird((resolve, reject) => { - this.collection.count(conditions, (err, results) => { - if (err) - return reject(err); - return resolve(results); - }); - }); - }).nodeify(callback); - } - remove(conds, options, callback) { - let conditions = conds; - if (typeof options === "function") { - callback = options; - options = {}; - } - if (typeof conds === "function") { - callback = conds; - options = {}; - conditions = {}; - } - conditions = conditions || {}; - options = options || {}; - _.defaults(options, { - w: "majority" - }); - if (!_.isPlainObject(conditions)) - conditions = { - _id: conditions - }; - return Bluebird.resolve().then(() => { - conditions = this._helpers.convertToDB(conditions); - return new Bluebird((resolve, reject) => { - if (options.single) - return this.collection.deleteOne(conditions, options, (err, response) => { - if (err) - return reject(err); - return resolve(response.result.n); - }); - this.collection.deleteMany(conditions, options, (err, response) => { - if (err) - return reject(err); - return resolve(response.result.n); - }); - }); - }).then((count) => { - if (count === 1) - this._cache.clear(conditions); - return Bluebird.resolve(count); - }).nodeify(callback); - } - aggregate(pipeline) { - return new Bluebird((resolve, reject) => { - this.collection.aggregate(pipeline, (err, results) => { - if (err) - return reject(err); - return resolve(results); - }); - }); - } - ensureIndex(specification, options, callback) { - if (typeof options === "function") { - callback = options; - options = {}; - } - return new Bluebird((resolve, reject) => { - this.collection.createIndex(specification, options, (err, name) => { - if (err) - return reject(err); - return resolve(name); - }); - }).nodeify(callback); - } - /** - * Ensures that all indexes defined in the model's options are created - * @param {function(Error, String[])} callback A callback which is triggered when the operation completes - * @returns {Promise} The names of the indexes - */ - ensureIndexes(callback) { - return Bluebird.resolve(this._indexes).map((index) => { - return this.ensureIndex(index.spec || index, index.options || {}); - }).nodeify(callback); - } - dropIndex(specification, callback) { - let index; - if (typeof (specification) === "string") - index = specification; - else { - index = _(specification).map((direction, key) => `${key}_${direction}`).reduce((x, y) => `${x}_${y}`); - } - return new Bluebird((resolve, reject) => { - this.collection.dropIndex(index, (err, result) => { - if (err) - return reject(err); - return resolve(!!result.ok); - }); - }).nodeify(callback); - } - /** - * Removes all indexes (except for _id) from the collection - * @param {function(Error, Boolean)} callback A callback which is triggered when the operation completes - * @returns {Promise} Whether the indexes were dropped - */ - dropIndexes(callback) { - return new Bluebird((resolve, reject) => { - this.collection.dropIndexes((err, count) => { - if (err) - return reject(err); - return resolve(count); - }); - }).nodeify(callback); - } -} -exports.Model = Model; -//# sourceMappingURL=Model.js.map \ No newline at end of file diff --git a/dist/lib/Model.js.map b/dist/lib/Model.js.map deleted file mode 100644 index d39bdcd..0000000 --- a/dist/lib/Model.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Model.js","sourceRoot":"","sources":["../../lib/Model.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/dist/lib/ModelCache.js b/dist/lib/ModelCache.js deleted file mode 100644 index d885208..0000000 --- a/dist/lib/ModelCache.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; -const Bluebird = require("bluebird"); -/** - * A centralized class which ties the cache and cache directors together in a cohesive way - * for use by Iridium. - * @internal - */ -class ModelCache { - constructor(model) { - this.model = model; - } - set(value) { - if (!this.model.cacheDirector || !this.model.cacheDirector.valid(value)) - return; - this.model.core.cache.set(this.model.cacheDirector.buildKey(value), value); - } - get(conditions) { - if (!this.model.cacheDirector || !this.model.cacheDirector.validQuery(conditions)) - return Bluebird.resolve(null); - return Bluebird.resolve(this.model.core.cache.get(this.model.cacheDirector.buildQueryKey(conditions))); - } - clear(conditions) { - if (!this.model.cacheDirector || !this.model.cacheDirector.validQuery(conditions)) - return; - this.model.core.cache.clear(this.model.cacheDirector.buildQueryKey(conditions)); - } -} -exports.ModelCache = ModelCache; -//# sourceMappingURL=ModelCache.js.map \ No newline at end of file diff --git a/dist/lib/ModelCache.js.map b/dist/lib/ModelCache.js.map deleted file mode 100644 index d35e475..0000000 --- a/dist/lib/ModelCache.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ModelCache.js","sourceRoot":"","sources":["../../lib/ModelCache.ts"],"names":[],"mappings":";AACA,MAAY,QAAQ,WAAM,UAAU,CAAC,CAAA;AAErC;;;;GAIG;AACH;IACI,YAAmB,KAAqB;QAArB,UAAK,GAAL,KAAK,CAAgB;IAExC,CAAC;IAED,GAAG,CAAI,KAAQ;QACX,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAAC,MAAM,CAAC;QAChF,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAC/E,CAAC;IAED,GAAG,CAAI,UAAe;QAClB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAI,IAAI,CAAC,CAAC;QACpH,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC9G,CAAC;IAED,KAAK,CAAC,UAAe;QACjB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAAC,MAAM,CAAC;QAC1F,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;IACpF,CAAC;AACL,CAAC;AAnBY,kBAAU,aAmBtB,CAAA"} \ No newline at end of file diff --git a/dist/lib/ModelHandlers.js b/dist/lib/ModelHandlers.js deleted file mode 100644 index f2691b3..0000000 --- a/dist/lib/ModelHandlers.js +++ /dev/null @@ -1,63 +0,0 @@ -"use strict"; -const _ = require("lodash"); -const Bluebird = require("bluebird"); -/** - * Provides a number of methods which are used to handle events that occur within - * the Iridium workflow - such as what happens when a document is received from - * the database, or how to handle the creation of new documents and saving of instances. - * - * Mostly this is for cache support, wrapping and hook triggering. - * @internal - */ -class ModelHandlers { - constructor(model) { - this.model = model; - } - documentReceived(conditions, result, wrapper, options = {}) { - _.defaults(options, { - cache: true, - partial: false - }); - let wrapped; - return Bluebird.resolve(this.model.helpers.transformFromDB(result, { document: true })).then((target) => { - return Bluebird - .resolve(this.model.hooks.onRetrieved && this.model.hooks.onRetrieved(target)) - .then(() => { - // Cache the document if caching is enabled - if (this.model.core.cache && options.cache && !options.fields) { - this.model.cache.set(target); // Does not block execution pipeline - fire and forget - } - // Wrap the document and trigger the ready hook - let wrapped = wrapper(target, false, !!options.fields); - // Only incur the additional promise's performance penalty if this hook is being used - if (this.model.hooks.onReady) - return Bluebird - .resolve(this.model.hooks.onReady(wrapped)) - .then(() => wrapped); - return wrapped; - }); - }); - } - creatingDocuments(documents) { - return Bluebird.all(documents.map((document) => { - return Bluebird - .resolve(this.model.hooks.onCreating && this.model.hooks.onCreating(document)) - .then(() => { - document = this.model.helpers.convertToDB(document, { document: true, properties: true }); - let validation = this.model.helpers.validate(document); - if (validation.failed) - return Bluebird.reject(validation.error); - return document; - }); - })); - } - savingDocument(instance, changes) { - return Bluebird - .resolve(this.model.hooks.onSaving && this.model.hooks.onSaving(instance, changes)) - .then(() => { - return instance; - }); - } -} -exports.ModelHandlers = ModelHandlers; -//# sourceMappingURL=ModelHandlers.js.map \ No newline at end of file diff --git a/dist/lib/ModelHandlers.js.map b/dist/lib/ModelHandlers.js.map deleted file mode 100644 index 14dbd8f..0000000 --- a/dist/lib/ModelHandlers.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ModelHandlers.js","sourceRoot":"","sources":["../../lib/ModelHandlers.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/dist/lib/ModelHelpers.js b/dist/lib/ModelHelpers.js deleted file mode 100644 index 1cd11d5..0000000 --- a/dist/lib/ModelHelpers.js +++ /dev/null @@ -1,131 +0,0 @@ -"use strict"; -const MongoDB = require("mongodb"); -const Skmatc = require("skmatc"); -const Omnom_1 = require("./utils/Omnom"); -const _ = require("lodash"); -/** - * A number of helper methods used commonly within Iridium, they provide a means to transform, - * validate, wrap and diff instances and documents. By keeping these methods in one place we - * help to improve testability and reduce code duplication (mouse abuse) throughout the codebase. - * @internal - */ -class ModelHelpers { - constructor(model) { - this.model = model; - this._validator = Skmatc.scope(model.schema); - model.validators.forEach(validator => this._validator.register(validator)); - } - /** - * Validates a document to ensure that it matches the model's ISchema requirements - * @param {any} document The document to validate against the ISchema - * @returns {SkmatcCore.IResult} The result of the validation - */ - validate(document) { - return this._validator.validate(document); - } - /** - * Wraps the given document in an instance wrapper for use throughout the application - * @param {any} document The document to be wrapped as an instance - * @param {Boolean} isNew Whether the instance originated from the database or was created by the application - * @param {Boolean} isPartial Whether the document supplied contains all information present in the database - * @returns {any} An instance which wraps this document - */ - wrapDocument(document, isNew, isPartial) { - return new this.model.Instance(document, isNew, isPartial); - } - /** - * Converts the given document to its database form into a form - * using the transforms defined on the model. - * @param {any} document The document to be converted - * @returns {any} The result of having transformed the document. - * @remarks This is only really called from insert/create - as - */ - transformToDB(document, options = { properties: true }) { - if (options.document && this.model.transforms.$document) - document = this.model.transforms.$document.toDB(document, "$document", this.model); - if (!options.properties) - return document; - for (let property in this.model.transforms) - if (property === "$document") - continue; - else if (document.hasOwnProperty(property)) { - document[property] = this.model.transforms[property].toDB(document[property], property, this.model); - } - return document; - } - /** - * Converts the given document from its database form using the - * transforms defined on the model. - * @param document The document to be converted. - * @returns The result of having transformed the document. - * @remarks Unlike the transformToDB function - this method only applies - * document level transforms, as property level transforms are applied in - * their relevant instance setters. - */ - transformFromDB(document, options = { properties: true }) { - if (options.document && this.model.transforms.$document) - document = this.model.transforms.$document.fromDB(document, "$document", this.model); - if (!options.properties) - return document; - for (let property in this.model.transforms) - if (property === "$document") - continue; - else if (document.hasOwnProperty(property)) { - document[property] = this.model.transforms[property].fromDB(document[property], property, this.model); - } - return document; - } - /** - * Converts the given document to its database form into a form - * using the transforms defined on the model. - * @param document The document to be converted - * @param processProperties Whether or not to process properties in addition - * document level transforms. - * @returns {any} A new document cloned from the original and transformed - */ - convertToDB(document, options = { properties: true }) { - let doc = this.cloneDocument(document); - return this.transformToDB(doc, options); - } - /** - * Performs a diff operation between two documents and creates a MongoDB changes object to represent the differences - * @param {any} original The original document prior to changes being made - * @param {any} modified The document after changes were made - */ - diff(original, modified) { - let omnom = new Omnom_1.Omnom(); - omnom.diff(original, modified); - return omnom.changes; - } - /** - * Clones the given document recursively, taking into account complex types like - * Buffers correctly. - * - * @param {any} The document you wish to clone deeply. - */ - cloneDocument(original) { - return _.cloneDeepWith(original, (value) => { - if (Buffer.isBuffer(value)) { - return value; - } - if (value instanceof MongoDB.Binary) { - return value; - } - if (value instanceof MongoDB.ObjectID) { - return value; - } - }); - } - /** - * Clones the given document recursively, taking into account complex types like - * Buffers correctly. Optimized for working with query documents instead of true - * documents. - * - * @param {any} The document you wish to clone deeply. - */ - cloneConditions(original) { - return this.cloneDocument(original); - } -} -exports.ModelHelpers = ModelHelpers; -//# sourceMappingURL=ModelHelpers.js.map \ No newline at end of file diff --git a/dist/lib/ModelHelpers.js.map b/dist/lib/ModelHelpers.js.map deleted file mode 100644 index d676232..0000000 --- a/dist/lib/ModelHelpers.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ModelHelpers.js","sourceRoot":"","sources":["../../lib/ModelHelpers.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/dist/lib/ModelInterfaces.js b/dist/lib/ModelInterfaces.js deleted file mode 100644 index acd3648..0000000 --- a/dist/lib/ModelInterfaces.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=ModelInterfaces.js.map \ No newline at end of file diff --git a/dist/lib/ModelInterfaces.js.map b/dist/lib/ModelInterfaces.js.map deleted file mode 100644 index a93281e..0000000 --- a/dist/lib/ModelInterfaces.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ModelInterfaces.js","sourceRoot":"","sources":["../../lib/ModelInterfaces.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/ModelOptions.js b/dist/lib/ModelOptions.js deleted file mode 100644 index 35117a5..0000000 --- a/dist/lib/ModelOptions.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=ModelOptions.js.map \ No newline at end of file diff --git a/dist/lib/ModelOptions.js.map b/dist/lib/ModelOptions.js.map deleted file mode 100644 index 09c7cce..0000000 --- a/dist/lib/ModelOptions.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ModelOptions.js","sourceRoot":"","sources":["../../lib/ModelOptions.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/ModelSpecificInstance.js b/dist/lib/ModelSpecificInstance.js deleted file mode 100644 index c462a86..0000000 --- a/dist/lib/ModelSpecificInstance.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; -const _ = require("lodash"); -/** - * Creates a new subclass of the given instanceType which correctly performs property transforms - * and associates the instance with the correct model when instantiated. - * - * @param TDocument The interface representing the structure of the documents found in the database. - * @param TInstance The interface or class representing the documents after they have been wrapped in an instance. - * - * @param model The model which instances should be associated with when the resulting constructor is used. - * @param instanceType The constructor used to create new instances of type TInstance. - * - * @internal - */ -function ModelSpecificInstance(model, instanceType) { - const instanceTypeConstructor = instanceType; - let virtualClass = class extends instanceTypeConstructor { - constructor(...args) { - super(model, ...args); - } - } - ; - _.each(Object.keys(model.schema), (property) => { - if (model.transforms.hasOwnProperty(property)) { - return Object.defineProperty(virtualClass.prototype, property, { - get: function () { - return model.transforms[property].fromDB(this._modified[property], property, model); - }, - set: function (value) { - this._modified[property] = model.transforms[property].toDB(value, property, model); - }, - enumerable: true, - configurable: true - }); - } - Object.defineProperty(virtualClass.prototype, property, { - get: function () { - return this._modified[property]; - }, - set: function (value) { - this._modified[property] = value; - }, - enumerable: true - }); - }); - return virtualClass; -} -exports.ModelSpecificInstance = ModelSpecificInstance; -//# sourceMappingURL=ModelSpecificInstance.js.map \ No newline at end of file diff --git a/dist/lib/ModelSpecificInstance.js.map b/dist/lib/ModelSpecificInstance.js.map deleted file mode 100644 index 689a40b..0000000 --- a/dist/lib/ModelSpecificInstance.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ModelSpecificInstance.js","sourceRoot":"","sources":["../../lib/ModelSpecificInstance.ts"],"names":[],"mappings":";AAIA,MAAY,CAAC,WAAM,QAAQ,CAAC,CAAA;AAE5B;;;;;;;;;;;GAWG;AACH,+BAAkF,KAAkC,EAAE,YAA0D;IAC5K,MAAM,uBAAuB,GAA6B,YAAY,CAAC;IAEvE,IAAI,YAAY,GAAG,cAAc,uBAAuB;QACpD,YAAY,GAAG,IAAI;YACf,MAAM,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;QAC1B,CAAC;IACL,CAAC;IAAA,CAAA;IAED,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAC,CAAC,QAAQ;QACtC,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC5C,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE;gBAC3D,GAAG,EAAE;oBACD,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACxF,CAAC;gBACD,GAAG,EAAE,UAAU,KAAK;oBAChB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACvF,CAAC;gBACD,UAAU,EAAE,IAAI;gBAChB,YAAY,EAAE,IAAI;aACrB,CAAC,CAAC;QACP,CAAC;QAED,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE;YACpD,GAAG,EAAE;gBACD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YACpC,CAAC;YACD,GAAG,EAAE,UAAU,KAAK;gBAChB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;YACrC,CAAC;YACD,UAAU,EAAE,IAAI;SACnB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAM,YAAY,CAAC;AAC7B,CAAC;AAnCe,6BAAqB,wBAmCpC,CAAA"} \ No newline at end of file diff --git a/dist/lib/Plugins.js b/dist/lib/Plugins.js deleted file mode 100644 index 1090f76..0000000 --- a/dist/lib/Plugins.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=Plugins.js.map \ No newline at end of file diff --git a/dist/lib/Plugins.js.map b/dist/lib/Plugins.js.map deleted file mode 100644 index d04299e..0000000 --- a/dist/lib/Plugins.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Plugins.js","sourceRoot":"","sources":["../../lib/Plugins.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/Schema.js b/dist/lib/Schema.js deleted file mode 100644 index 46a2f69..0000000 --- a/dist/lib/Schema.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=Schema.js.map \ No newline at end of file diff --git a/dist/lib/Schema.js.map b/dist/lib/Schema.js.map deleted file mode 100644 index a5367a0..0000000 --- a/dist/lib/Schema.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Schema.js","sourceRoot":"","sources":["../../lib/Schema.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/Transforms.js b/dist/lib/Transforms.js deleted file mode 100644 index ffccfc7..0000000 --- a/dist/lib/Transforms.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; -const BSON_1 = require("./BSON"); -exports.DefaultTransforms = { - ObjectID: { - fromDB: value => value instanceof BSON_1.ObjectID ? value.toHexString() : value, - toDB: value => typeof value === "string" ? new BSON_1.ObjectID(value) : value - }, - Binary: { - fromDB: value => { - if (!value) - return null; - if (value instanceof BSON_1.Binary) - return value.buffer; - return value; - }, - toDB: value => { - if (Buffer.isBuffer(value)) - return new BSON_1.Binary(value); - if (Array.isArray(value)) - return new BSON_1.Binary(new Buffer(value)); - return null; - } - } -}; -//# sourceMappingURL=Transforms.js.map \ No newline at end of file diff --git a/dist/lib/Transforms.js.map b/dist/lib/Transforms.js.map deleted file mode 100644 index 09402cc..0000000 --- a/dist/lib/Transforms.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Transforms.js","sourceRoot":"","sources":["../../lib/Transforms.ts"],"names":[],"mappings":";AAAA,uBAA+B,QAAQ,CAAC,CAAA;AAqC3B,yBAAiB,GAAG;IAC/B,QAAQ,EAA+B;QACvC,MAAM,EAAE,KAAK,IAAI,KAAK,YAAY,eAAQ,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,KAAK;QACxE,IAAI,EAAE,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,GAAG,IAAI,eAAQ,CAAC,KAAK,CAAC,GAAG,KAAK;KACtE;IACD,MAAM,EAA6B;QAClC,MAAM,EAAE,KAAK;YACZ,EAAE,CAAA,CAAC,CAAC,KAAK,CAAC;gBAAC,MAAM,CAAC,IAAI,CAAC;YACvB,EAAE,CAAA,CAAC,KAAK,YAAY,aAAM,CAAC;gBAAC,MAAM,CAAO,KAAM,CAAC,MAAM,CAAC;YAEvD,MAAM,CAAC,KAAK,CAAC;QACd,CAAC;QACD,IAAI,EAAE,KAAK;YACV,EAAE,CAAA,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAAC,MAAM,CAAC,IAAI,aAAM,CAAC,KAAK,CAAC,CAAC;YACpD,EAAE,CAAA,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBAAC,MAAM,CAAC,IAAI,aAAM,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC9D,MAAM,CAAC,IAAI,CAAC;QACb,CAAC;KACD;CACD,CAAA"} \ No newline at end of file diff --git a/dist/lib/Validators.js b/dist/lib/Validators.js deleted file mode 100644 index 95ed205..0000000 --- a/dist/lib/Validators.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -const MongoDB = require("mongodb"); -const Skmatc = require("skmatc"); -function DefaultValidators() { - return [ - Skmatc.create(schema => schema === MongoDB.ObjectID, function (schema, data) { - return this.assert(!data || data instanceof MongoDB.ObjectID || (data._bsontype === "ObjectID" && data.id), "Expected " + JSON.stringify(data) + " to be a valid MongoDB.ObjectID object"); - }, { name: "ObjectID validation" }), - Skmatc.create(schema => schema === Buffer, function (schema, data) { - return this.assert(data && (data instanceof MongoDB.Binary || (data._bsontype === "Binary" && data.buffer)), "Expected " + JSON.stringify(data) + " to be a valid MongoDB.Binary object"); - }, { name: "Buffer validation" }) - ]; -} -exports.DefaultValidators = DefaultValidators; -//# sourceMappingURL=Validators.js.map \ No newline at end of file diff --git a/dist/lib/Validators.js.map b/dist/lib/Validators.js.map deleted file mode 100644 index 1c40740..0000000 --- a/dist/lib/Validators.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Validators.js","sourceRoot":"","sources":["../../lib/Validators.ts"],"names":[],"mappings":";AAAA,MAAY,OAAO,WAAM,SAAS,CAAC,CAAA;AACnC,MAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AAEjC;IACC,MAAM,CAAC;QACN,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,KAAK,OAAO,CAAC,QAAQ,EAAE,UAAS,MAAM,EAAE,IAAI;YACzE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,IAAI,IAAI,YAAY,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,SAAS,KAAK,UAAU,IAAI,IAAI,CAAC,EAAE,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,wCAAwC,CAAC,CAAC;QAC5L,CAAC,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,KAAK,MAAM,EAAE,UAAS,MAAM,EAAE,IAAI;YAC/D,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,YAAY,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,sCAAsC,CAAC,CAAC;QAC3L,CAAC,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC;KACjC,CAAC;AACH,CAAC;AATe,yBAAiB,oBAShC,CAAA"} \ No newline at end of file diff --git a/dist/lib/cacheControllers/IDDirector.js b/dist/lib/cacheControllers/IDDirector.js deleted file mode 100644 index 1bab615..0000000 --- a/dist/lib/cacheControllers/IDDirector.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; -const MongoDB = require("mongodb"); -/** - * Caches documents using their _id field as the unique cache key. This - * is useful if you primarily query your documents using their _id field, - * however can be suboptimal (or even a complete waste) if you use different - * types of queries. - */ -class CacheOnID { - valid(object) { - return !!object._id; - } - buildKey(object) { - if (object._id._bsontype === "ObjectID") - return new MongoDB.ObjectID(object._id.id).toHexString(); - return object._id; - } - validQuery(conditions) { - return !!conditions._id; - } - buildQueryKey(conditions) { - if (conditions._id._bsontype === "ObjectID") - return new MongoDB.ObjectID(conditions._id.id).toHexString(); - return conditions._id; - } -} -exports.CacheOnID = CacheOnID; -//# sourceMappingURL=IDDirector.js.map \ No newline at end of file diff --git a/dist/lib/cacheControllers/IDDirector.js.map b/dist/lib/cacheControllers/IDDirector.js.map deleted file mode 100644 index f8fe442..0000000 --- a/dist/lib/cacheControllers/IDDirector.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"IDDirector.js","sourceRoot":"","sources":["../../../lib/cacheControllers/IDDirector.ts"],"names":[],"mappings":";AACA,MAAY,OAAO,WAAM,SAAS,CAAC,CAAA;AAEnC;;;;;GAKG;AACH;IACI,KAAK,CAAC,MAAoB;QACtB,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IACxB,CAAC;IAED,QAAQ,CAAC,MAAoB;QACzB,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,KAAK,UAAU,CAAC;YACpC,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC7D,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,UAAU,CAAC,UAAU;QACjB,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC;IAC5B,CAAC;IAED,aAAa,CAAC,UAAU;QACpB,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,KAAK,UAAU,CAAC;YACxC,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QACjE,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC;IAC1B,CAAC;AACL,CAAC;AApBY,iBAAS,YAoBrB,CAAA"} \ No newline at end of file diff --git a/dist/lib/caches/MemoryCache.js b/dist/lib/caches/MemoryCache.js deleted file mode 100644 index f8b388a..0000000 --- a/dist/lib/caches/MemoryCache.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; -const Bluebird = require("bluebird"); -/** - * A cache implementation which stores documents in an in-memory cache. - * - * Be aware that this is an incredibly simplistic implementation which doesn't manage - * memory usage at all and is very likely NOT suitable for production use. - */ -class MemoryCache { - constructor() { - this.cache = {}; - } - set(key, value) { - this.cache[key] = value; - return Bluebird.resolve(value); - } - get(key) { - return Bluebird.resolve(this.cache[key]); - } - clear(key) { - let has = this.cache.hasOwnProperty(key); - if (has) - delete this.cache[key]; - return Bluebird.resolve(has); - } -} -exports.MemoryCache = MemoryCache; -//# sourceMappingURL=MemoryCache.js.map \ No newline at end of file diff --git a/dist/lib/caches/MemoryCache.js.map b/dist/lib/caches/MemoryCache.js.map deleted file mode 100644 index 882b4e6..0000000 --- a/dist/lib/caches/MemoryCache.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"MemoryCache.js","sourceRoot":"","sources":["../../../lib/caches/MemoryCache.ts"],"names":[],"mappings":";AAAA,MAAY,QAAQ,WAAM,UAAU,CAAC,CAAA;AAGrC;;;;;GAKG;AACH;IAAA;QACY,UAAK,GAAQ,EAAE,CAAC;IAgB5B,CAAC;IAdG,GAAG,CAAI,GAAW,EAAE,KAAQ;QACxB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACxB,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,GAAG,CAAI,GAAW;QACd,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,GAAW;QACb,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QACzC,EAAE,CAAA,CAAC,GAAG,CAAC;YAAC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;AACL,CAAC;AAjBY,mBAAW,cAiBvB,CAAA"} \ No newline at end of file diff --git a/dist/lib/caches/NoOpCache.js b/dist/lib/caches/NoOpCache.js deleted file mode 100644 index ba59586..0000000 --- a/dist/lib/caches/NoOpCache.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -const Bluebird = require("bluebird"); -/** - * A cache implementation which does not cache any received documents - * and returns nothing when requested - mimicking an empty cache. - * - * This is the default cache used if one is not supplied and should - * not impose any significant performance overhead. - */ -class NoOpCache { - set(key, object) { - return Bluebird.resolve(object); - } - get(key) { - return Bluebird.resolve(); - } - clear(key) { - return Bluebird.resolve(false); - } -} -exports.NoOpCache = NoOpCache; -//# sourceMappingURL=NoOpCache.js.map \ No newline at end of file diff --git a/dist/lib/caches/NoOpCache.js.map b/dist/lib/caches/NoOpCache.js.map deleted file mode 100644 index 0b4ea79..0000000 --- a/dist/lib/caches/NoOpCache.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"NoOpCache.js","sourceRoot":"","sources":["../../../lib/caches/NoOpCache.ts"],"names":[],"mappings":";AACA,MAAY,QAAQ,WAAM,UAAU,CAAC,CAAA;AAErC;;;;;;GAMG;AACH;IACI,GAAG,CAAI,GAAW,EAAE,MAAS;QACzB,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,GAAG,CAAI,GAAW;QACd,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,GAAW;QACb,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;AACL,CAAC;AAZY,iBAAS,YAYrB,CAAA"} \ No newline at end of file diff --git a/dist/lib/middleware/Express.js b/dist/lib/middleware/Express.js deleted file mode 100644 index 1e3662f..0000000 --- a/dist/lib/middleware/Express.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; -/** - * A factory method which creates Express/Connect compatible middleware functions to inject - * a "db" field on your request objects as well as ensuring that the Iridium Core is connected - * to a MongoDB database before handling any requests. - * - * @internal - */ -function ExpressMiddlewareFactory(core) { - return function (req, res, next) { - core.connect().then(function () { - Object.defineProperty(req, "db", { - get: function () { return core; } - }); - next(); - }).catch(next); - }; -} -exports.ExpressMiddlewareFactory = ExpressMiddlewareFactory; -//# sourceMappingURL=Express.js.map \ No newline at end of file diff --git a/dist/lib/middleware/Express.js.map b/dist/lib/middleware/Express.js.map deleted file mode 100644 index 1bdf548..0000000 --- a/dist/lib/middleware/Express.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Express.js","sourceRoot":"","sources":["../../../lib/middleware/Express.ts"],"names":[],"mappings":";AAIA;;;;;;GAMG;AACH,kCAAyC,IAAU;IAC/C,MAAM,CAAC,UAAU,GAAuB,EAAE,GAAwB,EAAE,IAA0C;QAC1G,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;YAChB,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE;gBAC7B,GAAG,EAAE,cAAa,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;aACnC,CAAC,CAAC;YACH,IAAI,EAAE,CAAC;QACX,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,CAAC;AACN,CAAC;AATe,gCAAwB,2BASvC,CAAA"} \ No newline at end of file diff --git a/dist/lib/utils/ObjectID.js b/dist/lib/utils/ObjectID.js deleted file mode 100644 index c5ae9f2..0000000 --- a/dist/lib/utils/ObjectID.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; -const MongoDB = require("mongodb"); -/** - * Converts a string to an ObjectID instance - a shortcut for require("mongodb").ObjectID.createFromHexString - * - * @param value The string representation of the ObjectID you wish to create. - * @returns A MongoDB ObjectID instance equivalent to the string you provided. - * - * You should be aware that this method performs no validation on the received string, MongoDB's ObjectID requires - * that it either be a 12 byte UTF8 string, or a 24 byte hexadecimal string in order to be converted correctly. - * - * This method removes the need for your application to directly depend on MongoDB's Node.js client library, - * which helps clean up your code a bit and reduces the headache of maintaining two different versions of the - * library (since Iridium also has one). - */ -function toObjectID(value) { - return MongoDB.ObjectID.createFromHexString(value); -} -exports.toObjectID = toObjectID; -//# sourceMappingURL=ObjectID.js.map \ No newline at end of file diff --git a/dist/lib/utils/ObjectID.js.map b/dist/lib/utils/ObjectID.js.map deleted file mode 100644 index 13c08c0..0000000 --- a/dist/lib/utils/ObjectID.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ObjectID.js","sourceRoot":"","sources":["../../../lib/utils/ObjectID.ts"],"names":[],"mappings":";AAAA,MAAY,OAAO,WAAM,SAAS,CAAC,CAAA;AAEnC;;;;;;;;;;;;GAYG;AACH,oBAA2B,KAAa;IACvC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACpD,CAAC;AAFe,kBAAU,aAEzB,CAAA"} \ No newline at end of file diff --git a/dist/lib/utils/Omnom.js b/dist/lib/utils/Omnom.js deleted file mode 100644 index 825aa6a..0000000 --- a/dist/lib/utils/Omnom.js +++ /dev/null @@ -1,186 +0,0 @@ -"use strict"; -const _ = require("lodash"); -const MongoDB = require("mongodb"); -class Omnom { - constructor(options = {}) { - this.options = options; - this._changes = {}; - } - get changes() { - return this._changes; - } - diff(original, modified) { - this.onObject(original, modified); - return this; - } - static diff(original, modified, options) { - return new Omnom(options).diff(original, modified).changes; - } - onObject(original, modified, changePath) { - if (original === undefined || original === null) - return (original !== modified) && this.set(changePath, modified); - if (typeof original === "number" && typeof modified === "number" && original !== modified) { - if (this.options.atomicNumbers) - return this.inc(changePath, modified - original); - return this.set(changePath, modified); - } - if (Array.isArray(original) && Array.isArray(modified)) - return this.onArray(original, modified, changePath); - if (original instanceof MongoDB.ObjectID && modified instanceof MongoDB.ObjectID) - return !original.equals(modified) && this.set(changePath, modified); - if (!_.isPlainObject(original) || !_.isPlainObject(modified)) - return !_.isEqual(original, modified) && this.set(changePath, modified); - _.forOwn(modified, (value, key) => { - // Handle array diffs in their own special way - if (Array.isArray(value) && Array.isArray(original[key])) - this.onArray(original[key], value, this.resolve(changePath, key)); - else - this.onObject(original[key], value, this.resolve(changePath, key)); - }, this); - // Unset removed properties - _.forOwn(original, (value, key) => { - if (modified[key] === undefined) - return this.unset(this.resolve(changePath, key)); - }, this); - } - onArray(original, modified, changePath) { - // Check if we can get from original => modified using just pulls - if (original.length > modified.length) { - return this.onSmallerArray(original, modified, changePath); - } - // Check if we can get from original => modified using just pushes - if (original.length < modified.length) { - return this.onLargerArray(original, modified, changePath); - } - // Otherwise, we need to use $set to generate the new array - return this.onSimilarArray(original, modified, changePath); - } - onSmallerArray(original, modified, changePath) { - let pulls = []; - let i = 0; - let j = 0; - for (; i < original.length && j < modified.length; i++) { - if (this.almostEqual(original[i], modified[j])) - j++; - else - pulls.push(original[i]); - } - for (; i < original.length; i++) - pulls.push(original[i]); - if (j === modified.length) { - if (pulls.length === 1) - return this.pull(changePath, pulls[0]); - // We can complete using just pulls - return pulls.forEach((pull) => this.pull(changePath, pull)); - } - else - return this.set(changePath, modified); - } - onLargerArray(original, modified, changePath) { - let canPush = true; - for (let i = 0; i < original.length; i++) - if (this.almostEqual(original[i], modified[i]) < 1) { - canPush = false; - break; - } - if (canPush) { - for (let i = original.length; i < modified.length; i++) - this.push(changePath, modified[i]); - return; - } - return this.onSimilarArray(original, modified, changePath); - } - onSimilarArray(original, modified, changePath) { - // Check how many manipulations would need to be performed, if it's more than half the array size - // then rather re-create the array - let sets = []; - let partials = []; - for (let i = 0; i < modified.length; i++) { - let equality = this.almostEqual(original[i], modified[i]); - if (equality === 0) - sets.push(i); - else if (equality < 1) - partials.push(i); - } - if (sets.length > modified.length / 2) - return this.set(changePath, modified); - for (let i = 0; i < sets.length; i++) - this.set(this.resolve(changePath, sets[i].toString()), modified[sets[i]]); - for (let i = 0; i < partials.length; i++) - this.onObject(original[partials[i]], modified[partials[i]], this.resolve(changePath, partials[i].toString())); - } - set(path, value) { - if (!this.changes.$set) - this.changes.$set = {}; - this.changes.$set[path] = value; - } - unset(path) { - if (!this.changes.$unset) - this.changes.$unset = {}; - this.changes.$unset[path] = 1; - } - inc(path, value) { - if (!this.changes.$inc) - this.changes.$inc = {}; - this.changes.$inc[path] = value; - } - push(path, value) { - if (!this.changes.$push) - this.changes.$push = {}; - if (this.changes.$push[path]) { - if (this.changes.$push[path].$each) - this.changes.$push[path].$each.push(value); - else - this.changes.$push[path] = { $each: [this.changes.$push[path], value] }; - } - else - this.changes.$push[path] = value; - } - pull(path, value) { - if (!this.changes.$pull) - this.changes.$pull = {}; - if (this.changes.$pullAll && this.changes.$pullAll[path]) { - return this.changes.$pullAll[path].push(value); - } - if (this.changes.$pull[path]) { - this.pullAll(path, [this.changes.$pull[path], value]); - delete this.changes.$pull[path]; - if (_.keys(this.changes.$pull).length === 0) - delete this.changes.$pull; - return; - } - this.changes.$pull[path] = value; - } - pullAll(path, values) { - if (!this.changes.$pullAll) - this.changes.$pullAll = {}; - this.changes.$pullAll[path] = values; - } - resolve(...args) { - let validArguments = []; - args.forEach(function (arg) { - if (arg) - validArguments.push(arg); - }); - return validArguments.join("."); - } - almostEqual(o1, o2) { - if (!_.isPlainObject(o1) || !_.isPlainObject(o2)) - return o1 == o2 ? 1 : 0; - let object1KeyIndex, object1Keys = Object.keys(o1); - let object2Keys = Object.keys(o2); - let commonKeys = []; - for (object1KeyIndex = 0; object1KeyIndex < object1Keys.length; object1KeyIndex++) - if (~object2Keys.indexOf(object1Keys[object1KeyIndex])) - commonKeys.push(object1Keys[object1KeyIndex]); - let totalKeys = object1Keys.length + object2Keys.length - commonKeys.length; - let keysDifference = totalKeys - commonKeys.length; - let requiredChanges = 0; - for (let i = 0; i < commonKeys.length; i++) - if (this.almostEqual(o1[commonKeys[i]], o2[commonKeys[i]]) < 1) - requiredChanges++; - return 1 - (keysDifference / totalKeys) - (requiredChanges / commonKeys.length); - } -} -exports.Omnom = Omnom; -//# sourceMappingURL=Omnom.js.map \ No newline at end of file diff --git a/dist/lib/utils/Omnom.js.map b/dist/lib/utils/Omnom.js.map deleted file mode 100644 index eae7474..0000000 --- a/dist/lib/utils/Omnom.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Omnom.js","sourceRoot":"","sources":["../../../lib/utils/Omnom.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/dist/main.d.ts b/dist/main.d.ts deleted file mode 100644 index c69133f..0000000 --- a/dist/main.d.ts +++ /dev/null @@ -1,4075 +0,0 @@ -// Generated by typings -// Source: dist/lib/middleware/Express.d.ts -declare module '~iridium/dist/lib/middleware/Express' { -import * as http from 'http'; -import { Core } from '~iridium/dist/lib/Core'; -/** - * A factory method which creates Express/Connect compatible middleware functions to inject - * a "db" field on your request objects as well as ensuring that the Iridium Core is connected - * to a MongoDB database before handling any requests. - * - * @internal - */ -export function ExpressMiddlewareFactory(core: Core): ExpressMiddleware; -/** - * An Express/Connect compatible middleware function which injects req.db and ensures that the Iridium Core - * has an active database connection before continuing the request handling process. - */ -export interface ExpressMiddleware { - (req: http.ServerRequest, res: http.ServerResponse, next: (err?: Error, route?: String) => void): any; -} -} -declare module 'iridium/dist/lib/middleware/Express' { -import alias = require('~iridium/dist/lib/middleware/Express'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/Core.d.ts -declare module '~iridium/dist/lib/Core' { -import * as Bluebird from '~iridium~bluebird'; -import * as MongoDB from '~iridium~mongodb'; -import { Configuration } from '~iridium/dist/lib/Configuration'; -import { Plugin } from '~iridium/dist/lib/Plugins'; -import * as ExpressMiddleware from '~iridium/dist/lib/middleware/Express'; -import { Cache } from '~iridium/dist/lib/Cache'; -/** - * The Iridium Core, responsible for managing the connection to the database as well - * as any plugins you are making use of. - * - * Generally you will subclass this to provide your own custom core with the models you - * make use of within your application. - */ -export class Core { - /** - * Creates a new Iridium Core instance connected to the specified MongoDB instance - * @param {Iridium.IridiumConfiguration} config The config object defining the database to connect to - * @constructs Core - */ - constructor(config: Configuration); - /** - * Creates a new Iridium Core instance connected to the specified MongoDB instance - * @param {String} url The URL of the MongoDB instance to connect to - * @param {Iridium.IridiumConfiguration} config The config object made available as settings - * @constructs Core - */ - constructor(uri: string, config?: Configuration); - private mongoConnectAsyc; - private _plugins; - private _url; - private _config; - private _connection; - private _cache; - private _connectPromise; - /** - * Gets the plugins registered with this Iridium Core - * @returns {[Iridium.Plugin]} - */ - plugins: Plugin[]; - /** - * Gets the configuration specified in the construction of this - * Iridium Core. - * @returns {Iridium.Configuration} - */ - settings: Configuration; - /** - * Gets the currently active database connection for this Iridium - * Core. - * @returns {MongoDB.Db} - */ - connection: MongoDB.Db; - /** - * Gets the URL used to connect to MongoDB - * @returns {String} - */ - url: string; - /** - * Gets the cache used to store objects retrieved from the database for performance reasons - * @returns {cache} - */ - cache: Cache; - /** - * Registers a new plugin with this Iridium Core - * @param {Iridium.Plugin} plugin The plugin to register with this Iridium Core - * @returns {Iridium.Core} - */ - register(plugin: Plugin): Core; - /** - * Connects to the database server specified in the provided configuration - * @param {function(Error, Iridium.Core)} [callback] A callback to be triggered once the connection is established. - * @returns {Promise} - */ - connect(callback?: (err: Error, core: Core) => any): Bluebird; - /** - * Closes the active database connection - * @type {Promise} - */ - close(): Bluebird; - /** - * Provides an express middleware which can be used to set the req.db property - * to the current Iridium instance. - * @returns {Iridium.ExpressMiddleware} - */ - express(): ExpressMiddleware.ExpressMiddleware; - /** - * A method which is called whenever a new connection is made to the database. - * - * @param connection The underlying MongoDB connection which was created, you can modify or replace this if you wish. - * @returns A promise for the connection, allowing you to perform any asynchronous initialization required by your application. - * - * In subclassed Iridium Cores this method can be overridden to manipulate the properties - * of the underlying MongoDB connection object, such as authenticating. Until this method - * resolves a connection object, Iridium will be unable to execute any queries. If you wish - * to run Iridium queries then look at the onConnected method. - */ - protected onConnecting(connection: MongoDB.Db): Bluebird; - /** - * A method which is called once a database connection has been established and accepted by Iridium - * - * In subclassed Iridium cores this method can be overridden to perform tasks whenever a - * connection to the database has been established - such as setting up indexes for your - * collections or seeding the database. - */ - protected onConnected(): Bluebird; -} -} -declare module 'iridium/dist/lib/Core' { -import alias = require('~iridium/dist/lib/Core'); -export = alias; -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-es6-promise/fb04188767acfec1defd054fc8024fafa5cd4de7/dist/es6-promise.d.ts -declare module '~iridium~mongodb~es6-promise/dist/es6-promise' { -export interface Thenable { - then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; - then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Thenable; -} - -export class Promise implements Thenable { - /** - * If you call resolve in the body of the callback passed to the constructor, - * your promise is fulfilled with result object passed to resolve. - * If you call reject your promise is rejected with the object passed to resolve. - * For consistency and debugging (eg stack traces), obj should be an instanceof Error. - * Any errors thrown in the constructor callback will be implicitly passed to reject(). - */ - constructor (callback: (resolve : (value?: R | Thenable) => void, reject: (error?: any) => void) => void); - - /** - * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. - * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. - * Both callbacks have a single parameter , the fulfillment value or rejection reason. - * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. - * If an error is thrown in the callback, the returned promise rejects with that error. - * - * @param onFulfilled called when/if "promise" resolves - * @param onRejected called when/if "promise" rejects - */ - then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise; - then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Promise; - - /** - * Sugar for promise.then(undefined, onRejected) - * - * @param onRejected called when/if "promise" rejects - */ - catch (onRejected?: (error: any) => U | Thenable): Promise; - - /** - * Make a new promise from the thenable. - * A thenable is promise-like in as far as it has a "then" method. - */ - static resolve (): Promise; - static resolve (value: R | Thenable): Promise; - - /** - * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error - */ - static reject (error: any): Promise; - - /** - * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. - * the array passed to all can be a mixture of promise-like objects and other objects. - * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. - */ - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable, T10 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable]): Promise<[T1, T2, T3, T4, T5]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable ]): Promise<[T1, T2, T3, T4]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable]): Promise<[T1, T2, T3]>; - static all(values: [T1 | Thenable, T2 | Thenable]): Promise<[T1, T2]>; - static all(values: [T1 | Thenable]): Promise<[T1]>; - static all(values: Array>): Promise; - - /** - * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. - */ - static race (promises: (R | Thenable)[]): Promise; -} - -/** - * The polyfill method will patch the global environment (in this case to the Promise name) when called. - */ -export function polyfill (): void; -} -declare module '~iridium~mongodb~es6-promise' { -import alias = require('~iridium~mongodb~es6-promise/dist/es6-promise'); -export = alias; -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/Think7/typings-mongodb/d4269a9c672ab28a7865b38c8614673e8aecc8e5/mongodb.d.ts -declare module '~iridium~mongodb/mongodb' { -// Type definitions for MongoDB v2.1 -// Project: https://github.com/mongodb/node-mongodb-native/tree/2.1 -// Definitions by: Andrew -// Federico Caselli -// Definitions: https://github.com/Think7/typings-mongodb - -// Documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/ - -// Use typings to install this type definition https://github.com/typings/typings - -import {EventEmitter} from 'events'; -import {Promise} from '~iridium~mongodb~es6-promise'; - -// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/MongoClient.html -export class MongoClient { - constructor(); - - static connect(uri: string, callback: MongoCallback): void; - static connect(uri: string, options?: MongoClientOptions): Promise; - static connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; - - connect(uri: string, callback: MongoCallback): void; - connect(uri: string, options?: MongoClientOptions): Promise; - connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; -} - -export interface MongoCallback { - (error: MongoError, result: T): void; -} - -// http://mongodb.github.io/node-mongodb-native/2.1/api/MongoError.html -export class MongoError extends Error { - constructor(message: string); - static create(options: Object): MongoError; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/MongoClient.html#.connect -export interface MongoClientOptions { - uri_decode_auth?: boolean; - db?: DbCreateOptions; - server?: ServerOptions; - replSet?: ReplSetOptions; - mongos?: MongosOptions; - promiseLibrary?: Object; -} - -// See : http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html -export interface DbCreateOptions { - authSource?: string; - // the write concern for the operation where < 1 is no acknowlegement of write and w >= 1, w = ‘majority’ or tag acknowledges the write. - w?: number | string; - // set the timeout for waiting for write concern to finish (combines with w option). - wtimeout?: number; - j?: boolean; - // use c++ bson parser. default:false. - native_parser?: boolean; - // force server to create _id fields instead of client. default:false. - forceServerObjectId?: boolean; - serializeFunctions?: boolean; - ignoreUndefined?: boolean; - // peform operations using raw bson buffers. default:false. - raw?: boolean; - // when deserializing a Long will fit it into a Number if it’s smaller than 53 bits. default:true. - promoteLongs?: boolean; - bufferMaxEntries?: number; - // the prefered read preference. use 'ReadPreference' class. - readPreference?: ReadPreference | string; - // custom primary key factory to generate _id values (see Custom primary keys). - pkFactory?: Object; - promiseLibrary?: Object; - readConcern?: { level?: Object }; -} - -// See http://mongodb.github.io/node-mongodb-native/2.1/api/ReadPreference.html -export class ReadPreference { - constructor(mode: string, tags: Object); - mode: string; - tags: any; - static PRIMARY: string; - static PRIMARY_PREFERRED: string; - static SECONDARY: string; - static SECONDARY_PREFERRED: string; - static NEAREST: string; - isValid(mode: string): boolean; - static isValid(mode: string): boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html -export interface SocketOptions { - // Reconnect on error. default:false - autoReconnect?: boolean; - // TCP Socket NoDelay option. default:true - noDelay?: boolean; - // TCP KeepAlive on the socket with a X ms delay before start. default:0 - keepAlive?: number; - // TCP Connection timeout setting. default 0 - connectTimeoutMS?: number; - // TCP Socket timeout setting. default 0 - socketTimeoutMS?: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html -export interface ServerOptions { - // - specify the number of connections in the pool default:5 - poolSize?: number; - ssl?: boolean; - sslValidate?: Object; - checkServerIdentity?: boolean | Function; - sslCA?: Array; - sslCert?: Buffer | string; - sslKey?: Buffer | string; - sslPass?: Buffer | string; - socketOptions?: SocketOptions; - reconnectTries?: number; - reconnectInterval?: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html -export interface ReplSetOptions { - ha?: boolean; - haInterval?: number; - replicaSet?: string; - secondaryAcceptableLatencyMS?: number; - connectWithNoPrimary?: boolean; - // - specify the number of connections in the pool default:5 - poolSize?: number; - ssl?: boolean; - sslValidate?: Object; - checkServerIdentity?: boolean | Function; - sslCA?: Array; - sslCert?: Buffer | string; - sslKey?: Buffer | string; - sslPass?: Buffer | string; - socketOptions?: SocketOptions; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Mongos.html -export interface MongosOptions { - ha?: boolean; - haInterval?: number; - // - specify the number of connections in the pool default:5 - poolSize?: number; - ssl?: boolean; - sslValidate?: Object; - checkServerIdentity?: boolean | Function; - sslCA?: Array; - sslCert?: Buffer | string; - sslKey?: Buffer | string; - sslPass?: Buffer | string; - socketOptions?: SocketOptions; -} - -// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html -export class Db extends EventEmitter { - constructor(databaseName: string, serverConfig: Server | ReplSet | Mongos, options?: DbCreateOptions); - - serverConfig: Server | ReplSet | Mongos; - bufferMaxEntries: number; - databaseName: string; - options: any; - native_parser: boolean; - slaveOk: boolean; - writeConcern: any; - - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser - addUser(username: string, password: string, callback: MongoCallback): void; - addUser(username: string, password: string, options?: DbAddUserOptions): Promise; - addUser(username: string, password: string, options: DbAddUserOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#admin - admin(): Admin; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#authenticate - authenticate(userName: string, password: string, callback: MongoCallback): void; - authenticate(userName: string, password: string, options?: { authMechanism: string }): Promise; - authenticate(userName: string, password: string, options: { authMechanism: string }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#close - close(callback: MongoCallback): void; - close(forceClose?: boolean): Promise; - close(forceClose: boolean, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection - collection(name: string): Collection; - collection(name: string, callback: MongoCallback): Collection; - collection(name: string, options: DbCollectionOptions, callback: MongoCallback): Collection; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collections - collections(): Promise; - collections(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#command - command(command: Object, callback: MongoCallback): void; - command(command: Object, options?: { readPreference: ReadPreference | string }): Promise; - command(command: Object, options: { readPreference: ReadPreference | string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection - createCollection(name: string, callback: MongoCallback): void; - createCollection(name: string, options?: CollectionCreateOptions): Promise; - createCollection(name: string, options: CollectionCreateOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createIndex - createIndex(name: string, fieldOrSpec: string | Object, callback: MongoCallback): void; - createIndex(name: string, fieldOrSpec: string | Object, options?: IndexOptions): Promise; - createIndex(name: string, fieldOrSpec: string | Object, options: IndexOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#db - db(dbName: string): Db; - db(dbName: string, options: { noListener?: boolean, returnNonCachedInstance?: boolean }): Db; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropCollection - dropCollection(name: string): Promise; - dropCollection(name: string, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropDatabase - dropDatabase(): Promise; - dropDatabase(callback: MongoCallback): void; - - //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#ensureIndex - // ensureIndex(collectionName: any, fieldOrSpec: any, options: IndexOptions, callback: Function): void; - //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#eval - // eval(code: any, parameters: any[], options?: any, callback?: MongoCallback): void; - - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#executeDbAdminCommand - executeDbAdminCommand(command: Object, callback: MongoCallback): void; - executeDbAdminCommand(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise; - executeDbAdminCommand(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#indexInformation - indexInformation(name: string, callback: MongoCallback): void; - indexInformation(name: string, options?: { full?: boolean, readPreference?: ReadPreference | string }): Promise; - indexInformation(name: string, options: { full?: boolean, readPreference?: ReadPreference | string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#listCollections - listCollections(filter: { name?: string }, options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#logout - logout(callback: MongoCallback): void; - logout(options?: { dbName?: string }): Promise; - logout(options: { dbName?: string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#open - open(): Promise; - open(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#removeUser - removeUser(username: string, callback: MongoCallback): void; - removeUser(username: string, options?: { w?: number | string, wtimeout?: number, j?: boolean }): Promise; - removeUser(username: string, options: { w?: number | string, wtimeout?: number, j?: boolean }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#renameCollection - renameCollection(fromCollection: string, toCollection: string, callback: MongoCallback): void; - renameCollection(fromCollection: string, toCollection: string, options?: { dropTarget?: boolean }): Promise; - renameCollection(fromCollection: string, toCollection: string, options: { dropTarget?: boolean }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#stats - stats(callback: MongoCallback): void; - stats(options?: { scale?: number }): Promise; - stats(options: { scale?: number }, callback: MongoCallback): void; -} - - - -// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html -export class Server extends EventEmitter { - constructor(host: string, port: number, options?: ServerOptions); - - connections(): Array; -} - -// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html -export class ReplSet extends EventEmitter { - constructor(servers: Array, options?: ReplSetOptions); - - connections(): Array; -} - -// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html -export class Mongos extends EventEmitter { - constructor(servers: Array, options?: MongosOptions); - - connections(): Array; -} -// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser -export interface DbAddUserOptions { - w?: string | number; - wtimeout?: number; - j?: boolean; - customData?: Object; - roles?: Object[]; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection -export interface CollectionCreateOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; - raw?: boolean; - pkFactory?: Object; - readPreference?: ReadPreference | string; - serializeFunctions?: boolean; - strict?: boolean; - capped?: boolean; - size?: number; - max?: number; - autoIndexId?: boolean; -} - -// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection -export interface DbCollectionOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; - raw?: boolean; - pkFactory?: Object; - readPreference?: ReadPreference | string; - serializeFunctions?: boolean; - strict?: boolean; - readConcern?: { level: Object }; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createIndex -export interface IndexOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; - // Creates an unique index. - unique?: boolean; - // Creates a sparse index. - sparse?: boolean; - // Creates the index in the background, yielding whenever possible. - background?: boolean; - // A unique index cannot be created on a key that has pre-existing duplicate values. - // If you would like to create the index anyway, keeping the first document the database indexes and - // deleting all subsequent documents that have duplicate value - dropDups?: boolean; - // For geo spatial indexes set the lower bound for the co-ordinates. - min?: number; - // For geo spatial indexes set the high bound for the co-ordinates. - max?: number; - // Specify the format version of the indexes. - v?: number; - // Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) - expireAfterSeconds?: number; - // Override the auto generated index name (useful if the resulting name is larger than 128 bytes) - name?: string; -} - -// http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html -export interface Admin { - // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser - addUser(username: string, password: string, callback: MongoCallback): void; - addUser(username: string, password: string, options?: AddUserOptions): Promise; - addUser(username: string, password: string, options: AddUserOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#authenticate - authenticate(username: string, callback: MongoCallback): void; - authenticate(username: string, password?: string): Promise; - authenticate(username: string, password: string, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#buildInfo - buildInfo(): Promise; - buildInfo(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#command - command(command: Object, callback: MongoCallback): void; - command(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise; - command(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#listDatabases - listDatabases(): Promise; - listDatabases(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#logout - logout(): Promise; - logout(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#ping - ping(): Promise; - ping(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingInfo - profilingInfo(): Promise; - profilingInfo(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingLevel - profilingLevel(): Promise; - profilingLevel(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser - removeUser(username: string, callback: MongoCallback): void; - removeUser(username: string, options?: FSyncOptions): Promise; - removeUser(username: string, options: FSyncOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#replSetGetStatus - replSetGetStatus(): Promise; - replSetGetStatus(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverInfo - serverInfo(): Promise; - serverInfo(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverStatus - serverStatus(): Promise; - serverStatus(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#setProfilingLevel - setProfilingLevel(level: string): Promise; - setProfilingLevel(level: string, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#validateCollection - validateCollection(collectionNme: string, callback: MongoCallback): void; - validateCollection(collectionNme: string, options?: Object): Promise; - validateCollection(collectionNme: string, options: Object, callback: MongoCallback): void; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser -export interface AddUserOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; - fsync: boolean; - customData?: Object; - roles?: Object[] -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser -export interface FSyncOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; - fsync?: boolean -} - -// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/ObjectID.html -export class ObjectID { - constructor(s?: string | number); - - generationTime: number; - - // Creates an ObjectID from a hex string representation of an ObjectID. - // hexString – create a ObjectID from a passed in 24 byte hexstring. - static createFromHexString(hexString: string): ObjectID; - // Creates an ObjectID from a second based number, with the rest of the ObjectID zeroed out. Used for comparisons or sorting the ObjectID. - // time – an integer number representing a number of seconds. - static createFromTime(time: number): ObjectID; - // Checks if a value is a valid bson ObjectId - // id - Value to be checked - static isValid(id: string | number): boolean; - //Compares the equality of this ObjectID with otherID. - equals(otherID: ObjectID): boolean; - // Generate a 12 byte id string used in ObjectID's - // time - optional parameter allowing to pass in a second based timestamp - generate(time?: number): string; - // Returns the generation date (accurate up to the second) that this ID was generated. - getTimestamp(): Date; - // Returns the ObjectID id as a 24 byte hex string representation - toHexString(): string; -} - -// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Binary.html -export class Binary { - constructor(buffer: Buffer, subType?: number); - - static SUBTYPE_BYTE_ARRAY: number; - static SUBTYPE_DEFAULT: number; - static SUBTYPE_FUNCTION: number; - static SUBTYPE_MD5: number; - static SUBTYPE_USER_DEFINED: number; - static SUBTYPE_UUID: number; - static SUBTYPE_UUID_OLD: number; - - // The length of the binary. - length(): number; - // Updates this binary with byte_value - put(byte_value: number | string): void; - // Reads length bytes starting at position. - read(position: number, length: number): Buffer; - // Returns the value of this binary as a string. - value(): string; - // Writes a buffer or string to the binary - write(buffer: Buffer | string, offset: number): void; -} -//http://mongodb.github.io/node-mongodb-native/2.1/api/Double.html -export class Double { - constructor(value: number); - - valueOf(): number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Long.html -export class Long { - constructor(low: number, high: number); - - static MAX_VALUE: Long; - static MIN_VALUE: Long; - static NEG_ONE: Long; - static ONE: Long; - static ZERO: Long; - - static fromBits(lowBits: number, highBits: number): Long; - static fromInt(value: number): Long; - static fromNumber(value: number): Long; - static fromString(str: string, radix?: number): Long; - - add(other: Long): Long; - and(other: Long): Long; - compare(other: Long): number; - div(other: Long): Long; - equals(other: Long): boolean; - getHighBits(): number; - getLowBits(): number; - getLowBitsUnsigned(): number; - getNumBitsAbs(): number; - greaterThan(other: Long): number; - greaterThanOrEqual(other: Long): number; - isNegative(): boolean; - isOdd(): boolean; - isZero(): boolean; - lessThan(other: Long): boolean; - lessThanOrEqual(other: Long): boolean; - modulo(other: Long): Long; - multiply(other: Long): Long; - negate(): Long; - not(): Long; - notEquals(other: Long): boolean; - or(other: Long): Long; - shiftLeft(other: number): Long; - shiftRight(other: number): Long; - shiftRightUnsigned(other: number): Long; - subtract(other: Long): Long; - toInt(): number; - toJSON(): string; - toNumber(): number; - toString(radix?: number): string; - xor(other: Long): Long; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/MaxKey.html -export class MaxKey { } - -//http://mongodb.github.io/node-mongodb-native/2.1/api/MinKey.html -export class MinKey { } - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Timestamp.html -export class Timestamp { - constructor(low: number, high: number); - - static MAX_VALUE: Timestamp; - static MIN_VALUE: Timestamp; - static NEG_ONE: Timestamp; - static ONE: Timestamp; - static ZERO: Timestamp; - - static fromBits(lowBits: number, highBits: number): Timestamp; - static fromInt(value: number): Timestamp; - static fromNumber(value: number): Timestamp; - static fromString(str: string, radix?: number): Timestamp; - - add(other: Timestamp): Timestamp; - and(other: Timestamp): Timestamp; - compare(other: Timestamp): number; - div(other: Timestamp): Timestamp; - equals(other: Timestamp): boolean; - getHighBits(): number; - getLowBits(): number; - getLowBitsUnsigned(): number; - getNumBitsAbs(): number; - greaterThan(other: Timestamp): number; - greaterThanOrEqual(other: Timestamp): number; - isNegative(): boolean; - isOdd(): boolean; - isZero(): boolean; - lessThan(other: Timestamp): boolean; - lessThanOrEqual(other: Timestamp): boolean; - modulo(other: Timestamp): Timestamp; - multiply(other: Timestamp): Timestamp; - negate(): Timestamp; - not(): Timestamp; - notEquals(other: Timestamp): boolean; - or(other: Timestamp): Timestamp; - shiftLeft(other: number): Timestamp; - shiftRight(other: number): Timestamp; - shiftRightUnsigned(other: number): Timestamp; - subtract(other: Timestamp): Timestamp; - toInt(): number; - toJSON(): string; - toNumber(): number; - toString(radix?: number): string; - xor(other: Timestamp): Timestamp; -} - -// Documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html -export interface Collection { - // Get the collection name. - collectionName: string; - // Get the full collection namespace. - namespace: string; - // The current write concern values. - writeConcern: any; - // The current read concern values. - readConcern: any; - // Get current index hint for collection. - hint: any; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate - aggregate(pipeline: Object[], callback: MongoCallback): AggregationCursor; - aggregate(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite - bulkWrite(operations: Object[], callback: MongoCallback): void; - bulkWrite(operations: Object[], options?: CollectionBluckWriteOptions): Promise; - bulkWrite(operations: Object[], options: CollectionBluckWriteOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#count - count(query: Object, callback: MongoCallback): void; - count(query: Object, options?: MongoCountPreferences): Promise; - count(query: Object, options: MongoCountPreferences, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndex - createIndex(fieldOrSpec: string | any, callback: MongoCallback): void; - createIndex(fieldOrSpec: string | any, options?: IndexOptions): Promise; - createIndex(fieldOrSpec: string | any, options: IndexOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndexes and http://docs.mongodb.org/manual/reference/command/createIndexes/ - createIndexes(indexSpecs: Object[]): Promise; - createIndexes(indexSpecs: Object[], callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany - deleteMany(filter: Object, callback: MongoCallback): void; - deleteMany(filter: Object, options?: CollectionOptions): Promise; - deleteMany(filter: Object, options: CollectionOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteOne - deleteOne(filter: Object, callback: MongoCallback): void; - deleteOne(filter: Object, options?: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }): Promise; - deleteOne(filter: Object, options: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#distinct - distinct(key: string, query: Object, callback: MongoCallback): void; - distinct(key: string, query: Object, options?: { readPreference?: ReadPreference | string }): Promise; - distinct(key: string, query: Object, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#drop - drop(): Promise; - drop(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndex - dropIndex(indexName: string, callback: MongoCallback): void; - dropIndex(indexName: string, options?: CollectionOptions): Promise; - dropIndex(indexName: string, options: CollectionOptions, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndexes - dropIndexes(): Promise; - dropIndexes(callback?: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#find - find(query?: Object): Cursor; - /** @deprecated */ - find(query: Object, fields?: Object, skip?: number, limit?: number, timeout?: number): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne - /** @deprecated use find().limit(1).next(function(err, doc){}) */ - findOne(filter: Object, callback: MongoCallback): void; - /** @deprecated use find().limit(1).next(function(err, doc){}) */ - findOne(filter: Object, options?: FindOneOptions): Promise; - /** @deprecated use find().limit(1).next(function(err, doc){}) */ - findOne(filter: Object, options: FindOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete - findOneAndDelete(filter: Object, callback: MongoCallback): void; - findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number }): Promise; - findOneAndDelete(filter: Object, options: { projection?: Object, sort?: Object, maxTimeMS?: number }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace - findOneAndReplace(filter: Object, replacement: Object, callback: MongoCallback): void; - findOneAndReplace(filter: Object, replacement: Object, options?: FindOneAndReplaceOption): Promise; - findOneAndReplace(filter: Object, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndUpdate - findOneAndUpdate(filter: Object, update: Object, callback: MongoCallback): void; - findOneAndUpdate(filter: Object, update: Object, options?: FindOneAndReplaceOption): Promise; - findOneAndUpdate(filter: Object, update: Object, options: FindOneAndReplaceOption, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch - geoHaystackSearch(x: number, y: number, callback: MongoCallback): void; - geoHaystackSearch(x: number, y: number, options?: GeoHaystackSearchOptions): Promise; - geoHaystackSearch(x: number, y: number, options: GeoHaystackSearchOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoNear - geoNear(x: number, y: number, callback: MongoCallback): void; - geoNear(x: number, y: number, options?: GeoNearOptions): Promise; - geoNear(x: number, y: number, options: GeoNearOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#group - group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, callback: MongoCallback): void; - group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options?: { readPreference?: ReadPreference | string }): Promise; - group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexes - indexes(): Promise; - indexes(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexExists - indexExists(indexes: string | string[]): Promise; - indexExists(indexes: string | string[], callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexInformation - indexInformation(callback: MongoCallback): void; - indexInformation(options?: { full: boolean }): Promise; - indexInformation(options: { full: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeOrderedBulkOp - initializeOrderedBulkOp(options?: CollectionOptions): OrderedBulkOperation; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeUnorderedBulkOp - initializeUnorderedBulkOp(options?: CollectionOptions): UnorderedBulkOperation; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne - /** @deprecated Use insertOne, insertMany or bulkWrite */ - insert(docs: Object, callback: MongoCallback): void; - /** @deprecated Use insertOne, insertMany or bulkWrite */ - insert(docs: Object, options?: CollectionInsertOneOptions): Promise; - /** @deprecated Use insertOne, insertMany or bulkWrite */ - insert(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany - insertMany(docs: Object[], callback: MongoCallback): void; - insertMany(docs: Object[], options?: CollectionInsertManyOptions): Promise; - insertMany(docs: Object[], options: CollectionInsertManyOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne - insertOne(docs: Object, callback: MongoCallback): void; - insertOne(docs: Object, options?: CollectionInsertOneOptions): Promise; - insertOne(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#isCapped - isCapped(): Promise; - isCapped(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#listIndexes - listIndexes(options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce - mapReduce(map: Function | string, reduce: Function | string, callback: MongoCallback): void; - mapReduce(map: Function | string, reduce: Function | string, options?: MapReduceOptions): Promise; - mapReduce(map: Function | string, reduce: Function | string, options: MapReduceOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#options - options(): Promise; - options(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan - parallelCollectionScan(callback: MongoCallback): void; - parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise; - parallelCollectionScan(options: ParallelCollectionScanOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#reIndex - reIndex(): Promise; - reIndex(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#rename - rename(newName: string, callback: MongoCallback): void; - rename(newName: string, options?: { dropTarget?: boolean }): Promise; - rename(newName: string, options: { dropTarget?: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#replaceOne - replaceOne(filter: Object, doc: Object, callback: MongoCallback): void; - replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise; - replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#save - /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ - save(doc: Object, callback: MongoCallback): void; - save(doc: Object, options?: CollectionOptions): Promise; - save(doc: Object, options: CollectionOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#stats - stats(callback: MongoCallback): void; - stats(options?: { scale: number }): Promise; - stats(options: { scale: number }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#update - /** @deprecated use updateOne, updateMany or bulkWrite */ - update(filter: Object, update: Object, callback: MongoCallback): void; - /** @deprecated use updateOne, updateMany or bulkWrite */ - update(filter: Object, update: Object, options?: ReplaceOneOptions & { multi?: boolean }): Promise; - /** @deprecated use updateOne, updateMany or bulkWrite */ - update(filter: Object, update: Object, options: ReplaceOneOptions & { multi?: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateMany - updateMany(filter: Object, update: Object, callback: MongoCallback): void; - updateMany(filter: Object, update: Object, options?: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }): Promise; - updateMany(filter: Object, update: Object, options: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateOne - updateOne(filter: Object, update: Object, callback: MongoCallback): void; - updateOne(filter: Object, update: Object, options?: ReplaceOneOptions): Promise; - updateOne(filter: Object, update: Object, options: ReplaceOneOptions, callback: MongoCallback): void; -} - -// Documentation: http://docs.mongodb.org/manual/reference/command/collStats/ -//TODO complete this -export interface CollStats { - // Namespace. - ns: string; - // Number of documents. - count: number; - // Collection size in bytes. - size: number; - // Average object size in bytes. - avgObjSize: number; - // (Pre)allocated space for the collection in bytes. - storageSize: number; - // Number of extents (contiguously allocated chunks of datafile space). - numExtents: number; - // Number of indexes. - nindexes: number; - // Size of the most recently created extent in bytes. - lastExtentSize: number; - // Padding can speed up updates if documents grow. - paddingFactor: number; - userFlags: number; - // Total index size in bytes. - totalIndexSize: number; - // Size of specific indexes in bytes. - indexSizes: { - _id_: number; - username: number; - }; - capped: boolean; - maxSize: boolean; - wiredTiger: any; - indexDetails: any; - ok: number -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate -export interface CollectionAggregationOptions { - readPreference?: ReadPreference | string; - // Return the query as cursor, on 2.6 > it returns as a real cursor - // on pre 2.6 it returns as an emulated cursor. - cursor?: { batchSize: number }; - // Explain returns the aggregation execution plan (requires mongodb 2.6 >). - explain?: boolean; - // lets the server know if it can use disk to store - // temporary results for the aggregation (requires mongodb 2.6 >). - allowDiskUse?: boolean; - // specifies a cumulative time limit in milliseconds for processing operations - // on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. - maxTimeMS?: boolean; - // Allow driver to bypass schema validation in MongoDB 3.2 or higher. - bypassDocumentValidation?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany -export interface CollectionInsertManyOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; - // Serialize functions on any object. - serializeFunctions?: boolean; - //Force server to assign _id values instead of driver. - forceServerObjectId?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite -export interface CollectionBluckWriteOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; - // Serialize functions on any object. - serializeFunctions?: boolean; - // Execute write operation in ordered or unordered fashion. - ordered?: boolean; - // Allow driver to bypass schema validation in MongoDB 3.2 or higher. - bypassDocumentValidation?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~BulkWriteOpResult -export interface BulkWriteOpResultObject { - insertedCount?: number; - matchedCount?: number; - modifiedCount?: number; - deletedCount?: number; - upsertedCount?: number; - insertedIds?: any; - upsertedIds?: any; - result?: any; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#count -export interface MongoCountPreferences { - // The limit of documents to count. - limit?: number; - // The number of documents to skip for the count. - skip?: boolean; - // An index name hint for the query. - hint?: string; - // The preferred read preference - readPreference?: ReadPreference | string; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~deleteWriteOpResult -export interface DeleteWriteOpResultObject { - //The raw result returned from MongoDB, field will vary depending on server version. - result: { - //Is 1 if the command executed correctly. - ok?: number; - //The total count of documents deleted. - n?: number; - } - //The connection object used for the operation. - connection?: any; - //The number of documents deleted. - deletedCount?: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~findAndModifyWriteOpResult -export interface FindAndModifyWriteOpResultObject { - //Document returned from findAndModify command. - value?: any; - //The raw lastErrorObject returned from the command. - lastErrorObject?: any; - //Is 1 if the command executed correctly. - ok?: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace -export interface FindOneAndReplaceOption { - projection?: Object; - sort?: Object; - maxTimeMS?: number; - upsert?: boolean; - returnOriginal?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch -export interface GeoHaystackSearchOptions { - readPreference?: ReadPreference | string; - maxDistance?: number; - search?: Object; - limit?: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoNear -export interface GeoNearOptions { - readPreference?: ReadPreference | string; - num?: number; - minDistance?: number; - maxDistance?: number; - distanceMultiplier?: number; - query?: Object; - spherical?: boolean; - uniqueDocs?: boolean; - includeLocs?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Code.html -export class Code { - constructor(code: string | Function, scope?: Object) - code: string | Function; - scope: any; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany -export interface CollectionOptions { - //The write concern. - w?: number | string; - //The write concern timeout. - wtimeout?: number; - //Specify a journal write concern. - j?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html -export interface OrderedBulkOperation { - length: number; - //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#execute - execute(callback: MongoCallback): void; - execute(options?: FSyncOptions): Promise; - execute(options: FSyncOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#find - find(selector: Object): FindOperatorsOrdered; - //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#insert - insert(doc: Object): OrderedBulkOperation; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/BulkWriteResult.html -export interface BulkWriteResult { - ok: number; - nInserted: number; - nUpdated: number; - nUpserted: number; - nModified: number; - nRemoved: number; - - getInsertedIds(): Array; - getLastOp(): Object; - getRawResponse(): Object; - getUpsertedIdAt(index: number): Object; - getUpsertedIds(): Array; - getWriteConcernError(): WriteConcernError; - getWriteErrorAt(index: number): WriteError; - getWriteErrorCount(): number; - getWriteErrors(): Array; - hasWriteErrors(): boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/WriteError.html -export interface WriteError { - //Write concern error code. - code: number; - //Write concern error original bulk operation index. - index: number; - //Write concern error message. - errmsg: string; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/WriteConcernError.html -export interface WriteConcernError { - //Write concern error code. - code: number; - //Write concern error message. - errmsg: string; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/FindOperatorsOrdered.html -export interface FindOperatorsOrdered { - delete(): OrderedBulkOperation; - deleteOne(): OrderedBulkOperation; - replaceOne(doc: Object): OrderedBulkOperation; - update(doc: Object): OrderedBulkOperation; - updateOne(doc: Object): OrderedBulkOperation; - upsert(): FindOperatorsOrdered; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html -export interface UnorderedBulkOperation { - //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#execute - execute(callback: MongoCallback): void; - execute(options?: FSyncOptions): Promise; - execute(options: FSyncOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#find - find(selector: Object): FindOperatorsUnordered; - //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#insert - insert(doc: Object): UnorderedBulkOperation; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/FindOperatorsUnordered.html -export interface FindOperatorsUnordered { - length: number; - remove(): UnorderedBulkOperation; - removeOne(): UnorderedBulkOperation; - replaceOne(doc: Object): UnorderedBulkOperation; - update(doc: Object): UnorderedBulkOperation; - updateOne(doc: Object): UnorderedBulkOperation; - upsert(): FindOperatorsUnordered; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne -export interface FindOneOptions { - limit?: number, - sort?: Array | Object, - fields?: Object, - skip?: number, - hint?: Object, - explain?: boolean, - snapshot?: boolean, - timeout?: boolean, - tailable?: boolean, - batchSize?: number, - returnKey?: boolean, - maxScan?: number, - min?: number, - max?: number, - showDiskLoc?: boolean, - comment?: string, - raw?: boolean, - readPreference?: ReadPreference | string, - partial?: boolean, - maxTimeMs?: number -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~insertWriteOpResult -export interface InsertWriteOpResult { - insertedCount: number; - ops: Array; - insertedIds: Array; - connection: any; - result: { ok: number, n: number } -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne -export interface CollectionInsertOneOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; - // Serialize functions on any object. - serializeFunctions?: boolean; - //Force server to assign _id values instead of driver. - forceServerObjectId?: boolean; - //Allow driver to bypass schema validation in MongoDB 3.2 or higher. - bypassDocumentValidation?: boolean -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~insertOneWriteOpResult -export interface InsertOneWriteOpResult { - insertedCount: number; - ops: Array; - insertedId: ObjectID; - connection: any; - result: { ok: number, n: number } -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan -export interface ParallelCollectionScanOptions { - readPreference?: ReadPreference | string; - batchSize?: number; - numCursors?: number; - raw?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#replaceOne -export interface ReplaceOneOptions { - upsert?: boolean; - w?: number | string; - wtimeout?: number; - j?: boolean; - bypassDocumentValidation?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~updateWriteOpResult -export interface UpdateWriteOpResult { - result: { ok: number, n: number, nModified: number }; - connection: any; - matchedCount: number; - modifiedCount: number; - upsertedCount: number; - upsertedId: { _id: ObjectID }; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce -export interface MapReduceOptions { - readPreference?: ReadPreference | string; - out?: Object; - query?: Object; - sort?: Object; - limit?: number; - keeptemp?: boolean; - finalize?: Function | string; - scope?: Object; - jsMode?: boolean; - verbose?: boolean; - bypassDocumentValidation?: boolean -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~WriteOpResult -export interface WriteOpResult { - ops: Array; - connection: any; - result: any; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/external-Readable.html -export interface Readable { - pause(): void; - pipe(destination: Writable, options?: Object): void; - read(size: number): string | Buffer | void; - resume(): void; - setEncoding(encoding: string): void; - unpipe(destination?: Writable): void; - unshift(stream: Buffer | string): void; - wrap(stream: Stream): void; -} - -export interface Writable { } -export interface Stream { } - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~resultCallback -export type CursorResult = any | void | boolean; - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html -export interface Cursor extends Readable, NodeJS.EventEmitter { - - sortValue: string; - timeout: boolean; - readPreference: ReadPreference; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html - addCursorFlag(flag: string, value: boolean): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#addQueryModifier - addQueryModifier(name: string, value: boolean): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#batchSize - batchSize(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#clone - clone(): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#close - close(): Promise; - close(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#comment - comment(value: string): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#count - count(applySkipLimit: boolean, callback: MongoCallback): void; - count(applySkipLimit: boolean, options?: CursorCommentOptions): Promise; - count(applySkipLimit: boolean, options: CursorCommentOptions, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#explain - explain(): Promise; - explain(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#filter - filter(filter: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#forEach - forEach(iterator: IteratorCallback, callback: EndCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#hasNext - hasNext(): Promise; - hasNext(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#hint - hint(hint: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#isClosed - isClosed(): boolean; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#limit - limit(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#map - map(transform: Function): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#max - max(max: number): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxAwaitTimeMS - maxAwaitTimeMS(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxScan - maxScan(maxScan: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxTimeMS - maxTimeMS(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#min - min(min: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#next - next(): Promise; - next(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#pause - pause(): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#pipe - pipe(destination: Writable, options?: Object): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#project - project(value: Object): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#read - read(size: number): string | Buffer | void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#resume - resume(): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#next - returnKey(returnKey: Object): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#rewind - rewind(): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setCursorOption - setCursorOption(field: string, value: Object): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setEncoding - setEncoding(encoding: string): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setReadPreference - setReadPreference(readPreference: string | ReadPreference): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#showRecordId - showRecordId(showRecordId: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#skip - skip(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#snapshot - snapshot(snapshot: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#sort - sort(keyOrList: string | Object[] | Object | Object, direction?: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#stream - stream(options?: { transform?: Function }): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#toArray - toArray(): Promise; - toArray(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#unpipe - unpipe(destination?: Writable): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#unshift - unshift(stream: Buffer | string): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#wrap - wrap(stream: Stream): void; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#count -export interface CursorCommentOptions { - skip?: number; - limit?: number; - maxTimeMS?: number; - hint?: string; - readPreference?: ReadPreference | string; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~iteratorCallback -export interface IteratorCallback { - (doc: any): void; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~endCallback -export interface EndCallback { - (error: MongoError): void; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#~resultCallback -export type AggregationCursorResult = any | void; - -//http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html -export interface AggregationCursor extends Readable, NodeJS.EventEmitter { - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#batchSize - batchSize(value: number): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#clone - clone(): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#close - close(): Promise; - close(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#each - each(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#explain - explain(): Promise; - explain(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#geoNear - geoNear(document: Object): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#group - group(document: Object): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#isClosed - isClosed(): boolean; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#limit - limit(value: number): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#match - match(document: Object): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#maxTimeMS - maxTimeMS(value: number): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#next - next(): Promise; - next(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#out - out(destination: string): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#pause - pause(): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#pipe - pipe(destination: Writable, options?: Object): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#project - project(document: Object): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#read - read(size: number): string | Buffer | void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#redact - redact(document: Object): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#resume - resume(): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#rewind - rewind(): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#setEncoding - setEncoding(encoding: string): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#skip - skip(value: number): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#sort - sort(document: Object): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#toArray - toArray(): Promise; - toArray(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unpipe - unpipe(destination?: Writable): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unshift - unshift(stream: Buffer | string): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unwind - unwind(field: string): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#wrap - wrap(stream: Stream): void; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html -export interface CommandCursor extends Readable, NodeJS.EventEmitter { - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#batchSize - batchSize(value: number): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#clone - clone(): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#close - close(): Promise; - close(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#each - each(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#isClosed - isClosed(): boolean; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#maxTimeMS - maxTimeMS(value: number): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#next - next(): Promise; - next(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#pause - pause(): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#pipe - pipe(destination: Writable, options?: Object): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#read - read(size: number): string | Buffer | void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#resume - resume(): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#rewind - rewind(): CommandCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#setEncoding - setEncoding(encoding: string): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#setReadPreference - setReadPreference(readPreference: string | ReadPreference): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#toArray - toArray(): Promise; - toArray(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#unpipe - unpipe(destination?: Writable): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#unshift - unshift(stream: Buffer | string): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#wrap - wrap(stream: Stream): void; -} -} -declare module '~iridium~mongodb' { -import alias = require('~iridium~mongodb/mongodb'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/Cursor.d.ts -declare module '~iridium/dist/lib/Cursor' { -import { Model } from '~iridium/dist/lib/Model'; -import * as General from '~iridium/dist/lib/General'; -import * as MongoDB from '~iridium~mongodb'; -import * as Bluebird from '~iridium~bluebird'; -import * as Index from '~iridium/dist/lib/Index'; -/** - * An Iridium collection cursor which allows the itteration through documents - * in the collection, automatically wrapping them in the correct instance type. - * - * @param TDocument The interface representing the collection's documents - * @param TInstance The interface or class used to represent the wrapped documents. - */ -export class Cursor { - private model; - private conditions; - cursor: MongoDB.Cursor; - /** - * Creates a new Iridium cursor which wraps a MongoDB cursor object - * @param {Model} model The Iridium model that this cursor belongs to - * @param {Object} conditions The conditions that resulte in this cursor being created - * @param {MongoDB.Cursor} cursor The MongoDB native cursor object to be wrapped - * @constructor - */ - constructor(model: Model, conditions: any, cursor: MongoDB.Cursor); - /** - * Counts the number of documents which are matched by this cursor - * @param {function(Error, Number)} callback A callback which is triggered when the result is available - * @return {Promise} A promise which will resolve with the number of documents matched by this cursor - */ - count(callback?: General.Callback): Bluebird; - /** - * Runs the specified handler over each instance in the query results - * @param {function(Instance)} handler The handler which is triggered for each element in the query - * @param {function(Error)} callback A callback which is triggered when all operations have been dispatched - * @return {Promise} A promise which is resolved when all operations have been dispatched - */ - forEach(handler: (instance: TInstance) => void, callback?: General.Callback): Bluebird; - /** - * Runs the specified transform over each instance in the query results and returns the resulting transformed objects - * @param {function(Instance): TResult} transform A handler which is used to transform the result objects - * @param {function(Error, TResult[])} callback A callback which is triggered when the transformations are completed - * @return {Promise} A promise which is fulfilled with the results of the transformations - */ - map(transform: (instance: TInstance) => TResult | Bluebird, callback?: General.Callback): Bluebird; - /** - * Retrieves all matching instances and returns them in an array - * @param {function(Error, TInstance[])} callback A callback which is triggered with the resulting instances - * @return {Promise} A promise which resolves with the instances returned by the query - */ - toArray(callback?: General.Callback): Bluebird; - /** - * Retrieves the next item in the results list - * @param {function(Error, TInstance)} callback A callback which is triggered when the next item becomes available - * @return {Promise} A promise which is resolved with the next item - */ - next(callback?: General.Callback): Bluebird; - /** - * Retrieves the next item in the result list and then closes the cursor - * @param {function(Error, TInstance)} callback A callback which is triggered when the next item becomes available - * @return {Promise} A promise which is resolved once the item becomes available and the cursor has been closed. - */ - one(callback?: General.Callback): Bluebird; - /** - * Returns a new cursor which behaves the same as this one did before any results were retrieved - * @return {Cursor} The new cursor which starts at the beginning of the results - */ - rewind(): Cursor; - /** - * Returns a new cursor which sorts its results by the given index expression - * @param {model.IndexSpecification} sortExpression The index expression dictating the sort order and direction to use - * @return {Cursor} The new cursor which sorts its results by the sortExpression - */ - sort(sortExpression: Index.IndexSpecification): Cursor; - /** - * Returns a new cursor which limits the number of returned results - * @param {Number} limit The maximum number of results to return - * @return {Cursor} The new cursor which will return a maximum number of results - */ - limit(limit: number): Cursor; - /** - * Returns a new cursor which skips a number of results before it begins - * returning any. - * @param {Number} skip The number of results to skip before the cursor beings returning - * @return {Cursor} The new cursor which skips a number of results - */ - skip(skip: number): Cursor; - /** - * Returns a new cursor which will read from the specified node type. - * @param {String} type The type of node to read from - see https://docs.mongodb.org/manual/core/read-preference/ - * @return {Cursor} The new cursor which reads from the specified node type - */ - readFrom(type: string): Cursor; -} -} -declare module 'iridium/dist/lib/Cursor' { -import alias = require('~iridium/dist/lib/Cursor'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/ModelCache.d.ts -declare module '~iridium/dist/lib/ModelCache' { -import { Model } from '~iridium/dist/lib/Model'; -import * as Bluebird from '~iridium~bluebird'; -/** - * A centralized class which ties the cache and cache directors together in a cohesive way - * for use by Iridium. - * @internal - */ -export class ModelCache { - model: Model; - constructor(model: Model); - set(value: T): void; - get(conditions: any): Bluebird; - clear(conditions: any): void; -} -} -declare module 'iridium/dist/lib/ModelCache' { -import alias = require('~iridium/dist/lib/ModelCache'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/ModelHelpers.d.ts -declare module '~iridium/dist/lib/ModelHelpers' { -import { Model } from '~iridium/dist/lib/Model'; -import * as Skmatc from '~iridium~skmatc'; -/** - * A number of helper methods used commonly within Iridium, they provide a means to transform, - * validate, wrap and diff instances and documents. By keeping these methods in one place we - * help to improve testability and reduce code duplication (mouse abuse) throughout the codebase. - * @internal - */ -export class ModelHelpers { - model: Model; - constructor(model: Model); - private _validator; - /** - * Validates a document to ensure that it matches the model's ISchema requirements - * @param {any} document The document to validate against the ISchema - * @returns {SkmatcCore.IResult} The result of the validation - */ - validate(document: TDocument): Skmatc.Result; - /** - * Wraps the given document in an instance wrapper for use throughout the application - * @param {any} document The document to be wrapped as an instance - * @param {Boolean} isNew Whether the instance originated from the database or was created by the application - * @param {Boolean} isPartial Whether the document supplied contains all information present in the database - * @returns {any} An instance which wraps this document - */ - wrapDocument(document: TDocument, isNew?: boolean, isPartial?: boolean): TInstance; - /** - * Converts the given document to its database form into a form - * using the transforms defined on the model. - * @param {any} document The document to be converted - * @returns {any} The result of having transformed the document. - * @remarks This is only really called from insert/create - as - */ - transformToDB(document: T, options?: TransformOptions): T; - /** - * Converts the given document from its database form using the - * transforms defined on the model. - * @param document The document to be converted. - * @returns The result of having transformed the document. - * @remarks Unlike the transformToDB function - this method only applies - * document level transforms, as property level transforms are applied in - * their relevant instance setters. - */ - transformFromDB(document: TDocument, options?: TransformOptions): TDocument; - /** - * Converts the given document to its database form into a form - * using the transforms defined on the model. - * @param document The document to be converted - * @param processProperties Whether or not to process properties in addition - * document level transforms. - * @returns {any} A new document cloned from the original and transformed - */ - convertToDB(document: T, options?: TransformOptions): T; - /** - * Performs a diff operation between two documents and creates a MongoDB changes object to represent the differences - * @param {any} original The original document prior to changes being made - * @param {any} modified The document after changes were made - */ - diff(original: TDocument, modified: TDocument): any; - /** - * Clones the given document recursively, taking into account complex types like - * Buffers correctly. - * - * @param {any} The document you wish to clone deeply. - */ - cloneDocument(original: T): T; - /** - * Clones the given document recursively, taking into account complex types like - * Buffers correctly. Optimized for working with query documents instead of true - * documents. - * - * @param {any} The document you wish to clone deeply. - */ - cloneConditions(original: T): T; -} -export interface TransformOptions { - properties?: boolean; - document?: boolean; -} -} -declare module 'iridium/dist/lib/ModelHelpers' { -import alias = require('~iridium/dist/lib/ModelHelpers'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/ModelHandlers.d.ts -declare module '~iridium/dist/lib/ModelHandlers' { -import { Model } from '~iridium/dist/lib/Model'; -import * as ModelOptions from '~iridium/dist/lib/ModelOptions'; -import * as Bluebird from '~iridium~bluebird'; -/** - * Provides a number of methods which are used to handle events that occur within - * the Iridium workflow - such as what happens when a document is received from - * the database, or how to handle the creation of new documents and saving of instances. - * - * Mostly this is for cache support, wrapping and hook triggering. - * @internal - */ -export class ModelHandlers { - model: Model; - constructor(model: Model); - documentReceived(conditions: any, result: TDocument, wrapper: (document: TDocument, isNew?: boolean, isPartial?: boolean) => TResult, options?: ModelOptions.QueryOptions): Bluebird; - creatingDocuments(documents: TDocument[]): Bluebird; - savingDocument(instance: TInstance, changes: any): Bluebird; -} -} -declare module 'iridium/dist/lib/ModelHandlers' { -import alias = require('~iridium/dist/lib/ModelHandlers'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/ModelInterfaces.d.ts -declare module '~iridium/dist/lib/ModelInterfaces' { -/** - * The interface to which a prepared instance constructor should conform. When called with a document - * object, it should instantiate a new instance of type TInstance which is associated with its parent - * model. - * - * This is primarily used internally for prepared model instance constructors. - * - * @param TDocument The interface used to describe the structure of the documents found in the database collection. - * @param TInstance The interface or class used to wrap the documents returned from the database. - * - * @internal - */ -export interface ModelSpecificInstanceConstructor { - new (doc: TDocument, isNew?: boolean, isPartial?: boolean): TInstance; -} -} -declare module 'iridium/dist/lib/ModelInterfaces' { -import alias = require('~iridium/dist/lib/ModelInterfaces'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/InstanceInterface.d.ts -declare module '~iridium/dist/lib/InstanceInterface' { -import * as Skmatc from '~iridium~skmatc'; -import { Schema } from '~iridium/dist/lib/Schema'; -import { Model } from '~iridium/dist/lib/Model'; -import * as Index from '~iridium/dist/lib/Index'; -import { CacheDirector } from '~iridium/dist/lib/CacheDirector'; -import { Transforms } from '~iridium/dist/lib/Transforms'; -/** - * This interface dictates the format of an instance class which wraps documents received - * from the database for a specific Iridium model. - * - * @param TDocument The interface representing the documents stored in the database, after being passed through the transforms pipeline. - * @param TInstance The type of object which is instantiated when calling this implementation's constructor. - * - * It is important to note that, when implementing this interface, each of the properties and methods - * should be exposed statically. That is, you would expose the collection property as a static variable - * on the instance implementation, since prototype methods and variables become available to consumers of the - * instance itself. - */ -export interface InstanceImplementation { - /** - * A constructor which creates a new instance tied to the given model and representing the given document. - * @param model The Iridium Model which this instance should be tied to, gives the instance access to the database collection and any other context it requires. - * @param doc The document this instance should wrap from the database. This provides the data context for the instance. - * @param isNew Whether this document is known to exist in the database or not, for example, if the instance was generated from user input and hasn't been saved yet. - * @param isPartial Whether the document which has been given to this instance had any field restrictions imposed on it during the query, and may therefore only contain partial data. - */ - new (model: Model, doc: TDocument, isNew?: boolean, isPartial?: boolean): TInstance; - /** - * The name of the database collection from which documents are retrieved, and to which they are stored. - */ - collection: string; - /** - * The database schematic used for validation of instances prior to storing them in the database. - * This schematic should follow the guides set out in skmatc's documentation, and is used whenever - * you insert a new document into the collection or save an instance using the default instance type. - * Operations like update() (and by extension, save() when using the update operations) cannot be checked - * by skmatc for consistency and as a result will not have their data validated - be careful when making - * use of them as a result. - */ - schema: Schema; - /** - * Any additional indexes on the collection which should be managed by Iridium. - * This field is optional, but if provided allows you to make use of the model's ensureIndexes() method - * to automatically generate all specified indexes. - */ - indexes?: (Index.Index | Index.IndexSpecification)[]; - /** - * An optional method which will be called whenever a document is about to be inserted into the database, - * allowing you to set default values and do any preprocessing you wish prior to the document being inserted. - * - * @param document The document which will be inserted into the database. - * - * This method is executed synchronously, however you can perform asynchronous operations by returning a - * promise which resolves once your task has completed. Be aware that this method is executed for every - * document inserted into the database. As a result, long running tasks will have a significant impact - * on the performance of your inserts. - */ - onCreating?(document: TDocument): Promise | PromiseLike | void; - /** - * An optional method which is called whenever a new document is received from the model's collection and - * prior to the document being wrapped, can be used to perform preprocessing if necessary - however we recommend - * you rather make use of transforms for that task. - * - * @param document The document that was retrieved from the database. - * - * This method is executed synchronously, however you can perform asynchronous operations by returning a - * promise which resolves once your task has completed. Be aware that this method is executed for every - * document retrieved from the database. As a result, long running tasks will have a significant impact - * on the performance of your queries. - */ - onRetrieved?(document: TDocument): Promise | PromiseLike | void; - /** - * An optional method which is called whenever a new document for this model has been wrapped in an instance. - * - * @param instance The instance which has been created. - * - * This method is executed synchronously, however you can perform asynchronous operations by returning a - * promise which resolves once your task has completed. Be aware that this method is executed for every - * document retrieved from the database. As a result, long running tasks will have a significant impact - * on the performance of your queries. - */ - onReady?(instance: TInstance): Promise | PromiseLike | void; - /** - * An optional method which is called prior to saving an instance, it is provided with the instance itself as - * well as the proposed changes to the instance. This allows you to make additional changes, such as updating - * a lastChanged property on the document, or abort changes by throwing an error. - * - * @param instance The instance to which the changes are being made - * @param changes The MongoDB change object describing the changes being made to the document. - * - * This method is executed synchronously, however you can perform asynchronous operations by returning a - * promise which resolves once your task has completed. Be aware that this method is executed for every - * call to save. As a result, long running tasks will have a significant impact on how quickly your save - * operations are dispatched. - */ - onSaving?(instance: TInstance, changes: any): Promise | PromiseLike | void; - /** - * The cache controller used to determine whether a document may be cached, as well as deriving a unique cache - * key for the document and similarly, for a query. This works in concert with the cache implementation itself - * to ensure that documents are cached in an intelligent manner. By default this will simply make use of the - * document's _id field as the cache key - however that behaviour may be modified if you wish to query on other - * properties instead. - */ - cache?: CacheDirector; - /** - * Any additional validation types you wish to make available for use within this model's database schema. This - * allows you to validate using conditions otherwise not available within skmatc itself. For more information - * on implementing a validator, take a look at the skmatc documentation on GitHub. - */ - validators?: Skmatc.Validator[]; - /** - * Any transform operations you would like to perform on documents received from the database, or prior to being - * sent to the database. These may include things such as converting ObjectIDs to strings for the application, and - * then back to ObjectIDs once they return to the database. - */ - transforms?: Transforms; -} -} -declare module 'iridium/dist/lib/InstanceInterface' { -import alias = require('~iridium/dist/lib/InstanceInterface'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/Aggregate.d.ts -declare module '~iridium/dist/lib/Aggregate' { -export interface Stage { -} -} -declare module 'iridium/dist/lib/Aggregate' { -import alias = require('~iridium/dist/lib/Aggregate'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/Model.d.ts -declare module '~iridium/dist/lib/Model' { -import * as MongoDB from '~iridium~mongodb'; -import * as Bluebird from '~iridium~bluebird'; -import * as Skmatc from '~iridium~skmatc'; -import { Core } from '~iridium/dist/lib/Core'; -import { Schema } from '~iridium/dist/lib/Schema'; -import { Hooks } from '~iridium/dist/lib/Hooks'; -import { CacheDirector } from '~iridium/dist/lib/CacheDirector'; -import * as General from '~iridium/dist/lib/General'; -import { Cursor } from '~iridium/dist/lib/Cursor'; -import * as Index from '~iridium/dist/lib/Index'; -import * as ModelOptions from '~iridium/dist/lib/ModelOptions'; -import { ModelCache } from '~iridium/dist/lib/ModelCache'; -import { ModelHelpers } from '~iridium/dist/lib/ModelHelpers'; -import { ModelHandlers } from '~iridium/dist/lib/ModelHandlers'; -import * as ModelInterfaces from '~iridium/dist/lib/ModelInterfaces'; -import { InstanceImplementation } from '~iridium/dist/lib/InstanceInterface'; -import { Transforms } from '~iridium/dist/lib/Transforms'; -import * as AggregationPipeline from '~iridium/dist/lib/Aggregate'; -/** - * An Iridium Model which represents a structured MongoDB collection. - * Models expose the methods you will generally use to query those collections, and ensure that - * the results of those queries are returned as {TInstance} instances. - * - * @param TDocument The interface used to determine the schema of documents in the collection. - * @param TInstance The interface or class used to represent collection documents in the JS world. - * - * @class - */ -export class Model { - /** - * Creates a new Iridium model representing a given ISchema and backed by a collection whose name is specified - * @param core The Iridium core that this model should use for database access - * @param instanceType The class which will be instantiated for each document retrieved from the database - * @constructor - */ - constructor(core: Core, instanceType: InstanceImplementation); - /** - * Loads any externally available properties (generally accessed using public getters/setters). - */ - private loadExternal(instanceType); - /** - * Loads any internally (protected/private) properties and helpers only used within Iridium itself. - */ - private loadInternal(); - /** - * Process any callbacks and plugin delegation for the creation of this model. - * It will generally be called whenever a new Iridium Core is created, however is - * more specifically tied to the lifespan of the models themselves. - */ - private onNewModel(); - private _helpers; - /** - * Provides helper methods used by Iridium for common tasks - * @returns A set of helper methods which are used within Iridium for common tasks - */ - helpers: ModelHelpers; - private _handlers; - /** - * Provides helper methods used by Iridium for hook delegation and common processes - * @returns A set of helper methods which perform common event and response handling tasks within Iridium. - */ - handlers: ModelHandlers; - private _hooks; - /** - * Gets the even hooks subscribed on this model for a number of different state changes. - * These hooks are primarily intended to allow lifecycle manipulation logic to be added - * in the user's model definition, allowing tasks such as the setting of default values - * or automatic client-side joins to take place. - */ - hooks: Hooks; - private _schema; - /** - * Gets the schema dictating the data structure represented by this model. - * The schema is used by skmatc to validate documents before saving to the database, however - * until MongoDB 3.1 becomes widely available (with server side validation support) we are - * limited in our ability to validate certain types of updates. As such, these validations - * act more as a data-integrity check than anything else, unless you purely make use of Omnom - * updates within instances. - * @public - * @returns The defined validation schema for this model - */ - schema: Schema; - private _core; - /** - * Gets the Iridium core that this model is associated with. - * @public - * @returns The Iridium core that this model is bound to - */ - core: Core; - private _collection; - /** - * Gets the underlying MongoDB collection from which this model's documents are retrieved. - * You can make use of this object if you require any low level access to the MongoDB collection, - * however we recommend you make use of the Iridium methods whereever possible, as we cannot - * guarantee the accuracy of the type definitions for the underlying MongoDB driver. - * @public - * @returns {Collection} - */ - collection: MongoDB.Collection; - /** - * Gets the name of the underlying MongoDB collection from which this model's documents are retrieved - * @public - */ - /** - * Sets the name of the underlying MongoDB collection from which this model's documents are retrieved - * @public - */ - collectionName: string; - private _cacheDirector; - /** - * Gets the cache controller which dictates which queries will be cached, and under which key - * @public - * @returns {CacheDirector} - */ - cacheDirector: CacheDirector; - private _cache; - /** - * Gets the cache responsible for storing objects for quick retrieval under certain conditions - * @public - * @returns {ModelCache} - */ - cache: ModelCache; - private _Instance; - /** - * Gets the constructor responsible for creating instances for this model - */ - Instance: ModelInterfaces.ModelSpecificInstanceConstructor; - private _transforms; - /** - * Gets the transforms which are applied whenever a document is received from the database, or - * prior to storing a document in the database. Tasks such as converting an ObjectID to a string - * and vice versa are all listed in this object. - */ - transforms: Transforms; - private _validators; - /** - * Gets the custom validation types available for this model. These validators are added to the - * default skmatc validators, as well as those available through plugins, for use when checking - * your instances. - */ - validators: Skmatc.Validator[]; - private _indexes; - /** - * Gets the indexes which Iridium will manage on this model's database collection. - */ - indexes: (Index.Index | Index.IndexSpecification)[]; - /** - * Retrieves all documents in the collection and wraps them as instances - * @param {function(Error, TInstance[])} callback An optional callback which will be triggered when results are available - * @returns {Promise} - */ - find(): Cursor; - /** - * Returns all documents in the collection which match the conditions and wraps them as instances - * @param {Object} conditions The MongoDB query dictating which documents to return - * @returns {Promise} - */ - find(conditions: { - _id?: any; - [key: string]: any; - } | any): Cursor; - /** - * Returns all documents in the collection which match the conditions - * @param {Object} conditions The MongoDB query dictating which documents to return - * @param {Object} fields The fields to include or exclude from the document - * @returns {Promise} - */ - find(conditions: { - _id?: any; - [key: string]: any; - } | any, fields: { - [name: string]: number; - }): Cursor; - /** - * Retrieves a single document from the collection and wraps it as an instance - * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available - * @returns {Promise} - */ - get(callback?: General.Callback): Bluebird; - /** - * Retrieves a single document from the collection with the given ID and wraps it as an instance - * @param {any} id The document's unique _id field value in downstream format - * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available - * @returns {Promise} - */ - get(id: any, callback?: General.Callback): Bluebird; - /** - * Retrieves a single document from the collection which matches the conditions - * @param {Object} conditions The MongoDB query dictating which document to return - * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available - * @returns {Promise} - */ - get(conditions: { - _id?: any; - [key: string]: any; - }, callback?: General.Callback): Bluebird; - /** - * Retrieves a single document from the collection with the given ID and wraps it as an instance - * @param {any} id The document's unique _id field value in downstream format - * @param {QueryOptions} options The options dictating how this function behaves - * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available - * @returns {Promise} - */ - get(id: any, options: ModelOptions.QueryOptions, callback?: General.Callback): Bluebird; - /** - * Retrieves a single document from the collection which matches the conditions - * @param {Object} conditions The MongoDB query dictating which document to return - * @param {QueryOptions} options The options dictating how this function behaves - * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available - * @returns {Promise} - */ - get(conditions: { - _id?: any; - [key: string]: any; - }, options: ModelOptions.QueryOptions, callback?: General.Callback): Bluebird; - /** - * Retrieves a single document from the collection and wraps it as an instance - * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available - * @returns {Promise} - */ - findOne(callback?: General.Callback): Bluebird; - /** - * Retrieves a single document from the collection with the given ID and wraps it as an instance - * @param {any} id The document's unique _id field value in downstream format - * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available - * @returns {Promise} - */ - findOne(id: any, callback?: General.Callback): Bluebird; - /** - * Retrieves a single document from the collection which matches the conditions - * @param {Object} conditions The MongoDB query dictating which document to return - * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available - * @returns {Promise} - */ - findOne(conditions: { - _id?: any; - [key: string]: any; - }, callback?: General.Callback): Bluebird; - /** - * Retrieves a single document from the collection with the given ID and wraps it as an instance - * @param {any} id The document's unique _id field value in downstream format - * @param {QueryOptions} options The options dictating how this function behaves - * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available - * @returns {Promise} - */ - findOne(id: any, options: ModelOptions.QueryOptions, callback?: General.Callback): Bluebird; - /** - * Retrieves a single document from the collection which matches the conditions - * @param {Object} conditions The MongoDB query dictating which document to return - * @param {QueryOptions} options The options dictating how this function behaves - * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available - * @returns {Promise} - */ - findOne(conditions: { - _id?: any; - [key: string]: any; - }, options: ModelOptions.QueryOptions, callback?: General.Callback): Bluebird; - /** - * Inserts an object into the collection after validating it against this model's schema - * @param {Object} object The object to insert into the collection - * @param {function(Error, TInstance)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - create(objects: TDocument, callback?: General.Callback): Bluebird; - /** - * Inserts an object into the collection after validating it against this model's schema - * @param {Object} object The object to insert into the collection - * @param {CreateOptions} options The options dictating how this function behaves - * @param {function(Error, TInstance)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - create(objects: TDocument, options: ModelOptions.CreateOptions, callback?: General.Callback): Bluebird; - /** - * Inserts the objects into the collection after validating them against this model's schema - * @param {Object[]} objects The objects to insert into the collection - * @param {function(Error, TInstance)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - create(objects: TDocument[], callback?: General.Callback): Bluebird; - /** - * Inserts the objects into the collection after validating them against this model's schema - * @param {Object[]} objects The objects to insert into the collection - * @param {CreateOptions} options The options dictating how this function behaves - * @param {function(Error, TInstance)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - create(objects: TDocument[], options: ModelOptions.CreateOptions, callback?: General.Callback): Bluebird; - /** - * Inserts an object into the collection after validating it against this model's schema - * @param {Object} object The object to insert into the collection - * @param {function(Error, TInstance)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - insert(objects: TDocument, callback?: General.Callback): Bluebird; - /** - * Inserts an object into the collection after validating it against this model's schema - * @param {Object} object The object to insert into the collection - * @param {CreateOptions} options The options dictating how this function behaves - * @param {function(Error, TInstance)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - insert(objects: TDocument, options: ModelOptions.CreateOptions, callback?: General.Callback): Bluebird; - /** - * Inserts the objects into the collection after validating them against this model's schema - * @param {Object[]} objects The objects to insert into the collection - * @param {function(Error, TInstance[])} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - insert(objects: TDocument[], callback?: General.Callback): Bluebird; - /** - * Inserts the objects into the collection after validating them against this model's schema - * @param {Object[]} objects The objects to insert into the collection - * @param {CreateOptions} options The options dictating how this function behaves - * @param {function(Error, TInstance[])} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - insert(objects: TDocument[], options: ModelOptions.CreateOptions, callback?: General.Callback): Bluebird; - /** - * Updates the documents in the backing collection which match the conditions using the given update instructions - * @param {Object} conditions The conditions which determine which documents will be updated - * @param {Object} changes The changes to make to the documents - * @param {function(Error, Number)} callback A callback which is triggered when the operation completes - */ - update(conditions: { - _id?: any; - [key: string]: any; - } | any, changes: any, callback?: General.Callback): Bluebird; - /** - * Updates the documents in the backing collection which match the conditions using the given update instructions - * @param {Object} conditions The conditions which determine which documents will be updated - * @param {Object} changes The changes to make to the documents - * @param {UpdateOptions} options The options which dictate how this function behaves - * @param {function(Error, Number)} callback A callback which is triggered when the operation completes - */ - update(conditions: { - _id?: any; - [key: string]: any; - } | any, changes: any, options: ModelOptions.UpdateOptions, callback?: General.Callback): Bluebird; - /** - * Counts the number of documents in the collection - * @param {function(Error, Number)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - count(callback?: General.Callback): Bluebird; - /** - * Counts the number of documents in the collection which match the conditions provided - * @param {Object} conditions The conditions which determine whether an object is counted or not - * @param {function(Error, Number)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - count(conditions: { - _id?: any; - [key: string]: any; - } | any, callback?: General.Callback): Bluebird; - /** - * Removes all documents from the collection - * @param {function(Error, Number)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - remove(callback?: General.Callback): Bluebird; - /** - * Removes all documents from the collection which match the conditions - * @param {Object} conditions The conditions determining whether an object is removed or not - * @param {function(Error, Number)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - remove(conditions: { - _id?: any; - [key: string]: any; - } | any, callback?: General.Callback): Bluebird; - /** - * Removes all documents from the collection which match the conditions - * @param {Object} conditions The conditions determining whether an object is removed or not - * @param {Object} options The options controlling the way in which the function behaves - * @param {function(Error, Number)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - remove(conditions: { - _id?: any; - [key: string]: any; - }, options: ModelOptions.RemoveOptions, callback?: General.Callback): Bluebird; - aggregate(pipeline: AggregationPipeline.Stage[]): Bluebird; - /** - * Ensures that the given index is created for the collection - * @param {Object} specification The index specification object used by MongoDB - * @param {function(Error, String)} callback A callback which is triggered when the operation completes - * @returns {Promise} The name of the index - */ - ensureIndex(specification: Index.IndexSpecification, callback?: General.Callback): Bluebird; - /** - * Ensures that the given index is created for the collection - * @param {Object} specification The index specification object used by MongoDB - * @param {MongoDB.IndexOptions} options The options dictating how the index is created and behaves - * @param {function(Error, String)} callback A callback which is triggered when the operation completes - * @returns {Promise} The name of the index - */ - ensureIndex(specification: Index.IndexSpecification, options: MongoDB.IndexOptions, callback?: General.Callback): Bluebird; - /** - * Ensures that all indexes defined in the model's options are created - * @param {function(Error, String[])} callback A callback which is triggered when the operation completes - * @returns {Promise} The names of the indexes - */ - ensureIndexes(callback?: General.Callback): Bluebird; - /** - * Drops the index with the specified name if it exists in the collection - * @param {String} name The name of the index to remove - * @param {function(Error, Boolean)} callback A callback which is triggered when the operation completes - * @returns {Promise} Whether the index was dropped - */ - dropIndex(name: string, callback?: General.Callback): Bluebird; - /** - * Drops the index if it exists in the collection - * @param {IndexSpecification} index The index to remove - * @param {function(Error, Boolean)} callback A callback which is triggered when the operation completes - * @returns {Promise} Whether the index was dropped - */ - dropIndex(index: Index.IndexSpecification, callback?: General.Callback): Bluebird; - /** - * Removes all indexes (except for _id) from the collection - * @param {function(Error, Boolean)} callback A callback which is triggered when the operation completes - * @returns {Promise} Whether the indexes were dropped - */ - dropIndexes(callback?: General.Callback): Bluebird; -} -} -declare module 'iridium/dist/lib/Model' { -import alias = require('~iridium/dist/lib/Model'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/General.d.ts -declare module '~iridium/dist/lib/General' { -/** - * A method which is called once an asynchronous operation has completed, an alternative - * to using Promises. - * @param T The type of object returned by the asynchronous operation. - */ -export interface Callback { - /** - * @param err The error object, if one occurred, otherwise null if the operation completed successfully. - * @param object The result of the asynchronous operation if it completed successfully. If err is defined, the presence of this value is unknown. - */ - (err: Error, object?: T): void; -} -/** - * A method which is used to determine whether a value within a collection meets a set of criteria. - * @param T The type of item in the collection. - */ -export interface Predicate { - /** - * @param object The value of the item in the collection - * @param key The key, if one is available, under which the item appeared within the collection - * @returns A true-y value if the item met the predicate conditions, false-y values if it did not. - */ - (object: T, key?: string): boolean; -} -/** - * A method which is called to retrieve a value of the given type. - * @param T The type of value to be retrieved. - */ -export interface PropertyGetter { - /** - * Gets the current value of the property - * @returns The current value - */ - (): T; -} -/** - * A method which is called to set a value of the given type. - * @param T The type of value to set - */ -export interface PropertySetter { - /** - * Sets the value to the provided one - * @param value The new value to set - */ - (value: T): void; -} -/** - * A compound property which provides either a getter, setter or both. - * @param T The type of objects stored in the property - */ -export interface Property { - /** - * An optional getter which can be used to retrieve the property's value - */ - get?: PropertyGetter; - /** - * An optional setter which can be used to set the property's value - */ - set?: PropertySetter; -} -} -declare module 'iridium/dist/lib/General' { -import alias = require('~iridium/dist/lib/General'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/Index.d.ts -declare module '~iridium/dist/lib/Index' { -import * as MongoDB from '~iridium~mongodb'; -export interface Index { - spec: IndexSpecification; - options?: MongoDB.IndexOptions; -} -export interface IndexSpecification { - [key: string]: number | string; -} -} -declare module 'iridium/dist/lib/Index' { -import alias = require('~iridium/dist/lib/Index'); -export = alias; -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-bluebird/8bd917a7ac4fef6796cd7fe5fc1d3b0fb118ad1a/bluebird.d.ts -declare module '~iridium~bluebird/bluebird' { -// Type definitions for Bluebird v3.x.x -// Project: http://bluebirdjs.com - -class Bluebird implements Bluebird.Thenable, Bluebird.Inspection { - /** - * Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise. - */ - constructor(callback: (resolve: (thenableOrResult: R | Bluebird.Thenable) => void, reject: (error: any) => void) => void); - - /** - * Promises/A+ `.then()`. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. - */ - then(onFulfill: (value: R) => U | Bluebird.Thenable, onReject?: (error: any) => U | Bluebird.Thenable): Bluebird; - then(onFulfill: (value: R) => U | Bluebird.Thenable, onReject?: (error: any) => void | Bluebird.Thenable): Bluebird; - - /** - * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler. - * - * Alias `.caught();` for compatibility with earlier ECMAScript version. - */ - catch(onReject?: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(onReject?: (error: any) => U | Bluebird.Thenable): Bluebird; - - /** - * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called. - * - * This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called. - * - * Alias `.caught();` for compatibility with earlier ECMAScript version. - */ - catch(predicate: (error: any) => boolean, onReject: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; - catch(ErrorClass: Function, onReject: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(ErrorClass: Function, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; - - /** - * Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections. - */ - error(onReject: (reason: any) => U | Bluebird.Thenable): Bluebird; - - /** - * Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler. - * - * Alias `.lastly();` for compatibility with earlier ECMAScript version. - */ - finally(handler: () => U | Bluebird.Thenable): Bluebird; - - lastly(handler: () => U | Bluebird.Thenable): Bluebird; - - /** - * Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise. - */ - bind(thisArg: any): Bluebird; - - /** - * Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error. - */ - done(onFulfilled?: (value: R) => U | Bluebird.Thenable, onRejected?: (error: any) => U | Bluebird.Thenable): void; - - /** - * Like `.finally()`, but not called for rejections. - */ - tap(onFulFill: (value: R) => Bluebird.Thenable): Bluebird; - tap(onFulfill: (value: R) => U): Bluebird; - - /** - * Same as calling `Promise.delay(ms, this)`. - */ - delay(ms: number): Bluebird; - - /** - * Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. - * However, if this promise is not fulfilled or rejected within ms milliseconds, the returned promise - * is rejected with a TimeoutError or the error as the reason. - * - * You may specify a custom error message with the `message` parameter. - */ - timeout(ms: number, message?: string | Error): Bluebird; - - /** - * Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success. - * If the `callback` argument is not a function, this method does not do anything. - */ - nodeify(callback: (err: any, value?: R) => void, options?: Bluebird.SpreadOption): this; - nodeify(...sink: any[]): this; - asCallback(callback: (err: any, value?: R) => void, options?: Bluebird.SpreadOption): this; - asCallback(...sink: any[]): this; - - /** - * See if this `promise` has been fulfilled. - */ - isFulfilled(): boolean; - - /** - * See if this `promise` has been rejected. - */ - isRejected(): boolean; - - /** - * See if this `promise` is still defer. - */ - isPending(): boolean; - - /** - * See if this `promise` is resolved -> either fulfilled or rejected. - */ - isResolved(): boolean; - - /** - * Get the fulfillment value of the underlying promise. Throws if the promise isn't fulfilled yet. - * - * throws `TypeError` - */ - value(): R; - - /** - * Get the rejection reason for the underlying promise. Throws if the promise isn't rejected yet. - * - * throws `TypeError` - */ - reason(): any; - - /** - * Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of - * the promise as snapshotted at the time of calling `.reflect()`. - */ - reflect(): Bluebird.Inspection; - - /** - * This is a convenience method for doing: - * - * - * promise.then(function(obj){ - * return obj[propertyName].call(obj, arg...); - * }); - * - */ - call(propertyName: string, ...args: any[]): Bluebird; - - /** - * This is a convenience method for doing: - * - * - * promise.then(function(obj){ - * return obj[propertyName]; - * }); - * - */ - // TODO: Use "type property type" once it's there - // @see https://github.com/Microsoft/TypeScript/issues/1295 - get(key: string | number): Bluebird; - - /** - * Convenience method for: - * - * - * .then(function() { - * return value; - * }); - * - * - * in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()` - * - * Alias `.thenReturn();` for compatibility with earlier ECMAScript version. - */ - return(): Bluebird; - thenReturn(): Bluebird; - return(value: U): Bluebird; - thenReturn(value: U): Bluebird; - - /** - * Convenience method for: - * - * - * .then(function() { - * throw reason; - * }); - * - * Same limitations apply as with `.return()`. - * - * Alias `.thenThrow();` for compatibility with earlier ECMAScript version. - */ - throw(reason: Error): Bluebird; - thenThrow(reason: Error): Bluebird; - - /** - * Convert to String. - */ - toString(): string; - - /** - * This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`. - */ - toJSON(): Object; - - /** - * Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers. - */ - spread(fulfilledHandler: (...values: W[]) => U | Bluebird.Thenable): Bluebird; - spread(fulfilledHandler: Function): Bluebird; - - /** - * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - all(): Bluebird; - - /** - * Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO how to model instance.props()? - props(): Bluebird; - - /** - * Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - any(): Bluebird; - - /** - * Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - some(count: number): Bluebird; - - /** - * Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - race(): Bluebird; - - /** - * Same as calling `Bluebird.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - map(mapper: (item: Q, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; - - /** - * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - reduce(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; - - /** - * Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - filter(filterer: (item: U, index: number, arrayLength: number) => boolean | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; - - /** - * Same as calling ``Bluebird.each(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - each(iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; - - /** - * Same as calling ``Bluebird.mapSeries(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - mapSeries(iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; - - /** - * Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise. - * - * Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call. - * - * Alias for `attempt();` for compatibility with earlier ECMAScript version. - */ - static try(fn: () => R | Bluebird.Thenable): Bluebird; - - static attempt(fn: () => R | Bluebird.Thenable): Bluebird; - - /** - * Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function. - * This method is convenient when a function can sometimes return synchronously or throw synchronously. - */ - static method(fn: Function): Function; - - /** - * Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state. - */ - static resolve(): Bluebird; - static resolve(value: R | Bluebird.Thenable): Bluebird; - - /** - * Create a promise that is rejected with the given `reason`. - */ - static reject(reason: any): Bluebird; - static reject(reason: any): Bluebird; - - /** - * Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?: Promise(#promise-resolution). - */ - static defer(): Bluebird.Resolver; - - /** - * Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable. - */ - static cast(value: R | Bluebird.Thenable): Bluebird; - - /** - * Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`. - */ - static bind(thisArg: any): Bluebird; - - /** - * See if `value` is a trusted Promise. - */ - static is(value: any): boolean; - - /** - * Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have already been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency. - */ - static longStackTraces(): void; - - /** - * Returns a promise that will be resolved with value (or undefined) after given ms milliseconds. - * If value is a promise, the delay will start counting down when it is fulfilled and the returned - * promise will be fulfilled with the fulfillment value of the value promise. - */ - static delay(ms: number, value: R | Bluebird.Thenable): Bluebird; - static delay(ms: number): Bluebird; - - /** - * Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument. - * - * If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them. - * - * If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`. - */ - static promisify(func: (callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): () => Bluebird; - static promisify(func: (arg1: A1, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird; - static promisify(nodeFunction: Function, options?: Bluebird.PromisifyOptions): Function; - - /** - * Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object. - * - * Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method. - */ - // TODO how to model promisifyAll? - static promisifyAll(target: Object, options?: Bluebird.PromisifyAllOptions): Object; - - /** - * Returns a promise that is resolved by a node style callback function. - */ - static fromNode(resolver: (callback: (err: any, result?: any) => void) => void, options?: Bluebird.FromNodeOptions): Bluebird; - static fromNode(resolver: (callback: (err: any, result?: T) => void) => void, options?: Bluebird.FromNodeOptions): Bluebird; - static fromCallback(resolver: (callback: (err: any, result?: any) => void) => void, options?: Bluebird.FromNodeOptions): Bluebird; - static fromCallback(resolver: (callback: (err: any, result?: T) => void) => void, options?: Bluebird.FromNodeOptions): Bluebird; - - /** - * Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. - */ - // TODO fix coroutine GeneratorFunction - static coroutine(generatorFunction: Function): Function; - - /** - * Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers. - * - * Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections. - */ - static onPossiblyUnhandledRejection(handler: (reason: any) => any): void; - - /** - * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason. - */ - // TODO enable more overloads - // array with promises of different types - static all(values: [Bluebird.Thenable | T1]): Bluebird<[T1]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2]): Bluebird<[T1, T2]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2, Bluebird.Thenable | T3]): Bluebird<[T1, T2, T3]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2, Bluebird.Thenable | T3, Bluebird.Thenable | T4]): Bluebird<[T1, T2, T3, T4]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2, Bluebird.Thenable | T3, Bluebird.Thenable | T4, Bluebird.Thenable | T5]): Bluebird<[T1, T2, T3, T4, T5]>; - // array with values - static all(values: ((R | Bluebird.Thenable) | Bluebird.Thenable<(R | Bluebird.Thenable)>)[]): Bluebird; - - /** - * Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason. - * - * If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties. - * - * *The original object is not modified.* - */ - // TODO verify this is correct - // trusted promise for object - static props(object: Bluebird): Bluebird; - // object - static props(object: Object): Bluebird; - - /** - * Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly. - */ - static any(values: Bluebird.Thenable<(Bluebird.Thenable | R)[]> | (Bluebird.Thenable | R)[]): Bluebird; - - /** - * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value. - * - * **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending. - */ - static race(values: Bluebird.Thenable<(Bluebird.Thenable | R)[]> | (Bluebird.Thenable | R)[]): Bluebird; - - /** - * Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution. - * - * If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in. - * - * *The original array is not modified.* - */ - // promise of array with promises of value - static some(values: Bluebird.Thenable[]>, count: number): Bluebird; - // promise of array with values - static some(values: Bluebird.Thenable, count: number): Bluebird; - // array with promises of value - static some(values: Bluebird.Thenable[], count: number): Bluebird; - // array with values - static some(values: R[], count: number): Bluebird; - - /** - * Promise.join( - * Promise|any values..., - * function handler - * ) -> Promise - * For coordinating multiple concurrent discrete promises. - * - * Note: In 1.x and 0.x Promise.join used to be a Promise.all that took the values in as arguments instead in an array. This behavior has been deprecated but is still supported partially - when the last argument is an immediate function value the new semantics will apply - */ - static join(arg1: A1 | Bluebird.Thenable, handler: (arg1?: A1) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, handler: (arg1?: A1, arg2?: A2) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, arg3: A3 | Bluebird.Thenable, handler: (arg1?: A1, arg2?: A2, arg3?: A3) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, arg3: A3 | Bluebird.Thenable, arg4: A4 | Bluebird.Thenable, handler: (arg1?: A1, arg2?: A2, arg3?: A3, arg4?: A4) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, arg3: A3 | Bluebird.Thenable, arg4: A4 | Bluebird.Thenable, arg5: A5 | Bluebird.Thenable, handler: (arg1?: A1, arg2?: A2, arg3?: A3, arg4?: A4, arg5?: A5) => R | Bluebird.Thenable): Bluebird; - - // variadic array - /** @deprecated use .all instead */ - static join(...values: (R | Bluebird.Thenable)[]): Bluebird; - - /** - * Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. - * - * If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well. - * - * *The original array is not modified.* - */ - // promise of array with promises of value - static map(values: Bluebird.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; - - // promise of array with values - static map(values: Bluebird.Thenable, mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; - - // array with promises of value - static map(values: Bluebird.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; - - // array with values - static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; - - /** - * Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. - * - * If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. - * - * *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.* - */ - // promise of array with promises of value - static reduce(values: Bluebird.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; - - // promise of array with values - static reduce(values: Bluebird.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; - - // array with promises of value - static reduce(values: Bluebird.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; - - // array with values - static reduce(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; - - /** - * Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. - * - * The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result. - * - * *The original array is not modified. - */ - // promise of array with promises of value - static filter(values: Bluebird.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; - - // promise of array with values - static filter(values: Bluebird.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; - - // array with promises of value - static filter(values: Bluebird.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; - - // array with values - static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; - - /** - * Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well. - * - * Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. - */ - // promise of array with promises of value - static each(values: Bluebird.Thenable[]>, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; - // array with promises of value - static each(values: Bluebird.Thenable[], iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; - // array with values OR promise of array with values - static each(values: R[] | Bluebird.Thenable, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; - - /** - * Given an Iterable(arrays are Iterable), or a promise of an Iterable, which produces promises (or a mix of promises and values), iterate over all the values in the Iterable into an array and iterate over the array serially, in-order. - * - * Returns a promise for an array that contains the values returned by the iterator function in their respective positions. The iterator won't be called for an item until its previous item, and the promise returned by the iterator for that item are fulfilled. This results in a mapSeries kind of utility but it can also be used simply as a side effect iterator similar to Array#forEach. - * - * If any promise in the input array is rejected or any promise returned by the iterator function is rejected, the result will be rejected as well. - */ - static mapSeries(values: (R | Bluebird.Thenable)[] | Bluebird.Thenable<(R | Bluebird.Thenable)[]>, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; - - /** - * A meta method used to specify the disposer method that cleans up a resource when using `Promise.using`. - * - * Returns a Disposer object which encapsulates both the resource as well as the method to clean it up. - * The user can pass this object to `Promise.using` to get access to the resource when it becomes available, - * as well as to ensure its automatically cleaned up. - * - * The second argument passed to a disposer is the result promise of the using block, which you can - * inspect synchronously. - */ - disposer(disposeFn: (arg: R, promise: Bluebird) => void | Bluebird.Thenable): Bluebird.Disposer; - - /** - * In conjunction with `.disposer`, using will make sure that no matter what, the specified disposer - * will be called when the promise returned by the callback passed to using has settled. The disposer is - * necessary because there is no standard interface in node for disposing resources. - */ - static using(disposer: Bluebird.Disposer, executor: (transaction: R) => Bluebird.Thenable): Bluebird; - static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2) => Bluebird.Thenable): Bluebird; - static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, disposer3: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2, transaction3: R3) => Bluebird.Thenable): Bluebird; - - /** - * Add handler as the handler to call when there is a possibly unhandled rejection. - * The default handler logs the error stack to stderr or console.error in browsers. - * - * Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections. - * - * Note: this hook is specific to the bluebird instance its called on, application developers should use global rejection events. - */ - static onPossiblyUnhandledRejection(handler?: (error: Error, promise: Bluebird) => void): void; - - /** - * Configure long stack traces, warnings, monitoring and cancellation. - * Note that even though false is the default here, a development environment might be detected which automatically - * enables long stack traces and warnings. - */ - static config(options: { - /** Enable warnings */ - warnings?: boolean | { - /** Enables all warnings except forgotten return statements. */ - wForgottenReturn: boolean; - }; - /** Enable long stack traces */ - longStackTraces?: boolean; - /** Enable cancellation */ - cancellation?: boolean; - /** Enable monitoring */ - monitoring?: boolean; - }): void; -} - -namespace Bluebird { - export interface ConcurrencyOption { - concurrency: number; - } - export interface SpreadOption { - spread: boolean; - } - export interface FromNodeOptions { - multiArgs?: boolean; - } - export interface PromisifyOptions { - context?: any; - multiArgs?: boolean; - } - export interface PromisifyAllOptions extends PromisifyOptions { - suffix?: string; - filter?: (name: string, func: Function, target?: any, passesDefaultFilter?: boolean) => boolean; - // The promisifier gets a reference to the original method and should return a function which returns a promise - promisifier?: (originalMethod: Function) => () => Thenable; - } - - /** - * Represents an error is an explicit promise rejection as opposed to a thrown error. - * For example, if an error is errbacked by a callback API promisified through undefined or undefined - * and is not a typed error, it will be converted to a `OperationalError` which has the original error in - * the `.cause` property. - * - * `OperationalError`s are caught in `.error` handlers. - */ - export class OperationalError extends Error { } - - /** - * Signals that an operation has timed out. Used as a custom cancellation reason in `.timeout`. - */ - export class TimeoutError extends Error { } - - /** - * Signals that an operation has been aborted or cancelled. The default reason used by `.cancel`. - */ - export class CancellationError extends Error {} - - /** - * A collection of errors. `AggregateError` is an array-like object, with numeric indices and a `.length` property. - * It supports all generic array methods such as `.forEach` directly. - * - * `AggregateError`s are caught in `.error` handlers, even if the contained errors are not operational. - * - * `Promise.some` and `Promise.any` use `AggregateError` as rejection reason when they fail. - */ - export class AggregateError extends Error {} - - /** - * returned by `Bluebird.disposer()`. - */ - export class Disposer { - } - - export interface Thenable { - then(onFulfilled: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; - then(onFulfilled: (value: R) => U | Thenable, onRejected?: (error: any) => void | Thenable): Thenable; - } - - export interface Resolver { - /** - * Returns a reference to the controlled promise that can be passed to clients. - */ - promise: Bluebird; - - /** - * Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state. - */ - resolve(value: R): void; - resolve(): void; - - /** - * Reject the underlying promise with `reason` as the rejection reason. - */ - reject(reason: any): void; - - /** - * Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions. - * - * If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values. - */ - // TODO specify resolver callback - callback: (err: any, value: R, ...values: R[]) => void; - } - - export interface Inspection { - /** - * See if the underlying promise was fulfilled at the creation time of this inspection object. - */ - isFulfilled(): boolean; - - /** - * See if the underlying promise was rejected at the creation time of this inspection object. - */ - isRejected(): boolean; - - /** - * See if the underlying promise was defer at the creation time of this inspection object. - */ - isPending(): boolean; - - /** - * Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object. - * - * throws `TypeError` - */ - value(): R; - - /** - * Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object. - * - * throws `TypeError` - */ - reason(): any; - } - - /** - * Changes how bluebird schedules calls a-synchronously. - * - * @param scheduler Should be a function that asynchronously schedules - * the calling of the passed in function - */ - export function setScheduler(scheduler: (callback: (...args: any[]) => void) => void): void; -} - -export = Bluebird; -} -declare module '~iridium~bluebird' { -import alias = require('~iridium~bluebird/bluebird'); -export = alias; -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/sierrasoftworks/skmatc/master/index.d.ts -declare module '~iridium~skmatc/index' { -export function scope(schema: any): Skmatc; - -export var validators: Validator[]; -export function create(handles: (schema: any) => boolean, validate: (schema: any, data: any, path: string) => Result, options?: { name?: string }): Validator; -export function validate(validators: Validator[], schema: any, data: any, path?: string): Result; -export function register(validator: Validator); - -export class Skmatc { - schema: any; - validators: Validator[]; - validate(data: any, path?: string): Result; - register(validator: Validator); -} - -export class Validator { - constructor(skmatc: Skmatc, options?: any); - static create(handles: (schema: any) => boolean, validate: (schema: any, data: any, path: string) => Result, options?: { name?: string }): Validator; - static module(handles: (schema: any) => boolean, validate: (schema: any, data: any, path: string) => Result, options?: { name?: string }): Validator; - - name: string; - skmatc: Skmatc; - handles(schema: any): boolean; - validate(schema: any, data: any, path: string): Result; - assert(schema: any, data: any, path: string, test: boolean, message?: string): Result; - fail(schema: any, data: any, path: string, message?: string): Result; -} - -export class Result { - constructor(failures: Failure[]); - static compound(results: Result[]): Result; - - failures: Failure[]; - success: boolean; - failed: boolean; - message: string; - messages: string[]; - error: Error; -} - -export class Failure { - constructor(validator: Validator, schema: any, data: any, path: string, message?: string); - validator: Validator; - schema: any; - data: any; - path: string; - message: string; -} - -export interface IValidationHandler { - (thisArg: { - validator: IValidationHandler; - skmatc: Skmatc; - fail(message?: string); - assert(test: boolean, message?: string); - }, schema: any, data: any, path: string): Result; -} -} -declare module '~iridium~skmatc' { -import alias = require('~iridium~skmatc/index'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/Instance.d.ts -declare module '~iridium/dist/lib/Instance' { -import { Model } from '~iridium/dist/lib/Model'; -import { CacheDirector } from '~iridium/dist/lib/CacheDirector'; -import * as General from '~iridium/dist/lib/General'; -import * as Index from '~iridium/dist/lib/Index'; -import { Schema } from '~iridium/dist/lib/Schema'; -import { Transforms } from '~iridium/dist/lib/Transforms'; -import * as Bluebird from '~iridium~bluebird'; -import * as Skmatc from '~iridium~skmatc'; -/** - * The default Iridium Instance implementation which provides methods for saving, refreshing and - * removing the wrapped document from the collection, as well as integrating with Omnom, our - * built in document diff processor which allows clean, atomic, document updates to be performed - * without needing to write the update queries yourself. - * - * @param TDocument The interface representing the structure of the documents in the collection. - * @param TInstance The type of instance which wraps the documents, generally the subclass of this class. - * - * This class will be subclassed automatically by Iridium to create a model specific instance - * which takes advantage of some of v8's optimizations to boost performance significantly. - * The instance returned by the model, and all of this instance's methods, will be of type - * TInstance - which should represent the merger of TSchema and IInstance for best results. - */ -export class Instance { - /** - * Creates a new instance which represents the given document as a type of model - * @param model The model that dictates the collection the document originated from as well as how validations are performed. - * @param document The document which should be wrapped by this instance - * @param isNew Whether the document is new (doesn't exist in the database) or not - * @param isPartial Whether the document has only a subset of its fields populated - * - */ - constructor(model: Model, document: TDocument, isNew?: boolean, isPartial?: boolean); - private _isNew; - private _isPartial; - private _model; - private _original; - private _modified; - /** - * Gets the underlying document representation of this instance - */ - document: TDocument; - [name: string]: any; - /** - * A function which is called whenever a new document is in the process of being inserted into the database. - * @param document The document which will be inserted into the database. - */ - static onCreating: (document: { - _id?: any; - }) => Promise | PromiseLike | void; - /** - * A function which is called whenever a document of this type is received from the database, prior to it being - * wrapped by an Instance object. - * @param document The document that was retrieved from the database. - */ - static onRetrieved: (document: { - _id?: any; - }) => Promise | PromiseLike | void; - /** - * A function which is called whenever a new instance has been created to wrap a document. - * @param instance The instance which has been created. - */ - static onReady: (instance: Instance<{ - _id?: any; - }, Instance<{ - _id?: any; - }, any>>) => Promise | PromiseLike | void; - /** - * A function which is called whenever an instance's save() method is called to allow you to interrogate and/or manipulate - * the changes which are being made. - * - * @param instance The instance to which the changes are being made - * @param changes The MongoDB change object describing the changes being made to the document. - */ - static onSaving: (instance: Instance<{ - _id?: any; - }, Instance<{ - _id?: any; - }, any>>, changes: any) => Promise | PromiseLike | void; - /** - * The name of the collection into which documents of this type are stored. - */ - static collection: string; - /** - * The schema used to validate documents of this type before being stored in the database. - */ - static schema: Schema; - /** - * Additional which should be made available for use in the schema definition for this instance. - */ - static validators: Skmatc.Validator[]; - /** - * The transformations which should be applied to properties of documents of this type. - */ - static transforms: Transforms; - /** - * The cache director used to derive unique cache keys for documents of this type. - */ - static cache: CacheDirector; - /** - * The indexes which should be managed by Iridium for the collection used by this type. - */ - static indexes: (Index.Index | Index.IndexSpecification)[]; - /** - * Saves any changes to this instance, using the built in diff algorithm to write the update query. - * @param {function(Error, IInstance)} callback A callback which is triggered when the save operation completes - * @returns {Promise} - */ - save(callback?: General.Callback): Bluebird; - /** - * Saves the given changes to this instance and updates the instance to match the latest database document. - * @param {Object} changes The MongoDB changes object to be used when updating this instance - * @param {function(Error, IInstance)} callback A callback which is triggered when the save operation completes - * @returns {Promise} - */ - save(changes: Object, callback?: General.Callback): Bluebird; - /** - * Saves the given changes to this instance and updates the instance to match the latest database document. - * @param {Object} conditions The conditions under which the update will take place - these will be merged with an _id query - * @param {Object} changes The MongoDB changes object to be used when updating this instance - * @param {function(Error, IInstance)} callback A callback which is triggered when the save operation completes - * @returns {Promise} - */ - save(conditions: Object, changes: Object, callback?: General.Callback): Bluebird; - /** - * Updates this instance to match the latest document available in the backing collection - * @param {function(Error, IInstance)} callback A callback which is triggered when the update completes - * @returns {Promise} - */ - update(callback?: General.Callback): Bluebird; - /** - * Updates this instance to match the latest document available in the backing collection - * @param {function(Error, IInstance)} callback A callback which is triggered when the update completes - * @returns {Promise} - */ - refresh(callback?: General.Callback): Bluebird; - /** - * Removes this instance's document from the backing collection - * @param {function(Error, IInstance)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - delete(callback?: General.Callback): Bluebird; - /** - * Removes this instance's document from the backing collection - * @param {function(Error, IInstance)} callback A callback which is triggered when the operation completes - * @returns {Promise} - */ - remove(callback?: General.Callback): Bluebird; - /** - * Retrieves the first element in an enumerable collection which matches the predicate - * @param collection The collection from which to retrieve the element - * @param predicate The function which determines whether to select an element - * @returns The first element in the array which matched the predicate. - */ - first(collection: T[], predicate: General.Predicate): T; - /** - * Retrieves the first element in an enumerable collection which matches the predicate - * @param collection The collection from which to retrieve the element - * @param predicate The function which determines whether to select an element - * @returns The first element in the object which matched the predicate. - */ - first(collection: { - [key: string]: T; - }, predicate: General.Predicate): T; - /** - * Retrieves a number of elements from an enumerable collection which match the predicate - * @param collection The collection from which elements will be plucked - * @param predicate The function which determines the elements to be plucked - * @returns A new array containing the elements in the array which matched the predicate. - */ - select(collection: T[], predicate: General.Predicate): T[]; - /** - * Retrieves a number of elements from an enumerable collection which match the predicate - * @param collection The collection from which elements will be plucked - * @param predicate The function which determines the elements to be plucked - * @returns An object with the properties from the collection which matched the predicate. - */ - select(collection: { - [key: string]: T; - }, predicate: General.Predicate): { - [key: string]: T; - }; - /** - * Gets the JSON representation of this instance - * @returns {TDocument} - */ - toJSON(): any; - /** - * Gets a string representation of this instance - * @returns {String} - */ - toString(): string; -} -} -declare module 'iridium/dist/lib/Instance' { -import alias = require('~iridium/dist/lib/Instance'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/Decorators.d.ts -declare module '~iridium/dist/lib/Decorators' { -import * as MongoDB from '~iridium~mongodb'; -import * as Skmatc from '~iridium~skmatc'; -import { Instance } from '~iridium/dist/lib/Instance'; -import { Model } from '~iridium/dist/lib/Model'; -import { IndexSpecification } from '~iridium/dist/lib/Index'; -import { InstanceImplementation } from '~iridium/dist/lib/InstanceInterface'; -/** - * Specifies the name of the collection to which this instance's documents should be sent. - * @param name The name of the MongoDB collection to store the documents in. - * - * This decorator replaces the use of the static collection property on instance implementation - * classes. If your transpiler does not support decorators then you are free to make use of the - * property instead. - */ -export function Collection(name: string): (target: InstanceImplementation) => void; -/** - * Specifies a MongoDB collection level index to be managed by Iridium for this instance type. - * More than one instance of this decorator may be used if you wish to specify multiple indexes. - * @param spec The formal index specification which defines the properties and ordering used in the index. - * @param options The options dictating the way in which the index behaves. - * - * This decorator replaces the use of the static indexes property on instance implementation - * classes. If your transpiler does not support decorators then you are free to make use of the - * property instead. - */ -export function Index(spec: IndexSpecification, options?: MongoDB.IndexOptions): (target: InstanceImplementation) => void; -/** - * Specifies a custom validator to be made available for this collection's schema. - * More than one instance of this decorator may be used if you wish to specify multiple validators. - * @param forType The value in the schema which will be delegated to this function for validation. - * @param validate A function which calls this.assert(condition) to determine whether a schema node is valid or not. - * - * This decorator replaces the use of the static validators property on instance implementation - * classes. If your transpiler does not support decorators then you are free to make use of the - * property instead. - */ -export function Validate(forType: any, validate: (schema: any, data: any, path: string) => Skmatc.Result): (target: InstanceImplementation) => void; -/** - * Specifies the schema type for the property this decorator is applied to. This can be used to replace the - * static schema property on your instance. Multiple instances of this decorator can be applied, but no more - * than one per property. - * - * @param asType The schema validation type to make use of for this property - * @param required Whether this property is required to have a value or not, defaults to true. - */ -export function Property(asType: any, required?: boolean): (target: Instance, name: string) => void; -/** - * Specifies the schema type for a property with the given name on the class this decorator is applied to. This - * can either compliment or replace the static schema property on your instance class. - * - * @param name The name of the property that is being targetted - * @param asType The schema validation type to make use of for this property - * @param required Whether this property is required to have a value or not, defaults to true. - */ -export function Property(name: string, asType: any, required?: boolean): (target: InstanceImplementation) => void; -/** - * Specifies a custom transform to be applied to the property this decorator is applied to. - * - * @param fromDB The function used to convert values from the database for the application. - * @param toDB The function used to convert values from the application to the form used in the database. - * - * This decorator can either compliment or replace the static transforms property on your instance - * class, however only one transform can be applied to any property at a time. - * If your transpiler does not support decorators then you are free to make use of the - * property instead. - * - * If this decorator is applied to the instance class itself, as opposed to a property, then - * it will be treated as a $document transformer - and will receive the full document as opposed - * to individual property values. Similarly, it is expected to return a full document when either - * fromDB or toDB is called. - */ -export function Transform(fromDB: (value: any, property: string, model: Model) => any, toDB: (value: any, property: string, model: Model) => any): (target: Instance, property?: string) => void; -/** - * Specifies that this property should be treated as an ObjectID, with the requisite validator and transforms. - * - * This decorator applies an ObjectID validator to the property, which ensures that values sent to the database - * are instances of the MongoDB ObjectID type, as well as applying a transform operation which converts ObjectIDs - * to strings for your application, and then converts strings back to ObjectIDs for the database. - */ -export function ObjectID(target: Instance, name: string): void; -/** - * Specifies that this property should be stored using the MongoDB binary type and represented as a Buffer. - * - * This decorator applies a Buffer validator to the property, which ensures that values you send to the database - * are well formatted Buffer objects represented using the BSON Binary datatype. In addition to this, it will - * apply a transform which ensures you only work with Buffer objects and that data is always stored in Binary - * format. - */ -export function Binary(target: Instance, name: string): void; -} -declare module 'iridium/dist/lib/Decorators' { -import alias = require('~iridium/dist/lib/Decorators'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/Plugins.d.ts -declare module '~iridium/dist/lib/Plugins' { -import { Model } from '~iridium/dist/lib/Model'; -import * as Skmatc from '~iridium~skmatc'; -export interface Plugin { - newModel?(model: Model): any; - newInstance?(instance: any, model: Model): any; - validate?: Skmatc.Validator | Skmatc.Validator[]; -} -} -declare module 'iridium/dist/lib/Plugins' { -import alias = require('~iridium/dist/lib/Plugins'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/Schema.d.ts -declare module '~iridium/dist/lib/Schema' { -export interface Schema { - _id: boolean | any; - [key: string]: any; -} -} -declare module 'iridium/dist/lib/Schema' { -import alias = require('~iridium/dist/lib/Schema'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/Cache.d.ts -declare module '~iridium/dist/lib/Cache' { -export interface Cache { - set(key: string, value: T): void; - get(key: string): PromiseLike; - clear(key: string): void; -} -} -declare module 'iridium/dist/lib/Cache' { -import alias = require('~iridium/dist/lib/Cache'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/CacheDirector.d.ts -declare module '~iridium/dist/lib/CacheDirector' { -export interface CacheDirector { - valid(object: T): boolean; - buildKey(object: T): string; - validQuery(conditions: any): boolean; - buildQueryKey(conditions: any): string; -} -} -declare module 'iridium/dist/lib/CacheDirector' { -import alias = require('~iridium/dist/lib/CacheDirector'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/ModelOptions.d.ts -declare module '~iridium/dist/lib/ModelOptions' { -import * as Index from '~iridium/dist/lib/Index'; -/** - * Options which can be used to control the way in which a query is executed - * against the MongoDB database. - */ -export interface QueryOptions { - cache?: boolean; - fields?: { - [name: string]: number; - }; - limit?: number; - skip?: number; - sort?: Index.IndexSpecification; -} -/** - * Options which can be used to control the way in which a document is created - * on the MongoDB server. - */ -export interface CreateOptions { - /** - * The write concern, can either be a number from 0 to the number of nodes within - * the cluster, or "majority" if you would like to wait for the majority of nodes - * within the cluster to confirm the write before returning. - * - * It is recommended that you set this to "majority", however in all situations - * where you mind if data is lost, you should set it to at least 1. - */ - w?: string | number; - /** - * The timeout in milliseconds before the write will be aborted by the MongoDB server - * and an error response (if the write concern is non-zero) is returned to the client. - */ - wtimeout?: number; - /** - * Whether to wait for the write to be commited to the server's journal (flushed to disk) - * or not. By specifying 1 here, you imply w:1 - howver this can be combined with w:"majority" - * to give excellent write reliability within a cluster, even across failures. - */ - j?: number; - /** - * Whether or not to serialize JavaScript functions which are provided as values. For security - * reasons it is probably best to set this to false, however it may come in handy under certain - * circumstances. - */ - serializeFunctions?: boolean; - /** - * Whether to generate document ObjectIDs within the client library or on the server, it is recommended - * that you leave this to default (false) unless you are making thousands of inserts per second from - * a single node and experiencing _id collisions. - */ - forceServerObjectId?: boolean; - /** - * Whether to perform an upsert operation if the document already exists. - */ - upsert?: boolean; - /** - * Whether to store the resulting document in the Iridium document cache to boost later retrieval times. - */ - cache?: boolean; -} -export interface UpdateOptions { - /** - * The write concern, can either be a number from 0 to the number of nodes within - * the cluster, or "majority" if you would like to wait for the majority of nodes - * within the cluster to confirm the write before returning. - * - * It is recommended that you set this to "majority", however in all situations - * where you mind if data is lost, you should set it to at least 1. - */ - w?: string | number; - /** - * The timeout in milliseconds before the write will be aborted by the MongoDB server - * and an error response (if the write concern is non-zero) is returned to the client. - */ - wtimeout?: number; - /** - * Whether to wait for the write to be commited to the server's journal (flushed to disk) - * or not. By specifying 1 here, you imply w:1 - howver this can be combined with w:"majority" - * to give excellent write reliability within a cluster, even across failures. - */ - j?: boolean; - /** - * Whether to perform an upsert operation if the document already exists. This can be combined - * with $setOnInsert to automatically create documents which do not exist in the database prior - * to making changes - and can be very handy for high-throughput systems. - */ - upsert?: boolean; - /** - * Whether to update multiple documents at once, defaults to false unless run using a method - * which explcitly sets it to true. - */ - multi?: boolean; -} -export interface RemoveOptions { - /** - * The write concern, can either be a number from 0 to the number of nodes within - * the cluster, or "majority" if you would like to wait for the majority of nodes - * within the cluster to confirm the write before returning. - * - * It is recommended that you set this to "majority", however in all situations - * where you mind if data is lost, you should set it to at least 1. - */ - w?: string | number; - /** - * The timeout in milliseconds before the write will be aborted by the MongoDB server - * and an error response (if the write concern is non-zero) is returned to the client. - */ - wtimeout?: number; - /** - * Whether to wait for the write to be commited to the server's journal (flushed to disk) - * or not. By specifying 1 here, you imply w:1 - howver this can be combined with w:"majority" - * to give excellent write reliability within a cluster, even across failures. - */ - j?: boolean; - /** - * Whether to only remove the first document in the collection or not, by default this is false - * and any document matching the conditions will be removed. - */ - single?: boolean; -} -} -declare module 'iridium/dist/lib/ModelOptions' { -import alias = require('~iridium/dist/lib/ModelOptions'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/Configuration.d.ts -declare module '~iridium/dist/lib/Configuration' { -export interface Configuration { - host?: string; - port?: number; - hosts?: { - address: string; - port?: number; - }[]; - database?: string; - username?: string; - password?: string; - options?: ConnectionOptions; - [key: string]: any; -} -export interface ConnectionOptions { - db?: DatabaseLevelConnectionOptions; - server?: ServerLevelConnectionOptions; - replset?: ReplicasetLevelConnectionOptions; - mongos?: MongosLevelConnectionOptions; -} -export interface DatabaseLevelConnectionOptions { - /** - * The write concern for the operation where < 1 is no acknowledgment of write and w >= 1 or w = ‘majority’ acknowledges the write - */ - w?: string | number; - /** - * Set the timeout for waiting for write concern to finish (combines with w option) - */ - wtimeout?: number; - /** - * Write waits for fsync before returning - */ - fsync?: boolean; - /** - * Write waits for journal sync before returning - */ - j?: boolean; - /** - * The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - */ - readPreference?: string; - /** - * The tags object {‘loc’:‘ny’} used with the readPreference. - */ - readPreferenceTags?: any; - /** - * Use c++ bson parser. - */ - native_parser?: boolean; - /** - * Force server to create _id fields instead of client. - */ - forceServerObjectId?: boolean; - /** - * Object overriding the basic ObjectID primary key generation. - */ - pkFactory?: any; - /** - * Serialize functions. - */ - serializeFunctions?: boolean; - /** - * Perform operations using raw bson buffers. - */ - raw?: boolean; - /** - * Number of milliseconds between retries. - */ - retryMiliseconds?: number; - /** - * Number of retries off connection. - */ - numberOfRetries?: number; - /** - * Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited. - */ - bufferMaxEntries?: number; -} -export interface ServerLevelConnectionOptions extends BasicConnectionOptions { - autoReconnect?: boolean; -} -export interface ReplicasetLevelConnectionOptions extends MongosLevelConnectionOptions { - replicaSet?: string; - connectWithNoPrimary?: boolean; -} -export interface MongosLevelConnectionOptions extends BasicConnectionOptions { - ha?: boolean; - haInterval?: number; - secondaryAcceptableLatencyMS?: number; -} -export interface BasicConnectionOptions { - poolSize?: number; - ssl?: boolean; - sslValidate?: boolean; - sslCA?: Buffer[] | string[]; - sslCert?: Buffer | string; - sslKey?: Buffer | string; - sslPass?: Buffer | string; - socketOptions?: { - noDelay?: boolean; - keepAlive?: number; - connectTimeoutMS?: number; - socketTimeoutMS?: number; - }; -} -} -declare module 'iridium/dist/lib/Configuration' { -import alias = require('~iridium/dist/lib/Configuration'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/Hooks.d.ts -declare module '~iridium/dist/lib/Hooks' { -export interface Hooks { - onCreating?(document: TDocument): Promise | PromiseLike | void; - onRetrieved?(document: TDocument): Promise | PromiseLike | void; - onReady?(instance: TInstance): Promise | PromiseLike | void; - onSaving?(instance: TInstance, changes: any): Promise | PromiseLike | void; -} -} -declare module 'iridium/dist/lib/Hooks' { -import alias = require('~iridium/dist/lib/Hooks'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/BSON.d.ts -declare module '~iridium/dist/lib/BSON' { -export { ObjectID, Binary } from '~iridium~mongodb'; -} -declare module 'iridium/dist/lib/BSON' { -import alias = require('~iridium/dist/lib/BSON'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/Transforms.d.ts -declare module '~iridium/dist/lib/Transforms' { -import { ObjectID, Binary } from '~iridium/dist/lib/BSON'; -import { Model } from '~iridium/dist/lib/Model'; -export interface Transforms { - /** - * A transform which is applied to the entire document. - */ - $document?: PropertyTransform; - _id?: PropertyTransform; - [property: string]: PropertyTransform; -} -/** - * Converts the value of a property to and from its database representation. - */ -export interface PropertyTransform { - /** - * Converts a property's value from its database representation into one - * suitable for the application. - * @param value The value stored in the MongoDB database document. - * @param property The name of the document property to which this transform is being applied. - * @param model The Iridium Model on which this transform is being applied - * @returns A derived value which is more useful to the application. - */ - fromDB(value: T, property: string, model: Model): any; - /** - * Converts a property's value into a representation more suitable for - * the database. - * @param value The value used by the application. - * @param property The name of the document property to which this transform is being applied. - * @param model The Iridium Model on which this transform is being applied - * @returns The database optimized representation of the value. - */ - toDB(value: any, property: string, model: Model): T; -} -export const DefaultTransforms: { - ObjectID: PropertyTransform; - Binary: PropertyTransform; -}; -} -declare module 'iridium/dist/lib/Transforms' { -import alias = require('~iridium/dist/lib/Transforms'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/caches/MemoryCache.d.ts -declare module '~iridium/dist/lib/caches/MemoryCache' { -import * as Bluebird from '~iridium~bluebird'; -import { Cache } from '~iridium/dist/lib/Cache'; -/** - * A cache implementation which stores documents in an in-memory cache. - * - * Be aware that this is an incredibly simplistic implementation which doesn't manage - * memory usage at all and is very likely NOT suitable for production use. - */ -export class MemoryCache implements Cache { - private cache; - set(key: string, value: T): Bluebird; - get(key: string): Bluebird; - clear(key: string): Bluebird; -} -} -declare module 'iridium/dist/lib/caches/MemoryCache' { -import alias = require('~iridium/dist/lib/caches/MemoryCache'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/caches/NoOpCache.d.ts -declare module '~iridium/dist/lib/caches/NoOpCache' { -import { Cache } from '~iridium/dist/lib/Cache'; -import * as Bluebird from '~iridium~bluebird'; -/** - * A cache implementation which does not cache any received documents - * and returns nothing when requested - mimicking an empty cache. - * - * This is the default cache used if one is not supplied and should - * not impose any significant performance overhead. - */ -export class NoOpCache implements Cache { - set(key: string, object: T): Bluebird; - get(key: string): Bluebird; - clear(key: string): Bluebird; -} -} -declare module 'iridium/dist/lib/caches/NoOpCache' { -import alias = require('~iridium/dist/lib/caches/NoOpCache'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/cacheControllers/IDDirector.d.ts -declare module '~iridium/dist/lib/cacheControllers/IDDirector' { -import { CacheDirector } from '~iridium/dist/lib/CacheDirector'; -/** - * Caches documents using their _id field as the unique cache key. This - * is useful if you primarily query your documents using their _id field, - * however can be suboptimal (or even a complete waste) if you use different - * types of queries. - */ -export class CacheOnID implements CacheDirector { - valid(object: { - _id: any; - }): boolean; - buildKey(object: { - _id: any; - }): any; - validQuery(conditions: any): boolean; - buildQueryKey(conditions: any): any; -} -} -declare module 'iridium/dist/lib/cacheControllers/IDDirector' { -import alias = require('~iridium/dist/lib/cacheControllers/IDDirector'); -export = alias; -} - -// Generated by typings -// Source: dist/lib/utils/ObjectID.d.ts -declare module '~iridium/dist/lib/utils/ObjectID' { -import * as MongoDB from '~iridium~mongodb'; -/** - * Converts a string to an ObjectID instance - a shortcut for require("mongodb").ObjectID.createFromHexString - * - * @param value The string representation of the ObjectID you wish to create. - * @returns A MongoDB ObjectID instance equivalent to the string you provided. - * - * You should be aware that this method performs no validation on the received string, MongoDB's ObjectID requires - * that it either be a 12 byte UTF8 string, or a 24 byte hexadecimal string in order to be converted correctly. - * - * This method removes the need for your application to directly depend on MongoDB's Node.js client library, - * which helps clean up your code a bit and reduces the headache of maintaining two different versions of the - * library (since Iridium also has one). - */ -export function toObjectID(value: string): MongoDB.ObjectID; -} -declare module 'iridium/dist/lib/utils/ObjectID' { -import alias = require('~iridium/dist/lib/utils/ObjectID'); -export = alias; -} - -// Generated by typings -// Source: dist/iridium.d.ts -declare module '~iridium/dist/iridium' { -export * from '~iridium/dist/lib/Core'; -export * from '~iridium/dist/lib/Model'; -export * from '~iridium/dist/lib/Instance'; -export * from '~iridium/dist/lib/Decorators'; -export * from '~iridium/dist/lib/Plugins'; -export * from '~iridium/dist/lib/Schema'; -export * from '~iridium/dist/lib/Cache'; -export * from '~iridium/dist/lib/CacheDirector'; -export * from '~iridium/dist/lib/ModelOptions'; -export * from '~iridium/dist/lib/Configuration'; -export * from '~iridium/dist/lib/Hooks'; -export * from '~iridium/dist/lib/Transforms'; -export * from '~iridium/dist/lib/caches/MemoryCache'; -export * from '~iridium/dist/lib/caches/NoOpCache'; -export * from '~iridium/dist/lib/cacheControllers/IDDirector'; -export * from '~iridium/dist/lib/utils/ObjectID'; -} -declare module 'iridium/dist/iridium' { -import alias = require('~iridium/dist/iridium'); -export = alias; -} -declare module 'iridium' { -import alias = require('~iridium/dist/iridium'); -export = alias; -} diff --git a/example/IntelliSense.ts b/example/IntelliSense.ts index 83c990c..584f564 100644 --- a/example/IntelliSense.ts +++ b/example/IntelliSense.ts @@ -66,8 +66,9 @@ db.connect().then(function () { }); db.Users.findOne().then(user => { - user.save().then(() => { - user.remove().then(() => { + if (!user) throw new Error("User could not be found..."); + user.save().then(user => { + user.remove().then(user => { user.username = "test"; return user.save(); }); diff --git a/example/UserModel.ts b/example/UserModel.ts index 1ab681d..ca73a30 100644 --- a/example/UserModel.ts +++ b/example/UserModel.ts @@ -207,12 +207,13 @@ export class User extends Iridium.Instance implements UserDo } } -export function Users(core: Iridium.Core): Iridium.Model { - return new Iridium.Model(core, User); +class Core extends Iridium.Core { + Users = new Iridium.Model(this, User); } -var usrModel = Users(null); -usrModel.findOne().then(function (user) { +let core = new Core("mongodb://localhost/iridium_users"); +core.Users.findOne().then(function (user) { + if (!user) throw new Error("Couldn't find a user"); if (user.checkPassword("test")) return true; return false; }); diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 167c76c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// -export * from "~iridium/dist/iridium"; \ No newline at end of file diff --git a/lib/Changes.ts b/lib/Changes.ts new file mode 100644 index 0000000..acfea52 --- /dev/null +++ b/lib/Changes.ts @@ -0,0 +1,66 @@ +import {Conditions, UnderlyingBSONType} from "./Conditions"; + +export interface Changes { + $set?: { + [property: string]: UnderlyingBSONType; + }; + + $unset?: { + [property: string]: boolean; + }; + + $inc?: { + [property: string]: number; + }; + + $mul?: { + [property: string]: number; + }; + + $addToSet?: { + [property: string]: { + $each: UnderlyingBSONType[]; + }|any; + } + + $push?: { + [property: string]: { + $each: UnderlyingBSONType[]; + $slice?: number; + $position?: number; + }|{ + $each: UnderlyingBSONType[]; + $slice: number; + $sort: { [property: string]: number; }; + $position?: number; + }|UnderlyingBSONType; + }; + + $pull?: { + [property: string]: Conditions; + }; + + $pullAll?: { + [property: string]: UnderlyingBSONType[]; + }; + + $rename?: { + [property: string]: string; + }; + + $min?: { + [property: string]: number; + }; + + $max?: { + [property: string]: number; + }; + + $currentDate?: { + [property: string]: boolean|{ $type: "timestamp"|"date" }; + }; + + $bit?: { + [property: string]: { and: number; }|{ or: number; }|{ xor: number; } + } +} \ No newline at end of file diff --git a/lib/Conditions.ts b/lib/Conditions.ts new file mode 100644 index 0000000..0a57a2a --- /dev/null +++ b/lib/Conditions.ts @@ -0,0 +1,25 @@ +import {ObjectID} from "mongodb"; + +export type UnderlyingBSONType = null + |number + |string|symbol + |{[property: string]: UnderlyingBSONType;} + //|UnderlyingBSONType[] + |ObjectID + |boolean + |Date + |RegExp; + +export interface Conditions { + [property: string]: { + $eq?: UnderlyingBSONType; + $ne?: UnderlyingBSONType; + $in?: UnderlyingBSONType[]; + $nin?: UnderlyingBSONType[]; + $elemMatch?: Conditions; + $gt?: UnderlyingBSONType; + $gte?: UnderlyingBSONType; + $lt?: UnderlyingBSONType; + $lte?: UnderlyingBSONType; + }|UnderlyingBSONType; +} \ No newline at end of file diff --git a/lib/Core.ts b/lib/Core.ts index b46d730..accd409 100644 --- a/lib/Core.ts +++ b/lib/Core.ts @@ -39,31 +39,25 @@ export class Core { */ constructor(uri: string, config?: Configuration); constructor(uri: string | Configuration, config?: Configuration) { - - let args = Array.prototype.slice.call(arguments, 0); - uri = config = null; - for (let i = 0; i < args.length; i++) { - if (typeof args[i] == "string") - uri = args[i]; - else if (typeof args[i] == "object") - config = args[i]; + if (typeof uri === "string") { + this._url = uri; + this._config = config; + } else if (uri) { + this._config = uri; + } else { + throw new Error("Expected either a URI or config object to be supplied when initializing Iridium"); } - - if (!uri && !config) throw new Error("Expected either a URI or config object to be supplied when initializing Iridium"); - - this._url = uri; - this._config = config; } private mongoConnectAsyc = Bluebird.promisify(MongoDB.MongoClient.connect); private _plugins: Plugin[] = []; private _url: string; - private _config: Configuration; - private _connection: MongoDB.Db; + private _config: Configuration|undefined; + private _connection: MongoDB.Db|undefined; private _cache: Cache = new NoOpCache(); - private _connectPromise: Bluebird; + private _connectPromise: Bluebird|undefined; /** * Gets the plugins registered with this Iridium Core @@ -78,7 +72,7 @@ export class Core { * Iridium Core. * @returns {Iridium.Configuration} */ - get settings(): Configuration { + get settings(): Configuration|undefined { return this._config; } @@ -88,6 +82,7 @@ export class Core { * @returns {MongoDB.Db} */ get connection(): MongoDB.Db { + if (!this._connection) throw new Error("Iridium Core not connected to a database."); return this._connection; } @@ -97,6 +92,8 @@ export class Core { */ get url(): string { if (this._url) return this._url; + if (!this._config) throw new Error("No URL or configuration provided"); + let url: string = "mongodb://"; if (this._config.username) { @@ -106,11 +103,11 @@ export class Core { url += "@"; } - let hosts = []; + let hosts: string[] = []; if (this._config.host) { if (this._config.port) - hosts.push(this._config.host + ":" + this._config.port); + hosts.push(`${this._config.host}:${this._config.port}`); else hosts.push(this._config.host); } @@ -118,9 +115,9 @@ export class Core { if (this._config.hosts) { _.each(this._config.hosts, (host) => { if (host.port) - hosts.push(host.address + ":" + host.port); - else if(this._config.port) - hosts.push(host.address + ":" + this._config.port); + hosts.push(`${host.address}:${host.port}`); + else if(this._config && this._config.port) + hosts.push(`${host.address}:${this._config.port}`); else hosts.push(host.address); }); @@ -130,8 +127,9 @@ export class Core { url += _.uniq(hosts).join(","); else url += "localhost"; - - url += "/" + this._config.database; + + if (this._config.database) + url += "/" + this._config.database; return url; } @@ -172,14 +170,14 @@ export class Core { return this.onConnecting(db); }).then(db => { this._connection = db; - this._connectPromise = null; + this._connectPromise = undefined; return this.onConnected(); }).then(() => { return this; }, (err) => { if (this._connection) this._connection.close(); - this._connection = null; - this._connectPromise = null; + this._connection = undefined; + this._connectPromise = undefined; return Bluebird.reject(err); }).nodeify(callback); } @@ -192,7 +190,7 @@ export class Core { return Bluebird.resolve().then(() => { if (!this._connection) return this; let conn: MongoDB.Db = this._connection; - this._connection = null; + this._connection = undefined; conn.close(); return this; }); diff --git a/lib/Cursor.ts b/lib/Cursor.ts index 6be1718..36f0822 100644 --- a/lib/Cursor.ts +++ b/lib/Cursor.ts @@ -32,7 +32,7 @@ export class Cursor { return new Bluebird((resolve, reject) => { this.cursor.count(true, (err, count) => { if (err) return reject(err); - return resolve(count); + return resolve(count); }); }).nodeify(callback); } @@ -50,7 +50,7 @@ export class Cursor { this.model.handlers.documentReceived(this.conditions, item, function () { return helpers.wrapDocument.apply(helpers, arguments); }).then(handler); }, (err) => { if (err) return reject(err); - return resolve(null); + return resolve(undefined); }); }).nodeify(callback); } @@ -83,9 +83,9 @@ export class Cursor { toArray(callback?: General.Callback): Bluebird { let helpers = this.model.helpers; return new Bluebird((resolve, reject) => { - this.cursor.toArray((err, results: any[]) => { + this.cursor.toArray((err, results: TDocument[]) => { if (err) return reject(err); - return resolve(results); + return resolve(results); }); }).map((document) => { return this.model.handlers.documentReceived(this.conditions, document, function () { return helpers.wrapDocument.apply(helpers, arguments); }); @@ -97,14 +97,14 @@ export class Cursor { * @param {function(Error, TInstance)} callback A callback which is triggered when the next item becomes available * @return {Promise} A promise which is resolved with the next item */ - next(callback?: General.Callback): Bluebird { - return new Bluebird((resolve, reject) => { - this.cursor.next((err, result: any) => { + next(callback?: General.Callback): Bluebird { + return new Bluebird((resolve, reject) => { + this.cursor.next((err, result: TDocument|undefined) => { if (err) return reject(err); - return resolve(result); + return resolve(result); }); }).then((document) => { - if (!document) return Bluebird.resolve(null); + if (!document) return Bluebird.resolve(undefined); return this.model.handlers.documentReceived(this.conditions, document, (document, isNew?, isPartial?) => this.model.helpers.wrapDocument(document, isNew, isPartial)); }).nodeify(callback); } @@ -114,21 +114,21 @@ export class Cursor { * @param {function(Error, TInstance)} callback A callback which is triggered when the next item becomes available * @return {Promise} A promise which is resolved once the item becomes available and the cursor has been closed. */ - one(callback?: General.Callback): Bluebird { - return new Bluebird((resolve, reject) => { - this.cursor.next((err, result: any) => { + one(callback?: General.Callback): Bluebird { + return new Bluebird((resolve, reject) => { + this.cursor.next((err, result: TDocument) => { if (err) return reject(err); return resolve(result); }); }).then((document) => { - return new Bluebird((resolve, reject) => { + return new Bluebird((resolve, reject) => { this.cursor.close((err) => { if (err) return reject(err); - return resolve(document); + return resolve(document); }); }); }).then((document) => { - if (!document) return Bluebird.resolve(null); + if (!document) return Bluebird.resolve(undefined); return this.model.handlers.documentReceived(this.conditions, document, (document, isNew?, isPartial?) => this.model.helpers.wrapDocument(document, isNew, isPartial)); }).nodeify(callback); } diff --git a/lib/Decorators.ts b/lib/Decorators.ts index b6a09c6..7ba0f11 100644 --- a/lib/Decorators.ts +++ b/lib/Decorators.ts @@ -48,7 +48,7 @@ export function Index(spec: IndexSpecification, options?: MongoDB.IndexOptions) * classes. If your transpiler does not support decorators then you are free to make use of the * property instead. */ -export function Validate(forType: any, validate: (schema: any, data: any, path: string) => Skmatc.Result) { +export function Validate(forType: any, validate: Skmatc.IValidationHandler) { return function(target: InstanceImplementation) { target.validators = (target.validators || []).concat(Skmatc.create(schema => schema === forType, validate)); } @@ -73,9 +73,9 @@ export function Property(asType: any, required?: boolean): (target: Instance) => void; export function Property(...args: any[]): (target: Instance | InstanceImplementation, name?: string) => void { - let name = null, - asType = false, - required = true; + let name: string|number|undefined = undefined, + asType: any = false, + required: boolean = true; if (args.length > 1 && typeof args[args.length - 1] === "boolean") required = args.pop(); @@ -90,8 +90,8 @@ export function Property(...args: any[]): (target: Instance | Instance asType = args.pop() || false; staticTarget.schema = _.clone(staticTarget.schema || { _id: false }); - if(!required && typeof asType !== "boolean") staticTarget.schema[name] = { $required: required, $type: asType }; - else staticTarget.schema[name] = asType; + if(!required && typeof asType !== "boolean") staticTarget.schema[name!] = { $required: required, $type: asType }; + else staticTarget.schema[name!] = asType; } } diff --git a/lib/General.ts b/lib/General.ts index 173f630..27a7972 100644 --- a/lib/General.ts +++ b/lib/General.ts @@ -15,13 +15,13 @@ export interface Callback { * A method which is used to determine whether a value within a collection meets a set of criteria. * @param T The type of item in the collection. */ -export interface Predicate { +export interface Predicate { /** * @param object The value of the item in the collection * @param key The key, if one is available, under which the item appeared within the collection * @returns A true-y value if the item met the predicate conditions, false-y values if it did not. */ - (object: T, key?: string): boolean; + (this: TThis, object: TObject, key?: string): boolean; } /** diff --git a/lib/Instance.ts b/lib/Instance.ts index 42f4e41..822cd24 100644 --- a/lib/Instance.ts +++ b/lib/Instance.ts @@ -8,6 +8,8 @@ import * as Index from "./Index"; import {Schema} from "./Schema"; import {Transforms} from "./Transforms"; import {DefaultValidators} from "./Validators"; +import {Conditions} from "./Conditions"; +import {Changes} from "./Changes"; import * as _ from "lodash"; import * as MongoDB from "mongodb"; @@ -91,7 +93,7 @@ export class Instance { * @param instance The instance to which the changes are being made * @param changes The MongoDB change object describing the changes being made to the document. */ - static onSaving: (instance: Instance<{ _id?: any }, Instance<{ _id?: any }, any>>, changes: any) => Promise | PromiseLike | void; + static onSaving: (instance: Instance<{ _id?: any }, Instance<{ _id?: any }, any>>, changes: Changes) => Promise | PromiseLike | void; /** * The name of the collection into which documents of this type are stored. @@ -139,7 +141,7 @@ export class Instance { * @param {function(Error, IInstance)} callback A callback which is triggered when the save operation completes * @returns {Promise} */ - save(changes: Object, callback?: General.Callback): Bluebird; + save(changes: Changes, callback?: General.Callback): Bluebird; /** * Saves the given changes to this instance and updates the instance to match the latest database document. * @param {Object} conditions The conditions under which the update will take place - these will be merged with an _id query @@ -147,9 +149,9 @@ export class Instance { * @param {function(Error, IInstance)} callback A callback which is triggered when the save operation completes * @returns {Promise} */ - save(conditions: Object, changes: Object, callback?: General.Callback): Bluebird; + save(conditions: Conditions, changes: Changes, callback?: General.Callback): Bluebird; save(...args: any[]): Bluebird { - let callback: General.Callback = null; + let callback: General.Callback|undefined = undefined; let changes: any = null; let conditions: any = {}; @@ -320,16 +322,16 @@ export class Instance { * @param predicate The function which determines whether to select an element * @returns The first element in the array which matched the predicate. */ - first(collection: T[], predicate: General.Predicate): T; + first(collection: T[], predicate: General.Predicate): T|null; /** * Retrieves the first element in an enumerable collection which matches the predicate * @param collection The collection from which to retrieve the element * @param predicate The function which determines whether to select an element * @returns The first element in the object which matched the predicate. */ - first(collection: { [key: string]: T }, predicate: General.Predicate): T; - first(collection: T[]| { [key: string]: T }, predicate: General.Predicate): T { - let result = null; + first(collection: { [key: string]: T }, predicate: General.Predicate): T|null; + first(collection: T[]| { [key: string]: T }, predicate: General.Predicate): T|null { + let result: T|null = null; _.each(collection, (value: T, key) => { if (predicate.call(this, value, key)) { @@ -347,15 +349,15 @@ export class Instance { * @param predicate The function which determines the elements to be plucked * @returns A new array containing the elements in the array which matched the predicate. */ - select(collection: T[], predicate: General.Predicate): T[]; + select(collection: T[], predicate: General.Predicate): T[]; /** * Retrieves a number of elements from an enumerable collection which match the predicate * @param collection The collection from which elements will be plucked * @param predicate The function which determines the elements to be plucked * @returns An object with the properties from the collection which matched the predicate. */ - select(collection: { [key: string]: T }, predicate: General.Predicate): { [key: string]: T }; - select(collection: T[]| { [key: string]: T }, predicate: General.Predicate): any { + select(collection: { [key: string]: T }, predicate: General.Predicate): { [key: string]: T }; + select(collection: T[]| { [key: string]: T }, predicate: General.Predicate): any { let isArray = Array.isArray(collection); let results: any = isArray ? [] : {}; diff --git a/lib/InstanceInterface.ts b/lib/InstanceInterface.ts index e8a28cd..6284e1b 100644 --- a/lib/InstanceInterface.ts +++ b/lib/InstanceInterface.ts @@ -4,6 +4,7 @@ import {Model} from "./Model"; import * as Index from "./Index"; import {CacheDirector} from "./CacheDirector"; import {Transforms} from "./Transforms"; +import {Changes} from "./Changes"; /** * This interface dictates the format of an instance class which wraps documents received @@ -101,7 +102,7 @@ export interface InstanceImplementation | PromiseLike | void; + onSaving? (instance: TInstance, changes: Changes): Promise | PromiseLike | void; /** * The cache controller used to determine whether a document may be cached, as well as deriving a unique cache @@ -125,4 +126,31 @@ export interface InstanceImplementation { + /** + * The original document received from the database + */ + _original: TDocument; + + /** + * A copy of the original document which may have had changes applied to it + */ + _modified: TDocument; + + /** + * Whether this instance is known to be present in the database or not + */ + _isNew: boolean; + + /** + * Whether this instance represents a partial document + */ + _isPartial: boolean; + + /** + * The model that this instance belongs to + */ + _model: Model; } \ No newline at end of file diff --git a/lib/Model.ts b/lib/Model.ts index b61ed34..5852e19 100644 --- a/lib/Model.ts +++ b/lib/Model.ts @@ -11,10 +11,13 @@ import {Hooks} from "./Hooks"; import {Plugin} from "./Plugins"; import {Cache} from "./Cache"; import {CacheDirector} from "./CacheDirector"; +import {CacheOnID} from "./cacheControllers/IDDirector"; import * as General from "./General"; import {Cursor} from "./Cursor"; import * as Index from "./Index"; import * as ModelOptions from "./ModelOptions"; +import {Conditions} from "./Conditions"; +import {Changes} from "./Changes"; import {Omnom} from "./utils/Omnom"; import {ModelCache} from "./ModelCache"; @@ -63,7 +66,7 @@ export class Model { this._collection = instanceType.collection; this._schema = instanceType.schema; this._hooks = instanceType; - this._cacheDirector = instanceType.cache; + this._cacheDirector = instanceType.cache || new CacheOnID(); this._transforms = instanceType.transforms || {}; this._validators = instanceType.validators || []; this._indexes = instanceType.indexes || []; @@ -162,7 +165,6 @@ export class Model { * @returns {Collection} */ get collection(): MongoDB.Collection { - if (!this.core.connection) throw new Error("Iridium Core not connected to a database."); return this.core.connection.collection(this._collection); } @@ -253,15 +255,15 @@ export class Model { * @param {Object} conditions The MongoDB query dictating which documents to return * @returns {Promise} */ - find(conditions: { _id?: any, [key: string]: any } | any): Cursor; + find(conditions: { _id?: string; } | Conditions | string): Cursor; /** * Returns all documents in the collection which match the conditions * @param {Object} conditions The MongoDB query dictating which documents to return * @param {Object} fields The fields to include or exclude from the document * @returns {Promise} */ - find(conditions: { _id?: any, [key: string]: any } | any, fields: { [name: string]: number }): Cursor; - find(conditions?: { _id?: any, [key: string]: any } | any, fields?: any): Cursor { + find(conditions: { _id?: string; } | Conditions | string, fields: { [name: string]: number }): Cursor; + find(conditions?: { _id?: string; } | Conditions | string, fields?: any): Cursor { conditions = conditions || {}; if (!_.isPlainObject(conditions)) conditions = { _id: conditions }; @@ -287,14 +289,14 @@ export class Model { * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available * @returns {Promise} */ - get(id: any, callback?: General.Callback): Bluebird; + get(id: string, callback?: General.Callback): Bluebird; /** * Retrieves a single document from the collection which matches the conditions * @param {Object} conditions The MongoDB query dictating which document to return * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available * @returns {Promise} */ - get(conditions: { _id?: any, [key: string]: any }, callback?: General.Callback): Bluebird; + get(conditions: { _id?: string; } | Conditions, callback?: General.Callback): Bluebird; /** * Retrieves a single document from the collection with the given ID and wraps it as an instance * @param {any} id The document's unique _id field value in downstream format @@ -302,7 +304,7 @@ export class Model { * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available * @returns {Promise} */ - get(id: any, options: ModelOptions.QueryOptions, callback?: General.Callback): Bluebird; + get(id: string, options: ModelOptions.QueryOptions, callback?: General.Callback): Bluebird; /** * Retrieves a single document from the collection which matches the conditions * @param {Object} conditions The MongoDB query dictating which document to return @@ -310,7 +312,7 @@ export class Model { * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available * @returns {Promise} */ - get(conditions: { _id?: any, [key: string]: any }, options: ModelOptions.QueryOptions, callback?: General.Callback): Bluebird; + get(conditions: { _id?: string; } | Conditions, options: ModelOptions.QueryOptions, callback?: General.Callback): Bluebird; get(...args: any[]): Bluebird { return this.findOne.apply(this, args); } @@ -320,21 +322,21 @@ export class Model { * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available * @returns {Promise} */ - findOne(callback?: General.Callback): Bluebird; + findOne(callback?: General.Callback): Bluebird; /** * Retrieves a single document from the collection with the given ID and wraps it as an instance * @param {any} id The document's unique _id field value in downstream format * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available * @returns {Promise} */ - findOne(id: any, callback?: General.Callback): Bluebird; + findOne(id: string, callback?: General.Callback): Bluebird; /** * Retrieves a single document from the collection which matches the conditions * @param {Object} conditions The MongoDB query dictating which document to return * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available * @returns {Promise} */ - findOne(conditions: { _id?: any, [key: string]: any }, callback?: General.Callback): Bluebird; + findOne(conditions: { _id?: string; } | Conditions, callback?: General.Callback): Bluebird; /** * Retrieves a single document from the collection with the given ID and wraps it as an instance * @param {any} id The document's unique _id field value in downstream format @@ -342,7 +344,7 @@ export class Model { * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available * @returns {Promise} */ - findOne(id: any, options: ModelOptions.QueryOptions, callback?: General.Callback): Bluebird; + findOne(id: string, options: ModelOptions.QueryOptions, callback?: General.Callback): Bluebird; /** * Retrieves a single document from the collection which matches the conditions * @param {Object} conditions The MongoDB query dictating which document to return @@ -350,11 +352,11 @@ export class Model { * @param {function(Error, TInstance)} callback An optional callback which will be triggered when a result is available * @returns {Promise} */ - findOne(conditions: { _id?: any, [key: string]: any }, options: ModelOptions.QueryOptions, callback?: General.Callback): Bluebird; - findOne(...args: any[]): Bluebird { - let conditions: { _id?: any, [key: string]: any } = null; - let options: ModelOptions.QueryOptions = null; - let callback: General.Callback = null; + findOne(conditions: { _id?: string; } | Conditions, options: ModelOptions.QueryOptions, callback?: General.Callback): Bluebird; + findOne(...args: any[]): Bluebird { + let conditions: { _id?: any, [key: string]: any }|undefined; + let options: ModelOptions.QueryOptions|undefined; + let callback: General.Callback|undefined; for (let argI = 0; argI < args.length; argI++) { if (typeof args[argI] === "function") callback = callback || args[argI]; @@ -378,27 +380,27 @@ export class Model { return this._cache.get(conditions); }).then((cachedDocument: TDocument) => { if (cachedDocument) return cachedDocument; - return new Bluebird((resolve, reject) => { + return new Bluebird((resolve, reject) => { let cursor = this.collection.find(conditions); - if(options.sort) - cursor = cursor.sort(options.sort); + if(options!.sort) + cursor = cursor.sort(options!.sort!); - if(typeof options.skip === "number") - cursor = cursor.skip(options.skip); + if(typeof options!.skip === "number") + cursor = cursor.skip(options!.skip!); cursor = cursor.limit(1); - if(options.fields) - cursor = cursor.project(options.fields); + if(options!.fields) + cursor = cursor.project(options!.fields!); return cursor.next((err, result) => { if (err) return reject(err); return resolve(result); }); }); - }).then((document: TDocument) => { - if (!document) return null; + }).then((document) => { + if (!document) return Bluebird.resolve(null); return this._handlers.documentReceived(conditions, document, (document, isNew?, isPartial?) => this._helpers.wrapDocument(document, isNew, isPartial), options); }).nodeify(callback); } @@ -470,7 +472,7 @@ export class Model { insert(objs: TDocument | TDocument[], ...args: any[]): Bluebird { let objects: TDocument[]; let options: ModelOptions.CreateOptions = {}; - let callback: General.Callback = null; + let callback: General.Callback|undefined = undefined; if (typeof args[0] === "function") callback = args[0]; else { options = args[0]; @@ -528,7 +530,7 @@ export class Model { * @param {Object} changes The changes to make to the documents * @param {function(Error, Number)} callback A callback which is triggered when the operation completes */ - update(conditions: { _id?: any, [key: string]: any } | any, changes: any, callback?: General.Callback): Bluebird; + update(conditions: { _id?: string; } | Conditions | string, changes: Changes, callback?: General.Callback): Bluebird; /** * Updates the documents in the backing collection which match the conditions using the given update instructions * @param {Object} conditions The conditions which determine which documents will be updated @@ -536,8 +538,8 @@ export class Model { * @param {UpdateOptions} options The options which dictate how this function behaves * @param {function(Error, Number)} callback A callback which is triggered when the operation completes */ - update(conditions: { _id?: any, [key: string]: any } | any, changes: any, options: ModelOptions.UpdateOptions, callback?: General.Callback): Bluebird; - update(conditions: { _id?: any, [key: string]: any } | any, changes: any, options?: ModelOptions.UpdateOptions, callback?: General.Callback): Bluebird { + update(conditions: { _id?: string; } | Conditions | string, changes: Changes, options: ModelOptions.UpdateOptions, callback?: General.Callback): Bluebird; + update(conditions: { _id?: string; } | Conditions | string, changes: Changes, options?: ModelOptions.UpdateOptions, callback?: General.Callback): Bluebird { if (typeof options === "function") { callback = >options; options = {}; @@ -558,7 +560,7 @@ export class Model { conditions = this._helpers.convertToDB(conditions); return new Bluebird((resolve, reject) => { - this.collection.updateMany(conditions, changes, options, (err, response) => { + this.collection.updateMany(conditions, changes, options!, (err, response) => { if (err) return reject(err); // New MongoDB 2.6+ response type @@ -583,9 +585,9 @@ export class Model { * @param {function(Error, Number)} callback A callback which is triggered when the operation completes * @returns {Promise} */ - count(conditions: { _id?: any, [key: string]: any } | any, callback?: General.Callback): Bluebird; + count(conditions: { _id?: string; } | Conditions, callback?: General.Callback): Bluebird; count(conds?: any, callback?: General.Callback): Bluebird { - let conditions: { _id?: any, [key: string]: any } = <{ _id?: any, [key: string]: any }>conds; + let conditions: { _id?: string; } | Conditions = conds; if (typeof conds === "function") { callback = >conds; conditions = {}; @@ -621,7 +623,7 @@ export class Model { * @param {function(Error, Number)} callback A callback which is triggered when the operation completes * @returns {Promise} */ - remove(conditions: { _id?: any, [key: string]: any } | any, callback?: General.Callback): Bluebird; + remove(conditions: { _id?: string; } | Conditions | any, callback?: General.Callback): Bluebird; /** * Removes all documents from the collection which match the conditions * @param {Object} conditions The conditions determining whether an object is removed or not @@ -629,9 +631,9 @@ export class Model { * @param {function(Error, Number)} callback A callback which is triggered when the operation completes * @returns {Promise} */ - remove(conditions: { _id?: any, [key: string]: any }, options: ModelOptions.RemoveOptions, callback?: General.Callback): Bluebird; + remove(conditions: { _id?: string; } | Conditions | string, options: ModelOptions.RemoveOptions, callback?: General.Callback): Bluebird; remove(conds?: any, options?: ModelOptions.RemoveOptions, callback?: General.Callback): Bluebird { - let conditions: { _id?: any, [key: string]: any } = <{ _id?: any, [key: string]: any }>conds; + let conditions: { _id?: string; } | Conditions = conds; if (typeof options === "function") { callback = >options; @@ -658,20 +660,21 @@ export class Model { return Bluebird.resolve().then(() => { conditions = this._helpers.convertToDB(conditions); - return new Bluebird((resolve, reject) => { - if(options.single) return this.collection.deleteOne(conditions, options, (err, response) => { + return new Bluebird((resolve, reject) => { + if(options!.single) return this.collection.deleteOne(conditions, options!, (err, response) => { if (err) return reject(err); return resolve(response.result.n); }); - this.collection.deleteMany(conditions, options, (err, response) => { + this.collection.deleteMany(conditions, options!, (err, response) => { if (err) return reject(err); return resolve(response.result.n); }); }); }).then((count) => { + if (count === undefined) return Bluebird.resolve(0); if (count === 1) this._cache.clear(conditions); - return Bluebird.resolve(count); + return Bluebird.resolve(count); }).nodeify(callback); } @@ -706,7 +709,7 @@ export class Model { } return new Bluebird((resolve, reject) => { - this.collection.createIndex(specification, options, (err, name: any) => { + this.collection.createIndex(specification, options || {}, (err, name: any) => { if (err) return reject(err); return resolve(name); }); diff --git a/lib/ModelCache.ts b/lib/ModelCache.ts index 15dad15..b9c250d 100644 --- a/lib/ModelCache.ts +++ b/lib/ModelCache.ts @@ -16,8 +16,8 @@ export class ModelCache { this.model.core.cache.set(this.model.cacheDirector.buildKey(value), value); } - get(conditions: any): Bluebird { - if (!this.model.cacheDirector || !this.model.cacheDirector.validQuery(conditions)) return Bluebird.resolve(null); + get(conditions: any): Bluebird { + if (!this.model.cacheDirector || !this.model.cacheDirector.validQuery(conditions)) return Bluebird.resolve(null); return Bluebird.resolve(this.model.core.cache.get(this.model.cacheDirector.buildQueryKey(conditions))); } diff --git a/lib/ModelHelpers.ts b/lib/ModelHelpers.ts index 81cc277..13f77c9 100644 --- a/lib/ModelHelpers.ts +++ b/lib/ModelHelpers.ts @@ -52,11 +52,16 @@ export class ModelHelpers { if(!options.properties) return document; - for (let property in this.model.transforms) - if(property === "$document") continue; - else if(document.hasOwnProperty(property)) { - document[property] = this.model.transforms[property].toDB(document[property], property, this.model); + for (let property in this.model.transforms) { + if (property === "$document") continue; + + const transform = this.model.transforms[property]; + if (!transform) continue; + + if(document.hasOwnProperty(property)) { + document[property] = transform.toDB(document[property], property, this.model); } + } return document; } @@ -76,11 +81,16 @@ export class ModelHelpers { if(!options.properties) return document; - for (let property in this.model.transforms) + for (let property in this.model.transforms) { if(property === "$document") continue; - else if(document.hasOwnProperty(property)) { - document[property] = this.model.transforms[property].fromDB(document[property], property, this.model); + + const transform = this.model.transforms[property]; + if (!transform) continue; + + if(document.hasOwnProperty(property)) { + document[property] = transform.fromDB(document[property], property, this.model); } + } return document; } diff --git a/lib/ModelSpecificInstance.ts b/lib/ModelSpecificInstance.ts index 24adc21..ab9f7ad 100644 --- a/lib/ModelSpecificInstance.ts +++ b/lib/ModelSpecificInstance.ts @@ -1,5 +1,5 @@ import {Model} from "./Model"; -import {InstanceImplementation} from "./InstanceInterface"; +import {InstanceImplementation, InstanceInternals} from "./InstanceInterface"; import {ModelSpecificInstanceConstructor} from "./ModelInterfaces"; import * as util from "util"; import * as _ from "lodash"; @@ -26,13 +26,14 @@ export function ModelSpecificInstance { - if (model.transforms.hasOwnProperty(property)) { + const transform = model.transforms[property]; + if (transform) { return Object.defineProperty(virtualClass.prototype, property, { - get: function () { - return model.transforms[property].fromDB(this._modified[property], property, model); + get: function (this: InstanceInternals) { + return transform.fromDB(this._modified[property], property, model); }, - set: function (value) { - this._modified[property] = model.transforms[property].toDB(value, property, model); + set: function (this: InstanceInternals, value) { + this._modified[property] = transform.toDB(value, property, model); }, enumerable: true, configurable: true @@ -40,10 +41,10 @@ export function ModelSpecificInstance) { return this._modified[property]; }, - set: function (value) { + set: function (this: InstanceInternals, value) { this._modified[property] = value; }, enumerable: true diff --git a/lib/Transforms.ts b/lib/Transforms.ts index d58a394..59e80b4 100644 --- a/lib/Transforms.ts +++ b/lib/Transforms.ts @@ -7,7 +7,7 @@ export interface Transforms { */ $document?: PropertyTransform; _id?: PropertyTransform; - [property:string]: PropertyTransform; + [property:string]: PropertyTransform|undefined; } /** diff --git a/lib/utils/Omnom.ts b/lib/utils/Omnom.ts index 2883635..f81b3d7 100644 --- a/lib/utils/Omnom.ts +++ b/lib/utils/Omnom.ts @@ -1,5 +1,6 @@ import * as _ from "lodash"; import * as MongoDB from "mongodb"; +import {Changes} from "../Changes"; export class Omnom { constructor(public options: { @@ -8,22 +9,8 @@ export class Omnom { this._changes = {}; } - private _changes: { - $set?: any; - $unset?: any; - $inc?: any; - $push?: any; - $pull?: any; - $pullAll?: any; - }; - get changes(): { - $set?: any; - $unset?: any; - $inc?: any; - $push?: any; - $pull?: any; - $pullAll?: any; - } { + private _changes: Changes; + get changes(): Changes { return this._changes; } @@ -55,39 +42,49 @@ export class Omnom { } private onObject(original: number, modified: number, changePath?: string): void; - private onObject(original: [any], modified: any[], changePath?: string): void; + private onObject(original: any[], modified: any[], changePath?: string): void; private onObject(original: MongoDB.ObjectID, modified: MongoDB.ObjectID, changePath?: string): void; private onObject(original: Object, modified: Object, changePath?: string): void; private onObject(original: any, modified: any, changePath?: string): void { - if (original === undefined || original === null) - return (original !== modified) && this.set(changePath, modified); + if (changePath) { + if (original === undefined || original === null) + return (original !== modified) && this.set(changePath, modified); - if (typeof original === "number" && typeof modified === "number" && original !== modified) { - if (this.options.atomicNumbers) return this.inc(changePath, modified - original); - return this.set(changePath, modified); - } + if (typeof original === "number" && typeof modified === "number" && original !== modified) { + if (this.options.atomicNumbers) return this.inc(changePath, modified - original); + return this.set(changePath, modified); + } - if (Array.isArray(original) && Array.isArray(modified)) - return this.onArray(original, modified, changePath); + if (Array.isArray(original) && Array.isArray(modified)) + return this.onArray(original, modified, changePath); - if (original instanceof MongoDB.ObjectID && modified instanceof MongoDB.ObjectID) - return !original.equals(modified) && this.set(changePath, modified); + if (original instanceof MongoDB.ObjectID && modified instanceof MongoDB.ObjectID) + return !original.equals(modified) && this.set(changePath, modified); - if (!_.isPlainObject(original) || !_.isPlainObject(modified)) - return !_.isEqual(original, modified) && this.set(changePath, modified); + if (!_.isPlainObject(original) || !_.isPlainObject(modified)) + return !_.isEqual(original, modified) && this.set(changePath, modified); + } + + if (!_.isPlainObject(original) || !_.isPlainObject(modified)) { + throw new Error("Unable to perform a diff of a top level object unless it is an object itself. Provide an object to diff or specify the changePath"); + } _.forOwn(modified, (value, key) => { + if (!key) return; + // Handle array diffs in their own special way if (Array.isArray(value) && Array.isArray(original[key])) this.onArray(original[key], value, this.resolve(changePath, key)); // Otherwise, just keep going else this.onObject(original[key], value, this.resolve(changePath, key)); - }, this); + }); // Unset removed properties _.forOwn(original, (value, key) => { + if (!key) return; + if (modified[key] === undefined) return this.unset(this.resolve(changePath, key)); - }, this); + }); } private onArray(original: any[], modified: any[], changePath: string): void { @@ -106,7 +103,7 @@ export class Omnom { } private onSmallerArray(original: any[], modified: any[], changePath: string): void { - let pulls = []; + let pulls: any[] = []; let i = 0; let j = 0; @@ -149,8 +146,8 @@ export class Omnom { private onSimilarArray(original: any[], modified: any[], changePath: string): void { // Check how many manipulations would need to be performed, if it's more than half the array size // then rather re-create the array - let sets = []; - let partials = []; + let sets: number[] = []; + let partials: number[] = []; for (let i = 0; i < modified.length; i++) { let equality = this.almostEqual(original[i], modified[i]); if (equality === 0) sets.push(i); @@ -178,7 +175,7 @@ export class Omnom { if (!this.changes.$unset) this.changes.$unset = {}; - this.changes.$unset[path] = 1; + this.changes.$unset[path] = true; } private inc(path: string, value: number) { @@ -193,10 +190,11 @@ export class Omnom { this.changes.$push = {}; if (this.changes.$push[path]) { - if (this.changes.$push[path].$each) - this.changes.$push[path].$each.push(value); + const change = <{ $each: any[]; }>this.changes.$push[path]; + if (change && change.$each) + change.$each.push(value); else - this.changes.$push[path] = { $each: [this.changes.$push[path], value] }; + this.changes.$push[path] = { $each: [change, value] }; } else this.changes.$push[path] = value; } @@ -205,7 +203,8 @@ export class Omnom { this.changes.$pull = {}; if (this.changes.$pullAll && this.changes.$pullAll[path]) { - return this.changes.$pullAll[path].push(value); + this.changes.$pullAll[path].push(value); + return; } if (this.changes.$pull[path]) { @@ -226,8 +225,8 @@ export class Omnom { this.changes.$pullAll[path] = values; } - private resolve(...args) { - let validArguments = []; + private resolve(...args: (string|undefined)[]) { + let validArguments: string[] = []; args.forEach(function (arg) { if (arg) validArguments.push(arg); }); @@ -241,7 +240,7 @@ export class Omnom { let object1KeyIndex, object1Keys = Object.keys(o1); let object2Keys = Object.keys(o2); - let commonKeys = []; + let commonKeys: string[] = []; for (object1KeyIndex = 0; object1KeyIndex < object1Keys.length; object1KeyIndex++) if (~object2Keys.indexOf(object1Keys[object1KeyIndex])) commonKeys.push(object1Keys[object1KeyIndex]); diff --git a/package.json b/package.json index 55ff470..910200f 100644 --- a/package.json +++ b/package.json @@ -17,11 +17,11 @@ ], "licence": "MIT", "main": "./dist/iridium.js", + "typings": "dist/iridium.d.ts", "scripts": { "build": "tsc", - "build:definitions": "node ./build/bundle.js", - "prepublish": "npm run build && npm run build:definitions", "pretest": "npm run build", + "prepublish": "npm run build", "test": "mocha --opts test/mocha.opts dist/test", "coverage": "istanbul cover node_modules/mocha/bin/_mocha -- --opts test/mocha.opts dist/test", "lint": "tslint lib/", @@ -42,33 +42,40 @@ "watch:build": "tsc --watch", "watch:test": "mocha --opts test/mocha.opts --watch dist/test" }, - "typings": "iridium.ts", "engines": { "node": ">= 0.10" }, "dependencies": { + "@types/bluebird": "^2.0.29", + "@types/lodash": "0.0.28", + "@types/mongodb": "^2.1.29", + "@types/chai": "^3.4.29", "bluebird": "^3.3.4", "lodash": "^4.8.1", "mongodb": "~2.1.14", - "skmatc": "~1.2.0" + "skmatc": "~1.2.1" + }, + "peerDependencies": { + "@types/bluebird": "^2.0.29", + "@types/lodash": "0.0.28", + "@types/mongodb": "^2.1.29", + "@types/chai": "^3.4.29" }, "devDependencies": { + "@types/chai": "^3.4.29", + "@types/chai-as-promised": "0.0.28", + "@types/mocha": "^2.2.28", "chai": "^3.5.0", "chai-as-promised": "^5.2.0", "chalk": "^1.1.3", "codeclimate-test-reporter": "^0.3.1", - "colors": "^1.1.2", "concurrently": "^2.1.0", "coveralls": "^2.11.8", "istanbul": "~0.4.3", "mocha": "^2.5.3", - "semver": "^5.1.0", - "tick": "~0.1.1", "tslint": "^3.5.0", "typedoc": "~0.4.2", - "typescript": "~1.8.10", - "typings-core": "^1.0.1", - "underscore": "~1.8.3" + "typescript": "~2.0.0" }, "keywords": [ "mongodb", diff --git a/test/Core.ts b/test/Core.ts index 642d5dd..0d31e58 100644 --- a/test/Core.ts +++ b/test/Core.ts @@ -49,7 +49,7 @@ describe("Core",() => { }); it("should throw an error if no URI or configuration object was provided",() => { - chai.expect(() => new Iridium.Core("")).to.throw("Expected either a URI or config object to be supplied when initializing Iridium"); + chai.expect(() => new Iridium.Core(undefined)).to.throw("Expected either a URI or config object to be supplied when initializing Iridium"); }); describe("should correctly convert the configuration object into a URI string", () => { @@ -157,7 +157,7 @@ describe("Core",() => { } }); - chai.expect(core.settings.options).to.eql({ + chai.expect(core.settings!.options).to.eql({ server: { socketOptions: { connectTimeoutMS: 1000 @@ -305,7 +305,7 @@ describe("Core",() => { it("should be triggered before the connection is established", (done) => { let core = new InheritedCoreWithHooks(); core.events.once("connecting", (connection) => { - chai.expect(core.connection).to.not.exist; + chai.expect(() => core.connection).to.throw; done(); }); @@ -327,7 +327,7 @@ describe("Core",() => { core.onConnectingResult = (conn) => Bluebird.reject(new Error("Test error")); return chai.expect(core.connect().then(() => false, (err) => { - chai.expect(core.connection).to.not.exist; + chai.expect(() => core.connection).to.throw; return Bluebird.resolve(true); })).to.eventually.be.true; }); @@ -371,7 +371,7 @@ describe("Core",() => { core.onConnectedResult = () => Bluebird.reject(new Error("Test error")); return chai.expect(core.connect().then(() => false, (err) => { - chai.expect(core.connection).to.not.exist; + chai.expect(() => core.connection).to.throw; return Bluebird.resolve(true); })).to.eventually.be.true; }); diff --git a/test/Decorators.ts b/test/Decorators.ts index d7ca796..5e98a48 100644 --- a/test/Decorators.ts +++ b/test/Decorators.ts @@ -10,14 +10,13 @@ interface TestDocument { email: string; } -function VersionValidator(schema, data) { - return this.assert(/^\d+\.\d+\.\d+(?:-.+)?$/.test(data)); -} @Iridium.Collection("test") @Iridium.Index({ name: 1 }) @Iridium.Index({ email: 1 }, { background: true }) -@Iridium.Validate("version", VersionValidator) +@Iridium.Validate("version", function (schema, data) { + return this.assert(/^\d+\.\d+\.\d+(?:-.+)?$/.test(data)); +}) @Iridium.Property("version", "version") @Iridium.Property("optional2", Boolean, false) class Test extends Iridium.Instance implements TestDocument { @@ -122,16 +121,16 @@ describe("Decorators", () => { describe("the ObjectID transform", () => { it("should convert an ObjectID to a string", () => { - chai.expect(Test.transforms["_id"].fromDB(Iridium.toObjectID("aaaaaaaaaaaaaaaaaaaaaaaa"), "_id", null)).to.eql("aaaaaaaaaaaaaaaaaaaaaaaa"); + chai.expect(Test.transforms["_id"]!.fromDB(Iridium.toObjectID("aaaaaaaaaaaaaaaaaaaaaaaa"), "_id", null)).to.eql("aaaaaaaaaaaaaaaaaaaaaaaa"); }); it("should convert a string to an ObjectID", () => { - chai.expect(Test.transforms["_id"].toDB("aaaaaaaaaaaaaaaaaaaaaaaa", "_id", null)).to.be.instanceOf(MongoDB.ObjectID); + chai.expect(Test.transforms["_id"]!.toDB("aaaaaaaaaaaaaaaaaaaaaaaa", "_id", null)).to.be.instanceOf(MongoDB.ObjectID); }); it("should handle undefined values correctly", () => { - chai.expect(Test.transforms["_id"].toDB(undefined, "_id", null)).to.not.exist; - chai.expect(Test.transforms["_id"].fromDB(undefined, "_id", null)).to.not.exist; + chai.expect(Test.transforms["_id"]!.toDB(undefined, "_id", null)).to.not.exist; + chai.expect(Test.transforms["_id"]!.fromDB(undefined, "_id", null)).to.not.exist; }); }); }); diff --git a/test/Hooks.ts b/test/Hooks.ts index e66c0fa..c5e13d1 100644 --- a/test/Hooks.ts +++ b/test/Hooks.ts @@ -42,7 +42,7 @@ class Test extends Iridium.Instance { } } -describe("Hooks", function () { +describe("Hooks", function (this: Mocha) { this.timeout(500); let core = new Iridium.Core({ database: "test" }); @@ -56,7 +56,7 @@ describe("Hooks", function () { describe("creating",() => { after(() => { // Not used again - Test.onCreating = null; + Test.onCreating = (doc) => Promise.resolve(); }); it("should be called when a document is being created",(done) => { @@ -89,7 +89,7 @@ describe("Hooks", function () { describe("ready",() => { after(() => { // Not used again - Test.onReady = null; + Test.onReady = () => Promise.resolve(); }); it("should be called when an instance is prepared",() => { @@ -127,7 +127,7 @@ describe("Hooks", function () { describe("retreived",() => { after(() => { // Not used again - Test.onRetrieved = null; + Test.onRetrieved = () => Promise.resolve(); }); it("should be called when a document is being retrieved",() => { @@ -165,7 +165,7 @@ describe("Hooks", function () { describe("saving", () => { after(() => { // Not used again - Test.onSaving = null; + Test.onSaving = () => Promise.resolve(); }); it("should be triggered when save() is called on an instance",() => { diff --git a/test/Model.ts b/test/Model.ts index 5848470..8110acb 100644 --- a/test/Model.ts +++ b/test/Model.ts @@ -5,6 +5,12 @@ import * as Promise from "bluebird"; import * as _ from "lodash"; import * as chai from "chai"; +class TestCore extends Iridium.Core { + constructor() { + super("mongodb://localhost/iridium_test"); + } +} + interface TestDocument { _id?: string; answer: number; @@ -44,7 +50,7 @@ describe("Model",() => { it("should throw an error if you don't provide a valid core",() => { chai.expect(() => { - new Iridium.Model(null, createInstanceImplementation({ + new Iridium.Model(null, createInstanceImplementation({ collection: "test", schema: { _id: false } })) @@ -53,7 +59,7 @@ describe("Model",() => { it("should throw an error if you don't provide a valid instanceType",() => { chai.expect(() => { - new Iridium.Model(core, null) + new Iridium.Model(core, null) }).to.throw("You failed to provide a valid instance constructor for this model"); }); @@ -362,12 +368,12 @@ describe("Model",() => { }); it("should support retrieving a document using its ID",() => { - return chai.expect(model.findOne().then((doc) => model.findOne(doc._id))).to.eventually.exist.and.have.property("answer").is.a("number"); + return chai.expect(model.findOne().then((doc) => model.findOne(doc!._id))).to.eventually.exist.and.have.property("answer").is.a("number"); }); it("should retrieve the correct document by its ID",() => { return model.findOne().then((doc) => { - return chai.expect(model.findOne(doc._id)).to.eventually.exist.and.have.property("_id", doc._id); + return chai.expect(model.findOne(doc!._id)).to.eventually.exist.and.have.property("_id", doc!._id); }); }); @@ -384,7 +390,7 @@ describe("Model",() => { it("should allow you to limit the returned fields",() => { return chai.expect(model.findOne({}, { fields: { answer: 0 } - }).then((instance) => instance.answer)).to.eventually.be.undefined; + }).then((instance) => instance!.answer)).to.eventually.be.undefined; }); it("should support a callback style instead of promises",(done) => { @@ -633,7 +639,7 @@ describe("Model",() => { it("which should start returning items from the start of the query",() => { let cursor = model.find(); - return cursor.next().then(firstItem => cursor.rewind().next().then(rewoundItem => chai.expect(firstItem.document).to.eql(rewoundItem.document))); + return cursor.next().then(firstItem => cursor.rewind().next().then(rewoundItem => chai.expect(firstItem!.document).to.eql(rewoundItem!.document))); }); it("should carry through any other attributes",() => { @@ -696,7 +702,7 @@ describe("Model",() => { }); it("should allow an ID to be specified directly",() => { - return model.find({ answer: 10 }).next().then((instance) => chai.expect(model.find(instance._id).count()).to.eventually.equal(1)); + return model.find({ answer: 10 }).next().then((instance) => chai.expect(model.find(instance!._id).count()).to.eventually.equal(1)); }); it("should transform the conditions",() => { @@ -840,7 +846,7 @@ describe("Model",() => { }); describe("ensureIndexes()", () => { - let model = null; + let model: Iridium.Model; before(() => { Test.indexes = [{ answer: 1 }]; @@ -945,8 +951,8 @@ describe("Model",() => { it("should have a default ObjectID to String converter", () => { let model = new Iridium.Model(core, Test); - chai.expect(model.transforms["_id"].fromDB(MongoDB.ObjectID.createFromHexString("aaaaaaaaaaaaaaaaaaaaaaaa"), "_id", model)).to.eql("aaaaaaaaaaaaaaaaaaaaaaaa"); - chai.expect(model.transforms["_id"].toDB("aaaaaaaaaaaaaaaaaaaaaaaa", "_id", model)).to.eql(MongoDB.ObjectID.createFromHexString("aaaaaaaaaaaaaaaaaaaaaaaa")); + chai.expect(model.transforms["_id"]!.fromDB(MongoDB.ObjectID.createFromHexString("aaaaaaaaaaaaaaaaaaaaaaaa"), "_id", model)).to.eql("aaaaaaaaaaaaaaaaaaaaaaaa"); + chai.expect(model.transforms["_id"]!.toDB("aaaaaaaaaaaaaaaaaaaaaaaa", "_id", model)).to.eql(MongoDB.ObjectID.createFromHexString("aaaaaaaaaaaaaaaaaaaaaaaa")); }); it("should allow you to specify a custom converter by providing a property on the class", () => { @@ -955,8 +961,8 @@ describe("Model",() => { chai.expect(model.transforms["_id"]).to.exist.and.have.property("fromDB").which.is.a("function"); chai.expect(model.transforms["_id"]).to.exist.and.have.property("toDB").which.is.a("function"); - chai.expect(model.transforms["_id"].fromDB(12, "_id", model)).to.eql(120); - chai.expect(model.transforms["_id"].toDB(120, "_id", model)).to.eql(12); + chai.expect(model.transforms["_id"]!.fromDB(12, "_id", model)).to.eql(120); + chai.expect(model.transforms["_id"]!.toDB(120, "_id", model)).to.eql(12); }); }); }); \ No newline at end of file diff --git a/test/Omnom.ts b/test/Omnom.ts index 8745015..b3fa888 100644 --- a/test/Omnom.ts +++ b/test/Omnom.ts @@ -22,7 +22,7 @@ describe("Omnom",() => { let expectedDiff = { $set: { a: 3, b: "tested", f: "new" }, - $unset: { e: 1 } + $unset: { e: true } }; chai.expect(Omnom.diff(oldObject, newObject)).to.exist.and.be.eql(expectedDiff); @@ -48,7 +48,7 @@ describe("Omnom",() => { let expectedDiff = { $set: { b: "tested", f: "new" }, $inc: { a: 2 }, - $unset: { e: 1 } + $unset: { e: true } }; chai.expect(Omnom.diff(oldObject, newObject, { atomicNumbers: true })).to.exist.and.be.eql(expectedDiff); @@ -73,7 +73,7 @@ describe("Omnom",() => { let expectedDiff = { $set: { "a.value": 3, "b.value1": "tested", "b.value2": 2, "e.value2": false }, - $unset: { "e.value": 1 } + $unset: { "e.value": true } }; chai.expect(Omnom.diff(oldObject, newObject)).to.exist.and.be.eql(expectedDiff); @@ -138,7 +138,7 @@ describe("Omnom",() => { let expectedDiff = { $set: { "a.b.c.n": { x: 1, y: 2, z: "test" }, "a.b.d.m.w": 1, "a.b.e.m.y": 4 }, - $unset: { "a.b.c.m": 1, "a.b.d.m.x": 1 } + $unset: { "a.b.c.m": true, "a.b.d.m.x": true } }; chai.expect(Omnom.diff(oldObject, newObject)).to.exist.and.be.eql(expectedDiff); @@ -178,7 +178,7 @@ describe("Omnom",() => { }; let expectedDiff = { - $unset: { b: 1 } + $unset: { b: true } }; chai.expect(Omnom.diff(oldObject, newObject)).to.exist.and.be.eql(expectedDiff); @@ -204,10 +204,10 @@ describe("Omnom",() => { describe("arrays", function () { it("should correctly handle two pure arrays",() => { - let oldObject = [1, 2, 3]; - let newObject = [4, 5, 6]; + let oldObject = { arr: [1, 2, 3] }; + let newObject = { arr: [4, 5, 6] }; let expectedDiff = { - $set: { undefined: [4, 5, 6] } + $set: { arr: [4, 5, 6] } }; chai.expect(Omnom.diff(oldObject, newObject)).to.exist.and.be.eql(expectedDiff); diff --git a/test/Plugins.ts b/test/Plugins.ts index 52d2f8c..f156b33 100644 --- a/test/Plugins.ts +++ b/test/Plugins.ts @@ -120,14 +120,14 @@ describe("Plugins",() => { it("should allow a plugin to define a single validator",() => { core.register({ newInstance: (instance, model) => { }, - validate: Skmatc.create((schema) => schema == "Test", (schema, data) => this.assert(data == "test")) + validate: Skmatc.create((schema) => schema == "Test", function (schema, data) { return this.assert(data == "test") }) }); }); it("should allow a plugin to define multiple validators",() => { core.register({ newInstance: (instance, model) => { }, - validate: [Skmatc.create((schema) => schema == "Test",(schema, data) => this.assert(data == "test"))] + validate: [Skmatc.create((schema) => schema == "Test", function (schema, data) { return this.assert(data == "test") })] }); }); }); diff --git a/test/Transforms.ts b/test/Transforms.ts index 71d066f..0b4b4ec 100644 --- a/test/Transforms.ts +++ b/test/Transforms.ts @@ -112,7 +112,7 @@ describe("Transforms", () => { chai.expect(onCreatingCalled).to.be.true; chai.expect(user).to.exist; chai.expect(user).to.have.property("document").with.property("lastModified"); - chai.expect(user.document.lastModified.valueOf()).to.be.closeTo(new Date().valueOf(), 1000); + chai.expect(user.document.lastModified!.valueOf()).to.be.closeTo(new Date().valueOf(), 1000); }); }); @@ -160,7 +160,7 @@ describe("Transforms", () => { }).then(person => { chai.expect(person).to.exist; chai.expect(person).to.have.property("document").with.property("lastModified"); - chai.expect(person.document.lastModified.valueOf()).to.be.closeTo(new Date().valueOf(), 1000); + chai.expect(person.document.lastModified!.valueOf()).to.be.closeTo(new Date().valueOf(), 1000); chai.expect(onSavingCalled).to.be.true; }); }); @@ -218,7 +218,7 @@ describe("Transforms", () => { describe("the default Buffer transform", () => { it("should convert a MongoDB BSON Binary object into a buffer", () => { let transform = DefaultTransforms.Binary.fromDB; - let result = transform(new MongoDB.Binary(new Buffer("test", "utf8")), "_id", null); + let result = transform(new MongoDB.Binary(new Buffer("test", "utf8")), "_id", null); chai.expect(result).to.exist; chai.expect(result.toString("utf8")).to.eql("test"); @@ -227,7 +227,7 @@ describe("Transforms", () => { it("should convert the buffer into a MongoDB.Binary object", () => { let transform = DefaultTransforms.Binary.toDB; let buffer = new Buffer("test", "utf8"); - let result = transform(buffer, "_id", null); + let result = transform(buffer, "_id", null); chai.expect(result).to.be.instanceOf(MongoDB.Binary); }); diff --git a/tsconfig.json b/tsconfig.json index 1fc57f4..5f00bee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,9 @@ "declaration": true, "experimentalDecorators": true, "outDir": "./dist/", - "moduleResolution": "node" + "moduleResolution": "node", + "strictNullChecks": true, + "noImplicitThis": true }, "exclude": [ "dist", diff --git a/typings.json b/typings.json deleted file mode 100644 index 6580e52..0000000 --- a/typings.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "iridium", - "version": false, - "main": "dist/iridium.d.ts", - "dependencies": { - "bluebird": "registry:npm/bluebird#3.3.4+20160515010139", - "lodash": "registry:npm/lodash#4.0.0+20160416211519", - "mongodb": "registry:npm/mongodb#2.1.0+20160422172506", - "skmatc": "github:sierrasoftworks/skmatc#master" - }, - "devDependencies": { - "chai": "registry:npm/chai#3.5.0+20160415060238", - "chai-as-promised": "registry:npm/chai-as-promised#5.1.0+20160310030142" - }, - "globalDevDependencies": { - "mocha": "registry:dt/mocha#2.2.5+20160317120654" - }, - "globalDependencies": { - "node": "registry:dt/node#6.0.0+20160514165920" - } -} diff --git a/typings/.gitignore b/typings/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/typings/.jshintignore b/typings/.jshintignore deleted file mode 100644 index e69de29..0000000 diff --git a/typings/globals/mocha/index.d.ts b/typings/globals/mocha/index.d.ts deleted file mode 100644 index 852e7b6..0000000 --- a/typings/globals/mocha/index.d.ts +++ /dev/null @@ -1,233 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/mocha/mocha.d.ts -interface MochaSetupOptions { - //milliseconds to wait before considering a test slow - slow?: number; - - // timeout in milliseconds - timeout?: number; - - // ui name "bdd", "tdd", "exports" etc - ui?: string; - - //array of accepted globals - globals?: any[]; - - // reporter instance (function or string), defaults to `mocha.reporters.Spec` - reporter?: any; - - // bail on the first test failure - bail?: boolean; - - // ignore global leaks - ignoreLeaks?: boolean; - - // grep string or regexp to filter tests with - grep?: any; -} - -interface MochaDone { - (error?: Error): void; -} - -declare var mocha: Mocha; -declare var describe: Mocha.IContextDefinition; -declare var xdescribe: Mocha.IContextDefinition; -// alias for `describe` -declare var context: Mocha.IContextDefinition; -// alias for `describe` -declare var suite: Mocha.IContextDefinition; -declare var it: Mocha.ITestDefinition; -declare var xit: Mocha.ITestDefinition; -// alias for `it` -declare var test: Mocha.ITestDefinition; - -declare function before(action: () => void): void; - -declare function before(action: (done: MochaDone) => void): void; - -declare function before(description: string, action: () => void): void; - -declare function before(description: string, action: (done: MochaDone) => void): void; - -declare function setup(action: () => void): void; - -declare function setup(action: (done: MochaDone) => void): void; - -declare function after(action: () => void): void; - -declare function after(action: (done: MochaDone) => void): void; - -declare function after(description: string, action: () => void): void; - -declare function after(description: string, action: (done: MochaDone) => void): void; - -declare function teardown(action: () => void): void; - -declare function teardown(action: (done: MochaDone) => void): void; - -declare function beforeEach(action: () => void): void; - -declare function beforeEach(action: (done: MochaDone) => void): void; - -declare function beforeEach(description: string, action: () => void): void; - -declare function beforeEach(description: string, action: (done: MochaDone) => void): void; - -declare function suiteSetup(action: () => void): void; - -declare function suiteSetup(action: (done: MochaDone) => void): void; - -declare function afterEach(action: () => void): void; - -declare function afterEach(action: (done: MochaDone) => void): void; - -declare function afterEach(description: string, action: () => void): void; - -declare function afterEach(description: string, action: (done: MochaDone) => void): void; - -declare function suiteTeardown(action: () => void): void; - -declare function suiteTeardown(action: (done: MochaDone) => void): void; - -declare class Mocha { - constructor(options?: { - grep?: RegExp; - ui?: string; - reporter?: string; - timeout?: number; - bail?: boolean; - }); - - /** Setup mocha with the given options. */ - setup(options: MochaSetupOptions): Mocha; - bail(value?: boolean): Mocha; - addFile(file: string): Mocha; - /** Sets reporter by name, defaults to "spec". */ - reporter(name: string): Mocha; - /** Sets reporter constructor, defaults to mocha.reporters.Spec. */ - reporter(reporter: (runner: Mocha.IRunner, options: any) => any): Mocha; - ui(value: string): Mocha; - grep(value: string): Mocha; - grep(value: RegExp): Mocha; - invert(): Mocha; - ignoreLeaks(value: boolean): Mocha; - checkLeaks(): Mocha; - /** - * Function to allow assertion libraries to throw errors directly into mocha. - * This is useful when running tests in a browser because window.onerror will - * only receive the 'message' attribute of the Error. - */ - throwError(error: Error): void; - /** Enables growl support. */ - growl(): Mocha; - globals(value: string): Mocha; - globals(values: string[]): Mocha; - useColors(value: boolean): Mocha; - useInlineDiffs(value: boolean): Mocha; - timeout(value: number): Mocha; - slow(value: number): Mocha; - enableTimeouts(value: boolean): Mocha; - asyncOnly(value: boolean): Mocha; - noHighlighting(value: boolean): Mocha; - /** Runs tests and invokes `onComplete()` when finished. */ - run(onComplete?: (failures: number) => void): Mocha.IRunner; -} - -// merge the Mocha class declaration with a module -declare namespace Mocha { - /** Partial interface for Mocha's `Runnable` class. */ - interface IRunnable { - title: string; - fn: Function; - async: boolean; - sync: boolean; - timedOut: boolean; - } - - /** Partial interface for Mocha's `Suite` class. */ - interface ISuite { - parent: ISuite; - title: string; - - fullTitle(): string; - } - - /** Partial interface for Mocha's `Test` class. */ - interface ITest extends IRunnable { - parent: ISuite; - pending: boolean; - - fullTitle(): string; - } - - /** Partial interface for Mocha's `Runner` class. */ - interface IRunner {} - - interface IContextDefinition { - (description: string, spec: () => void): ISuite; - only(description: string, spec: () => void): ISuite; - skip(description: string, spec: () => void): void; - timeout(ms: number): void; - } - - interface ITestDefinition { - (expectation: string, assertion?: () => void): ITest; - (expectation: string, assertion?: (done: MochaDone) => void): ITest; - only(expectation: string, assertion?: () => void): ITest; - only(expectation: string, assertion?: (done: MochaDone) => void): ITest; - skip(expectation: string, assertion?: () => void): void; - skip(expectation: string, assertion?: (done: MochaDone) => void): void; - timeout(ms: number): void; - } - - export module reporters { - export class Base { - stats: { - suites: number; - tests: number; - passes: number; - pending: number; - failures: number; - }; - - constructor(runner: IRunner); - } - - export class Doc extends Base {} - export class Dot extends Base {} - export class HTML extends Base {} - export class HTMLCov extends Base {} - export class JSON extends Base {} - export class JSONCov extends Base {} - export class JSONStream extends Base {} - export class Landing extends Base {} - export class List extends Base {} - export class Markdown extends Base {} - export class Min extends Base {} - export class Nyan extends Base {} - export class Progress extends Base { - /** - * @param options.open String used to indicate the start of the progress bar. - * @param options.complete String used to indicate a complete test on the progress bar. - * @param options.incomplete String used to indicate an incomplete test on the progress bar. - * @param options.close String used to indicate the end of the progress bar. - */ - constructor(runner: IRunner, options?: { - open?: string; - complete?: string; - incomplete?: string; - close?: string; - }); - } - export class Spec extends Base {} - export class TAP extends Base {} - export class XUnit extends Base { - constructor(runner: IRunner, options?: any); - } - } -} - -declare module "mocha" { - export = Mocha; -} \ No newline at end of file diff --git a/typings/globals/mocha/typings.json b/typings/globals/mocha/typings.json deleted file mode 100644 index e0c039d..0000000 --- a/typings/globals/mocha/typings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "resolution": "main", - "tree": { - "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/mocha/mocha.d.ts", - "raw": "registry:dt/mocha#2.2.5+20160317120654", - "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/mocha/mocha.d.ts" - } -} diff --git a/typings/globals/node/index.d.ts b/typings/globals/node/index.d.ts deleted file mode 100644 index 182774d..0000000 --- a/typings/globals/node/index.d.ts +++ /dev/null @@ -1,2381 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/eeede9d1ad03e27fe3537334c17ff09a77ac5819/node/node.d.ts -interface Error { - stack?: string; -} - - -// compat for TypeScript 1.8 -// if you use with --target es3 or --target es5 and use below definitions, -// use the lib.es6.d.ts that is bundled with TypeScript 1.8. -interface MapConstructor {} -interface WeakMapConstructor {} -interface SetConstructor {} -interface WeakSetConstructor {} - -/************************************************ -* * -* GLOBAL * -* * -************************************************/ -declare var process: NodeJS.Process; -declare var global: NodeJS.Global; - -declare var __filename: string; -declare var __dirname: string; - -declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; -declare function clearTimeout(timeoutId: NodeJS.Timer): void; -declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; -declare function clearInterval(intervalId: NodeJS.Timer): void; -declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; -declare function clearImmediate(immediateId: any): void; - -interface NodeRequireFunction { - (id: string): any; -} - -interface NodeRequire extends NodeRequireFunction { - resolve(id:string): string; - cache: any; - extensions: any; - main: any; -} - -declare var require: NodeRequire; - -interface NodeModule { - exports: any; - require: NodeRequireFunction; - id: string; - filename: string; - loaded: boolean; - parent: any; - children: any[]; -} - -declare var module: NodeModule; - -// Same as module.exports -declare var exports: any; -declare var SlowBuffer: { - new (str: string, encoding?: string): Buffer; - new (size: number): Buffer; - new (size: Uint8Array): Buffer; - new (array: any[]): Buffer; - prototype: Buffer; - isBuffer(obj: any): boolean; - byteLength(string: string, encoding?: string): number; - concat(list: Buffer[], totalLength?: number): Buffer; -}; - - -// Buffer class -type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "binary" | "hex"; -interface Buffer extends NodeBuffer {} - -/** - * Raw data is stored in instances of the Buffer class. - * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized. - * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' - */ -declare var Buffer: { - /** - * Allocates a new buffer containing the given {str}. - * - * @param str String to store in buffer. - * @param encoding encoding to use, optional. Default is 'utf8' - */ - new (str: string, encoding?: string): Buffer; - /** - * Allocates a new buffer of {size} octets. - * - * @param size count of octets to allocate. - */ - new (size: number): Buffer; - /** - * Allocates a new buffer containing the given {array} of octets. - * - * @param array The octets to store. - */ - new (array: Uint8Array): Buffer; - /** - * Produces a Buffer backed by the same allocated memory as - * the given {ArrayBuffer}. - * - * - * @param arrayBuffer The ArrayBuffer with which to share memory. - */ - new (arrayBuffer: ArrayBuffer): Buffer; - /** - * Allocates a new buffer containing the given {array} of octets. - * - * @param array The octets to store. - */ - new (array: any[]): Buffer; - /** - * Copies the passed {buffer} data onto a new {Buffer} instance. - * - * @param buffer The buffer to copy. - */ - new (buffer: Buffer): Buffer; - prototype: Buffer; - /** - * Allocates a new Buffer using an {array} of octets. - * - * @param array - */ - from(array: any[]): Buffer; - /** - * When passed a reference to the .buffer property of a TypedArray instance, - * the newly created Buffer will share the same allocated memory as the TypedArray. - * The optional {byteOffset} and {length} arguments specify a memory range - * within the {arrayBuffer} that will be shared by the Buffer. - * - * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer() - * @param byteOffset - * @param length - */ - from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?:number): Buffer; - /** - * Copies the passed {buffer} data onto a new Buffer instance. - * - * @param buffer - */ - from(buffer: Buffer): Buffer; - /** - * Creates a new Buffer containing the given JavaScript string {str}. - * If provided, the {encoding} parameter identifies the character encoding. - * If not provided, {encoding} defaults to 'utf8'. - * - * @param str - */ - from(str: string, encoding?: string): Buffer; - /** - * Returns true if {obj} is a Buffer - * - * @param obj object to test. - */ - isBuffer(obj: any): obj is Buffer; - /** - * Returns true if {encoding} is a valid encoding argument. - * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' - * - * @param encoding string to test. - */ - isEncoding(encoding: string): boolean; - /** - * Gives the actual byte length of a string. encoding defaults to 'utf8'. - * This is not the same as String.prototype.length since that returns the number of characters in a string. - * - * @param string string to test. - * @param encoding encoding used to evaluate (defaults to 'utf8') - */ - byteLength(string: string, encoding?: string): number; - /** - * Returns a buffer which is the result of concatenating all the buffers in the list together. - * - * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. - * If the list has exactly one item, then the first item of the list is returned. - * If the list has more than one item, then a new Buffer is created. - * - * @param list An array of Buffer objects to concatenate - * @param totalLength Total length of the buffers when concatenated. - * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. - */ - concat(list: Buffer[], totalLength?: number): Buffer; - /** - * The same as buf1.compare(buf2). - */ - compare(buf1: Buffer, buf2: Buffer): number; -}; - -/************************************************ -* * -* GLOBAL INTERFACES * -* * -************************************************/ -declare namespace NodeJS { - export interface ErrnoException extends Error { - errno?: number; - code?: string; - path?: string; - syscall?: string; - stack?: string; - } - - export interface EventEmitter { - addListener(event: string, listener: Function): this; - on(event: string, listener: Function): this; - once(event: string, listener: Function): this; - removeListener(event: string, listener: Function): this; - removeAllListeners(event?: string): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string): Function[]; - emit(event: string, ...args: any[]): boolean; - listenerCount(type: string): number; - } - - export interface ReadableStream extends EventEmitter { - readable: boolean; - read(size?: number): string|Buffer; - setEncoding(encoding: string): void; - pause(): void; - resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; - unshift(chunk: string): void; - unshift(chunk: Buffer): void; - wrap(oldStream: ReadableStream): ReadableStream; - } - - export interface WritableStream extends EventEmitter { - writable: boolean; - write(buffer: Buffer|string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - } - - export interface ReadWriteStream extends ReadableStream, WritableStream {} - - export interface Events extends EventEmitter { } - - export interface Domain extends Events { - run(fn: Function): void; - add(emitter: Events): void; - remove(emitter: Events): void; - bind(cb: (err: Error, data: any) => any): any; - intercept(cb: (data: any) => any): any; - dispose(): void; - - addListener(event: string, listener: Function): this; - on(event: string, listener: Function): this; - once(event: string, listener: Function): this; - removeListener(event: string, listener: Function): this; - removeAllListeners(event?: string): this; - } - - export interface MemoryUsage { - rss: number; - heapTotal: number; - heapUsed: number; - } - - export interface Process extends EventEmitter { - stdout: WritableStream; - stderr: WritableStream; - stdin: ReadableStream; - argv: string[]; - execArgv: string[]; - execPath: string; - abort(): void; - chdir(directory: string): void; - cwd(): string; - env: any; - exit(code?: number): void; - getgid(): number; - setgid(id: number): void; - setgid(id: string): void; - getuid(): number; - setuid(id: number): void; - setuid(id: string): void; - version: string; - versions: { - http_parser: string; - node: string; - v8: string; - ares: string; - uv: string; - zlib: string; - openssl: string; - }; - config: { - target_defaults: { - cflags: any[]; - default_configuration: string; - defines: string[]; - include_dirs: string[]; - libraries: string[]; - }; - variables: { - clang: number; - host_arch: string; - node_install_npm: boolean; - node_install_waf: boolean; - node_prefix: string; - node_shared_openssl: boolean; - node_shared_v8: boolean; - node_shared_zlib: boolean; - node_use_dtrace: boolean; - node_use_etw: boolean; - node_use_openssl: boolean; - target_arch: string; - v8_no_strict_aliasing: number; - v8_use_snapshot: boolean; - visibility: string; - }; - }; - kill(pid:number, signal?: string|number): void; - pid: number; - title: string; - arch: string; - platform: string; - memoryUsage(): MemoryUsage; - nextTick(callback: Function): void; - umask(mask?: number): number; - uptime(): number; - hrtime(time?:number[]): number[]; - domain: Domain; - - // Worker - send?(message: any, sendHandle?: any): void; - disconnect(): void; - connected: boolean; - } - - export interface Global { - Array: typeof Array; - ArrayBuffer: typeof ArrayBuffer; - Boolean: typeof Boolean; - Buffer: typeof Buffer; - DataView: typeof DataView; - Date: typeof Date; - Error: typeof Error; - EvalError: typeof EvalError; - Float32Array: typeof Float32Array; - Float64Array: typeof Float64Array; - Function: typeof Function; - GLOBAL: Global; - Infinity: typeof Infinity; - Int16Array: typeof Int16Array; - Int32Array: typeof Int32Array; - Int8Array: typeof Int8Array; - Intl: typeof Intl; - JSON: typeof JSON; - Map: MapConstructor; - Math: typeof Math; - NaN: typeof NaN; - Number: typeof Number; - Object: typeof Object; - Promise: Function; - RangeError: typeof RangeError; - ReferenceError: typeof ReferenceError; - RegExp: typeof RegExp; - Set: SetConstructor; - String: typeof String; - Symbol: Function; - SyntaxError: typeof SyntaxError; - TypeError: typeof TypeError; - URIError: typeof URIError; - Uint16Array: typeof Uint16Array; - Uint32Array: typeof Uint32Array; - Uint8Array: typeof Uint8Array; - Uint8ClampedArray: Function; - WeakMap: WeakMapConstructor; - WeakSet: WeakSetConstructor; - clearImmediate: (immediateId: any) => void; - clearInterval: (intervalId: NodeJS.Timer) => void; - clearTimeout: (timeoutId: NodeJS.Timer) => void; - console: typeof console; - decodeURI: typeof decodeURI; - decodeURIComponent: typeof decodeURIComponent; - encodeURI: typeof encodeURI; - encodeURIComponent: typeof encodeURIComponent; - escape: (str: string) => string; - eval: typeof eval; - global: Global; - isFinite: typeof isFinite; - isNaN: typeof isNaN; - parseFloat: typeof parseFloat; - parseInt: typeof parseInt; - process: Process; - root: Global; - setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any; - setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; - setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; - undefined: typeof undefined; - unescape: (str: string) => string; - gc: () => void; - v8debug?: any; - } - - export interface Timer { - ref() : void; - unref() : void; - } -} - -/** - * @deprecated - */ -interface NodeBuffer extends Uint8Array { - write(string: string, offset?: number, length?: number, encoding?: string): number; - toString(encoding?: string, start?: number, end?: number): string; - toJSON(): any; - equals(otherBuffer: Buffer): boolean; - compare(otherBuffer: Buffer): number; - copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; - slice(start?: number, end?: number): Buffer; - writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; - readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; - readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; - readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; - readUInt8(offset: number, noAssert?: boolean): number; - readUInt16LE(offset: number, noAssert?: boolean): number; - readUInt16BE(offset: number, noAssert?: boolean): number; - readUInt32LE(offset: number, noAssert?: boolean): number; - readUInt32BE(offset: number, noAssert?: boolean): number; - readInt8(offset: number, noAssert?: boolean): number; - readInt16LE(offset: number, noAssert?: boolean): number; - readInt16BE(offset: number, noAssert?: boolean): number; - readInt32LE(offset: number, noAssert?: boolean): number; - readInt32BE(offset: number, noAssert?: boolean): number; - readFloatLE(offset: number, noAssert?: boolean): number; - readFloatBE(offset: number, noAssert?: boolean): number; - readDoubleLE(offset: number, noAssert?: boolean): number; - readDoubleBE(offset: number, noAssert?: boolean): number; - writeUInt8(value: number, offset: number, noAssert?: boolean): number; - writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeInt8(value: number, offset: number, noAssert?: boolean): number; - writeInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeFloatLE(value: number, offset: number, noAssert?: boolean): number; - writeFloatBE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; - fill(value: any, offset?: number, end?: number): Buffer; - // TODO: encoding param - indexOf(value: string | number | Buffer, byteOffset?: number): number; - // TODO: entries - // TODO: includes - // TODO: keys - // TODO: values -} - -/************************************************ -* * -* MODULES * -* * -************************************************/ -declare module "buffer" { - export var INSPECT_MAX_BYTES: number; - var BuffType: typeof Buffer; - var SlowBuffType: typeof SlowBuffer; - export { BuffType as Buffer, SlowBuffType as SlowBuffer }; -} - -declare module "querystring" { - export interface StringifyOptions { - encodeURIComponent?: Function; - } - - export interface ParseOptions { - maxKeys?: number; - decodeURIComponent?: Function; - } - - export function stringify(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string; - export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any; - export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): T; - export function escape(str: string): string; - export function unescape(str: string): string; -} - -declare module "events" { - export class EventEmitter implements NodeJS.EventEmitter { - static EventEmitter: EventEmitter; - static listenerCount(emitter: EventEmitter, event: string): number; // deprecated - static defaultMaxListeners: number; - - addListener(event: string, listener: Function): this; - on(event: string, listener: Function): this; - once(event: string, listener: Function): this; - removeListener(event: string, listener: Function): this; - removeAllListeners(event?: string): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string): Function[]; - emit(event: string, ...args: any[]): boolean; - listenerCount(type: string): number; - } -} - -declare module "http" { - import * as events from "events"; - import * as net from "net"; - import * as stream from "stream"; - - export interface RequestOptions { - protocol?: string; - host?: string; - hostname?: string; - family?: number; - port?: number; - localAddress?: string; - socketPath?: string; - method?: string; - path?: string; - headers?: { [key: string]: any }; - auth?: string; - agent?: Agent|boolean; - } - - export interface Server extends events.EventEmitter, net.Server { - setTimeout(msecs: number, callback: Function): void; - maxHeadersCount: number; - timeout: number; - } - /** - * @deprecated Use IncomingMessage - */ - export interface ServerRequest extends IncomingMessage { - connection: net.Socket; - } - export interface ServerResponse extends events.EventEmitter, stream.Writable { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - writeContinue(): void; - writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; - writeHead(statusCode: number, headers?: any): void; - statusCode: number; - statusMessage: string; - headersSent: boolean; - setHeader(name: string, value: string | string[]): void; - sendDate: boolean; - getHeader(name: string): string; - removeHeader(name: string): void; - write(chunk: any, encoding?: string): any; - addTrailers(headers: any): void; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } - export interface ClientRequest extends events.EventEmitter, stream.Writable { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - write(chunk: any, encoding?: string): void; - abort(): void; - setTimeout(timeout: number, callback?: Function): void; - setNoDelay(noDelay?: boolean): void; - setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; - - setHeader(name: string, value: string | string[]): void; - getHeader(name: string): string; - removeHeader(name: string): void; - addTrailers(headers: any): void; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } - export interface IncomingMessage extends events.EventEmitter, stream.Readable { - httpVersion: string; - headers: any; - rawHeaders: string[]; - trailers: any; - rawTrailers: any; - setTimeout(msecs: number, callback: Function): NodeJS.Timer; - /** - * Only valid for request obtained from http.Server. - */ - method?: string; - /** - * Only valid for request obtained from http.Server. - */ - url?: string; - /** - * Only valid for response obtained from http.ClientRequest. - */ - statusCode?: number; - /** - * Only valid for response obtained from http.ClientRequest. - */ - statusMessage?: string; - socket: net.Socket; - } - /** - * @deprecated Use IncomingMessage - */ - export interface ClientResponse extends IncomingMessage { } - - export interface AgentOptions { - /** - * Keep sockets around in a pool to be used by other requests in the future. Default = false - */ - keepAlive?: boolean; - /** - * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. - * Only relevant if keepAlive is set to true. - */ - keepAliveMsecs?: number; - /** - * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity - */ - maxSockets?: number; - /** - * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. - */ - maxFreeSockets?: number; - } - - export class Agent { - maxSockets: number; - sockets: any; - requests: any; - - constructor(opts?: AgentOptions); - - /** - * Destroy any sockets that are currently in use by the agent. - * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, - * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, - * sockets may hang open for quite a long time before the server terminates them. - */ - destroy(): void; - } - - export var METHODS: string[]; - - export var STATUS_CODES: { - [errorCode: number]: string; - [errorCode: string]: string; - }; - export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) =>void ): Server; - export function createClient(port?: number, host?: string): any; - export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; - export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest; - export var globalAgent: Agent; -} - -declare module "cluster" { - import * as child from "child_process"; - import * as events from "events"; - - export interface ClusterSettings { - exec?: string; - args?: string[]; - silent?: boolean; - } - - export interface Address { - address: string; - port: number; - addressType: string; - } - - export class Worker extends events.EventEmitter { - id: string; - process: child.ChildProcess; - suicide: boolean; - send(message: any, sendHandle?: any): void; - kill(signal?: string): void; - destroy(signal?: string): void; - disconnect(): void; - isConnected(): boolean; - isDead(): boolean; - } - - export var settings: ClusterSettings; - export var isMaster: boolean; - export var isWorker: boolean; - export function setupMaster(settings?: ClusterSettings): void; - export function fork(env?: any): Worker; - export function disconnect(callback?: Function): void; - export var worker: Worker; - export var workers: { - [index: string]: Worker - }; - - // Event emitter - export function addListener(event: string, listener: Function): void; - export function on(event: "disconnect", listener: (worker: Worker) => void): void; - export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): void; - export function on(event: "fork", listener: (worker: Worker) => void): void; - export function on(event: "listening", listener: (worker: Worker, address: any) => void): void; - export function on(event: "message", listener: (worker: Worker, message: any) => void): void; - export function on(event: "online", listener: (worker: Worker) => void): void; - export function on(event: "setup", listener: (settings: any) => void): void; - export function on(event: string, listener: Function): any; - export function once(event: string, listener: Function): void; - export function removeListener(event: string, listener: Function): void; - export function removeAllListeners(event?: string): void; - export function setMaxListeners(n: number): void; - export function listeners(event: string): Function[]; - export function emit(event: string, ...args: any[]): boolean; -} - -declare module "zlib" { - import * as stream from "stream"; - export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } - - export interface Gzip extends stream.Transform { } - export interface Gunzip extends stream.Transform { } - export interface Deflate extends stream.Transform { } - export interface Inflate extends stream.Transform { } - export interface DeflateRaw extends stream.Transform { } - export interface InflateRaw extends stream.Transform { } - export interface Unzip extends stream.Transform { } - - export function createGzip(options?: ZlibOptions): Gzip; - export function createGunzip(options?: ZlibOptions): Gunzip; - export function createDeflate(options?: ZlibOptions): Deflate; - export function createInflate(options?: ZlibOptions): Inflate; - export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; - export function createInflateRaw(options?: ZlibOptions): InflateRaw; - export function createUnzip(options?: ZlibOptions): Unzip; - - export function deflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function deflateSync(buf: Buffer, options?: ZlibOptions): any; - export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function deflateRawSync(buf: Buffer, options?: ZlibOptions): any; - export function gzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function gzipSync(buf: Buffer, options?: ZlibOptions): any; - export function gunzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function gunzipSync(buf: Buffer, options?: ZlibOptions): any; - export function inflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function inflateSync(buf: Buffer, options?: ZlibOptions): any; - export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function inflateRawSync(buf: Buffer, options?: ZlibOptions): any; - export function unzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function unzipSync(buf: Buffer, options?: ZlibOptions): any; - - // Constants - export var Z_NO_FLUSH: number; - export var Z_PARTIAL_FLUSH: number; - export var Z_SYNC_FLUSH: number; - export var Z_FULL_FLUSH: number; - export var Z_FINISH: number; - export var Z_BLOCK: number; - export var Z_TREES: number; - export var Z_OK: number; - export var Z_STREAM_END: number; - export var Z_NEED_DICT: number; - export var Z_ERRNO: number; - export var Z_STREAM_ERROR: number; - export var Z_DATA_ERROR: number; - export var Z_MEM_ERROR: number; - export var Z_BUF_ERROR: number; - export var Z_VERSION_ERROR: number; - export var Z_NO_COMPRESSION: number; - export var Z_BEST_SPEED: number; - export var Z_BEST_COMPRESSION: number; - export var Z_DEFAULT_COMPRESSION: number; - export var Z_FILTERED: number; - export var Z_HUFFMAN_ONLY: number; - export var Z_RLE: number; - export var Z_FIXED: number; - export var Z_DEFAULT_STRATEGY: number; - export var Z_BINARY: number; - export var Z_TEXT: number; - export var Z_ASCII: number; - export var Z_UNKNOWN: number; - export var Z_DEFLATED: number; - export var Z_NULL: number; -} - -declare module "os" { - export interface CpuInfo { - model: string; - speed: number; - times: { - user: number; - nice: number; - sys: number; - idle: number; - irq: number; - }; - } - - export interface NetworkInterfaceInfo { - address: string; - netmask: string; - family: string; - mac: string; - internal: boolean; - } - - export function tmpdir(): string; - export function homedir(): string; - export function endianness(): string; - export function hostname(): string; - export function type(): string; - export function platform(): string; - export function arch(): string; - export function release(): string; - export function uptime(): number; - export function loadavg(): number[]; - export function totalmem(): number; - export function freemem(): number; - export function cpus(): CpuInfo[]; - export function networkInterfaces(): {[index: string]: NetworkInterfaceInfo[]}; - export var EOL: string; -} - -declare module "https" { - import * as tls from "tls"; - import * as events from "events"; - import * as http from "http"; - - export interface ServerOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - crl?: any; - ciphers?: string; - honorCipherOrder?: boolean; - requestCert?: boolean; - rejectUnauthorized?: boolean; - NPNProtocols?: any; - SNICallback?: (servername: string) => any; - } - - export interface RequestOptions extends http.RequestOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - ciphers?: string; - rejectUnauthorized?: boolean; - secureProtocol?: string; - } - - export interface Agent extends http.Agent { } - - export interface AgentOptions extends http.AgentOptions { - maxCachedSessions?: number; - } - - export var Agent: { - new (options?: AgentOptions): Agent; - }; - export interface Server extends tls.Server { } - export function createServer(options: ServerOptions, requestListener?: Function): Server; - export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest; - export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest; - export var globalAgent: Agent; -} - -declare module "punycode" { - export function decode(string: string): string; - export function encode(string: string): string; - export function toUnicode(domain: string): string; - export function toASCII(domain: string): string; - export var ucs2: ucs2; - interface ucs2 { - decode(string: string): number[]; - encode(codePoints: number[]): string; - } - export var version: any; -} - -declare module "repl" { - import * as stream from "stream"; - import * as events from "events"; - - export interface ReplOptions { - prompt?: string; - input?: NodeJS.ReadableStream; - output?: NodeJS.WritableStream; - terminal?: boolean; - eval?: Function; - useColors?: boolean; - useGlobal?: boolean; - ignoreUndefined?: boolean; - writer?: Function; - } - export function start(options: ReplOptions): events.EventEmitter; -} - -declare module "readline" { - import * as events from "events"; - import * as stream from "stream"; - - export interface Key { - sequence?: string; - name?: string; - ctrl?: boolean; - meta?: boolean; - shift?: boolean; - } - - export interface ReadLine extends events.EventEmitter { - setPrompt(prompt: string): void; - prompt(preserveCursor?: boolean): void; - question(query: string, callback: (answer: string) => void): void; - pause(): ReadLine; - resume(): ReadLine; - close(): void; - write(data: string|Buffer, key?: Key): void; - } - - export interface Completer { - (line: string): CompleterResult; - (line: string, callback: (err: any, result: CompleterResult) => void): any; - } - - export interface CompleterResult { - completions: string[]; - line: string; - } - - export interface ReadLineOptions { - input: NodeJS.ReadableStream; - output?: NodeJS.WritableStream; - completer?: Completer; - terminal?: boolean; - historySize?: number; - } - - export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine; - export function createInterface(options: ReadLineOptions): ReadLine; - - export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void; - export function moveCursor(stream: NodeJS.WritableStream, dx: number|string, dy: number|string): void; - export function clearLine(stream: NodeJS.WritableStream, dir: number): void; - export function clearScreenDown(stream: NodeJS.WritableStream): void; -} - -declare module "vm" { - export interface Context { } - export interface ScriptOptions { - filename?: string; - lineOffset?: number; - columnOffset?: number; - displayErrors?: boolean; - timeout?: number; - cachedData?: Buffer; - produceCachedData?: boolean; - } - export interface RunningScriptOptions { - filename?: string; - lineOffset?: number; - columnOffset?: number; - displayErrors?: boolean; - timeout?: number; - } - export class Script { - constructor(code: string, options?: ScriptOptions); - runInContext(contextifiedSandbox: Context, options?: RunningScriptOptions): any; - runInNewContext(sandbox?: Context, options?: RunningScriptOptions): any; - runInThisContext(options?: RunningScriptOptions): any; - } - export function createContext(sandbox?: Context): Context; - export function isContext(sandbox: Context): boolean; - export function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions): any; - export function runInDebugContext(code: string): any; - export function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions): any; - export function runInThisContext(code: string, options?: RunningScriptOptions): any; -} - -declare module "child_process" { - import * as events from "events"; - import * as stream from "stream"; - - export interface ChildProcess extends events.EventEmitter { - stdin: stream.Writable; - stdout: stream.Readable; - stderr: stream.Readable; - stdio: [stream.Writable, stream.Readable, stream.Readable]; - pid: number; - kill(signal?: string): void; - send(message: any, sendHandle?: any): void; - disconnect(): void; - unref(): void; - } - - export interface SpawnOptions { - cwd?: string; - env?: any; - stdio?: any; - detached?: boolean; - uid?: number; - gid?: number; - shell?: boolean | string; - } - export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess; - - export interface ExecOptions { - cwd?: string; - env?: any; - shell?: string; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - uid?: number; - gid?: number; - } - export interface ExecOptionsWithStringEncoding extends ExecOptions { - encoding: BufferEncoding; - } - export interface ExecOptionsWithBufferEncoding extends ExecOptions { - encoding: string; // specify `null`. - } - export function exec(command: string, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess; - export function exec(command: string, options: ExecOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess; - // usage. child_process.exec("tsc", {encoding: null as string}, (err, stdout, stderr) => {}); - export function exec(command: string, options: ExecOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function exec(command: string, options: ExecOptions, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess; - - export interface ExecFileOptions { - cwd?: string; - env?: any; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - uid?: number; - gid?: number; - } - export interface ExecFileOptionsWithStringEncoding extends ExecFileOptions { - encoding: BufferEncoding; - } - export interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions { - encoding: string; // specify `null`. - } - export function execFile(file: string, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess; - export function execFile(file: string, options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess; - // usage. child_process.execFile("file.sh", {encoding: null as string}, (err, stdout, stderr) => {}); - export function execFile(file: string, options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function execFile(file: string, options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess; - export function execFile(file: string, args?: string[], callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess; - export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess; - // usage. child_process.execFile("file.sh", ["foo"], {encoding: null as string}, (err, stdout, stderr) => {}); - export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function execFile(file: string, args?: string[], options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess; - - export interface ForkOptions { - cwd?: string; - env?: any; - execPath?: string; - execArgv?: string[]; - silent?: boolean; - uid?: number; - gid?: number; - } - export function fork(modulePath: string, args?: string[], options?: ForkOptions): ChildProcess; - - export interface SpawnSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: string; - shell?: boolean | string; - } - export interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions { - encoding: BufferEncoding; - } - export interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions { - encoding: string; // specify `null`. - } - export interface SpawnSyncReturns { - pid: number; - output: string[]; - stdout: T; - stderr: T; - status: number; - signal: string; - error: Error; - } - export function spawnSync(command: string): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions): SpawnSyncReturns; - - export interface ExecSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - shell?: string; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: string; - } - export interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions { - encoding: BufferEncoding; - } - export interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions { - encoding: string; // specify `null`. - } - export function execSync(command: string): Buffer; - export function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string; - export function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer; - export function execSync(command: string, options?: ExecSyncOptions): Buffer; - - export interface ExecFileSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: string; - } - export interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions { - encoding: BufferEncoding; - } - export interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions { - encoding: string; // specify `null`. - } - export function execFileSync(command: string): Buffer; - export function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string; - export function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer; - export function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithStringEncoding): string; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithBufferEncoding): Buffer; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions): Buffer; -} - -declare module "url" { - export interface Url { - href?: string; - protocol?: string; - auth?: string; - hostname?: string; - port?: string; - host?: string; - pathname?: string; - search?: string; - query?: string | any; - slashes?: boolean; - hash?: string; - path?: string; - } - - export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url; - export function format(url: Url): string; - export function resolve(from: string, to: string): string; -} - -declare module "dns" { - export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) =>void ): string; - export function lookup(domain: string, callback: (err: Error, address: string, family: number) =>void ): string; - export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve4(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve6(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function reverse(ip: string, callback: (err: Error, domains: string[]) =>void ): string[]; -} - -declare module "net" { - import * as stream from "stream"; - - export interface Socket extends stream.Duplex { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - connect(port: number, host?: string, connectionListener?: Function): void; - connect(path: string, connectionListener?: Function): void; - bufferSize: number; - setEncoding(encoding?: string): void; - write(data: any, encoding?: string, callback?: Function): void; - destroy(): void; - pause(): void; - resume(): void; - setTimeout(timeout: number, callback?: Function): void; - setNoDelay(noDelay?: boolean): void; - setKeepAlive(enable?: boolean, initialDelay?: number): void; - address(): { port: number; family: string; address: string; }; - unref(): void; - ref(): void; - - remoteAddress: string; - remoteFamily: string; - remotePort: number; - localAddress: string; - localPort: number; - bytesRead: number; - bytesWritten: number; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } - - export var Socket: { - new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket; - }; - - export interface ListenOptions { - port?: number; - host?: string; - backlog?: number; - path?: string; - exclusive?: boolean; - } - - export interface Server extends Socket { - listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): Server; - listen(port: number, hostname?: string, listeningListener?: Function): Server; - listen(port: number, backlog?: number, listeningListener?: Function): Server; - listen(port: number, listeningListener?: Function): Server; - listen(path: string, backlog?: number, listeningListener?: Function): Server; - listen(path: string, listeningListener?: Function): Server; - listen(handle: any, backlog?: number, listeningListener?: Function): Server; - listen(handle: any, listeningListener?: Function): Server; - listen(options: ListenOptions, listeningListener?: Function): Server; - close(callback?: Function): Server; - address(): { port: number; family: string; address: string; }; - getConnections(cb: (error: Error, count: number) => void): void; - ref(): Server; - unref(): Server; - maxConnections: number; - connections: number; - } - export function createServer(connectionListener?: (socket: Socket) =>void ): Server; - export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) =>void ): Server; - export function connect(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; - export function connect(port: number, host?: string, connectionListener?: Function): Socket; - export function connect(path: string, connectionListener?: Function): Socket; - export function createConnection(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; - export function createConnection(port: number, host?: string, connectionListener?: Function): Socket; - export function createConnection(path: string, connectionListener?: Function): Socket; - export function isIP(input: string): number; - export function isIPv4(input: string): boolean; - export function isIPv6(input: string): boolean; -} - -declare module "dgram" { - import * as events from "events"; - - interface RemoteInfo { - address: string; - port: number; - size: number; - } - - interface AddressInfo { - address: string; - family: string; - port: number; - } - - export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; - - interface Socket extends events.EventEmitter { - send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; - bind(port: number, address?: string, callback?: () => void): void; - close(): void; - address(): AddressInfo; - setBroadcast(flag: boolean): void; - setMulticastTTL(ttl: number): void; - setMulticastLoopback(flag: boolean): void; - addMembership(multicastAddress: string, multicastInterface?: string): void; - dropMembership(multicastAddress: string, multicastInterface?: string): void; - } -} - -declare module "fs" { - import * as stream from "stream"; - import * as events from "events"; - - interface Stats { - isFile(): boolean; - isDirectory(): boolean; - isBlockDevice(): boolean; - isCharacterDevice(): boolean; - isSymbolicLink(): boolean; - isFIFO(): boolean; - isSocket(): boolean; - dev: number; - ino: number; - mode: number; - nlink: number; - uid: number; - gid: number; - rdev: number; - size: number; - blksize: number; - blocks: number; - atime: Date; - mtime: Date; - ctime: Date; - birthtime: Date; - } - - interface FSWatcher extends events.EventEmitter { - close(): void; - } - - export interface ReadStream extends stream.Readable { - close(): void; - } - export interface WriteStream extends stream.Writable { - close(): void; - bytesWritten: number; - } - - /** - * Asynchronous rename. - * @param oldPath - * @param newPath - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Synchronous rename - * @param oldPath - * @param newPath - */ - export function renameSync(oldPath: string, newPath: string): void; - export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncateSync(path: string, len?: number): void; - export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function ftruncateSync(fd: number, len?: number): void; - export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chownSync(path: string, uid: number, gid: number): void; - export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchownSync(fd: number, uid: number, gid: number): void; - export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchownSync(path: string, uid: number, gid: number): void; - export function chmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmodSync(path: string, mode: number): void; - export function chmodSync(path: string, mode: string): void; - export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchmodSync(fd: number, mode: number): void; - export function fchmodSync(fd: number, mode: string): void; - export function lchmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmodSync(path: string, mode: number): void; - export function lchmodSync(path: string, mode: string): void; - export function stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function lstat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function statSync(path: string): Stats; - export function lstatSync(path: string): Stats; - export function fstatSync(fd: number): Stats; - export function link(srcpath: string, dstpath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function linkSync(srcpath: string, dstpath: string): void; - export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; - export function readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; - export function readlinkSync(path: string): string; - export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; - export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeJS.ErrnoException, resolvedPath: string) =>any): void; - export function realpathSync(path: string, cache?: { [path: string]: string }): string; - /* - * Asynchronous unlink - deletes the file specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous unlink - deletes the file specified in {path} - * - * @param path - */ - export function unlinkSync(path: string): void; - /* - * Asynchronous rmdir - removes the directory specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous rmdir - removes the directory specified in {path} - * - * @param path - */ - export function rmdirSync(path: string): void; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdirSync(path: string, mode?: number): void; - /* - * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdirSync(path: string, mode?: string): void; - /* - * Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. - * - * @param prefix - * @param callback The created folder path is passed as a string to the callback's second parameter. - */ - export function mkdtemp(prefix: string, callback?: (err: NodeJS.ErrnoException, folder: string) => void): void; - /* - * Synchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. - * - * @param prefix - * @returns Returns the created folder path. - */ - export function mkdtempSync(prefix: string): string; - export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; - export function readdirSync(path: string): string[]; - export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function closeSync(fd: number): void; - export function open(path: string, flags: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: number, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; - export function openSync(path: string, flags: string, mode?: number): number; - export function openSync(path: string, flags: string, mode?: string): number; - export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimes(path: string, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimesSync(path: string, atime: number, mtime: number): void; - export function utimesSync(path: string, atime: Date, mtime: Date): void; - export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function futimesSync(fd: number, atime: number, mtime: number): void; - export function futimesSync(fd: number, atime: Date, mtime: Date): void; - export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fsyncSync(fd: number): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; - export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position?: number): number; - export function writeSync(fd: number, data: any, position?: number, enconding?: string): number; - export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; - export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param encoding - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; - /* - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param encoding - */ - export function readFileSync(filename: string, encoding: string): string; - /* - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. - */ - export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; - /* - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. - */ - export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; - export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; - export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; - export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; - export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void; - export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void; - export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher; - export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; - export function exists(path: string, callback?: (exists: boolean) => void): void; - export function existsSync(path: string): boolean; - /** Constant for fs.access(). File is visible to the calling process. */ - export var F_OK: number; - /** Constant for fs.access(). File can be read by the calling process. */ - export var R_OK: number; - /** Constant for fs.access(). File can be written by the calling process. */ - export var W_OK: number; - /** Constant for fs.access(). File can be executed by the calling process. */ - export var X_OK: number; - /** Tests a user's permissions for the file specified by path. */ - export function access(path: string, callback: (err: NodeJS.ErrnoException) => void): void; - export function access(path: string, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; - /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */ - export function accessSync(path: string, mode ?: number): void; - export function createReadStream(path: string, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - autoClose?: boolean; - }): ReadStream; - export function createWriteStream(path: string, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - }): WriteStream; -} - -declare module "path" { - - /** - * A parsed path object generated by path.parse() or consumed by path.format(). - */ - export interface ParsedPath { - /** - * The root of the path such as '/' or 'c:\' - */ - root: string; - /** - * The full directory path such as '/home/user/dir' or 'c:\path\dir' - */ - dir: string; - /** - * The file name including extension (if any) such as 'index.html' - */ - base: string; - /** - * The file extension (if any) such as '.html' - */ - ext: string; - /** - * The file name without extension (if any) such as 'index' - */ - name: string; - } - - /** - * Normalize a string path, reducing '..' and '.' parts. - * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. - * - * @param p string path to normalize. - */ - export function normalize(p: string): string; - /** - * Join all arguments together and normalize the resulting path. - * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. - * - * @param paths string paths to join. - */ - export function join(...paths: any[]): string; - /** - * Join all arguments together and normalize the resulting path. - * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. - * - * @param paths string paths to join. - */ - export function join(...paths: string[]): string; - /** - * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. - * - * Starting from leftmost {from} paramter, resolves {to} to an absolute path. - * - * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory. - * - * @param pathSegments string paths to join. Non-string arguments are ignored. - */ - export function resolve(...pathSegments: any[]): string; - /** - * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. - * - * @param path path to test. - */ - export function isAbsolute(path: string): boolean; - /** - * Solve the relative path from {from} to {to}. - * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. - * - * @param from - * @param to - */ - export function relative(from: string, to: string): string; - /** - * Return the directory name of a path. Similar to the Unix dirname command. - * - * @param p the path to evaluate. - */ - export function dirname(p: string): string; - /** - * Return the last portion of a path. Similar to the Unix basename command. - * Often used to extract the file name from a fully qualified path. - * - * @param p the path to evaluate. - * @param ext optionally, an extension to remove from the result. - */ - export function basename(p: string, ext?: string): string; - /** - * Return the extension of the path, from the last '.' to end of string in the last portion of the path. - * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string - * - * @param p the path to evaluate. - */ - export function extname(p: string): string; - /** - * The platform-specific file separator. '\\' or '/'. - */ - export var sep: string; - /** - * The platform-specific file delimiter. ';' or ':'. - */ - export var delimiter: string; - /** - * Returns an object from a path string - the opposite of format(). - * - * @param pathString path to evaluate. - */ - export function parse(pathString: string): ParsedPath; - /** - * Returns a path string from an object - the opposite of parse(). - * - * @param pathString path to evaluate. - */ - export function format(pathObject: ParsedPath): string; - - export module posix { - export function normalize(p: string): string; - export function join(...paths: any[]): string; - export function resolve(...pathSegments: any[]): string; - export function isAbsolute(p: string): boolean; - export function relative(from: string, to: string): string; - export function dirname(p: string): string; - export function basename(p: string, ext?: string): string; - export function extname(p: string): string; - export var sep: string; - export var delimiter: string; - export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; - } - - export module win32 { - export function normalize(p: string): string; - export function join(...paths: any[]): string; - export function resolve(...pathSegments: any[]): string; - export function isAbsolute(p: string): boolean; - export function relative(from: string, to: string): string; - export function dirname(p: string): string; - export function basename(p: string, ext?: string): string; - export function extname(p: string): string; - export var sep: string; - export var delimiter: string; - export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; - } -} - -declare module "string_decoder" { - export interface NodeStringDecoder { - write(buffer: Buffer): string; - detectIncompleteChar(buffer: Buffer): number; - } - export var StringDecoder: { - new (encoding: string): NodeStringDecoder; - }; -} - -declare module "tls" { - import * as crypto from "crypto"; - import * as net from "net"; - import * as stream from "stream"; - - var CLIENT_RENEG_LIMIT: number; - var CLIENT_RENEG_WINDOW: number; - - export interface TlsOptions { - host?: string; - port?: number; - pfx?: any; //string or buffer - key?: any; //string or buffer - passphrase?: string; - cert?: any; - ca?: any; //string or buffer - crl?: any; //string or string array - ciphers?: string; - honorCipherOrder?: any; - requestCert?: boolean; - rejectUnauthorized?: boolean; - NPNProtocols?: any; //array or Buffer; - SNICallback?: (servername: string) => any; - } - - export interface ConnectionOptions { - host?: string; - port?: number; - socket?: net.Socket; - pfx?: string | Buffer - key?: string | Buffer - passphrase?: string; - cert?: string | Buffer - ca?: (string | Buffer)[]; - rejectUnauthorized?: boolean; - NPNProtocols?: (string | Buffer)[]; - servername?: string; - } - - export interface Server extends net.Server { - close(): Server; - address(): { port: number; family: string; address: string; }; - addContext(hostName: string, credentials: { - key: string; - cert: string; - ca: string; - }): void; - maxConnections: number; - connections: number; - } - - export interface ClearTextStream extends stream.Duplex { - authorized: boolean; - authorizationError: Error; - getPeerCertificate(): any; - getCipher: { - name: string; - version: string; - }; - address: { - port: number; - family: string; - address: string; - }; - remoteAddress: string; - remotePort: number; - } - - export interface SecurePair { - encrypted: any; - cleartext: any; - } - - export interface SecureContextOptions { - pfx?: string | Buffer; - key?: string | Buffer; - passphrase?: string; - cert?: string | Buffer; - ca?: string | Buffer; - crl?: string | string[] - ciphers?: string; - honorCipherOrder?: boolean; - } - - export interface SecureContext { - context: any; - } - - export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) =>void ): Server; - export function connect(options: TlsOptions, secureConnectionListener?: () =>void ): ClearTextStream; - export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; - export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; - export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair; - export function createSecureContext(details: SecureContextOptions): SecureContext; -} - -declare module "crypto" { - export interface CredentialDetails { - pfx: string; - key: string; - passphrase: string; - cert: string; - ca: string | string[]; - crl: string | string[]; - ciphers: string; - } - export interface Credentials { context?: any; } - export function createCredentials(details: CredentialDetails): Credentials; - export function createHash(algorithm: string): Hash; - export function createHmac(algorithm: string, key: string): Hmac; - export function createHmac(algorithm: string, key: Buffer): Hmac; - export interface Hash { - update(data: any, input_encoding?: string): Hash; - digest(encoding: 'buffer'): Buffer; - digest(encoding: string): any; - digest(): Buffer; - } - export interface Hmac extends NodeJS.ReadWriteStream { - update(data: any, input_encoding?: string): Hmac; - digest(encoding: 'buffer'): Buffer; - digest(encoding: string): any; - digest(): Buffer; - } - export function createCipher(algorithm: string, password: any): Cipher; - export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; - export interface Cipher extends NodeJS.ReadWriteStream { - update(data: Buffer): Buffer; - update(data: string, input_encoding: "utf8"|"ascii"|"binary"): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: "binary"|"base64"|"hex"): string; - update(data: string, input_encoding: "utf8"|"ascii"|"binary", output_encoding: "binary"|"base64"|"hex"): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding: boolean): void; - getAuthTag(): Buffer; - } - export function createDecipher(algorithm: string, password: any): Decipher; - export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; - export interface Decipher extends NodeJS.ReadWriteStream { - update(data: Buffer): Buffer; - update(data: string, input_encoding: "binary"|"base64"|"hex"): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: "utf8"|"ascii"|"binary"): string; - update(data: string, input_encoding: "binary"|"base64"|"hex", output_encoding: "utf8"|"ascii"|"binary"): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding: boolean): void; - setAuthTag(tag: Buffer): void; - } - export function createSign(algorithm: string): Signer; - export interface Signer extends NodeJS.WritableStream { - update(data: any): void; - sign(private_key: string, output_format: string): string; - } - export function createVerify(algorith: string): Verify; - export interface Verify extends NodeJS.WritableStream { - update(data: any): void; - verify(object: string, signature: string, signature_format?: string): boolean; - } - export function createDiffieHellman(prime_length: number): DiffieHellman; - export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman; - export interface DiffieHellman { - generateKeys(encoding?: string): string; - computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; - getPrime(encoding?: string): string; - getGenerator(encoding: string): string; - getPublicKey(encoding?: string): string; - getPrivateKey(encoding?: string): string; - setPublicKey(public_key: string, encoding?: string): void; - setPrivateKey(public_key: string, encoding?: string): void; - } - export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer; - export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string) : Buffer; - export function randomBytes(size: number): Buffer; - export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; - export function pseudoRandomBytes(size: number): Buffer; - export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; - export interface RsaPublicKey { - key: string; - padding?: any; - } - export interface RsaPrivateKey { - key: string; - passphrase?: string, - padding?: any; - } - export function publicEncrypt(public_key: string|RsaPublicKey, buffer: Buffer): Buffer - export function privateDecrypt(private_key: string|RsaPrivateKey, buffer: Buffer): Buffer -} - -declare module "stream" { - import * as events from "events"; - - export class Stream extends events.EventEmitter { - pipe(destination: T, options?: { end?: boolean; }): T; - } - - export interface ReadableOptions { - highWaterMark?: number; - encoding?: string; - objectMode?: boolean; - } - - export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { - readable: boolean; - constructor(opts?: ReadableOptions); - _read(size: number): void; - read(size?: number): any; - setEncoding(encoding: string): void; - pause(): void; - resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; - unshift(chunk: any): void; - wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; - push(chunk: any, encoding?: string): boolean; - } - - export interface WritableOptions { - highWaterMark?: number; - decodeStrings?: boolean; - objectMode?: boolean; - } - - export class Writable extends events.EventEmitter implements NodeJS.WritableStream { - writable: boolean; - constructor(opts?: WritableOptions); - _write(chunk: any, encoding: string, callback: Function): void; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } - - export interface DuplexOptions extends ReadableOptions, WritableOptions { - allowHalfOpen?: boolean; - } - - // Note: Duplex extends both Readable and Writable. - export class Duplex extends Readable implements NodeJS.ReadWriteStream { - writable: boolean; - constructor(opts?: DuplexOptions); - _write(chunk: any, encoding: string, callback: Function): void; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } - - export interface TransformOptions extends ReadableOptions, WritableOptions {} - - // Note: Transform lacks the _read and _write methods of Readable/Writable. - export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { - readable: boolean; - writable: boolean; - constructor(opts?: TransformOptions); - _transform(chunk: any, encoding: string, callback: Function): void; - _flush(callback: Function): void; - read(size?: number): any; - setEncoding(encoding: string): void; - pause(): void; - resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; - unshift(chunk: any): void; - wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; - push(chunk: any, encoding?: string): boolean; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } - - export class PassThrough extends Transform {} -} - -declare module "util" { - export interface InspectOptions { - showHidden?: boolean; - depth?: number; - colors?: boolean; - customInspect?: boolean; - } - - export function format(format: any, ...param: any[]): string; - export function debug(string: string): void; - export function error(...param: any[]): void; - export function puts(...param: any[]): void; - export function print(...param: any[]): void; - export function log(string: string): void; - export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string; - export function inspect(object: any, options: InspectOptions): string; - export function isArray(object: any): boolean; - export function isRegExp(object: any): boolean; - export function isDate(object: any): boolean; - export function isError(object: any): boolean; - export function inherits(constructor: any, superConstructor: any): void; - export function debuglog(key:string): (msg:string,...param: any[])=>void; -} - -declare module "assert" { - function internal (value: any, message?: string): void; - namespace internal { - export class AssertionError implements Error { - name: string; - message: string; - actual: any; - expected: any; - operator: string; - generatedMessage: boolean; - - constructor(options?: {message?: string; actual?: any; expected?: any; - operator?: string; stackStartFunction?: Function}); - } - - export function fail(actual?: any, expected?: any, message?: string, operator?: string): void; - export function ok(value: any, message?: string): void; - export function equal(actual: any, expected: any, message?: string): void; - export function notEqual(actual: any, expected: any, message?: string): void; - export function deepEqual(actual: any, expected: any, message?: string): void; - export function notDeepEqual(acutal: any, expected: any, message?: string): void; - export function strictEqual(actual: any, expected: any, message?: string): void; - export function notStrictEqual(actual: any, expected: any, message?: string): void; - export function deepStrictEqual(actual: any, expected: any, message?: string): void; - export function notDeepStrictEqual(actual: any, expected: any, message?: string): void; - export var throws: { - (block: Function, message?: string): void; - (block: Function, error: Function, message?: string): void; - (block: Function, error: RegExp, message?: string): void; - (block: Function, error: (err: any) => boolean, message?: string): void; - }; - - export var doesNotThrow: { - (block: Function, message?: string): void; - (block: Function, error: Function, message?: string): void; - (block: Function, error: RegExp, message?: string): void; - (block: Function, error: (err: any) => boolean, message?: string): void; - }; - - export function ifError(value: any): void; - } - - export = internal; -} - -declare module "tty" { - import * as net from "net"; - - export function isatty(fd: number): boolean; - export interface ReadStream extends net.Socket { - isRaw: boolean; - setRawMode(mode: boolean): void; - isTTY: boolean; - } - export interface WriteStream extends net.Socket { - columns: number; - rows: number; - isTTY: boolean; - } -} - -declare module "domain" { - import * as events from "events"; - - export class Domain extends events.EventEmitter implements NodeJS.Domain { - run(fn: Function): void; - add(emitter: events.EventEmitter): void; - remove(emitter: events.EventEmitter): void; - bind(cb: (err: Error, data: any) => any): any; - intercept(cb: (data: any) => any): any; - dispose(): void; - } - - export function create(): Domain; -} - -declare module "constants" { - export var E2BIG: number; - export var EACCES: number; - export var EADDRINUSE: number; - export var EADDRNOTAVAIL: number; - export var EAFNOSUPPORT: number; - export var EAGAIN: number; - export var EALREADY: number; - export var EBADF: number; - export var EBADMSG: number; - export var EBUSY: number; - export var ECANCELED: number; - export var ECHILD: number; - export var ECONNABORTED: number; - export var ECONNREFUSED: number; - export var ECONNRESET: number; - export var EDEADLK: number; - export var EDESTADDRREQ: number; - export var EDOM: number; - export var EEXIST: number; - export var EFAULT: number; - export var EFBIG: number; - export var EHOSTUNREACH: number; - export var EIDRM: number; - export var EILSEQ: number; - export var EINPROGRESS: number; - export var EINTR: number; - export var EINVAL: number; - export var EIO: number; - export var EISCONN: number; - export var EISDIR: number; - export var ELOOP: number; - export var EMFILE: number; - export var EMLINK: number; - export var EMSGSIZE: number; - export var ENAMETOOLONG: number; - export var ENETDOWN: number; - export var ENETRESET: number; - export var ENETUNREACH: number; - export var ENFILE: number; - export var ENOBUFS: number; - export var ENODATA: number; - export var ENODEV: number; - export var ENOENT: number; - export var ENOEXEC: number; - export var ENOLCK: number; - export var ENOLINK: number; - export var ENOMEM: number; - export var ENOMSG: number; - export var ENOPROTOOPT: number; - export var ENOSPC: number; - export var ENOSR: number; - export var ENOSTR: number; - export var ENOSYS: number; - export var ENOTCONN: number; - export var ENOTDIR: number; - export var ENOTEMPTY: number; - export var ENOTSOCK: number; - export var ENOTSUP: number; - export var ENOTTY: number; - export var ENXIO: number; - export var EOPNOTSUPP: number; - export var EOVERFLOW: number; - export var EPERM: number; - export var EPIPE: number; - export var EPROTO: number; - export var EPROTONOSUPPORT: number; - export var EPROTOTYPE: number; - export var ERANGE: number; - export var EROFS: number; - export var ESPIPE: number; - export var ESRCH: number; - export var ETIME: number; - export var ETIMEDOUT: number; - export var ETXTBSY: number; - export var EWOULDBLOCK: number; - export var EXDEV: number; - export var WSAEINTR: number; - export var WSAEBADF: number; - export var WSAEACCES: number; - export var WSAEFAULT: number; - export var WSAEINVAL: number; - export var WSAEMFILE: number; - export var WSAEWOULDBLOCK: number; - export var WSAEINPROGRESS: number; - export var WSAEALREADY: number; - export var WSAENOTSOCK: number; - export var WSAEDESTADDRREQ: number; - export var WSAEMSGSIZE: number; - export var WSAEPROTOTYPE: number; - export var WSAENOPROTOOPT: number; - export var WSAEPROTONOSUPPORT: number; - export var WSAESOCKTNOSUPPORT: number; - export var WSAEOPNOTSUPP: number; - export var WSAEPFNOSUPPORT: number; - export var WSAEAFNOSUPPORT: number; - export var WSAEADDRINUSE: number; - export var WSAEADDRNOTAVAIL: number; - export var WSAENETDOWN: number; - export var WSAENETUNREACH: number; - export var WSAENETRESET: number; - export var WSAECONNABORTED: number; - export var WSAECONNRESET: number; - export var WSAENOBUFS: number; - export var WSAEISCONN: number; - export var WSAENOTCONN: number; - export var WSAESHUTDOWN: number; - export var WSAETOOMANYREFS: number; - export var WSAETIMEDOUT: number; - export var WSAECONNREFUSED: number; - export var WSAELOOP: number; - export var WSAENAMETOOLONG: number; - export var WSAEHOSTDOWN: number; - export var WSAEHOSTUNREACH: number; - export var WSAENOTEMPTY: number; - export var WSAEPROCLIM: number; - export var WSAEUSERS: number; - export var WSAEDQUOT: number; - export var WSAESTALE: number; - export var WSAEREMOTE: number; - export var WSASYSNOTREADY: number; - export var WSAVERNOTSUPPORTED: number; - export var WSANOTINITIALISED: number; - export var WSAEDISCON: number; - export var WSAENOMORE: number; - export var WSAECANCELLED: number; - export var WSAEINVALIDPROCTABLE: number; - export var WSAEINVALIDPROVIDER: number; - export var WSAEPROVIDERFAILEDINIT: number; - export var WSASYSCALLFAILURE: number; - export var WSASERVICE_NOT_FOUND: number; - export var WSATYPE_NOT_FOUND: number; - export var WSA_E_NO_MORE: number; - export var WSA_E_CANCELLED: number; - export var WSAEREFUSED: number; - export var SIGHUP: number; - export var SIGINT: number; - export var SIGILL: number; - export var SIGABRT: number; - export var SIGFPE: number; - export var SIGKILL: number; - export var SIGSEGV: number; - export var SIGTERM: number; - export var SIGBREAK: number; - export var SIGWINCH: number; - export var SSL_OP_ALL: number; - export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; - export var SSL_OP_CIPHER_SERVER_PREFERENCE: number; - export var SSL_OP_CISCO_ANYCONNECT: number; - export var SSL_OP_COOKIE_EXCHANGE: number; - export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; - export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; - export var SSL_OP_EPHEMERAL_RSA: number; - export var SSL_OP_LEGACY_SERVER_CONNECT: number; - export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; - export var SSL_OP_MICROSOFT_SESS_ID_BUG: number; - export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number; - export var SSL_OP_NETSCAPE_CA_DN_BUG: number; - export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number; - export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; - export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; - export var SSL_OP_NO_COMPRESSION: number; - export var SSL_OP_NO_QUERY_MTU: number; - export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; - export var SSL_OP_NO_SSLv2: number; - export var SSL_OP_NO_SSLv3: number; - export var SSL_OP_NO_TICKET: number; - export var SSL_OP_NO_TLSv1: number; - export var SSL_OP_NO_TLSv1_1: number; - export var SSL_OP_NO_TLSv1_2: number; - export var SSL_OP_PKCS1_CHECK_1: number; - export var SSL_OP_PKCS1_CHECK_2: number; - export var SSL_OP_SINGLE_DH_USE: number; - export var SSL_OP_SINGLE_ECDH_USE: number; - export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; - export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; - export var SSL_OP_TLS_BLOCK_PADDING_BUG: number; - export var SSL_OP_TLS_D5_BUG: number; - export var SSL_OP_TLS_ROLLBACK_BUG: number; - export var ENGINE_METHOD_DSA: number; - export var ENGINE_METHOD_DH: number; - export var ENGINE_METHOD_RAND: number; - export var ENGINE_METHOD_ECDH: number; - export var ENGINE_METHOD_ECDSA: number; - export var ENGINE_METHOD_CIPHERS: number; - export var ENGINE_METHOD_DIGESTS: number; - export var ENGINE_METHOD_STORE: number; - export var ENGINE_METHOD_PKEY_METHS: number; - export var ENGINE_METHOD_PKEY_ASN1_METHS: number; - export var ENGINE_METHOD_ALL: number; - export var ENGINE_METHOD_NONE: number; - export var DH_CHECK_P_NOT_SAFE_PRIME: number; - export var DH_CHECK_P_NOT_PRIME: number; - export var DH_UNABLE_TO_CHECK_GENERATOR: number; - export var DH_NOT_SUITABLE_GENERATOR: number; - export var NPN_ENABLED: number; - export var RSA_PKCS1_PADDING: number; - export var RSA_SSLV23_PADDING: number; - export var RSA_NO_PADDING: number; - export var RSA_PKCS1_OAEP_PADDING: number; - export var RSA_X931_PADDING: number; - export var RSA_PKCS1_PSS_PADDING: number; - export var POINT_CONVERSION_COMPRESSED: number; - export var POINT_CONVERSION_UNCOMPRESSED: number; - export var POINT_CONVERSION_HYBRID: number; - export var O_RDONLY: number; - export var O_WRONLY: number; - export var O_RDWR: number; - export var S_IFMT: number; - export var S_IFREG: number; - export var S_IFDIR: number; - export var S_IFCHR: number; - export var S_IFLNK: number; - export var O_CREAT: number; - export var O_EXCL: number; - export var O_TRUNC: number; - export var O_APPEND: number; - export var F_OK: number; - export var R_OK: number; - export var W_OK: number; - export var X_OK: number; - export var UV_UDP_REUSEADDR: number; -} \ No newline at end of file diff --git a/typings/globals/node/typings.json b/typings/globals/node/typings.json deleted file mode 100644 index 9bb0b0b..0000000 --- a/typings/globals/node/typings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "resolution": "main", - "tree": { - "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/eeede9d1ad03e27fe3537334c17ff09a77ac5819/node/node.d.ts", - "raw": "registry:dt/node#6.0.0+20160514165920", - "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/eeede9d1ad03e27fe3537334c17ff09a77ac5819/node/node.d.ts" - } -} diff --git a/typings/index.d.ts b/typings/index.d.ts deleted file mode 100644 index 314d407..0000000 --- a/typings/index.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// -/// -/// -/// -/// -/// -/// -/// diff --git a/typings/modules/bluebird/index.d.ts b/typings/modules/bluebird/index.d.ts deleted file mode 100644 index 93800b5..0000000 --- a/typings/modules/bluebird/index.d.ts +++ /dev/null @@ -1,708 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-bluebird/8bd917a7ac4fef6796cd7fe5fc1d3b0fb118ad1a/bluebird.d.ts -declare module '~bluebird/bluebird' { -// Type definitions for Bluebird v3.x.x -// Project: http://bluebirdjs.com - -class Bluebird implements Bluebird.Thenable, Bluebird.Inspection { - /** - * Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise. - */ - constructor(callback: (resolve: (thenableOrResult: R | Bluebird.Thenable) => void, reject: (error: any) => void) => void); - - /** - * Promises/A+ `.then()`. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. - */ - then(onFulfill: (value: R) => U | Bluebird.Thenable, onReject?: (error: any) => U | Bluebird.Thenable): Bluebird; - then(onFulfill: (value: R) => U | Bluebird.Thenable, onReject?: (error: any) => void | Bluebird.Thenable): Bluebird; - - /** - * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler. - * - * Alias `.caught();` for compatibility with earlier ECMAScript version. - */ - catch(onReject?: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(onReject?: (error: any) => U | Bluebird.Thenable): Bluebird; - - /** - * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called. - * - * This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called. - * - * Alias `.caught();` for compatibility with earlier ECMAScript version. - */ - catch(predicate: (error: any) => boolean, onReject: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; - catch(ErrorClass: Function, onReject: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(ErrorClass: Function, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; - - /** - * Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections. - */ - error(onReject: (reason: any) => U | Bluebird.Thenable): Bluebird; - - /** - * Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler. - * - * Alias `.lastly();` for compatibility with earlier ECMAScript version. - */ - finally(handler: () => U | Bluebird.Thenable): Bluebird; - - lastly(handler: () => U | Bluebird.Thenable): Bluebird; - - /** - * Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise. - */ - bind(thisArg: any): Bluebird; - - /** - * Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error. - */ - done(onFulfilled?: (value: R) => U | Bluebird.Thenable, onRejected?: (error: any) => U | Bluebird.Thenable): void; - - /** - * Like `.finally()`, but not called for rejections. - */ - tap(onFulFill: (value: R) => Bluebird.Thenable): Bluebird; - tap(onFulfill: (value: R) => U): Bluebird; - - /** - * Same as calling `Promise.delay(ms, this)`. - */ - delay(ms: number): Bluebird; - - /** - * Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. - * However, if this promise is not fulfilled or rejected within ms milliseconds, the returned promise - * is rejected with a TimeoutError or the error as the reason. - * - * You may specify a custom error message with the `message` parameter. - */ - timeout(ms: number, message?: string | Error): Bluebird; - - /** - * Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success. - * If the `callback` argument is not a function, this method does not do anything. - */ - nodeify(callback: (err: any, value?: R) => void, options?: Bluebird.SpreadOption): this; - nodeify(...sink: any[]): this; - asCallback(callback: (err: any, value?: R) => void, options?: Bluebird.SpreadOption): this; - asCallback(...sink: any[]): this; - - /** - * See if this `promise` has been fulfilled. - */ - isFulfilled(): boolean; - - /** - * See if this `promise` has been rejected. - */ - isRejected(): boolean; - - /** - * See if this `promise` is still defer. - */ - isPending(): boolean; - - /** - * See if this `promise` is resolved -> either fulfilled or rejected. - */ - isResolved(): boolean; - - /** - * Get the fulfillment value of the underlying promise. Throws if the promise isn't fulfilled yet. - * - * throws `TypeError` - */ - value(): R; - - /** - * Get the rejection reason for the underlying promise. Throws if the promise isn't rejected yet. - * - * throws `TypeError` - */ - reason(): any; - - /** - * Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of - * the promise as snapshotted at the time of calling `.reflect()`. - */ - reflect(): Bluebird.Inspection; - - /** - * This is a convenience method for doing: - * - * - * promise.then(function(obj){ - * return obj[propertyName].call(obj, arg...); - * }); - * - */ - call(propertyName: string, ...args: any[]): Bluebird; - - /** - * This is a convenience method for doing: - * - * - * promise.then(function(obj){ - * return obj[propertyName]; - * }); - * - */ - // TODO: Use "type property type" once it's there - // @see https://github.com/Microsoft/TypeScript/issues/1295 - get(key: string | number): Bluebird; - - /** - * Convenience method for: - * - * - * .then(function() { - * return value; - * }); - * - * - * in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()` - * - * Alias `.thenReturn();` for compatibility with earlier ECMAScript version. - */ - return(): Bluebird; - thenReturn(): Bluebird; - return(value: U): Bluebird; - thenReturn(value: U): Bluebird; - - /** - * Convenience method for: - * - * - * .then(function() { - * throw reason; - * }); - * - * Same limitations apply as with `.return()`. - * - * Alias `.thenThrow();` for compatibility with earlier ECMAScript version. - */ - throw(reason: Error): Bluebird; - thenThrow(reason: Error): Bluebird; - - /** - * Convert to String. - */ - toString(): string; - - /** - * This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`. - */ - toJSON(): Object; - - /** - * Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers. - */ - spread(fulfilledHandler: (...values: W[]) => U | Bluebird.Thenable): Bluebird; - spread(fulfilledHandler: Function): Bluebird; - - /** - * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - all(): Bluebird; - - /** - * Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO how to model instance.props()? - props(): Bluebird; - - /** - * Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - any(): Bluebird; - - /** - * Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - some(count: number): Bluebird; - - /** - * Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - race(): Bluebird; - - /** - * Same as calling `Bluebird.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - map(mapper: (item: Q, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; - - /** - * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - reduce(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; - - /** - * Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - // TODO type inference from array-resolving promise? - filter(filterer: (item: U, index: number, arrayLength: number) => boolean | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; - - /** - * Same as calling ``Bluebird.each(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - each(iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; - - /** - * Same as calling ``Bluebird.mapSeries(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - mapSeries(iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; - - /** - * Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise. - * - * Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call. - * - * Alias for `attempt();` for compatibility with earlier ECMAScript version. - */ - static try(fn: () => R | Bluebird.Thenable): Bluebird; - - static attempt(fn: () => R | Bluebird.Thenable): Bluebird; - - /** - * Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function. - * This method is convenient when a function can sometimes return synchronously or throw synchronously. - */ - static method(fn: Function): Function; - - /** - * Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state. - */ - static resolve(): Bluebird; - static resolve(value: R | Bluebird.Thenable): Bluebird; - - /** - * Create a promise that is rejected with the given `reason`. - */ - static reject(reason: any): Bluebird; - static reject(reason: any): Bluebird; - - /** - * Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?: Promise(#promise-resolution). - */ - static defer(): Bluebird.Resolver; - - /** - * Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable. - */ - static cast(value: R | Bluebird.Thenable): Bluebird; - - /** - * Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`. - */ - static bind(thisArg: any): Bluebird; - - /** - * See if `value` is a trusted Promise. - */ - static is(value: any): boolean; - - /** - * Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have already been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency. - */ - static longStackTraces(): void; - - /** - * Returns a promise that will be resolved with value (or undefined) after given ms milliseconds. - * If value is a promise, the delay will start counting down when it is fulfilled and the returned - * promise will be fulfilled with the fulfillment value of the value promise. - */ - static delay(ms: number, value: R | Bluebird.Thenable): Bluebird; - static delay(ms: number): Bluebird; - - /** - * Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument. - * - * If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them. - * - * If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`. - */ - static promisify(func: (callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): () => Bluebird; - static promisify(func: (arg1: A1, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird; - static promisify(nodeFunction: Function, options?: Bluebird.PromisifyOptions): Function; - - /** - * Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object. - * - * Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method. - */ - // TODO how to model promisifyAll? - static promisifyAll(target: Object, options?: Bluebird.PromisifyAllOptions): Object; - - /** - * Returns a promise that is resolved by a node style callback function. - */ - static fromNode(resolver: (callback: (err: any, result?: any) => void) => void, options?: Bluebird.FromNodeOptions): Bluebird; - static fromNode(resolver: (callback: (err: any, result?: T) => void) => void, options?: Bluebird.FromNodeOptions): Bluebird; - static fromCallback(resolver: (callback: (err: any, result?: any) => void) => void, options?: Bluebird.FromNodeOptions): Bluebird; - static fromCallback(resolver: (callback: (err: any, result?: T) => void) => void, options?: Bluebird.FromNodeOptions): Bluebird; - - /** - * Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. - */ - // TODO fix coroutine GeneratorFunction - static coroutine(generatorFunction: Function): Function; - - /** - * Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers. - * - * Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections. - */ - static onPossiblyUnhandledRejection(handler: (reason: any) => any): void; - - /** - * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason. - */ - // TODO enable more overloads - // array with promises of different types - static all(values: [Bluebird.Thenable | T1]): Bluebird<[T1]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2]): Bluebird<[T1, T2]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2, Bluebird.Thenable | T3]): Bluebird<[T1, T2, T3]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2, Bluebird.Thenable | T3, Bluebird.Thenable | T4]): Bluebird<[T1, T2, T3, T4]>; - static all(values: [Bluebird.Thenable | T1, Bluebird.Thenable | T2, Bluebird.Thenable | T3, Bluebird.Thenable | T4, Bluebird.Thenable | T5]): Bluebird<[T1, T2, T3, T4, T5]>; - // array with values - static all(values: ((R | Bluebird.Thenable) | Bluebird.Thenable<(R | Bluebird.Thenable)>)[]): Bluebird; - - /** - * Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason. - * - * If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties. - * - * *The original object is not modified.* - */ - // TODO verify this is correct - // trusted promise for object - static props(object: Bluebird): Bluebird; - // object - static props(object: Object): Bluebird; - - /** - * Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly. - */ - static any(values: Bluebird.Thenable<(Bluebird.Thenable | R)[]> | (Bluebird.Thenable | R)[]): Bluebird; - - /** - * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value. - * - * **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending. - */ - static race(values: Bluebird.Thenable<(Bluebird.Thenable | R)[]> | (Bluebird.Thenable | R)[]): Bluebird; - - /** - * Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution. - * - * If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in. - * - * *The original array is not modified.* - */ - // promise of array with promises of value - static some(values: Bluebird.Thenable[]>, count: number): Bluebird; - // promise of array with values - static some(values: Bluebird.Thenable, count: number): Bluebird; - // array with promises of value - static some(values: Bluebird.Thenable[], count: number): Bluebird; - // array with values - static some(values: R[], count: number): Bluebird; - - /** - * Promise.join( - * Promise|any values..., - * function handler - * ) -> Promise - * For coordinating multiple concurrent discrete promises. - * - * Note: In 1.x and 0.x Promise.join used to be a Promise.all that took the values in as arguments instead in an array. This behavior has been deprecated but is still supported partially - when the last argument is an immediate function value the new semantics will apply - */ - static join(arg1: A1 | Bluebird.Thenable, handler: (arg1?: A1) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, handler: (arg1?: A1, arg2?: A2) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, arg3: A3 | Bluebird.Thenable, handler: (arg1?: A1, arg2?: A2, arg3?: A3) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, arg3: A3 | Bluebird.Thenable, arg4: A4 | Bluebird.Thenable, handler: (arg1?: A1, arg2?: A2, arg3?: A3, arg4?: A4) => R | Bluebird.Thenable): Bluebird; - static join(arg1: A1 | Bluebird.Thenable, arg2: A2 | Bluebird.Thenable, arg3: A3 | Bluebird.Thenable, arg4: A4 | Bluebird.Thenable, arg5: A5 | Bluebird.Thenable, handler: (arg1?: A1, arg2?: A2, arg3?: A3, arg4?: A4, arg5?: A5) => R | Bluebird.Thenable): Bluebird; - - // variadic array - /** @deprecated use .all instead */ - static join(...values: (R | Bluebird.Thenable)[]): Bluebird; - - /** - * Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. - * - * If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well. - * - * *The original array is not modified.* - */ - // promise of array with promises of value - static map(values: Bluebird.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; - - // promise of array with values - static map(values: Bluebird.Thenable, mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; - - // array with promises of value - static map(values: Bluebird.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; - - // array with values - static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable, options?: Bluebird.ConcurrencyOption): Bluebird; - - /** - * Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. - * - * If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. - * - * *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.* - */ - // promise of array with promises of value - static reduce(values: Bluebird.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; - - // promise of array with values - static reduce(values: Bluebird.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; - - // array with promises of value - static reduce(values: Bluebird.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; - - // array with values - static reduce(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable, initialValue?: U): Bluebird; - - /** - * Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. - * - * The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result. - * - * *The original array is not modified. - */ - // promise of array with promises of value - static filter(values: Bluebird.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; - - // promise of array with values - static filter(values: Bluebird.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; - - // array with promises of value - static filter(values: Bluebird.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; - - // array with values - static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable, option?: Bluebird.ConcurrencyOption): Bluebird; - - /** - * Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well. - * - * Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. - */ - // promise of array with promises of value - static each(values: Bluebird.Thenable[]>, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; - // array with promises of value - static each(values: Bluebird.Thenable[], iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; - // array with values OR promise of array with values - static each(values: R[] | Bluebird.Thenable, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; - - /** - * Given an Iterable(arrays are Iterable), or a promise of an Iterable, which produces promises (or a mix of promises and values), iterate over all the values in the Iterable into an array and iterate over the array serially, in-order. - * - * Returns a promise for an array that contains the values returned by the iterator function in their respective positions. The iterator won't be called for an item until its previous item, and the promise returned by the iterator for that item are fulfilled. This results in a mapSeries kind of utility but it can also be used simply as a side effect iterator similar to Array#forEach. - * - * If any promise in the input array is rejected or any promise returned by the iterator function is rejected, the result will be rejected as well. - */ - static mapSeries(values: (R | Bluebird.Thenable)[] | Bluebird.Thenable<(R | Bluebird.Thenable)[]>, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable): Bluebird; - - /** - * A meta method used to specify the disposer method that cleans up a resource when using `Promise.using`. - * - * Returns a Disposer object which encapsulates both the resource as well as the method to clean it up. - * The user can pass this object to `Promise.using` to get access to the resource when it becomes available, - * as well as to ensure its automatically cleaned up. - * - * The second argument passed to a disposer is the result promise of the using block, which you can - * inspect synchronously. - */ - disposer(disposeFn: (arg: R, promise: Bluebird) => void | Bluebird.Thenable): Bluebird.Disposer; - - /** - * In conjunction with `.disposer`, using will make sure that no matter what, the specified disposer - * will be called when the promise returned by the callback passed to using has settled. The disposer is - * necessary because there is no standard interface in node for disposing resources. - */ - static using(disposer: Bluebird.Disposer, executor: (transaction: R) => Bluebird.Thenable): Bluebird; - static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2) => Bluebird.Thenable): Bluebird; - static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, disposer3: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2, transaction3: R3) => Bluebird.Thenable): Bluebird; - - /** - * Add handler as the handler to call when there is a possibly unhandled rejection. - * The default handler logs the error stack to stderr or console.error in browsers. - * - * Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections. - * - * Note: this hook is specific to the bluebird instance its called on, application developers should use global rejection events. - */ - static onPossiblyUnhandledRejection(handler?: (error: Error, promise: Bluebird) => void): void; - - /** - * Configure long stack traces, warnings, monitoring and cancellation. - * Note that even though false is the default here, a development environment might be detected which automatically - * enables long stack traces and warnings. - */ - static config(options: { - /** Enable warnings */ - warnings?: boolean | { - /** Enables all warnings except forgotten return statements. */ - wForgottenReturn: boolean; - }; - /** Enable long stack traces */ - longStackTraces?: boolean; - /** Enable cancellation */ - cancellation?: boolean; - /** Enable monitoring */ - monitoring?: boolean; - }): void; -} - -namespace Bluebird { - export interface ConcurrencyOption { - concurrency: number; - } - export interface SpreadOption { - spread: boolean; - } - export interface FromNodeOptions { - multiArgs?: boolean; - } - export interface PromisifyOptions { - context?: any; - multiArgs?: boolean; - } - export interface PromisifyAllOptions extends PromisifyOptions { - suffix?: string; - filter?: (name: string, func: Function, target?: any, passesDefaultFilter?: boolean) => boolean; - // The promisifier gets a reference to the original method and should return a function which returns a promise - promisifier?: (originalMethod: Function) => () => Thenable; - } - - /** - * Represents an error is an explicit promise rejection as opposed to a thrown error. - * For example, if an error is errbacked by a callback API promisified through undefined or undefined - * and is not a typed error, it will be converted to a `OperationalError` which has the original error in - * the `.cause` property. - * - * `OperationalError`s are caught in `.error` handlers. - */ - export class OperationalError extends Error { } - - /** - * Signals that an operation has timed out. Used as a custom cancellation reason in `.timeout`. - */ - export class TimeoutError extends Error { } - - /** - * Signals that an operation has been aborted or cancelled. The default reason used by `.cancel`. - */ - export class CancellationError extends Error {} - - /** - * A collection of errors. `AggregateError` is an array-like object, with numeric indices and a `.length` property. - * It supports all generic array methods such as `.forEach` directly. - * - * `AggregateError`s are caught in `.error` handlers, even if the contained errors are not operational. - * - * `Promise.some` and `Promise.any` use `AggregateError` as rejection reason when they fail. - */ - export class AggregateError extends Error {} - - /** - * returned by `Bluebird.disposer()`. - */ - export class Disposer { - } - - export interface Thenable { - then(onFulfilled: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; - then(onFulfilled: (value: R) => U | Thenable, onRejected?: (error: any) => void | Thenable): Thenable; - } - - export interface Resolver { - /** - * Returns a reference to the controlled promise that can be passed to clients. - */ - promise: Bluebird; - - /** - * Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state. - */ - resolve(value: R): void; - resolve(): void; - - /** - * Reject the underlying promise with `reason` as the rejection reason. - */ - reject(reason: any): void; - - /** - * Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions. - * - * If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values. - */ - // TODO specify resolver callback - callback: (err: any, value: R, ...values: R[]) => void; - } - - export interface Inspection { - /** - * See if the underlying promise was fulfilled at the creation time of this inspection object. - */ - isFulfilled(): boolean; - - /** - * See if the underlying promise was rejected at the creation time of this inspection object. - */ - isRejected(): boolean; - - /** - * See if the underlying promise was defer at the creation time of this inspection object. - */ - isPending(): boolean; - - /** - * Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object. - * - * throws `TypeError` - */ - value(): R; - - /** - * Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object. - * - * throws `TypeError` - */ - reason(): any; - } - - /** - * Changes how bluebird schedules calls a-synchronously. - * - * @param scheduler Should be a function that asynchronously schedules - * the calling of the passed in function - */ - export function setScheduler(scheduler: (callback: (...args: any[]) => void) => void): void; -} - -export = Bluebird; -} -declare module 'bluebird/bluebird' { -import alias = require('~bluebird/bluebird'); -export = alias; -} -declare module 'bluebird' { -import alias = require('~bluebird/bluebird'); -export = alias; -} diff --git a/typings/modules/bluebird/typings.json b/typings/modules/bluebird/typings.json deleted file mode 100644 index 783cb64..0000000 --- a/typings/modules/bluebird/typings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "resolution": "main", - "tree": { - "src": "https://raw.githubusercontent.com/typed-typings/npm-bluebird/8bd917a7ac4fef6796cd7fe5fc1d3b0fb118ad1a/typings.json", - "raw": "registry:npm/bluebird#3.3.4+20160515010139", - "main": "bluebird.d.ts", - "version": "3.3.4", - "global": false, - "name": "bluebird", - "type": "typings" - } -} diff --git a/typings/modules/chai-as-promised/index.d.ts b/typings/modules/chai-as-promised/index.d.ts deleted file mode 100644 index a7cf58c..0000000 --- a/typings/modules/chai-as-promised/index.d.ts +++ /dev/null @@ -1,641 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/e8db615cea6be222a9547bead73ec66b82691108/lib/Assertion.d.ts -declare module '~chai-as-promised~chai/lib/Assertion' { -export interface AssertionStatic { - (target: any, message?: string): Assertion; -} - -export interface Assertion extends LanguageChains, NumericComparison, TypeComparison { - not: Assertion; - deep: Deep; - any: KeyFilter; - all: KeyFilter; - a: TypeComparison; - an: TypeComparison; - include: Include; - includes: Include; - contain: Include; - contains: Include; - ok: Assertion; - true: Assertion; - false: Assertion; - null: Assertion; - undefined: Assertion; - NaN: Assertion; - exist: Assertion; - empty: Assertion; - arguments: Assertion; - Arguments: Assertion; - equal: Equal; - equals: Equal; - eq: Equal; - eql: Equal; - eqls: Equal; - property: Property; - ownProperty: OwnProperty; - haveOwnProperty: OwnProperty; - ownPropertyDescriptor: OwnPropertyDescriptor; - haveOwnPropertyDescriptor: OwnPropertyDescriptor; - length: Length; - lengthOf: Length; - match: Match; - matches: Match; - string(string: string, message?: string): Assertion; - keys: Keys; - key(string: string): Assertion; - throw: Throw; - throws: Throw; - Throw: Throw; - respondTo: RespondTo; - respondsTo: RespondTo; - itself: Assertion; - satisfy: Satisfy; - satisfies: Satisfy; - closeTo: CloseTo; - approximately: CloseTo; - members: Members; - increase: PropertyChange; - increases: PropertyChange; - decrease: PropertyChange; - decreases: PropertyChange; - change: PropertyChange; - changes: PropertyChange; - extensible: Assertion; - sealed: Assertion; - frozen: Assertion; - oneOf(list: any[], message?: string): Assertion; -} - -export interface LanguageChains { - to: Assertion; - be: Assertion; - been: Assertion; - is: Assertion; - that: Assertion; - which: Assertion; - and: Assertion; - has: Assertion; - have: Assertion; - with: Assertion; - at: Assertion; - of: Assertion; - same: Assertion; -} - -export interface NumericComparison { - above: NumberComparer; - gt: NumberComparer; - greaterThan: NumberComparer; - least: NumberComparer; - gte: NumberComparer; - below: NumberComparer; - lt: NumberComparer; - lessThan: NumberComparer; - most: NumberComparer; - lte: NumberComparer; - within(start: number, finish: number, message?: string): Assertion; -} - -export interface NumberComparer { - (value: number, message?: string): Assertion; -} - -export interface TypeComparison { - (type: string, message?: string): Assertion; - instanceof: InstanceOf; - instanceOf: InstanceOf; -} - -export interface InstanceOf { - (constructor: Object, message?: string): Assertion; -} - -export interface CloseTo { - (expected: number, delta: number, message?: string): Assertion; -} - -export interface Deep { - equal: Equal; - include: Include; - property: Property; - members: Members; -} - -export interface KeyFilter { - keys: Keys; -} - -export interface Equal { - (value: any, message?: string): Assertion; -} - -export interface Property { - (name: string, value?: any, message?: string): Assertion; -} - -export interface OwnProperty { - (name: string, message?: string): Assertion; -} - -export interface OwnPropertyDescriptor { - (name: string, descriptor: PropertyDescriptor, message?: string): Assertion; - (name: string, message?: string): Assertion; -} - -export interface Length extends LanguageChains, NumericComparison { - (length: number, message?: string): Assertion; -} - -export interface Include { - (value: Object, message?: string): Assertion; - (value: string, message?: string): Assertion; - (value: number, message?: string): Assertion; - keys: Keys; - members: Members; - any: KeyFilter; - all: KeyFilter; -} - -export interface Match { - (regexp: RegExp | string, message?: string): Assertion; -} - -export interface Keys { - (...keys: string[]): Assertion; - (keys: any[]): Assertion; - (keys: Object): Assertion; -} - -export interface Throw { - (): Assertion; - (expected: string, message?: string): Assertion; - (expected: RegExp, message?: string): Assertion; - (constructor: Error, expected?: string, message?: string): Assertion; - (constructor: Error, expected?: RegExp, message?: string): Assertion; - (constructor: Function, expected?: string, message?: string): Assertion; - (constructor: Function, expected?: RegExp, message?: string): Assertion; -} - -export interface RespondTo { - (method: string, message?: string): Assertion; -} - -export interface Satisfy { - (matcher: Function, message?: string): Assertion; -} - -export interface Members { - (set: any[], message?: string): Assertion; -} - -export interface PropertyChange { - (object: Object, prop: string, msg?: string): Assertion; -} -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/e8db615cea6be222a9547bead73ec66b82691108/lib/Assert.d.ts -declare module '~chai-as-promised~chai/lib/Assert' { -export interface AssertStatic extends Assert { -} - -export interface Assert { - /** - * @param expression Expression to test for truthiness. - * @param message Message to display on error. - */ - (expression: any, message?: string): void; - - fail(actual?: any, expected?: any, msg?: string, operator?: string): void; - - ok(val: any, msg?: string): void; - isOk(val: any, msg?: string): void; - notOk(val: any, msg?: string): void; - isNotOk(val: any, msg?: string): void; - - equal(act: any, exp: any, msg?: string): void; - notEqual(act: any, exp: any, msg?: string): void; - - strictEqual(act: any, exp: any, msg?: string): void; - notStrictEqual(act: any, exp: any, msg?: string): void; - - deepEqual(act: any, exp: any, msg?: string): void; - notDeepEqual(act: any, exp: any, msg?: string): void; - - isTrue(val: any, msg?: string): void; - isFalse(val: any, msg?: string): void; - - isNotTrue(val: any, msg?: string): void; - isNotFalse(val: any, msg?: string): void; - - isNull(val: any, msg?: string): void; - isNotNull(val: any, msg?: string): void; - - isUndefined(val: any, msg?: string): void; - isDefined(val: any, msg?: string): void; - - isNaN(val: any, msg?: string): void; - isNotNaN(val: any, msg?: string): void; - - isAbove(val: number, abv: number, msg?: string): void; - isBelow(val: number, blw: number, msg?: string): void; - - isAtLeast(val: number, atlst: number, msg?: string): void; - isAtMost(val: number, atmst: number, msg?: string): void; - - isFunction(val: any, msg?: string): void; - isNotFunction(val: any, msg?: string): void; - - isObject(val: any, msg?: string): void; - isNotObject(val: any, msg?: string): void; - - isArray(val: any, msg?: string): void; - isNotArray(val: any, msg?: string): void; - - isString(val: any, msg?: string): void; - isNotString(val: any, msg?: string): void; - - isNumber(val: any, msg?: string): void; - isNotNumber(val: any, msg?: string): void; - - isBoolean(val: any, msg?: string): void; - isNotBoolean(val: any, msg?: string): void; - - typeOf(val: any, type: string, msg?: string): void; - notTypeOf(val: any, type: string, msg?: string): void; - - instanceOf(val: any, type: Function, msg?: string): void; - notInstanceOf(val: any, type: Function, msg?: string): void; - - include(exp: string, inc: any, msg?: string): void; - include(exp: any[], inc: any, msg?: string): void; - - notInclude(exp: string, inc: any, msg?: string): void; - notInclude(exp: any[], inc: any, msg?: string): void; - - match(exp: any, re: RegExp, msg?: string): void; - notMatch(exp: any, re: RegExp, msg?: string): void; - - property(obj: Object, prop: string, msg?: string): void; - notProperty(obj: Object, prop: string, msg?: string): void; - deepProperty(obj: Object, prop: string, msg?: string): void; - notDeepProperty(obj: Object, prop: string, msg?: string): void; - - propertyVal(obj: Object, prop: string, val: any, msg?: string): void; - propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; - - deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void; - deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; - - lengthOf(exp: any, len: number, msg?: string): void; - //alias frenzy - throw(fn: Function, msg?: string): void; - throw(fn: Function, regExp: RegExp): void; - throw(fn: Function, errType: Function, msg?: string): void; - throw(fn: Function, errType: Function, regExp: RegExp): void; - - throws(fn: Function, msg?: string): void; - throws(fn: Function, regExp: RegExp): void; - throws(fn: Function, errType: Function, msg?: string): void; - throws(fn: Function, errType: Function, regExp: RegExp): void; - - Throw(fn: Function, msg?: string): void; - Throw(fn: Function, regExp: RegExp): void; - Throw(fn: Function, errType: Function, msg?: string): void; - Throw(fn: Function, errType: Function, regExp: RegExp): void; - - doesNotThrow(fn: Function, msg?: string): void; - doesNotThrow(fn: Function, regExp: RegExp): void; - doesNotThrow(fn: Function, errType: Function, msg?: string): void; - doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void; - - operator(val: any, operator: string, val2: any, msg?: string): void; - closeTo(act: number, exp: number, delta: number, msg?: string): void; - approximately(act: number, exp: number, delta: number, msg?: string): void; - - sameMembers(set1: any[], set2: any[], msg?: string): void; - sameDeepMembers(set1: any[], set2: any[], msg?: string): void; - includeMembers(superset: any[], subset: any[], msg?: string): void; - - ifError(val: any, msg?: string): void; - - isExtensible(obj: {}, msg?: string): void; - extensible(obj: {}, msg?: string): void; - isNotExtensible(obj: {}, msg?: string): void; - notExtensible(obj: {}, msg?: string): void; - - isSealed(obj: {}, msg?: string): void; - sealed(obj: {}, msg?: string): void; - isNotSealed(obj: {}, msg?: string): void; - notSealed(obj: {}, msg?: string): void; - - isFrozen(obj: Object, msg?: string): void; - frozen(obj: Object, msg?: string): void; - isNotFrozen(obj: Object, msg?: string): void; - notFrozen(obj: Object, msg?: string): void; - - oneOf(inList: any, list: any[], msg?: string): void; - } -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/asvetliakov/typings-chai-as-promised/06e0c2fef27801c64a2a03be52bc9235b7e8660d/index.d.ts -declare module '~chai-as-promised/index' { -import {LanguageChains} from '~chai-as-promised~chai/lib/Assertion'; -import {NumericComparison} from '~chai-as-promised~chai/lib/Assertion'; -import {TypeComparison} from '~chai-as-promised~chai/lib/Assertion'; -import { Assert } from '~chai-as-promised~chai/lib/Assert'; -import '~chai/lib/Assertion'; -import '~chai/lib/Assert'; - -namespace ChaiPromised { - - // For BDD API - - // Eventually does not have .then(), but PromisedAssertion have. - interface Eventually extends PromisedLanguageChains, PromisedNumericComparison, PromisedTypeComparison { - // From chai-as-promised - become(expected: Promise): PromisedAssertion; - fulfilled: PromisedAssertion; - rejected: PromisedAssertion; - rejectedWith(expected: any): PromisedAssertion; - notify(fn: Function): PromisedAssertion; - - // From chai - not: PromisedAssertion; - deep: PromisedDeep; - a: PromisedTypeComparison; - an: PromisedTypeComparison; - include: PromisedInclude; - contain: PromisedInclude; - ok: PromisedAssertion; - true: PromisedAssertion; - false: PromisedAssertion; - null: PromisedAssertion; - undefined: PromisedAssertion; - exist: PromisedAssertion; - empty: PromisedAssertion; - arguments: PromisedAssertion; - Arguments: PromisedAssertion; - equal: PromisedEqual; - equals: PromisedEqual; - eq: PromisedEqual; - eql: PromisedEqual; - eqls: PromisedEqual; - property: PromisedProperty; - ownProperty: PromisedOwnProperty; - haveOwnProperty: PromisedOwnProperty; - length: PromisedLength; - lengthOf: PromisedLength; - match(regexp: RegExp|string, message?: string): PromisedAssertion; - string(string: string, message?: string): PromisedAssertion; - keys: PromisedKeys; - key(string: string): PromisedAssertion; - throw: PromisedThrow; - throws: PromisedThrow; - Throw: PromisedThrow; - respondTo(method: string, message?: string): PromisedAssertion; - itself: PromisedAssertion; - satisfy(matcher: Function, message?: string): PromisedAssertion; - closeTo(expected: number, delta: number, message?: string): PromisedAssertion; - members: PromisedMembers; - } - - interface PromisedAssertion extends Eventually, Promise { - } - - interface PromisedLanguageChains { - eventually: Eventually; - - // From chai - to: PromisedAssertion; - be: PromisedAssertion; - been: PromisedAssertion; - is: PromisedAssertion; - that: PromisedAssertion; - which: PromisedAssertion; - and: PromisedAssertion; - has: PromisedAssertion; - have: PromisedAssertion; - with: PromisedAssertion; - at: PromisedAssertion; - of: PromisedAssertion; - same: PromisedAssertion; - } - - interface PromisedNumericComparison { - above: PromisedNumberComparer; - gt: PromisedNumberComparer; - greaterThan: PromisedNumberComparer; - least: PromisedNumberComparer; - gte: PromisedNumberComparer; - below: PromisedNumberComparer; - lt: PromisedNumberComparer; - lessThan: PromisedNumberComparer; - most: PromisedNumberComparer; - lte: PromisedNumberComparer; - within(start: number, finish: number, message?: string): PromisedAssertion; - } - - interface PromisedNumberComparer { - (value: number, message?: string): PromisedAssertion; - } - - interface PromisedTypeComparison { - (type: string, message?: string): PromisedAssertion; - instanceof: PromisedInstanceOf; - instanceOf: PromisedInstanceOf; - } - - interface PromisedInstanceOf { - (constructor: Object, message?: string): PromisedAssertion; - } - - interface PromisedDeep { - equal: PromisedEqual; - include: PromisedInclude; - property: PromisedProperty; - } - - interface PromisedEqual { - (value: any, message?: string): PromisedAssertion; - } - - interface PromisedProperty { - (name: string, value?: any, message?: string): PromisedAssertion; - } - - interface PromisedOwnProperty { - (name: string, message?: string): PromisedAssertion; - } - - interface PromisedLength extends PromisedLanguageChains, PromisedNumericComparison { - (length: number, message?: string): PromisedAssertion; - } - - interface PromisedInclude { - (value: Object, message?: string): PromisedAssertion; - (value: string, message?: string): PromisedAssertion; - (value: number, message?: string): PromisedAssertion; - keys: PromisedKeys; - members: PromisedMembers; - } - - interface PromisedKeys { - (...keys: string[]): PromisedAssertion; - (keys: any[]): PromisedAssertion; - } - - interface PromisedThrow { - (): PromisedAssertion; - (expected: string, message?: string): PromisedAssertion; - (expected: RegExp, message?: string): PromisedAssertion; - (constructor: Error, expected?: string, message?: string): PromisedAssertion; - (constructor: Error, expected?: RegExp, message?: string): PromisedAssertion; - (constructor: Function, expected?: string, message?: string): PromisedAssertion; - (constructor: Function, expected?: RegExp, message?: string): PromisedAssertion; - } - - interface PromisedMembers { - (set: any[], message?: string): PromisedAssertion; - } - - // For Assert API - - export interface PromisedAssert { - fail(actual?: any, expected?: any, msg?: string, operator?: string): Promise; - - ok(val: any, msg?: string): Promise; - notOk(val: any, msg?: string): Promise; - - equal(act: any, exp: any, msg?: string): Promise; - notEqual(act: any, exp: any, msg?: string): Promise; - - strictEqual(act: any, exp: any, msg?: string): Promise; - notStrictEqual(act: any, exp: any, msg?: string): Promise; - - deepEqual(act: any, exp: any, msg?: string): Promise; - notDeepEqual(act: any, exp: any, msg?: string): Promise; - - isTrue(val: any, msg?: string): Promise; - isFalse(val: any, msg?: string): Promise; - - isNull(val: any, msg?: string): Promise; - isNotNull(val: any, msg?: string): Promise; - - isUndefined(val: any, msg?: string): Promise; - isDefined(val: any, msg?: string): Promise; - - isFunction(val: any, msg?: string): Promise; - isNotFunction(val: any, msg?: string): Promise; - - isObject(val: any, msg?: string): Promise; - isNotObject(val: any, msg?: string): Promise; - - isArray(val: any, msg?: string): Promise; - isNotArray(val: any, msg?: string): Promise; - - isString(val: any, msg?: string): Promise; - isNotString(val: any, msg?: string): Promise; - - isNumber(val: any, msg?: string): Promise; - isNotNumber(val: any, msg?: string): Promise; - - isBoolean(val: any, msg?: string): Promise; - isNotBoolean(val: any, msg?: string): Promise; - - typeOf(val: any, type: string, msg?: string): Promise; - notTypeOf(val: any, type: string, msg?: string): Promise; - - instanceOf(val: any, type: Function, msg?: string): Promise; - notInstanceOf(val: any, type: Function, msg?: string): Promise; - - include(exp: string, inc: any, msg?: string): Promise; - include(exp: any[], inc: any, msg?: string): Promise; - - notInclude(exp: string, inc: any, msg?: string): Promise; - notInclude(exp: any[], inc: any, msg?: string): Promise; - - match(exp: any, re: RegExp, msg?: string): Promise; - notMatch(exp: any, re: RegExp, msg?: string): Promise; - - property(obj: Object, prop: string, msg?: string): Promise; - notProperty(obj: Object, prop: string, msg?: string): Promise; - deepProperty(obj: Object, prop: string, msg?: string): Promise; - notDeepProperty(obj: Object, prop: string, msg?: string): Promise; - - propertyVal(obj: Object, prop: string, val: any, msg?: string): Promise; - propertyNotVal(obj: Object, prop: string, val: any, msg?: string): Promise; - - deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): Promise; - deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): Promise; - - lengthOf(exp: any, len: number, msg?: string): Promise; - //alias frenzy - throw(fn: Function, msg?: string): Promise; - throw(fn: Function, regExp: RegExp): Promise; - throw(fn: Function, errType: Function, msg?: string): Promise; - throw(fn: Function, errType: Function, regExp: RegExp): Promise; - - throws(fn: Function, msg?: string): Promise; - throws(fn: Function, regExp: RegExp): Promise; - throws(fn: Function, errType: Function, msg?: string): Promise; - throws(fn: Function, errType: Function, regExp: RegExp): Promise; - - Throw(fn: Function, msg?: string): Promise; - Throw(fn: Function, regExp: RegExp): Promise; - Throw(fn: Function, errType: Function, msg?: string): Promise; - Throw(fn: Function, errType: Function, regExp: RegExp): Promise; - - doesNotThrow(fn: Function, msg?: string): Promise; - doesNotThrow(fn: Function, regExp: RegExp): Promise; - doesNotThrow(fn: Function, errType: Function, msg?: string): Promise; - doesNotThrow(fn: Function, errType: Function, regExp: RegExp): Promise; - - operator(val: any, operator: string, val2: any, msg?: string): Promise; - closeTo(act: number, exp: number, delta: number, msg?: string): Promise; - - sameMembers(set1: any[], set2: any[], msg?: string): Promise; - includeMembers(set1: any[], set2: any[], msg?: string): Promise; - - ifError(val: any, msg?: string): Promise; - } -} - -module '~chai/lib/Assertion' { - interface Assertion { - eventually: ChaiPromised.PromisedAssertion; - become(expected: any): ChaiPromised.PromisedAssertion; - fulfilled: ChaiPromised.PromisedAssertion; - rejected: ChaiPromised.PromisedAssertion; - rejectedWith(expected: any, message?: string): ChaiPromised.PromisedAssertion; - notify(fn: Function): ChaiPromised.PromisedAssertion; - } -} - -module '~chai/lib/Assert' { - interface Assert { - eventually: ChaiPromised.PromisedAssert; - isFulfilled(promise: Promise, message?: string): Promise; - becomes(promise: Promise, expected: any, message?: string): Promise; - doesNotBecome(promise: Promise, expected: any, message?: string): Promise; - isRejected(promise: Promise, message?: string): Promise; - isRejected(promise: Promise, expected: any, message?: string): Promise; - isRejected(promise: Promise, match: RegExp, message?: string): Promise; - notify(fn: Function): Promise; - } -} - - -function chaiAsPromised(chai: any, utils: any): void; -namespace chaiAsPromised {} -export = chaiAsPromised; -} -declare module 'chai-as-promised/index' { -import alias = require('~chai-as-promised/index'); -export = alias; -} -declare module 'chai-as-promised' { -import alias = require('~chai-as-promised/index'); -export = alias; -} diff --git a/typings/modules/chai-as-promised/typings.json b/typings/modules/chai-as-promised/typings.json deleted file mode 100644 index b1189b5..0000000 --- a/typings/modules/chai-as-promised/typings.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "resolution": "main", - "tree": { - "src": "https://raw.githubusercontent.com/asvetliakov/typings-chai-as-promised/06e0c2fef27801c64a2a03be52bc9235b7e8660d/typings.json", - "raw": "registry:npm/chai-as-promised#5.1.0+20160310030142", - "main": "index.d.ts", - "global": false, - "dependencies": { - "chai": { - "src": "https://raw.githubusercontent.com/typed-typings/npm-chai/e8db615cea6be222a9547bead73ec66b82691108/typings.json", - "raw": "registry:npm/chai#3.4.0+20160308201903", - "main": "index.d.ts", - "global": false, - "dependencies": { - "assertion-error": { - "src": "https://raw.githubusercontent.com/typed-typings/npm-assertion-error/105841317bd2bdd5d110bfb763e49e482a77230d/typings.json", - "raw": "github:typed-typings/npm-assertion-error#105841317bd2bdd5d110bfb763e49e482a77230d", - "main": "main.d.ts", - "global": false, - "name": "assertion-error", - "type": "typings" - } - }, - "name": "chai", - "type": "typings" - } - }, - "name": "chai-as-promised", - "type": "typings" - } -} diff --git a/typings/modules/chai/index.d.ts b/typings/modules/chai/index.d.ts deleted file mode 100644 index 0d262ae..0000000 --- a/typings/modules/chai/index.d.ts +++ /dev/null @@ -1,547 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-assertion-error/105841317bd2bdd5d110bfb763e49e482a77230d/main.d.ts -declare module '~chai~assertion-error/main' { -// Type definitions for assertion-error 1.0.0 -// Project: https://github.com/chaijs/assertion-error -// Definitions by: Bart van der Schoor -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -export class AssertionError implements Error { - constructor(message: string, props?: any, ssf?: Function); - public name: string; - public message: string; - public showDiff: boolean; - public stack: string; - - /** - * Allow errors to be converted to JSON for static transfer. - * - * @param {Boolean} include stack (default: `true`) - * @return {Object} object that can be `JSON.stringify` - */ - public toJSON(stack: boolean): Object; -} -} -declare module '~chai~assertion-error' { -import alias = require('~chai~assertion-error/main'); -export = alias; -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Assert.d.ts -declare module '~chai/lib/Assert' { -export interface AssertStatic extends Assert { -} - -export interface Assert { - /** - * @param expression Expression to test for truthiness. - * @param message Message to display on error. - */ - (expression: any, message?: string): void; - (expression: any, messageCallback: () => string): void; - - fail(actual?: any, expected?: any, msg?: string, operator?: string): void; - - ok(val: any, msg?: string): void; - isOk(val: any, msg?: string): void; - notOk(val: any, msg?: string): void; - isNotOk(val: any, msg?: string): void; - - equal(act: any, exp: any, msg?: string): void; - notEqual(act: any, exp: any, msg?: string): void; - - strictEqual(act: any, exp: any, msg?: string): void; - notStrictEqual(act: any, exp: any, msg?: string): void; - - deepEqual(act: any, exp: any, msg?: string): void; - notDeepEqual(act: any, exp: any, msg?: string): void; - - isTrue(val: any, msg?: string): void; - isFalse(val: any, msg?: string): void; - - isNotTrue(val: any, msg?: string): void; - isNotFalse(val: any, msg?: string): void; - - isNull(val: any, msg?: string): void; - isNotNull(val: any, msg?: string): void; - - isUndefined(val: any, msg?: string): void; - isDefined(val: any, msg?: string): void; - - isNaN(val: any, msg?: string): void; - isNotNaN(val: any, msg?: string): void; - - isAbove(val: number, abv: number, msg?: string): void; - isBelow(val: number, blw: number, msg?: string): void; - - isAtLeast(val: number, atlst: number, msg?: string): void; - isAtMost(val: number, atmst: number, msg?: string): void; - - isFunction(val: any, msg?: string): void; - isNotFunction(val: any, msg?: string): void; - - isObject(val: any, msg?: string): void; - isNotObject(val: any, msg?: string): void; - - isArray(val: any, msg?: string): void; - isNotArray(val: any, msg?: string): void; - - isString(val: any, msg?: string): void; - isNotString(val: any, msg?: string): void; - - isNumber(val: any, msg?: string): void; - isNotNumber(val: any, msg?: string): void; - - isBoolean(val: any, msg?: string): void; - isNotBoolean(val: any, msg?: string): void; - - typeOf(val: any, type: string, msg?: string): void; - notTypeOf(val: any, type: string, msg?: string): void; - - instanceOf(val: any, type: Function, msg?: string): void; - notInstanceOf(val: any, type: Function, msg?: string): void; - - include(exp: string, inc: any, msg?: string): void; - include(exp: any[], inc: any, msg?: string): void; - include(exp: Object, inc: Object, msg?: string): void; - - notInclude(exp: string, inc: any, msg?: string): void; - notInclude(exp: any[], inc: any, msg?: string): void; - - match(exp: any, re: RegExp, msg?: string): void; - notMatch(exp: any, re: RegExp, msg?: string): void; - - property(obj: Object, prop: string, msg?: string): void; - notProperty(obj: Object, prop: string, msg?: string): void; - deepProperty(obj: Object, prop: string, msg?: string): void; - notDeepProperty(obj: Object, prop: string, msg?: string): void; - - propertyVal(obj: Object, prop: string, val: any, msg?: string): void; - propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; - - deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void; - deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; - - lengthOf(exp: any, len: number, msg?: string): void; - - throw(fn: Function, msg?: string): void; - throw(fn: Function, regExp: RegExp): void; - throw(fn: Function, errType: Function, msg?: string): void; - throw(fn: Function, errType: Function, regExp: RegExp): void; - - throws(fn: Function, msg?: string): void; - throws(fn: Function, regExp: RegExp): void; - throws(fn: Function, errType: Function, msg?: string): void; - throws(fn: Function, errType: Function, regExp: RegExp): void; - - Throw(fn: Function, msg?: string): void; - Throw(fn: Function, regExp: RegExp): void; - Throw(fn: Function, errType: Function, msg?: string): void; - Throw(fn: Function, errType: Function, regExp: RegExp): void; - - doesNotThrow(fn: Function, msg?: string): void; - doesNotThrow(fn: Function, regExp: RegExp): void; - doesNotThrow(fn: Function, errType: Function, msg?: string): void; - doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void; - - operator(val: any, operator: string, val2: any, msg?: string): void; - closeTo(act: number, exp: number, delta: number, msg?: string): void; - approximately(act: number, exp: number, delta: number, msg?: string): void; - - sameMembers(set1: any[], set2: any[], msg?: string): void; - sameDeepMembers(set1: any[], set2: any[], msg?: string): void; - includeMembers(superset: any[], subset: any[], msg?: string): void; - includeDeepMembers(superset: any[], subset: any[], msg?: string): void; - - ifError(val: any, msg?: string): void; - - isExtensible(obj: {}, msg?: string): void; - extensible(obj: {}, msg?: string): void; - isNotExtensible(obj: {}, msg?: string): void; - notExtensible(obj: {}, msg?: string): void; - - isSealed(obj: {}, msg?: string): void; - sealed(obj: {}, msg?: string): void; - isNotSealed(obj: {}, msg?: string): void; - notSealed(obj: {}, msg?: string): void; - - isFrozen(obj: Object, msg?: string): void; - frozen(obj: Object, msg?: string): void; - isNotFrozen(obj: Object, msg?: string): void; - notFrozen(obj: Object, msg?: string): void; - - oneOf(inList: any, list: any[], msg?: string): void; - - changes(fn: Function, obj: {}, property: string): void; - doesNotChange(fn: Function, obj: {}, property: string): void; - increases(fn: Function, obj: {}, property: string): void; - doesNotIncrease(fn: Function, obj: {}, property: string): void; - - decreases(fn: Function, obj: {}, property: string): void; - doesNotDecrease(fn: Function, obj: {}, property: string): void; - } -} -declare module 'chai/lib/Assert' { -import alias = require('~chai/lib/Assert'); -export = alias; -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Assertion.d.ts -declare module '~chai/lib/Assertion' { -export interface AssertionStatic { - (target?: any, message?: string, stack?: Function): Assertion; - new (target?: any, message?: string, stack?: Function): Assertion; -} - -export interface Assertion extends LanguageChains, NumericComparison, TypeComparison { - not: Assertion; - deep: Deep; - any: KeyFilter; - all: KeyFilter; - a: TypeComparison; - an: TypeComparison; - include: Include; - includes: Include; - contain: Include; - contains: Include; - ok: Assertion; - true: Assertion; - false: Assertion; - null: Assertion; - undefined: Assertion; - NaN: Assertion; - exist: Assertion; - empty: Assertion; - arguments: Assertion; - Arguments: Assertion; - equal: Equal; - equals: Equal; - eq: Equal; - eql: Equal; - eqls: Equal; - property: Property; - ownProperty: OwnProperty; - haveOwnProperty: OwnProperty; - ownPropertyDescriptor: OwnPropertyDescriptor; - haveOwnPropertyDescriptor: OwnPropertyDescriptor; - length: Length; - lengthOf: Length; - match: Match; - matches: Match; - string(str: string, message?: string): Assertion; - keys: Keys; - key(str: string): Assertion; - throw: Throw; - throws: Throw; - Throw: Throw; - respondTo: RespondTo; - respondsTo: RespondTo; - itself: Assertion; - satisfy: Satisfy; - satisfies: Satisfy; - closeTo: CloseTo; - approximately: CloseTo; - members: Members; - increase: PropertyChange; - increases: PropertyChange; - decrease: PropertyChange; - decreases: PropertyChange; - change: PropertyChange; - changes: PropertyChange; - extensible: Assertion; - sealed: Assertion; - frozen: Assertion; - oneOf(list: any[], message?: string): Assertion; -} - -export interface LanguageChains { - to: Assertion; - be: Assertion; - been: Assertion; - is: Assertion; - that: Assertion; - which: Assertion; - and: Assertion; - has: Assertion; - have: Assertion; - with: Assertion; - at: Assertion; - of: Assertion; - same: Assertion; -} - -export interface NumericComparison { - above: NumberComparer; - gt: NumberComparer; - greaterThan: NumberComparer; - least: NumberComparer; - gte: NumberComparer; - below: NumberComparer; - lt: NumberComparer; - lessThan: NumberComparer; - most: NumberComparer; - lte: NumberComparer; - within(start: number, finish: number, message?: string): Assertion; -} - -export interface NumberComparer { - (value: number, message?: string): Assertion; -} - -export interface TypeComparison { - (type: string, message?: string): Assertion; - instanceof: InstanceOf; - instanceOf: InstanceOf; -} - -export interface InstanceOf { - (constructor: Object, message?: string): Assertion; -} - -export interface CloseTo { - (expected: number, delta: number, message?: string): Assertion; -} - -export interface Deep { - equal: Equal; - equals: Equal; - eq: Equal; - include: Include; - property: Property; - members: Members; -} - -export interface KeyFilter { - keys: Keys; -} - -export interface Equal { - (value: any, message?: string): Assertion; -} - -export interface Property { - (name: string, value?: any, message?: string): Assertion; -} - -export interface OwnProperty { - (name: string, message?: string): Assertion; -} - -export interface OwnPropertyDescriptor { - (name: string, descriptor: PropertyDescriptor, message?: string): Assertion; - (name: string, message?: string): Assertion; -} - -export interface Length extends LanguageChains, NumericComparison { - (length: number, message?: string): Assertion; -} - -export interface Include { - (value: Object, message?: string): Assertion; - (value: string, message?: string): Assertion; - (value: number, message?: string): Assertion; - string(value: string, message?: string): Assertion; - keys: Keys; - members: Members; - any: KeyFilter; - all: KeyFilter; -} - -export interface Match { - (regexp: RegExp | string, message?: string): Assertion; -} - -export interface Keys { - (...keys: any[]): Assertion; - (keys: any[]): Assertion; - (keys: Object): Assertion; -} - -export interface Throw { - (): Assertion; - (expected: string, message?: string): Assertion; - (expected: RegExp, message?: string): Assertion; - (constructor: Error, expected?: string, message?: string): Assertion; - (constructor: Error, expected?: RegExp, message?: string): Assertion; - (constructor: Function, expected?: string, message?: string): Assertion; - (constructor: Function, expected?: RegExp, message?: string): Assertion; -} - -export interface RespondTo { - (method: string, message?: string): Assertion; -} - -export interface Satisfy { - (matcher: Function, message?: string): Assertion; -} - -export interface Members { - (set: any[], message?: string): Assertion; -} - -export interface PropertyChange { - (object: Object, prop: string, msg?: string): Assertion; -} -} -declare module 'chai/lib/Assertion' { -import alias = require('~chai/lib/Assertion'); -export = alias; -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Expect.d.ts -declare module '~chai/lib/Expect' { -import {AssertionStatic} from '~chai/lib/Assertion'; - -export interface ExpectStatic extends AssertionStatic { - fail(actual?: any, expected?: any, message?: string, operator?: string): void; -} -} -declare module 'chai/lib/Expect' { -import alias = require('~chai/lib/Expect'); -export = alias; -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Should.d.ts -declare module '~chai/lib/Should' { -export interface Should extends ShouldAssertion { - not: ShouldAssertion; - fail(actual: any, expected: any, message?: string, operator?: string): void; -} - -export interface ShouldAssertion { - Throw: ShouldThrow; - throw: ShouldThrow; - equal(value1: any, value2: any, message?: string): void; - exist(value: any, message?: string): void; -} - -export interface ShouldThrow { - (actual: Function): void; - (actual: Function, expected: string | RegExp, message?: string): void; - (actual: Function, constructor: Error | Function, expected?: string | RegExp, message?: string): void; -} -} -declare module 'chai/lib/Should' { -import alias = require('~chai/lib/Should'); -export = alias; -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Config.d.ts -declare module '~chai/lib/Config' { -export interface Config { - includeStack: boolean; - showDiff: boolean; - truncateThreshold: number; -} -} -declare module 'chai/lib/Config' { -import alias = require('~chai/lib/Config'); -export = alias; -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Utils.d.ts -declare module '~chai/lib/Utils' { -import {Assertion} from '~chai/lib/Assertion'; - -export interface PathInfo { - parent: any; - name: number|string; - value: any; - exists: boolean; -} - -export interface Utils { - addChainableMethod(ctx: any, name: string, chainingBehavior: (value: any) => void): void; - addMethod(ctx: any, name: string, method: (value: any) => void): void; - addProperty(ctx: any, name: string, getter: () => void): void; - expectTypes(obj: Object, types: string[]): void; - flag(obj: Object, key: string, value?: any): any; - getActual(obj: Object, actual?: any): any; - getEnumerableProperties(obj: Object): string[]; - getMessage(obj: Object, params: any[]): string; - getMessage(obj: Object, message: string, negateMessage: string): string; - getName(func: Function): string; - getPathInfo(path: string, obj: Object): PathInfo; - getPathValue(path: string, obj: Object): any; - getProperties(obj: Object): string[]; - hasProperty(obj: Object, name: string): boolean; - transferFlags(assertion: Assertion | any, obj: Object, includeAll?: boolean): void; - inspect(obj: any): any; -} -} -declare module 'chai/lib/Utils' { -import alias = require('~chai/lib/Utils'); -export = alias; -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Chai.d.ts -declare module '~chai/lib/Chai' { -import * as AE from '~chai~assertion-error'; - -import * as Assert from '~chai/lib/Assert'; -import * as A from '~chai/lib/Assertion'; -import * as Expect from '~chai/lib/Expect'; -import * as Should from '~chai/lib/Should'; -import * as Config from '~chai/lib/Config'; -import * as Utils from '~chai/lib/Utils'; - -namespace chai { - export interface AssertionStatic extends A.AssertionStatic {} - export class AssertionError extends AE.AssertionError {} - export var Assertion: A.AssertionStatic; - export var expect: Expect.ExpectStatic; - export var assert: Assert.AssertStatic; - export var config: Config.Config; - export var util: Utils.Utils; - export function should(): Should.Should; - export function Should(): Should.Should; - /** - * Provides a way to extend the internals of Chai - */ - export function use(fn: (chai: any, utils: Utils.Utils) => void): typeof chai; -} - -export = chai; - -/* tslint:disable:no-internal-module */ -global { - interface Object { - should: A.Assertion; - } -} -} -declare module 'chai/lib/Chai' { -import alias = require('~chai/lib/Chai'); -export = alias; -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/index.d.ts -declare module '~chai/index' { -// Type definitions for chai 3.4.0 -// Project: http://chaijs.com/ -// Original Definitions by: Jed Mao , -// Bart van der Schoor , -// Andrew Brown , -// Olivier Chevet , -// Matt Wistrand - -import chai = require('~chai/lib/Chai'); - -export = chai; -} -declare module 'chai/index' { -import alias = require('~chai/index'); -export = alias; -} -declare module 'chai' { -import alias = require('~chai/index'); -export = alias; -} diff --git a/typings/modules/chai/typings.json b/typings/modules/chai/typings.json deleted file mode 100644 index f81ca6b..0000000 --- a/typings/modules/chai/typings.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "resolution": "main", - "tree": { - "src": "https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/typings.json", - "raw": "registry:npm/chai#3.5.0+20160415060238", - "main": "index.d.ts", - "global": false, - "dependencies": { - "assertion-error": { - "src": "https://raw.githubusercontent.com/typed-typings/npm-assertion-error/105841317bd2bdd5d110bfb763e49e482a77230d/typings.json", - "raw": "github:typed-typings/npm-assertion-error#105841317bd2bdd5d110bfb763e49e482a77230d", - "main": "main.d.ts", - "global": false, - "name": "assertion-error", - "type": "typings" - } - }, - "name": "chai", - "type": "typings" - } -} diff --git a/typings/modules/lodash/index.d.ts b/typings/modules/lodash/index.d.ts deleted file mode 100644 index 6548312..0000000 --- a/typings/modules/lodash/index.d.ts +++ /dev/null @@ -1,18293 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-lodash/7ccf9dc406a792d702067f4eab0fa8df4109fcaa/index.d.ts -declare module '~lodash/index' { -/* -### 4.0.0 Changelog (https://github.com/lodash/lodash/wiki/Changelog) - -#### TODO: -removed: -- [x] Removed _.support -- [x] Removed _.findWhere in favor of _.find with iteratee shorthand -- [x] Removed _.where in favor of _.filter with iteratee shorthand -- [x] Removed _.pluck in favor of _.map with iteratee shorthand - -renamed: -- [x] Renamed _.first to _.head -- [x] Renamed _.indexBy to _.keyBy -- [x] Renamed _.invoke to _.invokeMap -- [x] Renamed _.overArgs to _.overArgs -- [x] Renamed _.padLeft & _.padRight to _.padStart & _.padEnd -- [x] Renamed _.pairs to _.toPairs -- [x] Renamed _.rest to _.tail -- [x] Renamed _.restParam to _.rest -- [x] Renamed _.sortByOrder to _.orderBy -- [x] Renamed _.trimLeft & _.trimRight to _.trimStart & _.trimEnd -- [x] Renamed _.trunc to _.truncate - -split: -- [x] Split _.indexOf & _.lastIndexOf into _.sortedIndexOf & _.sortedLastIndexOf -- [x] Split _.max & _.min into _.maxBy & _.minBy -- [x] Split _.omit & _.pick into _.omitBy & _.pickBy -- [x] Split _.sample into _.sampleSize -- [x] Split _.sortedIndex into _.sortedIndexBy -- [x] Split _.sortedLastIndex into _.sortedLastIndexBy -- [x] Split _.uniq into _.sortedUniq, _.sortedUniqBy, & _.uniqBy - -changes: -- [x] Absorbed _.sortByAll into _.sortBy -- [x] Changed the category of _.at to “Object” -- [x] Changed the category of _.bindAll to “Utility” -- [x] Made _.capitalize uppercase the first character & lowercase the rest -- [x] Made _.functions return only own method names - - -added 23 array methods: -- [x] _.concat -- [x] _.differenceBy -- [x] _.differenceWith -- [x] _.flatMap -- [x] _.fromPairs -- [x] _.intersectionBy -- [x] _.intersectionWith -- [x] _.join -- [x] _.pullAll -- [x] _.pullAllBy -- [x] _.reverse -- [x] _.sortedIndexBy -- [x] _.sortedIndexOf -- [x] _.sortedLastIndexBy -- [x] _.sortedLastIndexOf -- [x] _.sortedUniq -- [x] _.sortedUniqBy -- [x] _.unionBy -- [x] _.unionWith -- [x] _.uniqBy -- [x] _.uniqWith -- [x] _.xorBy -- [x] _.xorWith - -added 18 lang methods: -- [x] _.cloneDeepWith -- [x] _.cloneWith -- [x] _.eq -- [x] _.isArrayLike -- [x] _.isArrayLikeObject -- [x] _.isEqualWith -- [x] _.isInteger -- [x] _.isLength -- [x] _.isMatchWith -- [x] _.isNil -- [x] _.isObjectLike -- [x] _.isSafeInteger -- [x] _.isSymbol -- [x] _.toInteger -- [x] _.toLength -- [x] _.toNumber -- [x] _.toSafeInteger -- [x] _.toString - -added 13 object methods: -- [x] _.assignIn -- [x] _.assignInWith -- [x] _.assignWith -- [x] _.functionsIn -- [x] _.hasIn -- [x] _.mergeWith -- [x] _.omitBy -- [x] _.pickBy - - -added 8 string methods: -- [x] _.lowerCase -- [x] _.lowerFirst -- [x] _.upperCase -- [x] _.upperFirst -- [x] _.toLower -- [x] _.toUpper - -added 8 utility methods: -- [x] _.toPath - -added 4 math methods: -- [x] _.maxBy -- [x] _.mean -- [x] _.minBy -- [x] _.sumBy - -added 2 function methods: -- [x] _.flip -- [x] _.unary - -added 2 number methods: -- [x] _.clamp -- [x] _.subtract - -added collection method: -- [x] _.sampleSize - -Added 3 aliases - -- [x] _.first as an alias of _.head - -Removed 17 aliases -- [x] Removed aliase _.all -- [x] Removed aliase _.any -- [x] Removed aliase _.backflow -- [x] Removed aliase _.callback -- [x] Removed aliase _.collect -- [x] Removed aliase _.compose -- [x] Removed aliase _.contains -- [x] Removed aliase _.detect -- [x] Removed aliase _.foldl -- [x] Removed aliase _.foldr -- [x] Removed aliase _.include -- [x] Removed aliase _.inject -- [x] Removed aliase _.methods -- [x] Removed aliase _.object -- [x] Removed aliase _.run -- [x] Removed aliase _.select -- [x] Removed aliase _.unique - -Other changes -- [x] Added support for array buffers to _.isEqual -- [x] Added support for converting iterators to _.toArray -- [x] Added support for deep paths to _.zipObject -- [x] Changed UMD to export to window or self when available regardless of other exports -- [x] Ensured debounce cancel clears args & thisArg references -- [x] Ensured _.add, _.subtract, & _.sum don’t skip NaN values -- [x] Ensured _.clone treats generators like functions -- [x] Ensured _.clone produces clones with the source’s [[Prototype]] -- [x] Ensured _.defaults assigns properties that shadow Object.prototype -- [x] Ensured _.defaultsDeep doesn’t merge a string into an array -- [x] Ensured _.defaultsDeep & _.merge don’t modify sources -- [x] Ensured _.defaultsDeep works with circular references -- [x] Ensured _.keys skips “length” on strict mode arguments objects in Safari 9 -- [x] Ensured _.merge doesn’t convert strings to arrays -- [x] Ensured _.merge merges plain-objects onto non plain-objects -- [x] Ensured _#plant resets iterator data of cloned sequences -- [x] Ensured _.random swaps min & max if min is greater than max -- [x] Ensured _.range preserves the sign of start of -0 -- [x] Ensured _.reduce & _.reduceRight use getIteratee in their array branch -- [x] Fixed rounding issue with the precision param of _.floor - -** LATER ** -Misc: -- [ ] Made _.forEach, _.forIn, _.forOwn, & _.times implicitly end a chain sequence -- [ ] Removed thisArg params from most methods -- [ ] Made “By” methods provide a single param to iteratees -- [ ] Made _.words chainable by default -- [ ] Removed isDeep params from _.clone & _.flatten -- [ ] Removed _.bindAll support for binding all methods when no names are provided -- [ ] Removed func-first param signature from _.before & _.after -- [ ] _.extend as an alias of _.assignIn -- [ ] _.extendWith as an alias of _.assignInWith -- [ ] Added clear method to _.memoize.Cache -- [ ] Added flush method to debounced & throttled functions -- [ ] Added support for ES6 maps, sets, & symbols to _.clone, _.isEqual, & _.toArray -- [ ] Enabled _.flow & _.flowRight to accept an array of functions -- [ ] Ensured “Collection” methods treat functions as objects -- [ ] Ensured _.assign, _.defaults, & _.merge coerce object values to objects -- [ ] Ensured _.bindKey bound functions call object[key] when called with the new operator -- [ ] Ensured _.isFunction returns true for generator functions -- [ ] Ensured _.merge assigns typed arrays directly -- [ ] Made _(...) an iterator & iterable -- [ ] Made _.drop, _.take, & right forms coerce n of undefined to 0 - -Methods: -- [ ] _.concat -- [ ] _.differenceBy -- [ ] _.differenceWith -- [ ] _.flatMap -- [x] _.fromPairs -- [ ] _.intersectionBy -- [ ] _.intersectionWith -- [ ] _.join -- [ ] _.pullAll -- [ ] _.pullAllBy -- [ ] _.reverse -- [ ] _.sortedLastIndexOf -- [ ] _.unionBy -- [ ] _.unionWith -- [ ] _.uniqWith -- [ ] _.xorBy -- [ ] _.xorWith -- [ ] _.toString - -- [ ] _.invoke -- [ ] _.setWith -- [ ] _.toPairs -- [ ] _.toPairsIn -- [ ] _.unset - -- [ ] _.replace -- [ ] _.split - -- [ ] _.cond -- [ ] _.conforms -- [ ] _.nthArg -- [ ] _.over -- [ ] _.overEvery -- [ ] _.overSome -- [ ] _.rangeRight - -- [ ] _.next -*/ - -var _: _.LoDashStatic; - -namespace _ { - interface LoDashStatic { - /** - * Creates a lodash object which wraps the given value to enable intuitive method chaining. - * - * In addition to Lo-Dash methods, wrappers also have the following Array methods: - * concat, join, pop, push, reverse, shift, slice, sort, splice, and unshift - * - * Chaining is supported in custom builds as long as the value method is implicitly or - * explicitly included in the build. - * - * The chainable wrapper functions are: - * after, assign, bind, bindAll, bindKey, chain, chunk, compact, compose, concat, countBy, - * createCallback, curry, debounce, defaults, defer, delay, difference, filter, flatten, - * forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, functions, groupBy, - * keyBy, initial, intersection, invert, invoke, keys, map, max, memoize, merge, min, - * object, omit, once, pairs, partial, partialRight, pick, pluck, pull, push, range, reject, - * remove, rest, reverse, sample, shuffle, slice, sort, sortBy, splice, tap, throttle, times, - * toArray, transform, union, uniq, unset, unshift, unzip, values, where, without, wrap, and zip - * - * The non-chainable wrapper functions are: - * clone, cloneDeep, contains, escape, every, find, findIndex, findKey, findLast, - * findLastIndex, findLastKey, has, identity, indexOf, isArguments, isArray, isBoolean, - * isDate, isElement, isEmpty, isEqual, isFinite, isFunction, isNaN, isNull, isNumber, - * isObject, isPlainObject, isRegExp, isString, isUndefined, join, lastIndexOf, mixin, - * noConflict, parseInt, pop, random, reduce, reduceRight, result, shift, size, some, - * sortedIndex, runInContext, template, unescape, uniqueId, and value - * - * The wrapper functions first and last return wrapped values when n is provided, otherwise - * they return unwrapped values. - * - * Explicit chaining can be enabled by using the _.chain method. - */ - (value: number): LoDashImplicitWrapper; - (value: string): LoDashImplicitStringWrapper; - (value: boolean): LoDashImplicitWrapper; - (value: Array): LoDashImplicitNumberArrayWrapper; - (value: Array): LoDashImplicitArrayWrapper; - (value: T): LoDashImplicitObjectWrapper; - (value: any): LoDashImplicitWrapper; - - /** - * The semantic version number. - */ - VERSION: string; - - /** - * By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby - * (ERB). Change the following template settings to use alternative delimiters. - */ - templateSettings: TemplateSettings; - } - - /** - * By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby - * (ERB). Change the following template settings to use alternative delimiters. - */ - interface TemplateSettings { - /** - * The "escape" delimiter. - */ - escape?: RegExp; - - /** - * The "evaluate" delimiter. - */ - evaluate?: RegExp; - - /** - * An object to import into the template as local variables. - */ - imports?: Dictionary; - - /** - * The "interpolate" delimiter. - */ - interpolate?: RegExp; - - /** - * Used to reference the data object in the template text. - */ - variable?: string; - } - - /** - * Creates a cache object to store key/value pairs. - */ - interface MapCache { - /** - * Removes `key` and its value from the cache. - * @param key The key of the value to remove. - * @return Returns `true` if the entry was removed successfully, else `false`. - */ - delete(key: string): boolean; - - /** - * Gets the cached value for `key`. - * @param key The key of the value to get. - * @return Returns the cached value. - */ - get(key: string): any; - - /** - * Checks if a cached value for `key` exists. - * @param key The key of the entry to check. - * @return Returns `true` if an entry for `key` exists, else `false`. - */ - has(key: string): boolean; - - /** - * Sets `value` to `key` of the cache. - * @param key The key of the value to cache. - * @param value The value to cache. - * @return Returns the cache object. - */ - set(key: string, value: any): _.Dictionary; - } - - interface LoDashWrapperBase { } - - interface LoDashImplicitWrapperBase extends LoDashWrapperBase { } - - interface LoDashExplicitWrapperBase extends LoDashWrapperBase { } - - interface LoDashImplicitWrapper extends LoDashImplicitWrapperBase> { } - - interface LoDashExplicitWrapper extends LoDashExplicitWrapperBase> { } - - interface LoDashImplicitStringWrapper extends LoDashImplicitWrapper { } - - interface LoDashExplicitStringWrapper extends LoDashExplicitWrapper { } - - interface LoDashImplicitObjectWrapper extends LoDashImplicitWrapperBase> { } - - interface LoDashExplicitObjectWrapper extends LoDashExplicitWrapperBase> { } - - interface LoDashImplicitArrayWrapper extends LoDashImplicitWrapperBase> { - pop(): T; - push(...items: T[]): LoDashImplicitArrayWrapper; - shift(): T; - sort(compareFn?: (a: T, b: T) => number): LoDashImplicitArrayWrapper; - splice(start: number): LoDashImplicitArrayWrapper; - splice(start: number, deleteCount: number, ...items: any[]): LoDashImplicitArrayWrapper; - unshift(...items: T[]): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper extends LoDashExplicitWrapperBase> { } - - interface LoDashImplicitNumberArrayWrapper extends LoDashImplicitArrayWrapper { } - - interface LoDashExplicitNumberArrayWrapper extends LoDashExplicitArrayWrapper { } - - /********* - * Array * - ********/ - - // _.chunk - interface LoDashStatic { - /** - * Creates an array of elements split into groups the length of size. If collection can’t be split evenly, the - * final chunk will be the remaining elements. - * - * @param array The array to process. - * @param size The length of each chunk. - * @return Returns the new array containing chunks. - */ - chunk( - array: List, - size?: number - ): T[][]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.chunk - */ - chunk(size?: number): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.chunk - */ - chunk(size?: number): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.chunk - */ - chunk(size?: number): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.chunk - */ - chunk(size?: number): LoDashExplicitArrayWrapper; - } - - // _.compact - interface LoDashStatic { - /** - * Creates an array with all falsey values removed. The values false, null, 0, "", undefined, and NaN are - * falsey. - * - * @param array The array to compact. - * @return (Array) Returns the new array of filtered values. - */ - compact(array?: List): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.compact - */ - compact(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.compact - */ - compact(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.compact - */ - compact(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.compact - */ - compact(): LoDashExplicitArrayWrapper; - } - - // _.concat DUMMY - interface LoDashStatic { - /** - * Creates a new array concatenating `array` with any additional arrays - * and/or values. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to concatenate. - * @param {...*} [values] The values to concatenate. - * @returns {Array} Returns the new concatenated array. - * @example - * - * var array = [1]; - * var other = _.concat(array, 2, [3], [[4]]); - * - * console.log(other); - * // => [1, 2, 3, [4]] - * - * console.log(array); - * // => [1] - */ - concat(...values: (T[] | List)[]): T[]; - } - - // _.difference - interface LoDashStatic { - /** - * Creates an array of unique array values not included in the other provided arrays using SameValueZero for - * equality comparisons. - * - * @param array The array to inspect. - * @param values The arrays of values to exclude. - * @return Returns the new array of filtered values. - */ - difference( - array: T[] | List, - ...values: Array> - ): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.difference - */ - difference(...values: (T[] | List)[]): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.difference - */ - difference(...values: (TValue[] | List)[]): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.difference - */ - difference(...values: (T[] | List)[]): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.difference - */ - difference(...values: (TValue[] | List)[]): LoDashExplicitArrayWrapper; - } - - // _.differenceBy - interface LoDashStatic { - /** - * This method is like _.difference except that it accepts iteratee which is invoked for each element of array - * and values to generate the criterion by which uniqueness is computed. The iteratee is invoked with one - * argument: (value). - * - * @param array The array to inspect. - * @param values The values to exclude. - * @param iteratee The iteratee invoked per element. - * @returns Returns the new array of filtered values. - */ - differenceBy( - array: T[] | List, - values?: T[] | List, - iteratee?: ((value: T) => any) | string - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: T[] | List, - values?: T[] | List, - iteratee?: W - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: T[] | List, - values1?: T[] | List, - values2?: T[] | List, - iteratee?: ((value: T) => any) | string - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: T[] | List, - values1?: T[] | List, - values2?: T[] | List, - iteratee?: W - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: T[] | List, - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - iteratee?: ((value: T) => any) | string - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: T[] | List, - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - iteratee?: W - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: T[] | List, - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - iteratee?: W - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: T[] | List, - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - iteratee?: ((value: T) => any) | string - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: T[] | List, - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - values5?: T[] | List, - iteratee?: ((value: T) => any) | string - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: T[] | List, - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - values5?: T[] | List, - iteratee?: W - ): T[]; - - /** - * @see _.differenceBy - */ - differenceBy( - array: T[] | List, - ...values: any[] - ): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.differenceBy - */ - differenceBy( - values?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values?: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - values5?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - values5?: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - ...values: any[] - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.differenceBy - */ - differenceBy( - values?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values?: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - values5?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - values5?: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - ...values: any[] - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.differenceBy - */ - differenceBy( - values?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values?: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - values5?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - values5?: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - ...values: any[] - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.differenceBy - */ - differenceBy( - values?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values?: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - values5?: T[] | List, - iteratee?: ((value: T) => any) | string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - values1?: T[] | List, - values2?: T[] | List, - values3?: T[] | List, - values4?: T[] | List, - values5?: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.differenceBy - */ - differenceBy( - ...values: any[] - ): LoDashExplicitArrayWrapper; - } - - // _.differenceWith DUMMY - interface LoDashStatic { - /** - * Creates an array of unique `array` values not included in the other - * provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The values to exclude. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.difference([3, 2, 1], [4, 2]); - * // => [3, 1] - */ - differenceWith( - array: any[] | List, - ...values: any[] - ): any[]; - } - - // _.drop - interface LoDashStatic { - /** - * Creates a slice of array with n elements dropped from the beginning. - * - * @param array The array to query. - * @param n The number of elements to drop. - * @return Returns the slice of array. - */ - drop(array: T[] | List, n?: number): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.drop - */ - drop(n?: number): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.drop - */ - drop(n?: number): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.drop - */ - drop(n?: number): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.drop - */ - drop(n?: number): LoDashExplicitArrayWrapper; - } - - // _.dropRight - interface LoDashStatic { - /** - * Creates a slice of array with n elements dropped from the end. - * - * @param array The array to query. - * @param n The number of elements to drop. - * @return Returns the slice of array. - */ - dropRight( - array: List, - n?: number - ): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.dropRight - */ - dropRight(n?: number): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.dropRight - */ - dropRight(n?: number): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.dropRight - */ - dropRight(n?: number): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.dropRight - */ - dropRight(n?: number): LoDashExplicitArrayWrapper; - } - - // _.dropRightWhile - interface LoDashStatic { - /** - * Creates a slice of array excluding elements dropped from the end. Elements are dropped until predicate - * returns falsey. The predicate is bound to thisArg and invoked with three arguments: (value, index, array). - * - * If a property name is provided for predicate the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for predicate the created _.matches style callback returns true for elements that - * match the properties of the given object, else false. - * - * @param array The array to query. - * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. - * @return Returns the slice of array. - */ - dropRightWhile( - array: List, - predicate?: ListIterator, - thisArg?: any - ): TValue[]; - - /** - * @see _.dropRightWhile - */ - dropRightWhile( - array: List, - predicate?: string, - thisArg?: any - ): TValue[]; - - /** - * @see _.dropRightWhile - */ - dropRightWhile( - array: List, - predicate?: TWhere - ): TValue[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.dropRightWhile - */ - dropRightWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.dropRightWhile - */ - dropRightWhile( - predicate?: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.dropRightWhile - */ - dropRightWhile( - predicate?: TWhere - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.dropRightWhile - */ - dropRightWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.dropRightWhile - */ - dropRightWhile( - predicate?: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.dropRightWhile - */ - dropRightWhile( - predicate?: TWhere - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.dropRightWhile - */ - dropRightWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.dropRightWhile - */ - dropRightWhile( - predicate?: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.dropRightWhile - */ - dropRightWhile( - predicate?: TWhere - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.dropRightWhile - */ - dropRightWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.dropRightWhile - */ - dropRightWhile( - predicate?: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.dropRightWhile - */ - dropRightWhile( - predicate?: TWhere - ): LoDashExplicitArrayWrapper; - } - - // _.dropWhile - interface LoDashStatic { - /** - * Creates a slice of array excluding elements dropped from the beginning. Elements are dropped until predicate - * returns falsey. The predicate is bound to thisArg and invoked with three arguments: (value, index, array). - * - * If a property name is provided for predicate the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for predicate the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * @param array The array to query. - * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. - * @return Returns the slice of array. - */ - dropWhile( - array: List, - predicate?: ListIterator, - thisArg?: any - ): TValue[]; - - /** - * @see _.dropWhile - */ - dropWhile( - array: List, - predicate?: string, - thisArg?: any - ): TValue[]; - - /** - * @see _.dropWhile - */ - dropWhile( - array: List, - predicate?: TWhere - ): TValue[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.dropWhile - */ - dropWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.dropWhile - */ - dropWhile( - predicate?: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.dropWhile - */ - dropWhile( - predicate?: TWhere - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.dropWhile - */ - dropWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.dropWhile - */ - dropWhile( - predicate?: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.dropWhile - */ - dropWhile( - predicate?: TWhere - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.dropWhile - */ - dropWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.dropWhile - */ - dropWhile( - predicate?: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.dropWhile - */ - dropWhile( - predicate?: TWhere - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.dropWhile - */ - dropWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.dropWhile - */ - dropWhile( - predicate?: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.dropWhile - */ - dropWhile( - predicate?: TWhere - ): LoDashExplicitArrayWrapper; - } - - // _.fill - interface LoDashStatic { - /** - * Fills elements of array with value from start up to, but not including, end. - * - * Note: This method mutates array. - * - * @param array The array to fill. - * @param value The value to fill array with. - * @param start The start position. - * @param end The end position. - * @return Returns array. - */ - fill( - array: any[], - value: T, - start?: number, - end?: number - ): T[]; - - /** - * @see _.fill - */ - fill( - array: List, - value: T, - start?: number, - end?: number - ): List; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.fill - */ - fill( - value: T, - start?: number, - end?: number - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.fill - */ - fill( - value: T, - start?: number, - end?: number - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.fill - */ - fill( - value: T, - start?: number, - end?: number - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.fill - */ - fill( - value: T, - start?: number, - end?: number - ): LoDashExplicitObjectWrapper>; - } - - // _.findIndex - interface LoDashStatic { - /** - * This method is like _.find except that it returns the index of the first element predicate returns truthy - * for instead of the element itself. - * - * If a property name is provided for predicate the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for predicate the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * @param array The array to search. - * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. - * @return Returns the index of the found element, else -1. - */ - findIndex( - array: List, - predicate?: ListIterator, - thisArg?: any - ): number; - - /** - * @see _.findIndex - */ - findIndex( - array: List, - predicate?: string, - thisArg?: any - ): number; - - /** - * @see _.findIndex - */ - findIndex( - array: List, - predicate?: W - ): number; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.findIndex - */ - findIndex( - predicate?: ListIterator, - thisArg?: any - ): number; - - /** - * @see _.findIndex - */ - findIndex( - predicate?: string, - thisArg?: any - ): number; - - /** - * @see _.findIndex - */ - findIndex( - predicate?: W - ): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.findIndex - */ - findIndex( - predicate?: ListIterator, - thisArg?: any - ): number; - - /** - * @see _.findIndex - */ - findIndex( - predicate?: string, - thisArg?: any - ): number; - - /** - * @see _.findIndex - */ - findIndex( - predicate?: W - ): number; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.findIndex - */ - findIndex( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findIndex - */ - findIndex( - predicate?: string, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findIndex - */ - findIndex( - predicate?: W - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.findIndex - */ - findIndex( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findIndex - */ - findIndex( - predicate?: string, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findIndex - */ - findIndex( - predicate?: W - ): LoDashExplicitWrapper; - } - - // _.findLastIndex - interface LoDashStatic { - /** - * This method is like _.findIndex except that it iterates over elements of collection from right to left. - * - * If a property name is provided for predicate the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for predicate the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * @param array The array to search. - * @param predicate The function invoked per iteration. - * @param thisArg The function invoked per iteration. - * @return Returns the index of the found element, else -1. - */ - findLastIndex( - array: List, - predicate?: ListIterator, - thisArg?: any - ): number; - - /** - * @see _.findLastIndex - */ - findLastIndex( - array: List, - predicate?: string, - thisArg?: any - ): number; - - /** - * @see _.findLastIndex - */ - findLastIndex( - array: List, - predicate?: W - ): number; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.findLastIndex - */ - findLastIndex( - predicate?: ListIterator, - thisArg?: any - ): number; - - /** - * @see _.findLastIndex - */ - findLastIndex( - predicate?: string, - thisArg?: any - ): number; - - /** - * @see _.findLastIndex - */ - findLastIndex( - predicate?: W - ): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.findLastIndex - */ - findLastIndex( - predicate?: ListIterator, - thisArg?: any - ): number; - - /** - * @see _.findLastIndex - */ - findLastIndex( - predicate?: string, - thisArg?: any - ): number; - - /** - * @see _.findLastIndex - */ - findLastIndex( - predicate?: W - ): number; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.findLastIndex - */ - findLastIndex( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findLastIndex - */ - findLastIndex( - predicate?: string, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findLastIndex - */ - findLastIndex( - predicate?: W - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.findLastIndex - */ - findLastIndex( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findLastIndex - */ - findLastIndex( - predicate?: string, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findLastIndex - */ - findLastIndex( - predicate?: W - ): LoDashExplicitWrapper; - } - - // _.first - interface LoDashStatic { - /** - * @see _.head - */ - first(array: List): T; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.head - */ - first(): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.head - */ - first(): TResult; - } - - interface RecursiveArray extends Array> { } - interface ListOfRecursiveArraysOrValues extends List> { } - - // _.flatMap DUMMY - interface LoDashStatic { - /** - * Creates an array of flattened values by running each element in `array` - * through `iteratee` and concating its result to the other mapped values. - * The iteratee is invoked with three arguments: (value, index|key, array). - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new array. - * @example - * - * function duplicate(n) { - * return [n, n]; - * } - * - * _.flatMap([1, 2], duplicate); - * // => [1, 1, 2, 2] - */ - flatMap( - array: any[] | List, - ...values: any[] - ): any[]; - } - - // _.flatten - interface LoDashStatic { - /** - * Flattens a nested array. If isDeep is true the array is recursively flattened, otherwise it’s only - * flattened a single level. - * - * @param array The array to flatten. - * @param isDeep Specify a deep flatten. - * @return Returns the new flattened array. - */ - flatten(array: ListOfRecursiveArraysOrValues, isDeep: boolean): T[]; - - /** - * @see _.flatten - */ - flatten(array: List): T[]; - - /** - * @see _.flatten - */ - flatten(array: ListOfRecursiveArraysOrValues): RecursiveArray; - } - - interface LoDashImplicitWrapper { - /** - * @see _.flatten - */ - flatten(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.flatten - */ - flatten(isDeep?: boolean): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.flatten - */ - flatten(isDeep?: boolean): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.flatten - */ - flatten(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.flatten - */ - flatten(isDeep?: boolean): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.flatten - */ - flatten(isDeep?: boolean): LoDashExplicitArrayWrapper; - } - - // _.flattenDeep - interface LoDashStatic { - /** - * Recursively flattens a nested array. - * - * @param array The array to recursively flatten. - * @return Returns the new flattened array. - */ - flattenDeep(array: ListOfRecursiveArraysOrValues): T[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.flattenDeep - */ - flattenDeep(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.flattenDeep - */ - flattenDeep(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.flattenDeep - */ - flattenDeep(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.flattenDeep - */ - flattenDeep(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.flattenDeep - */ - flattenDeep(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.flattenDeep - */ - flattenDeep(): LoDashExplicitArrayWrapper; - } - - // _.fromPairs - interface LoDashStatic { - /** - * The inverse of `_.toPairs`; this method returns an object composed - * from key-value `pairs`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} pairs The key-value pairs. - * @returns {Object} Returns the new object. - * @example - * - * _.fromPairs([['fred', 30], ['barney', 40]]); - * // => { 'fred': 30, 'barney': 40 } - */ - fromPairs( - array: Array<[string, T]> | List<[string, T]> - ): Dictionary; - } - - // _.head - interface LoDashStatic { - /** - * Gets the first element of array. - * - * @alias _.first - * - * @param array The array to query. - * @return Returns the first element of array. - */ - head(array: List): T; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.first - */ - head(): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.first - */ - head(): TResult; - } - - // _.indexOf - interface LoDashStatic { - /** - * Gets the index at which the first occurrence of `value` is found in `array` - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. If `fromIndex` is negative, it's used as the offset - * from the end of `array`. If `array` is sorted providing `true` for `fromIndex` - * performs a faster binary search. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.indexOf([1, 2, 1, 2], 2); - * // => 1 - * - * // using `fromIndex` - * _.indexOf([1, 2, 1, 2], 2, 2); - * // => 3 - */ - indexOf( - array: List, - value: T, - fromIndex?: boolean | number - ): number; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.indexOf - */ - indexOf( - value: T, - fromIndex?: boolean | number - ): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.indexOf - */ - indexOf( - value: TValue, - fromIndex?: boolean | number - ): number; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.indexOf - */ - indexOf( - value: T, - fromIndex?: boolean | number - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.indexOf - */ - indexOf( - value: TValue, - fromIndex?: boolean | number - ): LoDashExplicitWrapper; - } - - // _.intersectionBy DUMMY - interface LoDashStatic { - /** - * This method is like `_.intersection` except that it accepts `iteratee` - * which is invoked for each element of each `arrays` to generate the criterion - * by which uniqueness is computed. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new array of shared values. - * @example - * - * _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor); - * // => [2.1] - * - * // using the `_.property` iteratee shorthand - * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }] - */ - intersectionBy( - array: any[] | List, - ...values: any[] - ): any[]; - } - - // _.intersectionWith DUMMY - interface LoDashStatic { - /** - * This method is like `_.intersection` except that it accepts `comparator` - * which is invoked to compare elements of `arrays`. The comparator is invoked - * with two arguments: (arrVal, othVal). - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of shared values. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; - * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; - * - * _.intersectionWith(objects, others, _.isEqual); - * // => [{ 'x': 1, 'y': 2 }] - */ - intersectionWith( - array: any[] | List, - ...values: any[] - ): any[]; - } - - // _.join - interface LoDashStatic { - /** - * Converts all elements in `array` into a string separated by `separator`. - * - * @param array The array to convert. - * @param separator The element separator. - * @returns Returns the joined string. - */ - join( - array: List, - separator?: string - ): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.join - */ - join(separator?: string): string; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.join - */ - join(separator?: string): string; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.join - */ - join(separator?: string): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.join - */ - join(separator?: string): LoDashExplicitWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.join - */ - join(separator?: string): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.join - */ - join(separator?: string): LoDashExplicitWrapper; - } - - // _.pullAll DUMMY - interface LoDashStatic { - /** - * This method is like `_.pull` except that it accepts an array of values to remove. - * - * **Note:** Unlike `_.difference`, this method mutates `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @returns {Array} Returns `array`. - * @example - * - * var array = [1, 2, 3, 1, 2, 3]; - * - * _.pull(array, [2, 3]); - * console.log(array); - * // => [1, 1] - */ - pullAll( - array: any[] | List, - ...values: any[] - ): any[]; - } - - // _.pullAllBy DUMMY - interface LoDashStatic { - /** - * This method is like `_.pullAll` except that it accepts `iteratee` which is - * invoked for each element of `array` and `values` to to generate the criterion - * by which uniqueness is computed. The iteratee is invoked with one argument: (value). - * - * **Note:** Unlike `_.differenceBy`, this method mutates `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns `array`. - * @example - * - * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; - * - * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); - * console.log(array); - * // => [{ 'x': 2 }] - */ - pullAllBy( - array: any[] | List, - ...values: any[] - ): any[]; - } - - // _.reverse DUMMY - interface LoDashStatic { - /** - * Reverses `array` so that the first element becomes the last, the second - * element becomes the second to last, and so on. - * - * **Note:** This method mutates `array` and is based on - * [`Array#reverse`](https://mdn.io/Array/reverse). - * - * @memberOf _ - * @category Array - * @returns {Array} Returns `array`. - * @example - * - * var array = [1, 2, 3]; - * - * _.reverse(array); - * // => [3, 2, 1] - * - * console.log(array); - * // => [3, 2, 1] - */ - reverse( - array: any[] | List, - ...values: any[] - ): any[]; - } - - // _.sortedIndexOf - interface LoDashStatic { - /** - * This method is like `_.indexOf` except that it performs a binary - * search on a sorted `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.sortedIndexOf([1, 1, 2, 2], 2); - * // => 2 - */ - sortedIndexOf( - array: List, - value: T - ): number; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.sortedIndexOf - */ - sortedIndexOf( - value: T - ): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.sortedIndexOf - */ - sortedIndexOf( - value: TValue - ): number; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.sortedIndexOf - */ - sortedIndexOf( - value: T - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.sortedIndexOf - */ - sortedIndexOf( - value: TValue - ): LoDashExplicitWrapper; - } - - // _.initial - interface LoDashStatic { - /** - * Gets all but the last element of array. - * - * @param array The array to query. - * @return Returns the slice of array. - */ - initial(array: List): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.initial - */ - initial(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.initial - */ - initial(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.initial - */ - initial(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.initial - */ - initial(): LoDashExplicitArrayWrapper; - } - - // _.intersection - interface LoDashStatic { - /** - * Creates an array of unique values that are included in all of the provided arrays using SameValueZero for - * equality comparisons. - * - * @param arrays The arrays to inspect. - * @return Returns the new array of shared values. - */ - intersection(...arrays: (T[] | List)[]): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.intersection - */ - intersection(...arrays: (TResult[] | List)[]): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.intersection - */ - intersection(...arrays: (TResult[] | List)[]): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.intersection - */ - intersection(...arrays: (TResult[] | List)[]): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.intersection - */ - intersection(...arrays: (TResult[] | List)[]): LoDashExplicitArrayWrapper; - } - - // _.last - interface LoDashStatic { - /** - * Gets the last element of array. - * - * @param array The array to query. - * @return Returns the last element of array. - */ - last(array: List): T; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.last - */ - last(): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.last - */ - last(): T; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.last - */ - last(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.last - */ - last(): LoDashExplicitObjectWrapper; - } - - // _.lastIndexOf - interface LoDashStatic { - /** - * This method is like _.indexOf except that it iterates over elements of array from right to left. - * - * @param array The array to search. - * @param value The value to search for. - * @param fromIndex The index to search from or true to perform a binary search on a sorted array. - * @return Returns the index of the matched value, else -1. - */ - lastIndexOf( - array: List, - value: T, - fromIndex?: boolean | number - ): number; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.lastIndexOf - */ - lastIndexOf( - value: T, - fromIndex?: boolean | number - ): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.lastIndexOf - */ - lastIndexOf( - value: TResult, - fromIndex?: boolean | number - ): number; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.lastIndexOf - */ - lastIndexOf( - value: T, - fromIndex?: boolean | number - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.lastIndexOf - */ - lastIndexOf( - value: TResult, - fromIndex?: boolean | number - ): LoDashExplicitWrapper; - } - - // _.pull - interface LoDashStatic { - /** - * Removes all provided values from array using SameValueZero for equality comparisons. - * - * Note: Unlike _.without, this method mutates array. - * - * @param array The array to modify. - * @param values The values to remove. - * @return Returns array. - */ - pull( - array: T[], - ...values: T[] - ): T[]; - - /** - * @see _.pull - */ - pull( - array: List, - ...values: T[] - ): List; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.pull - */ - pull(...values: T[]): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.pull - */ - pull(...values: TValue[]): LoDashImplicitObjectWrapper>; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.pull - */ - pull(...values: T[]): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.pull - */ - pull(...values: TValue[]): LoDashExplicitObjectWrapper>; - } - - // _.pullAt - interface LoDashStatic { - /** - * Removes elements from array corresponding to the given indexes and returns an array of the removed elements. - * Indexes may be specified as an array of indexes or as individual arguments. - * - * Note: Unlike _.at, this method mutates array. - * - * @param array The array to modify. - * @param indexes The indexes of elements to remove, specified as individual indexes or arrays of indexes. - * @return Returns the new array of removed elements. - */ - pullAt( - array: List, - ...indexes: (number | number[])[] - ): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.pullAt - */ - pullAt(...indexes: (number | number[])[]): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.pullAt - */ - pullAt(...indexes: (number | number[])[]): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.pullAt - */ - pullAt(...indexes: (number | number[])[]): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.pullAt - */ - pullAt(...indexes: (number | number[])[]): LoDashExplicitArrayWrapper; - } - - // _.remove - interface LoDashStatic { - /** - * Removes all elements from array that predicate returns truthy for and returns an array of the removed - * elements. The predicate is bound to thisArg and invoked with three arguments: (value, index, array). - * - * If a property name is provided for predicate the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for predicate the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * Note: Unlike _.filter, this method mutates array. - * - * @param array The array to modify. - * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. - * @return Returns the new array of removed elements. - */ - remove( - array: List, - predicate?: ListIterator, - thisArg?: any - ): T[]; - - /** - * @see _.remove - */ - remove( - array: List, - predicate?: string, - thisArg?: any - ): T[]; - - /** - * @see _.remove - */ - remove( - array: List, - predicate?: W - ): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.remove - */ - remove( - predicate?: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.remove - */ - remove( - predicate?: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.remove - */ - remove( - predicate?: W - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.remove - */ - remove( - predicate?: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.remove - */ - remove( - predicate?: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.remove - */ - remove( - predicate?: W - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.remove - */ - remove( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.remove - */ - remove( - predicate?: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.remove - */ - remove( - predicate?: W - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.remove - */ - remove( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.remove - */ - remove( - predicate?: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.remove - */ - remove( - predicate?: W - ): LoDashExplicitArrayWrapper; - } - - // _.tail - interface LoDashStatic { - /** - * Gets all but the first element of array. - * - * @alias _.tail - * - * @param array The array to query. - * @return Returns the slice of array. - */ - tail(array: List): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.tail - */ - tail(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.tail - */ - tail(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.tail - */ - tail(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.tail - */ - tail(): LoDashExplicitArrayWrapper; - } - - // _.slice - interface LoDashStatic { - /** - * Creates a slice of array from start up to, but not including, end. - * - * @param array The array to slice. - * @param start The start position. - * @param end The end position. - * @return Returns the slice of array. - */ - slice( - array: T[], - start?: number, - end?: number - ): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.slice - */ - slice( - start?: number, - end?: number - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.slice - */ - slice( - start?: number, - end?: number - ): LoDashExplicitArrayWrapper; - } - - // _.sortedIndex - interface LoDashStatic { - /** - * Uses a binary search to determine the lowest index at which `value` should - * be inserted into `array` in order to maintain its sort order. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted into `array`. - * @example - * - * _.sortedIndex([30, 50], 40); - * // => 1 - * - * _.sortedIndex([4, 5], 4); - * // => 0 - */ - sortedIndex( - array: List, - value: T - ): number; - - /** - * @see _.sortedIndex - */ - sortedIndex( - array: List, - value: T - ): number; - - /** - * @see _.sortedIndex - */ - sortedIndex( - array: List, - value: T - ): number; - - /** - * @see _.sortedIndex - */ - sortedIndex( - array: List, - value: T - ): number; - - /** - * @see _.sortedIndex - */ - sortedIndex( - array: List, - value: T - ): number; - } - - interface LoDashImplicitWrapper { - /** - * @see _.sortedIndex - */ - sortedIndex( - value: string - ): number; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.sortedIndex - */ - sortedIndex( - value: T - ): number; - - /** - * @see _.sortedIndex - */ - sortedIndex( - value: T - ): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.sortedIndex - */ - sortedIndex( - value: T - ): number; - - /** - * @see _.sortedIndex - */ - sortedIndex( - value: T - ): number; - - /** - * @see _.sortedIndex - */ - sortedIndex( - value: T - ): number; - } - - interface LoDashExplicitWrapper { - /** - * @see _.sortedIndex - */ - sortedIndex( - value: string - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.sortedIndex - */ - sortedIndex( - value: T - ): LoDashExplicitWrapper; - - /** - * @see _.sortedIndex - */ - sortedIndex( - value: T - ): LoDashExplicitWrapper; - - /** - * @see _.sortedIndex - */ - sortedIndex( - value: T - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.sortedIndex - */ - sortedIndex( - value: T - ): LoDashExplicitWrapper; - - /** - * @see _.sortedIndex - */ - sortedIndex( - value: T - ): LoDashExplicitWrapper; - - /** - * @see _.sortedIndex - */ - sortedIndex( - value: T - ): LoDashExplicitWrapper; - - - } - - // _.sortedIndexBy - interface LoDashStatic { - /** - * This method is like `_.sortedIndex` except that it accepts `iteratee` - * which is invoked for `value` and each element of `array` to compute their - * sort ranking. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted into `array`. - * @example - * - * var dict = { 'thirty': 30, 'forty': 40, 'fifty': 50 }; - * - * _.sortedIndexBy(['thirty', 'fifty'], 'forty', _.propertyOf(dict)); - * // => 1 - * - * // using the `_.property` iteratee shorthand - * _.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); - * // => 0 - */ - sortedIndexBy( - array: List, - value: T, - iteratee: (x: T) => TSort - ): number; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - array: List, - value: T, - iteratee: (x: T) => any - ): number; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - array: List, - value: T, - iteratee: string - ): number; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - array: List, - value: T, - iteratee: W - ): number; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - array: List, - value: T, - iteratee: Object - ): number; - } - - interface LoDashImplicitWrapper { - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: string, - iteratee: (x: string) => TSort - ): number; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: (x: T) => TSort - ): number; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: string - ): number; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: W - ): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: (x: T) => TSort - ): number; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: (x: T) => any - ): number; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: string - ): number; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: W - ): number; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: Object - ): number; - } - - interface LoDashExplicitWrapper { - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: string, - iteratee: (x: string) => TSort - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: (x: T) => TSort - ): LoDashExplicitWrapper; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: string - ): LoDashExplicitWrapper; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: W - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: (x: T) => TSort - ): LoDashExplicitWrapper; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: (x: T) => any - ): LoDashExplicitWrapper; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: string - ): LoDashExplicitWrapper; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: W - ): LoDashExplicitWrapper; - - /** - * @see _.sortedIndexBy - */ - sortedIndexBy( - value: T, - iteratee: Object - ): LoDashExplicitWrapper; - } - - // _.sortedLastIndex - interface LoDashStatic { - /** - * This method is like `_.sortedIndex` except that it returns the highest - * index at which `value` should be inserted into `array` in order to - * maintain its sort order. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted into `array`. - * @example - * - * _.sortedLastIndex([4, 5], 4); - * // => 1 - */ - sortedLastIndex( - array: List, - value: T - ): number; - - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - array: List, - value: T - ): number; - - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - array: List, - value: T - ): number; - - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - array: List, - value: T - ): number; - - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - array: List, - value: T - ): number; - } - - interface LoDashImplicitWrapper { - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - value: string - ): number; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - value: T - ): number; - - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - value: T - ): number; - - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - value: T - ): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - value: T - ): number; - - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - value: T - ): number; - - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - value: T - ): number; - } - - interface LoDashExplicitWrapper { - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - value: string - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - value: T - ): LoDashExplicitWrapper; - - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - value: T - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - value: T - ): LoDashExplicitWrapper; - - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - value: T - ): LoDashExplicitWrapper; - - /** - * @see _.sortedLastIndex - */ - sortedLastIndex( - value: T - ): LoDashExplicitWrapper; - } - - // _.sortedLastIndexBy - interface LoDashStatic { - /** - * This method is like `_.sortedLastIndex` except that it accepts `iteratee` - * which is invoked for `value` and each element of `array` to compute their - * sort ranking. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted into `array`. - * @example - * - * // using the `_.property` iteratee shorthand - * _.sortedLastIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); - * // => 1 - */ - sortedLastIndexBy( - array: List, - value: T, - iteratee: (x: T) => TSort - ): number; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - array: List, - value: T, - iteratee: (x: T) => any - ): number; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - array: List, - value: T, - iteratee: string - ): number; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - array: List, - value: T, - iteratee: W - ): number; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - array: List, - value: T, - iteratee: Object - ): number; - } - - interface LoDashImplicitWrapper { - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: string, - iteratee: (x: string) => TSort - ): number; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: (x: T) => TSort - ): number; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: string - ): number; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: W - ): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: (x: T) => TSort - ): number; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: (x: T) => any - ): number; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: string - ): number; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: W - ): number; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: Object - ): number; - } - - interface LoDashExplicitWrapper { - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: string, - iteratee: (x: string) => TSort - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: (x: T) => TSort - ): LoDashExplicitWrapper; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: string - ): LoDashExplicitWrapper; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: W - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: (x: T) => TSort - ): LoDashExplicitWrapper; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: (x: T) => any - ): LoDashExplicitWrapper; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: string - ): LoDashExplicitWrapper; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: W - ): LoDashExplicitWrapper; - - /** - * @see _.sortedLastIndexBy - */ - sortedLastIndexBy( - value: T, - iteratee: Object - ): LoDashExplicitWrapper; - } - - // _.sortedLastIndexOf DUMMY - interface LoDashStatic { - /** - * This method is like `_.lastIndexOf` except that it performs a binary - * search on a sorted `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.sortedLastIndexOf([1, 1, 2, 2], 2); - * // => 3 - */ - sortedLastIndexOf( - array: any[] | List, - ...values: any[] - ): any[]; - } - - // _.tail - interface LoDashStatic { - /** - * @see _.rest - */ - tail(array: List): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.rest - */ - tail(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.rest - */ - tail(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.rest - */ - tail(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.rest - */ - tail(): LoDashExplicitArrayWrapper; - } - - // _.take - interface LoDashStatic { - /** - * Creates a slice of array with n elements taken from the beginning. - * - * @param array The array to query. - * @param n The number of elements to take. - * @return Returns the slice of array. - */ - take( - array: List, - n?: number - ): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.take - */ - take(n?: number): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.take - */ - take(n?: number): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.take - */ - take(n?: number): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.take - */ - take(n?: number): LoDashExplicitArrayWrapper; - } - - // _.takeRight - interface LoDashStatic { - /** - * Creates a slice of array with n elements taken from the end. - * - * @param array The array to query. - * @param n The number of elements to take. - * @return Returns the slice of array. - */ - takeRight( - array: List, - n?: number - ): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.takeRight - */ - takeRight(n?: number): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.takeRight - */ - takeRight(n?: number): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.takeRight - */ - takeRight(n?: number): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.takeRight - */ - takeRight(n?: number): LoDashExplicitArrayWrapper; - } - - // _.takeRightWhile - interface LoDashStatic { - /** - * Creates a slice of array with elements taken from the end. Elements are taken until predicate returns - * falsey. The predicate is bound to thisArg and invoked with three arguments: (value, index, array). - * - * If a property name is provided for predicate the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for predicate the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * @param array The array to query. - * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. - * @return Returns the slice of array. - */ - takeRightWhile( - array: List, - predicate?: ListIterator, - thisArg?: any - ): TValue[]; - - /** - * @see _.takeRightWhile - */ - takeRightWhile( - array: List, - predicate?: string, - thisArg?: any - ): TValue[]; - - /** - * @see _.takeRightWhile - */ - takeRightWhile( - array: List, - predicate?: TWhere - ): TValue[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.takeRightWhile - */ - takeRightWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.takeRightWhile - */ - takeRightWhile( - predicate?: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.takeRightWhile - */ - takeRightWhile( - predicate?: TWhere - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.takeRightWhile - */ - takeRightWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.takeRightWhile - */ - takeRightWhile( - predicate?: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.takeRightWhile - */ - takeRightWhile( - predicate?: TWhere - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.takeRightWhile - */ - takeRightWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.takeRightWhile - */ - takeRightWhile( - predicate?: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.takeRightWhile - */ - takeRightWhile( - predicate?: TWhere - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.takeRightWhile - */ - takeRightWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.takeRightWhile - */ - takeRightWhile( - predicate?: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.takeRightWhile - */ - takeRightWhile( - predicate?: TWhere - ): LoDashExplicitArrayWrapper; - } - - // _.takeWhile - interface LoDashStatic { - /** - * Creates a slice of array with elements taken from the beginning. Elements are taken until predicate returns - * falsey. The predicate is bound to thisArg and invoked with three arguments: (value, index, array). - * - * If a property name is provided for predicate the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for predicate the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * @param array The array to query. - * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. - * @return Returns the slice of array. - */ - takeWhile( - array: List, - predicate?: ListIterator, - thisArg?: any - ): TValue[]; - - /** - * @see _.takeWhile - */ - takeWhile( - array: List, - predicate?: string, - thisArg?: any - ): TValue[]; - - /** - * @see _.takeWhile - */ - takeWhile( - array: List, - predicate?: TWhere - ): TValue[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.takeWhile - */ - takeWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.takeWhile - */ - takeWhile( - predicate?: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.takeWhile - */ - takeWhile( - predicate?: TWhere - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.takeWhile - */ - takeWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.takeWhile - */ - takeWhile( - predicate?: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.takeWhile - */ - takeWhile( - predicate?: TWhere - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.takeWhile - */ - takeWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.takeWhile - */ - takeWhile( - predicate?: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.takeWhile - */ - takeWhile( - predicate?: TWhere - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.takeWhile - */ - takeWhile( - predicate?: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.takeWhile - */ - takeWhile( - predicate?: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.takeWhile - */ - takeWhile( - predicate?: TWhere - ): LoDashExplicitArrayWrapper; - } - - // _.union - interface LoDashStatic { - /** - * Creates an array of unique values, in order, from all of the provided arrays using SameValueZero for - * equality comparisons. - * - * @param arrays The arrays to inspect. - * @return Returns the new array of combined values. - */ - union(...arrays: List[]): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.union - */ - union(...arrays: List[]): LoDashImplicitArrayWrapper; - - /** - * @see _.union - */ - union(...arrays: List[]): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.union - */ - union(...arrays: List[]): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.union - */ - union(...arrays: List[]): LoDashExplicitArrayWrapper; - - /** - * @see _.union - */ - union(...arrays: List[]): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.union - */ - union(...arrays: List[]): LoDashExplicitArrayWrapper; - } - - // _.unionBy - interface LoDashStatic { - /** - * This method is like `_.union` except that it accepts `iteratee` which is - * invoked for each element of each `arrays` to generate the criterion by which - * uniqueness is computed. The iteratee is invoked with one argument: (value). - * - * @param arrays The arrays to inspect. - * @param iteratee The iteratee invoked per element. - * @return Returns the new array of combined values. - */ - unionBy( - arrays: T[] | List, - iteratee?: (value: T) => any - ): T[]; - - /** - * @see _.unionBy - */ - unionBy( - arrays: T[] | List, - iteratee?: W - ): T[]; - - /** - * @see _.unionBy - */ - unionBy( - arrays1: T[] | List, - arrays2: T[] | List, - iteratee?: (value: T) => any - ): T[]; - - /** - * @see _.unionBy - */ - unionBy( - arrays1: T[] | List, - arrays2: T[] | List, - iteratee?: W - ): T[]; - - /** - * @see _.unionBy - */ - unionBy( - arrays1: T[] | List, - arrays2: T[] | List, - arrays3: T[] | List, - iteratee?: (value: T) => any - ): T[]; - - /** - * @see _.unionBy - */ - unionBy( - arrays1: T[] | List, - arrays2: T[] | List, - arrays3: T[] | List, - iteratee?: W - ): T[]; - - /** - * @see _.unionBy - */ - unionBy( - arrays1: T[] | List, - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - iteratee?: (value: T) => any - ): T[]; - - /** - * @see _.unionBy - */ - unionBy( - arrays1: T[] | List, - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - iteratee?: W - ): T[]; - - /** - * @see _.unionBy - */ - unionBy( - arrays1: T[] | List, - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - arrays5: T[] | List, - iteratee?: (value: T) => any - ): T[]; - - /** - * @see _.unionBy - */ - unionBy( - arrays1: T[] | List, - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - arrays5: T[] | List, - iteratee?: W - ): T[]; - - /** - * @see _.unionBy - */ - unionBy( - arrays: T[] | List, - ...iteratee: any[] - ): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.unionBy - */ - unionBy( - iteratee?: (value: T) => any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - iteratee?: (value: T) => any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - iteratee?: (value: T) => any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - iteratee?: (value: T) => any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - arrays5: T[] | List, - iteratee?: (value: T) => any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - arrays5: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - ...iteratee: any[] - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.unionBy - */ - unionBy( - iteratee?: (value: T) => any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - iteratee?: (value: T) => any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - iteratee?: (value: T) => any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - iteratee?: (value: T) => any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - arrays5: T[] | List, - iteratee?: (value: T) => any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - arrays5: T[] | List, - iteratee?: W - ): LoDashImplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - ...iteratee: any[] - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.unionBy - */ - unionBy( - iteratee?: (value: T) => any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - iteratee?: (value: T) => any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - iteratee?: (value: T) => any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - iteratee?: (value: T) => any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - arrays5: T[] | List, - iteratee?: (value: T) => any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - arrays5: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - ...iteratee: any[] - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.unionBy - */ - unionBy( - iteratee?: (value: T) => any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - iteratee?: (value: T) => any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - iteratee?: (value: T) => any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - iteratee?: (value: T) => any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - arrays5: T[] | List, - iteratee?: (value: T) => any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - arrays2: T[] | List, - arrays3: T[] | List, - arrays4: T[] | List, - arrays5: T[] | List, - iteratee?: W - ): LoDashExplicitArrayWrapper; - - /** - * @see _.unionBy - */ - unionBy( - ...iteratee: any[] - ): LoDashExplicitArrayWrapper; - } - - // _.uniq - interface LoDashStatic { - /** - * Creates a duplicate-free version of an array, using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons, in which only the first occurrence of each element - * is kept. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to inspect. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * _.uniq([2, 1, 2]); - * // => [2, 1] - */ - uniq( - array: List - ): T[]; - - /** - * @see _.uniq - */ - uniq( - array: List - ): T[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.uniq - */ - uniq(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.uniq - */ - uniq(): LoDashImplicitArrayWrapper; - - /** - * @see _.uniq - */ - uniq(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - uniq(): LoDashImplicitArrayWrapper; - - /** - * @see _.uniq - */ - uniq(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.uniq - */ - uniq(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.uniq - */ - uniq(): LoDashExplicitArrayWrapper; - - /** - * @see _.uniq - */ - uniq(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.uniq - */ - uniq(): LoDashExplicitArrayWrapper; - - /** - * @see _.uniq - */ - uniq(): LoDashExplicitArrayWrapper; - } - - // _.uniqBy - interface LoDashStatic { - /** - * This method is like `_.uniq` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the criterion by which - * uniqueness is computed. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * _.uniqBy([2.1, 1.2, 2.3], Math.floor); - * // => [2.1, 1.2] - * - * // using the `_.property` iteratee shorthand - * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }, { 'x': 2 }] - */ - uniqBy( - array: List, - iteratee: ListIterator - ): T[]; - - /** - * @see _.uniqBy - */ - uniqBy( - array: List, - iteratee: ListIterator - ): T[]; - - /** - * @see _.uniqBy - */ - uniqBy( - array: List, - iteratee: string - ): T[]; - - /** - * @see _.uniqBy - */ - uniqBy( - array: List, - iteratee: Object - ): T[]; - - /** - * @see _.uniqBy - */ - uniqBy( - array: List, - iteratee: TWhere - ): T[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: ListIterator - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: ListIterator - ): LoDashImplicitArrayWrapper; - - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: TWhere - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: ListIterator - ): LoDashImplicitArrayWrapper; - - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: ListIterator - ): LoDashImplicitArrayWrapper; - - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: Object - ): LoDashImplicitArrayWrapper; - - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: TWhere - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: ListIterator - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: ListIterator - ): LoDashExplicitArrayWrapper; - - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: TWhere - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: ListIterator - ): LoDashExplicitArrayWrapper; - - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: ListIterator - ): LoDashExplicitArrayWrapper; - - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: Object - ): LoDashExplicitArrayWrapper; - - /** - * @see _.uniqBy - */ - uniqBy( - iteratee: TWhere - ): LoDashExplicitArrayWrapper; - } - - // _.sortedUniq - interface LoDashStatic { - /** - * This method is like `_.uniq` except that it's designed and optimized - * for sorted arrays. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to inspect. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * _.sortedUniq([1, 1, 2]); - * // => [1, 2] - */ - sortedUniq( - array: List - ): T[]; - - /** - * @see _.sortedUniq - */ - sortedUniq( - array: List - ): T[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.sortedUniq - */ - sortedUniq(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.sortedUniq - */ - sortedUniq(): LoDashImplicitArrayWrapper; - - /** - * @see _.sortedUniq - */ - sortedUniq(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - sortedUniq(): LoDashImplicitArrayWrapper; - - /** - * @see _.sortedUniq - */ - sortedUniq(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.sortedUniq - */ - sortedUniq(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.sortedUniq - */ - sortedUniq(): LoDashExplicitArrayWrapper; - - /** - * @see _.sortedUniq - */ - sortedUniq(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.sortedUniq - */ - sortedUniq(): LoDashExplicitArrayWrapper; - - /** - * @see _.sortedUniq - */ - sortedUniq(): LoDashExplicitArrayWrapper; - } - - // _.sortedUniqBy - interface LoDashStatic { - /** - * This method is like `_.uniqBy` except that it's designed and optimized - * for sorted arrays. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); - * // => [1.1, 2.2] - */ - sortedUniqBy( - array: List, - iteratee: ListIterator - ): T[]; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - array: List, - iteratee: ListIterator - ): T[]; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - array: List, - iteratee: string - ): T[]; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - array: List, - iteratee: Object - ): T[]; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - array: List, - iteratee: TWhere - ): T[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: ListIterator - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: ListIterator - ): LoDashImplicitArrayWrapper; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: TWhere - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: ListIterator - ): LoDashImplicitArrayWrapper; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: ListIterator - ): LoDashImplicitArrayWrapper; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: Object - ): LoDashImplicitArrayWrapper; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: TWhere - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: ListIterator - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: ListIterator - ): LoDashExplicitArrayWrapper; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: TWhere - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: ListIterator - ): LoDashExplicitArrayWrapper; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: ListIterator - ): LoDashExplicitArrayWrapper; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: Object - ): LoDashExplicitArrayWrapper; - - /** - * @see _.sortedUniqBy - */ - sortedUniqBy( - iteratee: TWhere - ): LoDashExplicitArrayWrapper; - } - - // _.unionWith DUMMY - interface LoDashStatic { - /** - * This method is like `_.union` except that it accepts `comparator` which - * is invoked to compare elements of `arrays`. The comparator is invoked - * with two arguments: (arrVal, othVal). - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of combined values. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; - * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; - * - * _.unionWith(objects, others, _.isEqual); - * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] - */ - unionWith( - array: any[] | List, - ...values: any[] - ): any[]; - } - - // _.uniqWith DUMMY - interface LoDashStatic { - /** - * This method is like `_.uniq` except that it accepts `comparator` which - * is invoked to compare elements of `array`. The comparator is invoked with - * two arguments: (arrVal, othVal). - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new duplicate free array. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; - * - * _.uniqWith(objects, _.isEqual); - * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] - */ - uniqWith( - array: any[] | List, - ...values: any[] - ): any[]; - } - - // _.unzip - interface LoDashStatic { - /** - * This method is like _.zip except that it accepts an array of grouped elements and creates an array - * regrouping the elements to their pre-zip configuration. - * - * @param array The array of grouped elements to process. - * @return Returns the new array of regrouped elements. - */ - unzip(array: List>): T[][]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.unzip - */ - unzip(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.unzip - */ - unzip(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.unzip - */ - unzip(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.unzip - */ - unzip(): LoDashExplicitArrayWrapper; - } - - // _.unzipWith - interface LoDashStatic { - /** - * This method is like _.unzip except that it accepts an iteratee to specify how regrouped values should be - * combined. The iteratee is bound to thisArg and invoked with four arguments: (accumulator, value, index, - * group). - * - * @param array The array of grouped elements to process. - * @param iteratee The function to combine regrouped values. - * @param thisArg The this binding of iteratee. - * @return Returns the new array of regrouped elements. - */ - unzipWith( - array: List>, - iteratee?: MemoIterator, - thisArg?: any - ): TResult[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.unzipWith - */ - unzipWith( - iteratee?: MemoIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.unzipWith - */ - unzipWith( - iteratee?: MemoIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - } - - // _.without - interface LoDashStatic { - /** - * Creates an array excluding all provided values using SameValueZero for equality comparisons. - * - * @param array The array to filter. - * @param values The values to exclude. - * @return Returns the new array of filtered values. - */ - without( - array: List, - ...values: T[] - ): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.without - */ - without(...values: T[]): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.without - */ - without(...values: T[]): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.without - */ - without(...values: T[]): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.without - */ - without(...values: T[]): LoDashExplicitArrayWrapper; - } - - // _.xor - interface LoDashStatic { - /** - * Creates an array of unique values that is the symmetric difference of the provided arrays. - * - * @param arrays The arrays to inspect. - * @return Returns the new array of values. - */ - xor(...arrays: List[]): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.xor - */ - xor(...arrays: List[]): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.xor - */ - xor(...arrays: List[]): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.xor - */ - xor(...arrays: List[]): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.xor - */ - xor(...arrays: List[]): LoDashExplicitArrayWrapper; - } - - // _.xorBy DUMMY - interface LoDashStatic { - /** - * This method is like `_.xor` except that it accepts `iteratee` which is - * invoked for each element of each `arrays` to generate the criterion by which - * uniqueness is computed. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new array of values. - * @example - * - * _.xorBy([2.1, 1.2], [4.3, 2.4], Math.floor); - * // => [1.2, 4.3] - * - * // using the `_.property` iteratee shorthand - * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 2 }] - */ - xorBy( - array: any[] | List, - ...values: any[] - ): any[]; - } - - // _.xorWith DUMMY - interface LoDashStatic { - /** - * This method is like `_.xor` except that it accepts `comparator` which is - * invoked to compare elements of `arrays`. The comparator is invoked with - * two arguments: (arrVal, othVal). - * - * @static - * @memberOf _ - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of values. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; - * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; - * - * _.xorWith(objects, others, _.isEqual); - * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] - */ - xorWith( - array: any[] | List, - ...values: any[] - ): any[]; - } - - // _.zip - interface LoDashStatic { - /** - * Creates an array of grouped elements, the first of which contains the first elements of the given arrays, - * the second of which contains the second elements of the given arrays, and so on. - * - * @param arrays The arrays to process. - * @return Returns the new array of grouped elements. - */ - zip(...arrays: List[]): T[][]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.zip - */ - zip(...arrays: List[]): _.LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.zip - */ - zip(...arrays: List[]): _.LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.zip - */ - zip(...arrays: List[]): _.LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.zip - */ - zip(...arrays: List[]): _.LoDashExplicitArrayWrapper; - } - - // _.zipObject - interface LoDashStatic { - /** - * The inverse of _.pairs; this method returns an object composed from arrays of property names and values. - * Provide either a single two dimensional array, e.g. [[key1, value1], [key2, value2]] or two arrays, one of - * property names and one of corresponding values. - * - * @param props The property names. - * @param values The property values. - * @return Returns the new object. - */ - zipObject( - props: List | List>, - values?: List - ): TResult; - - /** - * @see _.zipObject - */ - zipObject( - props: List | List>, - values?: List - ): TResult; - - /** - * @see _.zipObject - */ - zipObject( - props: List | List>, - values?: List - ): _.Dictionary; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.zipObject - */ - zipObject( - values?: List - ): _.LoDashImplicitObjectWrapper; - - /** - * @see _.zipObject - */ - zipObject( - values?: List - ): _.LoDashImplicitObjectWrapper; - - /** - * @see _.zipObject - */ - zipObject( - values?: List - ): _.LoDashImplicitObjectWrapper<_.Dictionary>; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.zipObject - */ - zipObject( - values?: List - ): _.LoDashImplicitObjectWrapper; - - /** - * @see _.zipObject - */ - zipObject( - values?: List - ): _.LoDashImplicitObjectWrapper; - - /** - * @see _.zipObject - */ - zipObject( - values?: List - ): _.LoDashImplicitObjectWrapper<_.Dictionary>; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.zipObject - */ - zipObject( - values?: List - ): _.LoDashExplicitObjectWrapper; - - /** - * @see _.zipObject - */ - zipObject( - values?: List - ): _.LoDashExplicitObjectWrapper; - - /** - * @see _.zipObject - */ - zipObject( - values?: List - ): _.LoDashExplicitObjectWrapper<_.Dictionary>; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.zipObject - */ - zipObject( - values?: List - ): _.LoDashExplicitObjectWrapper; - - /** - * @see _.zipObject - */ - zipObject( - values?: List - ): _.LoDashExplicitObjectWrapper; - - /** - * @see _.zipObject - */ - zipObject( - values?: List - ): _.LoDashExplicitObjectWrapper<_.Dictionary>; - } - - // _.zipWith - interface LoDashStatic { - /** - * This method is like _.zip except that it accepts an iteratee to specify how grouped values should be - * combined. The iteratee is bound to thisArg and invoked with four arguments: (accumulator, value, index, - * group). - * @param {...Array} [arrays] The arrays to process. - * @param {Function} [iteratee] The function to combine grouped values. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @return Returns the new array of grouped elements. - */ - zipWith(...args: any[]): TResult[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.zipWith - */ - zipWith(...args: any[]): LoDashImplicitArrayWrapper; - } - - /********* - * Chain * - ********/ - - // _.chain - interface LoDashStatic { - /** - * Creates a lodash object that wraps value with explicit method chaining enabled. - * - * @param value The value to wrap. - * @return Returns the new lodash wrapper instance. - */ - chain(value: number): LoDashExplicitWrapper; - chain(value: string): LoDashExplicitWrapper; - chain(value: boolean): LoDashExplicitWrapper; - chain(value: T[]): LoDashExplicitArrayWrapper; - chain(value: T): LoDashExplicitObjectWrapper; - chain(value: any): LoDashExplicitWrapper; - } - - interface LoDashImplicitWrapper { - /** - * @see _.chain - */ - chain(): LoDashExplicitWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.chain - */ - chain(): LoDashExplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.chain - */ - chain(): LoDashExplicitObjectWrapper; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.chain - */ - chain(): TWrapper; - } - - // _.tap - interface LoDashStatic { - /** - * This method invokes interceptor and returns value. The interceptor is bound to thisArg and invoked with one - * argument; (value). The purpose of this method is to "tap into" a method chain in order to perform operations - * on intermediate results within the chain. - * - * @param value The value to provide to interceptor. - * @param interceptor The function to invoke. - * @parem thisArg The this binding of interceptor. - * @return Returns value. - */ - tap( - value: T, - interceptor: (value: T) => void, - thisArg?: any - ): T; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.tap - */ - tap( - interceptor: (value: T) => void, - thisArg?: any - ): TWrapper; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.tap - */ - tap( - interceptor: (value: T) => void, - thisArg?: any - ): TWrapper; - } - - // _.thru - interface LoDashStatic { - /** - * This method is like _.tap except that it returns the result of interceptor. - * - * @param value The value to provide to interceptor. - * @param interceptor The function to invoke. - * @param thisArg The this binding of interceptor. - * @return Returns the result of interceptor. - */ - thru( - value: T, - interceptor: (value: T) => TResult, - thisArg?: any - ): TResult; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.thru - */ - thru( - interceptor: (value: T) => TResult, - thisArg?: any): LoDashImplicitWrapper; - - /** - * @see _.thru - */ - thru( - interceptor: (value: T) => TResult, - thisArg?: any): LoDashImplicitWrapper; - - /** - * @see _.thru - */ - thru( - interceptor: (value: T) => TResult, - thisArg?: any): LoDashImplicitWrapper; - - /** - * @see _.thru - */ - thru( - interceptor: (value: T) => TResult, - thisArg?: any): LoDashImplicitObjectWrapper; - - /** - * @see _.thru - */ - thru( - interceptor: (value: T) => TResult[], - thisArg?: any): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.thru - */ - thru( - interceptor: (value: T) => TResult, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.thru - */ - thru( - interceptor: (value: T) => TResult, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.thru - */ - thru( - interceptor: (value: T) => TResult, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.thru - */ - thru( - interceptor: (value: T) => TResult, - thisArg?: any - ): LoDashExplicitObjectWrapper; - - /** - * @see _.thru - */ - thru( - interceptor: (value: T) => TResult[], - thisArg?: any - ): LoDashExplicitArrayWrapper; - } - - // _.prototype.commit - interface LoDashImplicitWrapperBase { - /** - * Executes the chained sequence and returns the wrapped result. - * - * @return Returns the new lodash wrapper instance. - */ - commit(): TWrapper; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.commit - */ - commit(): TWrapper; - } - - // _.prototype.concat - interface LoDashImplicitWrapperBase { - /** - * Creates a new array joining a wrapped array with any additional arrays and/or values. - * - * @param items - * @return Returns the new concatenated array. - */ - concat(...items: Array>): LoDashImplicitArrayWrapper; - - /** - * @see _.concat - */ - concat(...items: Array>): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.concat - */ - concat(...items: Array>): LoDashExplicitArrayWrapper; - - /** - * @see _.concat - */ - concat(...items: Array>): LoDashExplicitArrayWrapper; - } - - // _.prototype.plant - interface LoDashImplicitWrapperBase { - /** - * Creates a clone of the chained sequence planting value as the wrapped value. - * @param value The value to plant as the wrapped value. - * @return Returns the new lodash wrapper instance. - */ - plant(value: number): LoDashImplicitWrapper; - - /** - * @see _.plant - */ - plant(value: string): LoDashImplicitStringWrapper; - - /** - * @see _.plant - */ - plant(value: boolean): LoDashImplicitWrapper; - - /** - * @see _.plant - */ - plant(value: number[]): LoDashImplicitNumberArrayWrapper; - - /** - * @see _.plant - */ - plant(value: T[]): LoDashImplicitArrayWrapper; - - /** - * @see _.plant - */ - plant(value: T): LoDashImplicitObjectWrapper; - - /** - * @see _.plant - */ - plant(value: any): LoDashImplicitWrapper; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.plant - */ - plant(value: number): LoDashExplicitWrapper; - - /** - * @see _.plant - */ - plant(value: string): LoDashExplicitStringWrapper; - - /** - * @see _.plant - */ - plant(value: boolean): LoDashExplicitWrapper; - - /** - * @see _.plant - */ - plant(value: number[]): LoDashExplicitNumberArrayWrapper; - - /** - * @see _.plant - */ - plant(value: T[]): LoDashExplicitArrayWrapper; - - /** - * @see _.plant - */ - plant(value: T): LoDashExplicitObjectWrapper; - - /** - * @see _.plant - */ - plant(value: any): LoDashExplicitWrapper; - } - - // _.prototype.reverse - interface LoDashImplicitArrayWrapper { - /** - * Reverses the wrapped array so the first element becomes the last, the second element becomes the second to - * last, and so on. - * - * Note: This method mutates the wrapped array. - * - * @return Returns the new reversed lodash wrapper instance. - */ - reverse(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.reverse - */ - reverse(): LoDashExplicitArrayWrapper; - } - - // _.prototype.toJSON - interface LoDashWrapperBase { - /** - * @see _.value - */ - toJSON(): T; - } - - // _.prototype.toString - interface LoDashWrapperBase { - /** - * Produces the result of coercing the unwrapped value to a string. - * - * @return Returns the coerced string value. - */ - toString(): string; - } - - // _.prototype.value - interface LoDashWrapperBase { - /** - * Executes the chained sequence to extract the unwrapped value. - * - * @alias _.toJSON, _.valueOf - * - * @return Returns the resolved unwrapped value. - */ - value(): T; - } - - // _.valueOf - interface LoDashWrapperBase { - /** - * @see _.value - */ - valueOf(): T; - } - - /************** - * Collection * - *************/ - - // _.at - interface LoDashStatic { - /** - * Creates an array of elements corresponding to the given keys, or indexes, of collection. Keys may be - * specified as individual arguments or as arrays of keys. - * - * @param collection The collection to iterate over. - * @param props The property names or indexes of elements to pick, specified individually or in arrays. - * @return Returns the new array of picked elements. - */ - at( - collection: List | Dictionary, - ...props: (number | string | (number | string)[])[] - ): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.at - */ - at(...props: (number | string | (number | string)[])[]): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.at - */ - at(...props: (number | string | (number | string)[])[]): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.at - */ - at(...props: (number | string | (number | string)[])[]): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.at - */ - at(...props: (number | string | (number | string)[])[]): LoDashExplicitArrayWrapper; - } - - // _.countBy - interface LoDashStatic { - /** - * Creates an object composed of keys generated from the results of running each element of collection through - * iteratee. The corresponding value of each key is the number of times the key was returned by iteratee. The - * iteratee is bound to thisArg and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for iteratee the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for iteratee the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * @param collection The collection to iterate over. - * @param iteratee The function invoked per iteration. - * @param thisArg The this binding of iteratee. - * @return Returns the composed aggregate object. - */ - countBy( - collection: List, - iteratee?: ListIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.countBy - */ - countBy( - collection: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.countBy - */ - countBy( - collection: NumericDictionary, - iteratee?: NumericDictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.countBy - */ - countBy( - collection: List | Dictionary | NumericDictionary, - iteratee?: string, - thisArg?: any - ): Dictionary; - - /** - * @see _.countBy - */ - countBy( - collection: List | Dictionary | NumericDictionary, - iteratee?: W - ): Dictionary; - - /** - * @see _.countBy - */ - countBy( - collection: List | Dictionary | NumericDictionary, - iteratee?: Object - ): Dictionary; - } - - interface LoDashImplicitWrapper { - /** - * @see _.countBy - */ - countBy( - iteratee?: ListIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.countBy - */ - countBy( - iteratee?: ListIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.countBy - */ - countBy( - iteratee?: string, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.countBy - */ - countBy( - iteratee?: W - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.countBy - */ - countBy( - iteratee?: ListIterator | DictionaryIterator | NumericDictionaryIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.countBy - */ - countBy( - iteratee?: string, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.countBy - */ - countBy( - iteratee?: W - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashExplicitWrapper { - /** - * @see _.countBy - */ - countBy( - iteratee?: ListIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.countBy - */ - countBy( - iteratee?: ListIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.countBy - */ - countBy( - iteratee?: string, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.countBy - */ - countBy( - iteratee?: W - ): LoDashExplicitObjectWrapper>; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.countBy - */ - countBy( - iteratee?: ListIterator | DictionaryIterator | NumericDictionaryIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.countBy - */ - countBy( - iteratee?: string, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.countBy - */ - countBy( - iteratee?: W - ): LoDashExplicitObjectWrapper>; - } - - // _.each - interface LoDashStatic { - /** - * @see _.forEach - */ - each( - collection: T[], - iteratee?: ListIterator, - thisArg?: any - ): T[]; - - /** - * @see _.forEach - */ - each( - collection: List, - iteratee?: ListIterator, - thisArg?: any - ): List; - - /** - * @see _.forEach - */ - each( - collection: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.forEach - */ - each( - collection: T, - iteratee?: ObjectIterator, - thisArgs?: any - ): T; - - /** - * @see _.forEach - */ - each( - collection: T, - iteratee?: ObjectIterator, - thisArgs?: any - ): T; - } - - interface LoDashImplicitWrapper { - /** - * @see _.forEach - */ - each( - iteratee: ListIterator, - thisArg?: any - ): LoDashImplicitWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.forEach - */ - each( - iteratee: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.forEach - */ - each( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.forEach - */ - each( - iteratee: ListIterator, - thisArg?: any - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.forEach - */ - each( - iteratee: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.forEach - */ - each( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper; - } - - // _.eachRight - interface LoDashStatic { - /** - * @see _.forEachRight - */ - eachRight( - collection: T[], - iteratee?: ListIterator, - thisArg?: any - ): T[]; - - /** - * @see _.forEachRight - */ - eachRight( - collection: List, - iteratee?: ListIterator, - thisArg?: any - ): List; - - /** - * @see _.forEachRight - */ - eachRight( - collection: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.forEachRight - */ - eachRight( - collection: T, - iteratee?: ObjectIterator, - thisArgs?: any - ): T; - - /** - * @see _.forEachRight - */ - eachRight( - collection: T, - iteratee?: ObjectIterator, - thisArgs?: any - ): T; - } - - interface LoDashImplicitWrapper { - /** - * @see _.forEachRight - */ - eachRight( - iteratee: ListIterator, - thisArg?: any - ): LoDashImplicitWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.forEachRight - */ - eachRight( - iteratee: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.forEachRight - */ - eachRight( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.forEachRight - */ - eachRight( - iteratee: ListIterator, - thisArg?: any - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.forEachRight - */ - eachRight( - iteratee: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.forEachRight - */ - eachRight( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper; - } - - // _.every - interface LoDashStatic { - /** - * Checks if predicate returns truthy for all elements of collection. Iteration is stopped once predicate - * returns falsey. The predicate is invoked with three arguments: (value, index|key, collection). - * - * @param collection The collection to iterate over. - * @param predicate The function invoked per iteration. - * @return Returns true if all elements pass the predicate check, else false. - */ - every( - collection: List, - predicate?: ListIterator - ): boolean; - - /** - * @see _.every - */ - every( - collection: Dictionary, - predicate?: DictionaryIterator - ): boolean; - - /** - * @see _.every - */ - every( - collection: NumericDictionary, - predicate?: NumericDictionaryIterator - ): boolean; - - /** - * @see _.every - */ - every( - collection: List | Dictionary | NumericDictionary, - predicate?: string | any[] - ): boolean; - - /** - * @see _.every - */ - every( - collection: List | Dictionary | NumericDictionary, - predicate?: TObject - ): boolean; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.every - */ - every( - predicate?: ListIterator | NumericDictionaryIterator - ): boolean; - - /** - * @see _.every - */ - every( - predicate?: string | any[] - ): boolean; - - /** - * @see _.every - */ - every( - predicate?: TObject - ): boolean; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.every - */ - every( - predicate?: ListIterator | DictionaryIterator | NumericDictionaryIterator - ): boolean; - - /** - * @see _.every - */ - every( - predicate?: string | any[] - ): boolean; - - /** - * @see _.every - */ - every( - predicate?: TObject - ): boolean; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.every - */ - every( - predicate?: ListIterator | NumericDictionaryIterator - ): LoDashExplicitWrapper; - - /** - * @see _.every - */ - every( - predicate?: string | any[] - ): LoDashExplicitWrapper; - - /** - * @see _.every - */ - every( - predicate?: TObject - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.every - */ - every( - predicate?: ListIterator | DictionaryIterator | NumericDictionaryIterator - ): LoDashExplicitWrapper; - - /** - * @see _.every - */ - every( - predicate?: string | any[] - ): LoDashExplicitWrapper; - - /** - * @see _.every - */ - every( - predicate?: TObject - ): LoDashExplicitWrapper; - } - - // _.filter - interface LoDashStatic { - /** - * Iterates over elements of collection, returning an array of all elements predicate returns truthy for. The - * predicate is bound to thisArg and invoked with three arguments: (value, index|key, collection). - * - * If a property name is provided for predicate the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for predicate the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * @param collection The collection to iterate over. - * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. - * @return Returns the new filtered array. - */ - filter( - collection: List, - predicate?: ListIterator, - thisArg?: any - ): T[]; - - /** - * @see _.filter - */ - filter( - collection: Dictionary, - predicate?: DictionaryIterator, - thisArg?: any - ): T[]; - - /** - * @see _.filter - */ - filter( - collection: string, - predicate?: StringIterator, - thisArg?: any - ): string[]; - - /** - * @see _.filter - */ - filter( - collection: List | Dictionary, - predicate: string, - thisArg?: any - ): T[]; - - /** - * @see _.filter - */ - filter( - collection: List | Dictionary, - predicate: W - ): T[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.filter - */ - filter( - predicate?: StringIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.filter - */ - filter( - predicate: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.filter - */ - filter( - predicate: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.filter - */ - filter(predicate: W): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.filter - */ - filter( - predicate: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.filter - */ - filter( - predicate: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.filter - */ - filter(predicate: W): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.filter - */ - filter( - predicate?: StringIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.filter - */ - filter( - predicate: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.filter - */ - filter( - predicate: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.filter - */ - filter(predicate: W): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.filter - */ - filter( - predicate: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.filter - */ - filter( - predicate: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.filter - */ - filter(predicate: W): LoDashExplicitArrayWrapper; - } - - // _.find - interface LoDashStatic { - /** - * Iterates over elements of collection, returning the first element predicate returns truthy for. - * The predicate is bound to thisArg and invoked with three arguments: (value, index|key, collection). - * - * If a property name is provided for predicate the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for predicate the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * @param collection The collection to search. - * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. - * @return Returns the matched element, else undefined. - */ - find( - collection: List, - predicate?: ListIterator, - thisArg?: any - ): T; - - /** - * @see _.find - */ - find( - collection: Dictionary, - predicate?: DictionaryIterator, - thisArg?: any - ): T; - - /** - * @see _.find - */ - find( - collection: List | Dictionary, - predicate?: string, - thisArg?: any - ): T; - - /** - * @see _.find - */ - find( - collection: List | Dictionary, - predicate?: TObject - ): T; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.find - */ - find( - predicate?: ListIterator, - thisArg?: any - ): T; - - /** - * @see _.find - */ - find( - predicate?: string, - thisArg?: any - ): T; - - /** - * @see _.find - */ - find( - predicate?: TObject - ): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.find - */ - find( - predicate?: ListIterator | DictionaryIterator, - thisArg?: any - ): TResult; - - /** - * @see _.find - */ - find( - predicate?: string, - thisArg?: any - ): TResult; - - /** - * @see _.find - */ - find( - predicate?: TObject - ): TResult; - } - - // _.findLast - interface LoDashStatic { - /** - * This method is like _.find except that it iterates over elements of a collection from - * right to left. - * @param collection Searches for a value in this list. - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - * @return The found element, else undefined. - */ - findLast( - collection: Array, - callback: ListIterator, - thisArg?: any): T; - - /** - * @see _.find - */ - findLast( - collection: List, - callback: ListIterator, - thisArg?: any): T; - - /** - * @see _.find - */ - findLast( - collection: Dictionary, - callback: DictionaryIterator, - thisArg?: any): T; - - /** - * @see _.find - * @param _.pluck style callback - */ - findLast( - collection: Array, - whereValue: W): T; - - /** - * @see _.find - * @param _.pluck style callback - */ - findLast( - collection: List, - whereValue: W): T; - - /** - * @see _.find - * @param _.pluck style callback - */ - findLast( - collection: Dictionary, - whereValue: W): T; - - /** - * @see _.find - * @param _.where style callback - */ - findLast( - collection: Array, - pluckValue: string): T; - - /** - * @see _.find - * @param _.where style callback - */ - findLast( - collection: List, - pluckValue: string): T; - - /** - * @see _.find - * @param _.where style callback - */ - findLast( - collection: Dictionary, - pluckValue: string): T; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.findLast - */ - findLast( - callback: ListIterator, - thisArg?: any): T; - /** - * @see _.findLast - * @param _.where style callback - */ - findLast( - whereValue: W): T; - - /** - * @see _.findLast - * @param _.where style callback - */ - findLast( - pluckValue: string): T; - } - - // _.forEach - interface LoDashStatic { - /** - * Iterates over elements of collection invoking iteratee for each element. The iteratee is bound to thisArg - * and invoked with three arguments: - * (value, index|key, collection). Iteratee functions may exit iteration early by explicitly returning false. - * - * Note: As with other "Collections" methods, objects with a "length" property are iterated like arrays. To - * avoid this behavior _.forIn or _.forOwn may be used for object iteration. - * - * @alias _.each - * - * @param collection The collection to iterate over. - * @param iteratee The function invoked per iteration. - * @param thisArg The this binding of iteratee. - */ - forEach( - collection: T[], - iteratee?: ListIterator, - thisArg?: any - ): T[]; - - /** - * @see _.forEach - */ - forEach( - collection: List, - iteratee?: ListIterator, - thisArg?: any - ): List; - - /** - * @see _.forEach - */ - forEach( - collection: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.forEach - */ - forEach( - collection: T, - iteratee?: ObjectIterator, - thisArgs?: any - ): T; - - /** - * @see _.forEach - */ - forEach( - collection: T, - iteratee?: ObjectIterator, - thisArgs?: any - ): T; - } - - interface LoDashImplicitWrapper { - /** - * @see _.forEach - */ - forEach( - iteratee: ListIterator, - thisArg?: any - ): LoDashImplicitWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.forEach - */ - forEach( - iteratee: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.forEach - */ - forEach( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.forEach - */ - forEach( - iteratee: ListIterator, - thisArg?: any - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.forEach - */ - forEach( - iteratee: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.forEach - */ - forEach( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper; - } - - // _.forEachRight - interface LoDashStatic { - /** - * This method is like _.forEach except that it iterates over elements of collection from right to left. - * - * @alias _.eachRight - * - * @param collection The collection to iterate over. - * @param iteratee The function called per iteration. - * @param thisArg The this binding of callback. - */ - forEachRight( - collection: T[], - iteratee?: ListIterator, - thisArg?: any - ): T[]; - - /** - * @see _.forEachRight - */ - forEachRight( - collection: List, - iteratee?: ListIterator, - thisArg?: any - ): List; - - /** - * @see _.forEachRight - */ - forEachRight( - collection: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.forEachRight - */ - forEachRight( - collection: T, - iteratee?: ObjectIterator, - thisArgs?: any - ): T; - - /** - * @see _.forEachRight - */ - forEachRight( - collection: T, - iteratee?: ObjectIterator, - thisArgs?: any - ): T; - } - - interface LoDashImplicitWrapper { - /** - * @see _.forEachRight - */ - forEachRight( - iteratee: ListIterator, - thisArg?: any - ): LoDashImplicitWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.forEachRight - */ - forEachRight( - iteratee: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.forEachRight - */ - forEachRight( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.forEachRight - */ - forEachRight( - iteratee: ListIterator, - thisArg?: any - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.forEachRight - */ - forEachRight( - iteratee: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.forEachRight - */ - forEachRight( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper; - } - - // _.groupBy - interface LoDashStatic { - /** - * Creates an object composed of keys generated from the results of running each element of collection through - * iteratee. The corresponding value of each key is an array of the elements responsible for generating the - * key. The iteratee is bound to thisArg and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for iteratee the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for iteratee the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * @param collection The collection to iterate over. - * @param iteratee The function invoked per iteration. - * @param thisArg The this binding of iteratee. - * @return Returns the composed aggregate object. - */ - groupBy( - collection: List, - iteratee?: ListIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.groupBy - */ - groupBy( - collection: List, - iteratee?: ListIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.groupBy - */ - groupBy( - collection: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.groupBy - */ - groupBy( - collection: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.groupBy - */ - groupBy( - collection: List | Dictionary, - iteratee?: string, - thisArg?: TValue - ): Dictionary; - - /** - * @see _.groupBy - */ - groupBy( - collection: List | Dictionary, - iteratee?: string, - thisArg?: any - ): Dictionary; - - /** - * @see _.groupBy - */ - groupBy( - collection: List | Dictionary, - iteratee?: TWhere - ): Dictionary; - - /** - * @see _.groupBy - */ - groupBy( - collection: List | Dictionary, - iteratee?: Object - ): Dictionary; - } - - interface LoDashImplicitWrapper { - /** - * @see _.groupBy - */ - groupBy( - iteratee?: ListIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.groupBy - */ - groupBy( - iteratee?: ListIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: string, - thisArg?: TValue - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: TWhere - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.groupBy - */ - groupBy( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: string, - thisArg?: TValue - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: string, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: TWhere - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: Object - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashExplicitWrapper { - /** - * @see _.groupBy - */ - groupBy( - iteratee?: ListIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.groupBy - */ - groupBy( - iteratee?: ListIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: string, - thisArg?: TValue - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: TWhere - ): LoDashExplicitObjectWrapper>; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.groupBy - */ - groupBy( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: string, - thisArg?: TValue - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: string, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: TWhere - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.groupBy - */ - groupBy( - iteratee?: Object - ): LoDashExplicitObjectWrapper>; - } - - // _.includes - interface LoDashStatic { - /** - * Checks if target is in collection using SameValueZero for equality comparisons. If fromIndex is negative, - * it’s used as the offset from the end of collection. - * - * @param collection The collection to search. - * @param target The value to search for. - * @param fromIndex The index to search from. - * @return True if the target element is found, else false. - */ - includes( - collection: List | Dictionary, - target: T, - fromIndex?: number - ): boolean; - - /** - * @see _.includes - */ - includes( - collection: string, - target: string, - fromIndex?: number - ): boolean; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.includes - */ - includes( - target: T, - fromIndex?: number - ): boolean; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.includes - */ - includes( - target: TValue, - fromIndex?: number - ): boolean; - } - - interface LoDashImplicitWrapper { - /** - * @see _.includes - */ - includes( - target: string, - fromIndex?: number - ): boolean; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.includes - */ - includes( - target: T, - fromIndex?: number - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.includes - */ - includes( - target: TValue, - fromIndex?: number - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.includes - */ - includes( - target: string, - fromIndex?: number - ): LoDashExplicitWrapper; - } - - // _.keyBy - interface LoDashStatic { - /** - * Creates an object composed of keys generated from the results of running each element of collection through - * iteratee. The corresponding value of each key is the last element responsible for generating the key. The - * iteratee function is bound to thisArg and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for iteratee the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for iteratee the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * @param collection The collection to iterate over. - * @param iteratee The function invoked per iteration. - * @param thisArg The this binding of iteratee. - * @return Returns the composed aggregate object. - */ - keyBy( - collection: List, - iteratee?: ListIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.keyBy - */ - keyBy( - collection: NumericDictionary, - iteratee?: NumericDictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.keyBy - */ - keyBy( - collection: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.keyBy - */ - keyBy( - collection: List | NumericDictionary | Dictionary, - iteratee?: string, - thisArg?: any - ): Dictionary; - - /** - * @see _.keyBy - */ - keyBy( - collection: List | NumericDictionary | Dictionary, - iteratee?: W - ): Dictionary; - - /** - * @see _.keyBy - */ - keyBy( - collection: List | NumericDictionary | Dictionary, - iteratee?: Object - ): Dictionary; - } - - interface LoDashImplicitWrapper { - /** - * @see _.keyBy - */ - keyBy( - iteratee?: ListIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.keyBy - */ - keyBy( - iteratee?: ListIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.keyBy - */ - keyBy( - iteratee?: string, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.keyBy - */ - keyBy( - iteratee?: W - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.keyBy - */ - keyBy( - iteratee?: ListIterator | NumericDictionaryIterator | DictionaryIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.keyBy - */ - keyBy( - iteratee?: string, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.keyBy - */ - keyBy( - iteratee?: W - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.keyBy - */ - keyBy( - iteratee?: Object - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashExplicitWrapper { - /** - * @see _.keyBy - */ - keyBy( - iteratee?: ListIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.keyBy - */ - keyBy( - iteratee?: ListIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.keyBy - */ - keyBy( - iteratee?: string, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.keyBy - */ - keyBy( - iteratee?: W - ): LoDashExplicitObjectWrapper>; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.keyBy - */ - keyBy( - iteratee?: ListIterator | NumericDictionaryIterator | DictionaryIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.keyBy - */ - keyBy( - iteratee?: string, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.keyBy - */ - keyBy( - iteratee?: W - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.keyBy - */ - keyBy( - iteratee?: Object - ): LoDashExplicitObjectWrapper>; - } - - // _.invokeMap - interface LoDashStatic { - /** - * Invokes the method named by methodName on each element in the collection returning - * an array of the results of each invoked method. Additional arguments will be provided - * to each invoked method. If methodName is a function it will be invoked for, and this - * bound to, each element in the collection. - * @param collection The collection to iterate over. - * @param methodName The name of the method to invoke. - * @param args Arguments to invoke the method with. - */ - invokeMap( - collection: TValue[], - methodName: string, - ...args: any[]): TResult[]; - - /** - * @see _.invokeMap - */ - invokeMap( - collection: Dictionary, - methodName: string, - ...args: any[]): TResult[]; - - /** - * @see _.invokeMap - */ - invokeMap( - collection: {}[], - methodName: string, - ...args: any[]): TResult[]; - - /** - * @see _.invokeMap - */ - invokeMap( - collection: Dictionary<{}>, - methodName: string, - ...args: any[]): TResult[]; - - /** - * @see _.invokeMap - */ - invokeMap( - collection: TValue[], - method: (...args: any[]) => TResult, - ...args: any[]): TResult[]; - - /** - * @see _.invokeMap - */ - invokeMap( - collection: Dictionary, - method: (...args: any[]) => TResult, - ...args: any[]): TResult[]; - - /** - * @see _.invokeMap - */ - invokeMap( - collection: {}[], - method: (...args: any[]) => TResult, - ...args: any[]): TResult[]; - - /** - * @see _.invokeMap - */ - invokeMap( - collection: Dictionary<{}>, - method: (...args: any[]) => TResult, - ...args: any[]): TResult[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.invokeMap - */ - invokeMap( - methodName: string, - ...args: any[]): LoDashImplicitArrayWrapper; - - /** - * @see _.invokeMap - */ - invokeMap( - method: (...args: any[]) => TResult, - ...args: any[]): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.invokeMap - */ - invokeMap( - methodName: string, - ...args: any[]): LoDashImplicitArrayWrapper; - - /** - * @see _.invokeMap - */ - invokeMap( - method: (...args: any[]) => TResult, - ...args: any[]): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.invokeMap - */ - invokeMap( - methodName: string, - ...args: any[]): LoDashExplicitArrayWrapper; - - /** - * @see _.invokeMap - */ - invokeMap( - method: (...args: any[]) => TResult, - ...args: any[]): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.invokeMap - */ - invokeMap( - methodName: string, - ...args: any[]): LoDashExplicitArrayWrapper; - - /** - * @see _.invokeMap - */ - invokeMap( - method: (...args: any[]) => TResult, - ...args: any[]): LoDashExplicitArrayWrapper; - } - - // _.map - interface LoDashStatic { - /** - * Creates an array of values by running each element in collection through iteratee. The iteratee is bound to - * thisArg and invoked with three arguments: (value, index|key, collection). - * - * If a property name is provided for iteratee the created _.property style callback returns the property value - * of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for iteratee the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * Many lodash methods are guarded to work as iteratees for methods like _.every, _.filter, _.map, _.mapValues, - * _.reject, and _.some. - * - * The guarded methods are: - * ary, callback, chunk, clone, create, curry, curryRight, drop, dropRight, every, fill, flatten, invert, max, - * min, parseInt, slice, sortBy, take, takeRight, template, trim, trimLeft, trimRight, trunc, random, range, - * sample, some, sum, uniq, and words - * - * @param collection The collection to iterate over. - * @param iteratee The function invoked per iteration. - * @param thisArg The this binding of iteratee. - * @return Returns the new mapped array. - */ - map( - collection: List, - iteratee?: ListIterator, - thisArg?: any - ): TResult[]; - - /** - * @see _.map - */ - map( - collection: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): TResult[]; - - map( - collection: NumericDictionary, - iteratee?: NumericDictionaryIterator, - thisArg?: any - ): TResult[]; - - /** - * @see _.map - */ - map( - collection: List | Dictionary | NumericDictionary, - iteratee?: string - ): TResult[]; - - /** - * @see _.map - */ - map( - collection: List | Dictionary | NumericDictionary, - iteratee?: TObject - ): boolean[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.map - */ - map( - iteratee?: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.map - */ - map( - iteratee?: string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.map - */ - map( - iteratee?: TObject - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.map - */ - map( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.map - */ - map( - iteratee?: string - ): LoDashImplicitArrayWrapper; - - /** - * @see _.map - */ - map( - iteratee?: TObject - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.map - */ - map( - iteratee?: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.map - */ - map( - iteratee?: string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.map - */ - map( - iteratee?: TObject - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.map - */ - map( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.map - */ - map( - iteratee?: string - ): LoDashExplicitArrayWrapper; - - /** - * @see _.map - */ - map( - iteratee?: TObject - ): LoDashExplicitArrayWrapper; - } - - // _.partition - interface LoDashStatic { - /** - * Creates an array of elements split into two groups, the first of which contains elements predicate returns truthy for, - * while the second of which contains elements predicate returns falsey for. - * The predicate is bound to thisArg and invoked with three arguments: (value, index|key, collection). - * - * If a property name is provided for predicate the created _.property style callback - * returns the property value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback - * returns true for elements that have a matching property value, else false. - * - * If an object is provided for predicate the created _.matches style callback returns - * true for elements that have the properties of the given object, else false. - * - * @param collection The collection to iterate over. - * @param callback The function called per iteration. - * @param thisArg The this binding of predicate. - * @return Returns the array of grouped elements. - */ - partition( - collection: List, - callback: ListIterator, - thisArg?: any): T[][]; - - /** - * @see _.partition - */ - partition( - collection: Dictionary, - callback: DictionaryIterator, - thisArg?: any): T[][]; - - /** - * @see _.partition - */ - partition( - collection: List, - whereValue: W): T[][]; - - /** - * @see _.partition - */ - partition( - collection: Dictionary, - whereValue: W): T[][]; - - /** - * @see _.partition - */ - partition( - collection: List, - path: string, - srcValue: any): T[][]; - - /** - * @see _.partition - */ - partition( - collection: Dictionary, - path: string, - srcValue: any): T[][]; - - /** - * @see _.partition - */ - partition( - collection: List, - pluckValue: string): T[][]; - - /** - * @see _.partition - */ - partition( - collection: Dictionary, - pluckValue: string): T[][]; - } - - interface LoDashImplicitStringWrapper { - /** - * @see _.partition - */ - partition( - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.partition - */ - partition( - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; - /** - * @see _.partition - */ - partition( - whereValue: W): LoDashImplicitArrayWrapper; - /** - * @see _.partition - */ - partition( - path: string, - srcValue: any): LoDashImplicitArrayWrapper; - /** - * @see _.partition - */ - partition( - pluckValue: string): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.partition - */ - partition( - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; - - /** - * @see _.partition - */ - partition( - callback: DictionaryIterator, - thisArg?: any): LoDashImplicitArrayWrapper; - - /** - * @see _.partition - */ - partition( - whereValue: W): LoDashImplicitArrayWrapper; - - /** - * @see _.partition - */ - partition( - path: string, - srcValue: any): LoDashImplicitArrayWrapper; - - /** - * @see _.partition - */ - partition( - pluckValue: string): LoDashImplicitArrayWrapper; - } - - // _.reduce - interface LoDashStatic { - /** - * Reduces a collection to a value which is the accumulated result of running each - * element in the collection through the callback, where each successive callback execution - * consumes the return value of the previous execution. If accumulator is not provided the - * first element of the collection will be used as the initial accumulator value. The callback - * is bound to thisArg and invoked with four arguments; (accumulator, value, index|key, collection). - * @param collection The collection to iterate over. - * @param callback The function called per iteration. - * @param accumulator Initial value of the accumulator. - * @param thisArg The this binding of callback. - * @return Returns the accumulated value. - */ - reduce( - collection: Array, - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; - - /** - * @see _.reduce - */ - reduce( - collection: List, - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; - - /** - * @see _.reduce - */ - reduce( - collection: Dictionary, - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; - - /** - * @see _.reduce - */ - reduce( - collection: NumericDictionary, - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; - - /** - * @see _.reduce - */ - reduce( - collection: Array, - callback: MemoIterator, - thisArg?: any): TResult; - - /** - * @see _.reduce - */ - reduce( - collection: List, - callback: MemoIterator, - thisArg?: any): TResult; - - /** - * @see _.reduce - */ - reduce( - collection: Dictionary, - callback: MemoIterator, - thisArg?: any): TResult; - - /** - * @see _.reduce - */ - reduce( - collection: NumericDictionary, - callback: MemoIterator, - thisArg?: any): TResult; - - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.reduce - */ - reduce( - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; - - /** - * @see _.reduce - */ - reduce( - callback: MemoIterator, - thisArg?: any): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.reduce - */ - reduce( - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; - - /** - * @see _.reduce - */ - reduce( - callback: MemoIterator, - thisArg?: any): TResult; - } - - // _.reduceRight - interface LoDashStatic { - /** - * This method is like _.reduce except that it iterates over elements of a collection from - * right to left. - * @param collection The collection to iterate over. - * @param callback The function called per iteration. - * @param accumulator Initial value of the accumulator. - * @param thisArg The this binding of callback. - * @return The accumulated value. - */ - reduceRight( - collection: Array, - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; - - /** - * @see _.reduceRight - */ - reduceRight( - collection: List, - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; - - /** - * @see _.reduceRight - */ - reduceRight( - collection: Dictionary, - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; - - /** - * @see _.reduceRight - */ - reduceRight( - collection: Array, - callback: MemoIterator, - thisArg?: any): TResult; - - /** - * @see _.reduceRight - */ - reduceRight( - collection: List, - callback: MemoIterator, - thisArg?: any): TResult; - - /** - * @see _.reduceRight - */ - reduceRight( - collection: Dictionary, - callback: MemoIterator, - thisArg?: any): TResult; - } - - // _.reject - interface LoDashStatic { - /** - * The opposite of _.filter; this method returns the elements of collection that predicate does not return - * truthy for. - * - * @param collection The collection to iterate over. - * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. - * @return Returns the new filtered array. - */ - reject( - collection: List, - predicate?: ListIterator, - thisArg?: any - ): T[]; - - /** - * @see _.reject - */ - reject( - collection: Dictionary, - predicate?: DictionaryIterator, - thisArg?: any - ): T[]; - - /** - * @see _.reject - */ - reject( - collection: string, - predicate?: StringIterator, - thisArg?: any - ): string[]; - - /** - * @see _.reject - */ - reject( - collection: List | Dictionary, - predicate: string, - thisArg?: any - ): T[]; - - /** - * @see _.reject - */ - reject( - collection: List | Dictionary, - predicate: W - ): T[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.reject - */ - reject( - predicate?: StringIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.reject - */ - reject( - predicate: ListIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.reject - */ - reject( - predicate: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.reject - */ - reject(predicate: W): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.reject - */ - reject( - predicate: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.reject - */ - reject( - predicate: string, - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.reject - */ - reject(predicate: W): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.reject - */ - reject( - predicate?: StringIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.reject - */ - reject( - predicate: ListIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.reject - */ - reject( - predicate: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.reject - */ - reject(predicate: W): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.reject - */ - reject( - predicate: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.reject - */ - reject( - predicate: string, - thisArg?: any - ): LoDashExplicitArrayWrapper; - - /** - * @see _.reject - */ - reject(predicate: W): LoDashExplicitArrayWrapper; - } - - // _.sample - interface LoDashStatic { - /** - * Gets a random element from `collection`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object} collection The collection to sample. - * @returns {*} Returns the random element. - * @example - * - * _.sample([1, 2, 3, 4]); - * // => 2 - */ - sample(collection: Array): T; - - /** - * @see _.sample - */ - sample(collection: List): T; - - /** - * @see _.sample - */ - sample(collection: Dictionary): T; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.sample - */ - sample(): LoDashImplicitWrapper; - } - - // _.sampleSize - interface LoDashStatic { - /** - * Gets `n` random elements from `collection`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object} collection The collection to sample. - * @param {number} [n=0] The number of elements to sample. - * @returns {Array} Returns the random elements. - * @example - * - * _.sampleSize([1, 2, 3, 4], 2); - * // => [3, 1] - */ - sampleSize(collection: Array, n: number): T[]; - - /** - * @see _.sampleSize - */ - sampleSize(collection: List, n: number): T[]; - - /** - * @see _.sampleSize - */ - sampleSize(collection: Dictionary, n: number): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.sampleSize - */ - sampleSize(n: number): LoDashImplicitArrayWrapper; - - /** - * @see _.sampleSize - */ - sampleSize(): LoDashImplicitWrapper; - } - - // _.shuffle - interface LoDashStatic { - /** - * Creates an array of shuffled values, using a version of the Fisher-Yates shuffle. - * - * @param collection The collection to shuffle. - * @return Returns the new shuffled array. - */ - shuffle(collection: List | Dictionary): T[]; - - /** - * @see _.shuffle - */ - shuffle(collection: string): string[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.shuffle - */ - shuffle(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.shuffle - */ - shuffle(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.shuffle - */ - shuffle(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.shuffle - */ - shuffle(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.shuffle - */ - shuffle(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.shuffle - */ - shuffle(): LoDashExplicitArrayWrapper; - } - - // _.size - interface LoDashStatic { - /** - * Gets the size of collection by returning its length for array-like values or the number of own enumerable - * properties for objects. - * - * @param collection The collection to inspect. - * @return Returns the size of collection. - */ - size(collection: List | Dictionary): number; - - /** - * @see _.size - */ - size(collection: string): number; - } - - interface LoDashImplicitWrapper { - /** - * @see _.size - */ - size(): number; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.size - */ - size(): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.size - */ - size(): number; - } - - interface LoDashExplicitWrapper { - /** - * @see _.size - */ - size(): LoDashExplicitWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.size - */ - size(): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.size - */ - size(): LoDashExplicitWrapper; - } - - // _.some - interface LoDashStatic { - /** - * Checks if predicate returns truthy for any element of collection. Iteration is stopped once predicate - * returns truthy. The predicate is invoked with three arguments: (value, index|key, collection). - * - * @param collection The collection to iterate over. - * @param predicate The function invoked per iteration. - * @return Returns true if any element passes the predicate check, else false. - */ - some( - collection: List, - predicate?: ListIterator - ): boolean; - - /** - * @see _.some - */ - some( - collection: Dictionary, - predicate?: DictionaryIterator - ): boolean; - - /** - * @see _.some - */ - some( - collection: NumericDictionary, - predicate?: NumericDictionaryIterator - ): boolean; - - /** - * @see _.some - */ - some( - collection: List | Dictionary | NumericDictionary, - predicate?: string | any[] - ): boolean; - - /** - * @see _.some - */ - some( - collection: List | Dictionary | NumericDictionary, - predicate?: TObject - ): boolean; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.some - */ - some( - predicate?: ListIterator | NumericDictionaryIterator - ): boolean; - - /** - * @see _.some - */ - some( - predicate?: string | any[] - ): boolean; - - /** - * @see _.some - */ - some( - predicate?: TObject - ): boolean; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.some - */ - some( - predicate?: ListIterator | DictionaryIterator | NumericDictionaryIterator - ): boolean; - - /** - * @see _.some - */ - some( - predicate?: string | any[] - ): boolean; - - /** - * @see _.some - */ - some( - predicate?: TObject - ): boolean; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.some - */ - some( - predicate?: ListIterator | NumericDictionaryIterator - ): LoDashExplicitWrapper; - - /** - * @see _.some - */ - some( - predicate?: string | any[] - ): LoDashExplicitWrapper; - - /** - * @see _.some - */ - some( - predicate?: TObject - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.some - */ - some( - predicate?: ListIterator | DictionaryIterator | NumericDictionaryIterator - ): LoDashExplicitWrapper; - - /** - * @see _.some - */ - some( - predicate?: string | any[] - ): LoDashExplicitWrapper; - - /** - * @see _.some - */ - some( - predicate?: TObject - ): LoDashExplicitWrapper; - } - - // _.sortBy - interface LoDashStatic { - /** - * Creates an array of elements, sorted in ascending order by the results of - * running each element in a collection through each iteratee. This method - * performs a stable sort, that is, it preserves the original sort order of - * equal elements. The iteratees are invoked with one argument: (value). - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {...(Function|Function[]|Object|Object[]|string|string[])} [iteratees=[_.identity]] - * The iteratees to sort by, specified individually or in arrays. - * @returns {Array} Returns the new sorted array. - * @example - * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 42 }, - * { 'user': 'barney', 'age': 34 } - * ]; - * - * _.sortBy(users, function(o) { return o.user; }); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] - * - * _.sortBy(users, ['user', 'age']); - * // => objects for [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] - * - * _.sortBy(users, 'user', function(o) { - * return Math.floor(o.age / 10); - * }); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] - */ - sortBy( - collection: List, - iteratee?: ListIterator - ): T[]; - - /** - * @see _.sortBy - */ - sortBy( - collection: Dictionary, - iteratee?: DictionaryIterator - ): T[]; - - /** - * @see _.sortBy - */ - sortBy( - collection: List | Dictionary, - iteratee: string - ): T[]; - - /** - * @see _.sortBy - */ - sortBy( - collection: List | Dictionary, - whereValue: W - ): T[]; - - /** - * @see _.sortBy - */ - sortBy( - collection: List | Dictionary - ): T[]; - - /** - * @see _.sortBy - */ - sortBy( - collection: (Array | List), - iteratees: (ListIterator | string | Object)[]): T[]; - - /** - * @see _.sortBy - */ - sortBy( - collection: (Array | List), - ...iteratees: (ListIterator | Object | string)[]): T[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.sortBy - */ - sortBy( - iteratee?: ListIterator - ): LoDashImplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(iteratee: string): LoDashImplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(whereValue: W): LoDashImplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(): LoDashImplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(...iteratees: (ListIterator | Object | string)[]): LoDashImplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(iteratees: (ListIterator | string | Object)[]): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.sortBy - */ - sortBy( - iteratee?: ListIterator | DictionaryIterator - ): LoDashImplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(iteratee: string): LoDashImplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(whereValue: W): LoDashImplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.sortBy - */ - sortBy( - iteratee?: ListIterator - ): LoDashExplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(iteratee: string): LoDashExplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(whereValue: W): LoDashExplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.sortBy - */ - sortBy( - iteratee?: ListIterator | DictionaryIterator - ): LoDashExplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(iteratee: string): LoDashExplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(whereValue: W): LoDashExplicitArrayWrapper; - - /** - * @see _.sortBy - */ - sortBy(): LoDashExplicitArrayWrapper; - } - - // _.orderBy - interface LoDashStatic { - /** - * This method is like `_.sortBy` except that it allows specifying the sort - * orders of the iteratees to sort by. If `orders` is unspecified, all values - * are sorted in ascending order. Otherwise, specify an order of "desc" for - * descending or "asc" for ascending sort order of corresponding values. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function[]|Object[]|string[]} [iteratees=[_.identity]] The iteratees to sort by. - * @param {string[]} [orders] The sort orders of `iteratees`. - * @param- {Object} [guard] Enables use as an iteratee for functions like `_.reduce`. - * @returns {Array} Returns the new sorted array. - * @example - * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 34 }, - * { 'user': 'fred', 'age': 42 }, - * { 'user': 'barney', 'age': 36 } - * ]; - * - * // sort by `user` in ascending order and by `age` in descending order - * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] - */ - orderBy( - collection: List, - iteratees: ListIterator | string | W | (ListIterator | string | W)[], - orders?: boolean | string | (boolean | string)[] - ): T[]; - - /** - * @see _.orderBy - */ - orderBy( - collection: List, - iteratees: ListIterator | string | Object | (ListIterator | string | Object)[], - orders?: boolean | string | (boolean | string)[] - ): T[]; - - /** - * @see _.orderBy - */ - orderBy( - collection: NumericDictionary, - iteratees: NumericDictionaryIterator | string | W | (NumericDictionaryIterator | string | W)[], - orders?: boolean | string | (boolean | string)[] - ): T[]; - - /** - * @see _.orderBy - */ - orderBy( - collection: NumericDictionary, - iteratees: NumericDictionaryIterator | string | Object | (NumericDictionaryIterator | string | Object)[], - orders?: boolean | string | (boolean | string)[] - ): T[]; - - /** - * @see _.orderBy - */ - orderBy( - collection: Dictionary, - iteratees: DictionaryIterator | string | W | (DictionaryIterator | string | W)[], - orders?: boolean | string | (boolean | string)[] - ): T[]; - - /** - * @see _.orderBy - */ - orderBy( - collection: Dictionary, - iteratees: DictionaryIterator | string | Object | (DictionaryIterator | string | Object)[], - orders?: boolean | string | (boolean | string)[] - ): T[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.orderBy - */ - orderBy( - iteratees: ListIterator | string | (ListIterator | string)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.orderBy - */ - orderBy( - iteratees: ListIterator | string | W | (ListIterator | string | W)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.orderBy - */ - orderBy( - iteratees: ListIterator | string | W | (ListIterator | string | W)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashImplicitArrayWrapper; - - /** - * @see _.orderBy - */ - orderBy( - iteratees: ListIterator | string | Object | (ListIterator | string | Object)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashImplicitArrayWrapper; - - /** - * @see _.orderBy - */ - orderBy( - iteratees: NumericDictionaryIterator | string | W | (NumericDictionaryIterator | string | W)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashImplicitArrayWrapper; - - /** - * @see _.orderBy - */ - orderBy( - iteratees: NumericDictionaryIterator | string | Object | (NumericDictionaryIterator | string | Object)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashImplicitArrayWrapper; - - /** - * @see _.orderBy - */ - orderBy( - iteratees: DictionaryIterator | string | W | (DictionaryIterator | string | W)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashImplicitArrayWrapper; - - /** - * @see _.orderBy - */ - orderBy( - iteratees: DictionaryIterator | string | Object | (DictionaryIterator | string | Object)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.orderBy - */ - orderBy( - iteratees: ListIterator | string | (ListIterator | string)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.orderBy - */ - orderBy( - iteratees: ListIterator | string | W | (ListIterator | string | W)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.orderBy - */ - orderBy( - iteratees: ListIterator | string | W | (ListIterator | string | W)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashExplicitArrayWrapper; - - /** - * @see _.orderBy - */ - orderBy( - iteratees: ListIterator | string | Object | (ListIterator | string | Object)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashExplicitArrayWrapper; - - /** - * @see _.orderBy - */ - orderBy( - iteratees: NumericDictionaryIterator | string | W | (NumericDictionaryIterator | string | W)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashExplicitArrayWrapper; - - /** - * @see _.orderBy - */ - orderBy( - iteratees: NumericDictionaryIterator | string | Object | (NumericDictionaryIterator | string | Object)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashExplicitArrayWrapper; - - /** - * @see _.orderBy - */ - orderBy( - iteratees: DictionaryIterator | string | W | (DictionaryIterator | string | W)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashExplicitArrayWrapper; - - /** - * @see _.orderBy - */ - orderBy( - iteratees: DictionaryIterator | string | Object | (DictionaryIterator | string | Object)[], - orders?: boolean | string | (boolean | string)[] - ): LoDashExplicitArrayWrapper; - } - - /******** - * Date * - *******/ - - // _.now - interface LoDashStatic { - /** - * Gets the number of milliseconds that have elapsed since the Unix epoch (1 January 1970 00:00:00 UTC). - * - * @return The number of milliseconds. - */ - now(): number; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.now - */ - now(): number; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.now - */ - now(): LoDashExplicitWrapper; - } - - /************* - * Functions * - ************/ - - // _.after - interface LoDashStatic { - /** - * The opposite of _.before; this method creates a function that invokes func once it’s called n or more times. - * - * @param n The number of calls before func is invoked. - * @param func The function to restrict. - * @return Returns the new restricted function. - */ - after( - n: number, - func: TFunc - ): TFunc; - } - - interface LoDashImplicitWrapper { - /** - * @see _.after - */ - after(func: TFunc): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.after - */ - after(func: TFunc): LoDashExplicitObjectWrapper; - } - - // _.ary - interface LoDashStatic { - /** - * Creates a function that accepts up to n arguments ignoring any additional arguments. - * - * @param func The function to cap arguments for. - * @param n The arity cap. - * @returns Returns the new function. - */ - ary( - func: Function, - n?: number - ): TResult; - - ary( - func: T, - n?: number - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.ary - */ - ary(n?: number): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.ary - */ - ary(n?: number): LoDashExplicitObjectWrapper; - } - - // _.before - interface LoDashStatic { - /** - * Creates a function that invokes func, with the this binding and arguments of the created function, while - * it’s called less than n times. Subsequent calls to the created function return the result of the last func - * invocation. - * - * @param n The number of calls at which func is no longer invoked. - * @param func The function to restrict. - * @return Returns the new restricted function. - */ - before( - n: number, - func: TFunc - ): TFunc; - } - - interface LoDashImplicitWrapper { - /** - * @see _.before - */ - before(func: TFunc): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.before - */ - before(func: TFunc): LoDashExplicitObjectWrapper; - } - - // _.bind - interface FunctionBind { - placeholder: any; - - ( - func: T, - thisArg: any, - ...partials: any[] - ): TResult; - - ( - func: Function, - thisArg: any, - ...partials: any[] - ): TResult; - } - - interface LoDashStatic { - /** - * Creates a function that invokes func with the this binding of thisArg and prepends any additional _.bind - * arguments to those provided to the bound function. - * - * The _.bind.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for - * partially applied arguments. - * - * Note: Unlike native Function#bind this method does not set the "length" property of bound functions. - * - * @param func The function to bind. - * @param thisArg The this binding of func. - * @param partials The arguments to be partially applied. - * @return Returns the new bound function. - */ - bind: FunctionBind; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.bind - */ - bind( - thisArg: any, - ...partials: any[] - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.bind - */ - bind( - thisArg: any, - ...partials: any[] - ): LoDashExplicitObjectWrapper; - } - - // _.bindAll - interface LoDashStatic { - /** - * Binds methods of an object to the object itself, overwriting the existing method. Method names may be - * specified as individual arguments or as arrays of method names. If no method names are provided all - * enumerable function properties, own and inherited, of object are bound. - * - * Note: This method does not set the "length" property of bound functions. - * - * @param object The object to bind and assign the bound methods to. - * @param methodNames The object method names to bind, specified as individual method names or arrays of - * method names. - * @return Returns object. - */ - bindAll( - object: T, - ...methodNames: (string | string[])[] - ): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.bindAll - */ - bindAll(...methodNames: (string | string[])[]): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.bindAll - */ - bindAll(...methodNames: (string | string[])[]): LoDashExplicitObjectWrapper; - } - - // _.bindKey - interface FunctionBindKey { - placeholder: any; - - ( - object: T, - key: any, - ...partials: any[] - ): TResult; - - ( - object: Object, - key: any, - ...partials: any[] - ): TResult; - } - - interface LoDashStatic { - /** - * Creates a function that invokes the method at object[key] and prepends any additional _.bindKey arguments - * to those provided to the bound function. - * - * This method differs from _.bind by allowing bound functions to reference methods that may be redefined - * or don’t yet exist. See Peter Michaux’s article for more details. - * - * The _.bindKey.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder - * for partially applied arguments. - * - * @param object The object the method belongs to. - * @param key The key of the method. - * @param partials The arguments to be partially applied. - * @return Returns the new bound function. - */ - bindKey: FunctionBindKey; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.bindKey - */ - bindKey( - key: any, - ...partials: any[] - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.bindKey - */ - bindKey( - key: any, - ...partials: any[] - ): LoDashExplicitObjectWrapper; - } - - // _.createCallback - interface LoDashStatic { - /** - * Produces a callback bound to an optional thisArg. If func is a property name the created - * callback will return the property value for a given element. If func is an object the created - * callback will return true for elements that contain the equivalent object properties, - * otherwise it will return false. - * @param func The value to convert to a callback. - * @param thisArg The this binding of the created callback. - * @param argCount The number of arguments the callback accepts. - * @return A callback function. - */ - createCallback( - func: string, - thisArg?: any, - argCount?: number): () => any; - - /** - * @see _.createCallback - */ - createCallback( - func: Dictionary, - thisArg?: any, - argCount?: number): () => boolean; - } - - interface LoDashImplicitWrapper { - /** - * @see _.createCallback - */ - createCallback( - thisArg?: any, - argCount?: number): LoDashImplicitObjectWrapper<() => any>; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.createCallback - */ - createCallback( - thisArg?: any, - argCount?: number): LoDashImplicitObjectWrapper<() => any>; - } - - // _.curry - interface LoDashStatic { - /** - * Creates a function that accepts one or more arguments of func that when called either invokes func returning - * its result, if all func arguments have been provided, or returns a function that accepts one or more of the - * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. - * @param func The function to curry. - * @return Returns the new curried function. - */ - curry(func: (t1: T1) => R): - CurriedFunction1; - /** - * Creates a function that accepts one or more arguments of func that when called either invokes func returning - * its result, if all func arguments have been provided, or returns a function that accepts one or more of the - * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. - * @param func The function to curry. - * @return Returns the new curried function. - */ - curry(func: (t1: T1, t2: T2) => R): - CurriedFunction2; - /** - * Creates a function that accepts one or more arguments of func that when called either invokes func returning - * its result, if all func arguments have been provided, or returns a function that accepts one or more of the - * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. - * @param func The function to curry. - * @return Returns the new curried function. - */ - curry(func: (t1: T1, t2: T2, t3: T3) => R): - CurriedFunction3; - /** - * Creates a function that accepts one or more arguments of func that when called either invokes func returning - * its result, if all func arguments have been provided, or returns a function that accepts one or more of the - * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. - * @param func The function to curry. - * @return Returns the new curried function. - */ - curry(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R): - CurriedFunction4; - /** - * Creates a function that accepts one or more arguments of func that when called either invokes func returning - * its result, if all func arguments have been provided, or returns a function that accepts one or more of the - * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. - * @param func The function to curry. - * @return Returns the new curried function. - */ - curry(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R): - CurriedFunction5; - /** - * Creates a function that accepts one or more arguments of func that when called either invokes func returning - * its result, if all func arguments have been provided, or returns a function that accepts one or more of the - * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. - * @param func The function to curry. - * @param arity The arity of func. - * @return Returns the new curried function. - */ - curry( - func: Function, - arity?: number): TResult; - } - - interface CurriedFunction1 { - (): CurriedFunction1; - (t1: T1): R; - } - - interface CurriedFunction2 { - (): CurriedFunction2; - (t1: T1): CurriedFunction1; - (t1: T1, t2: T2): R; - } - - interface CurriedFunction3 { - (): CurriedFunction3; - (t1: T1): CurriedFunction2; - (t1: T1, t2: T2): CurriedFunction1; - (t1: T1, t2: T2, t3: T3): R; - } - - interface CurriedFunction4 { - (): CurriedFunction4; - (t1: T1): CurriedFunction3; - (t1: T1, t2: T2): CurriedFunction2; - (t1: T1, t2: T2, t3: T3): CurriedFunction1; - (t1: T1, t2: T2, t3: T3, t4: T4): R; - } - - interface CurriedFunction5 { - (): CurriedFunction5; - (t1: T1): CurriedFunction4; - (t1: T1, t2: T2): CurriedFunction3; - (t1: T1, t2: T2, t3: T3): CurriedFunction2; - (t1: T1, t2: T2, t3: T3, t4: T4): CurriedFunction1; - (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): R; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.curry - */ - curry(arity?: number): LoDashImplicitObjectWrapper; - } - - // _.curryRight - interface LoDashStatic { - /** - * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight - * instead of _.partial. - * @param func The function to curry. - * @return Returns the new curried function. - */ - curryRight(func: (t1: T1) => R): - CurriedFunction1; - /** - * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight - * instead of _.partial. - * @param func The function to curry. - * @return Returns the new curried function. - */ - curryRight(func: (t1: T1, t2: T2) => R): - CurriedFunction2; - /** - * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight - * instead of _.partial. - * @param func The function to curry. - * @return Returns the new curried function. - */ - curryRight(func: (t1: T1, t2: T2, t3: T3) => R): - CurriedFunction3; - /** - * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight - * instead of _.partial. - * @param func The function to curry. - * @return Returns the new curried function. - */ - curryRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R): - CurriedFunction4; - /** - * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight - * instead of _.partial. - * @param func The function to curry. - * @return Returns the new curried function. - */ - curryRight(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R): - CurriedFunction5; - /** - * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight - * instead of _.partial. - * @param func The function to curry. - * @param arity The arity of func. - * @return Returns the new curried function. - */ - curryRight( - func: Function, - arity?: number): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.curryRight - */ - curryRight(arity?: number): LoDashImplicitObjectWrapper; - } - - // _.debounce - interface DebounceSettings { - /** - * Specify invoking on the leading edge of the timeout. - */ - leading?: boolean; - - /** - * The maximum time func is allowed to be delayed before it’s invoked. - */ - maxWait?: number; - - /** - * Specify invoking on the trailing edge of the timeout. - */ - trailing?: boolean; - } - - interface LoDashStatic { - /** - * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since - * the last time the debounced function was invoked. The debounced function comes with a cancel method to - * cancel delayed invocations. Provide an options object to indicate that func should be invoked on the - * leading and/or trailing edge of the wait timeout. Subsequent calls to the debounced function return the - * result of the last func invocation. - * - * Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only - * if the the debounced function is invoked more than once during the wait timeout. - * - * See David Corbacho’s article for details over the differences between _.debounce and _.throttle. - * - * @param func The function to debounce. - * @param wait The number of milliseconds to delay. - * @param options The options object. - * @param options.leading Specify invoking on the leading edge of the timeout. - * @param options.maxWait The maximum time func is allowed to be delayed before it’s invoked. - * @param options.trailing Specify invoking on the trailing edge of the timeout. - * @return Returns the new debounced function. - */ - debounce( - func: T, - wait?: number, - options?: DebounceSettings - ): T & Cancelable; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.debounce - */ - debounce( - wait?: number, - options?: DebounceSettings - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.debounce - */ - debounce( - wait?: number, - options?: DebounceSettings - ): LoDashExplicitObjectWrapper; - } - - // _.defer - interface LoDashStatic { - /** - * Defers invoking the func until the current call stack has cleared. Any additional arguments are provided to - * func when it’s invoked. - * - * @param func The function to defer. - * @param args The arguments to invoke the function with. - * @return Returns the timer id. - */ - defer( - func: T, - ...args: any[] - ): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.defer - */ - defer(...args: any[]): LoDashImplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.defer - */ - defer(...args: any[]): LoDashExplicitWrapper; - } - - // _.delay - interface LoDashStatic { - /** - * Invokes func after wait milliseconds. Any additional arguments are provided to func when it’s invoked. - * - * @param func The function to delay. - * @param wait The number of milliseconds to delay invocation. - * @param args The arguments to invoke the function with. - * @return Returns the timer id. - */ - delay( - func: T, - wait: number, - ...args: any[] - ): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.delay - */ - delay( - wait: number, - ...args: any[] - ): LoDashImplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.delay - */ - delay( - wait: number, - ...args: any[] - ): LoDashExplicitWrapper; - } - - interface LoDashStatic { - /** - * Creates a function that invokes `func` with arguments reversed. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to flip arguments for. - * @returns {Function} Returns the new function. - * @example - * - * var flipped = _.flip(function() { - * return _.toArray(arguments); - * }); - * - * flipped('a', 'b', 'c', 'd'); - * // => ['d', 'c', 'b', 'a'] - */ - flip(func: T): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.flip - */ - flip(): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.flip - */ - flip(): LoDashExplicitObjectWrapper; - } - - // _.flow - interface LoDashStatic { - /** - * Creates a function that returns the result of invoking the provided functions with the this binding of the - * created function, where each successive invocation is supplied the return value of the previous. - * - * @param funcs Functions to invoke. - * @return Returns the new function. - */ - flow(...funcs: Function[]): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.flow - */ - flow(...funcs: Function[]): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.flow - */ - flow(...funcs: Function[]): LoDashExplicitObjectWrapper; - } - - // _.flowRight - interface LoDashStatic { - /** - * This method is like _.flow except that it creates a function that invokes the provided functions from right - * to left. - * - * @param funcs Functions to invoke. - * @return Returns the new function. - */ - flowRight(...funcs: Function[]): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.flowRight - */ - flowRight(...funcs: Function[]): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.flowRight - */ - flowRight(...funcs: Function[]): LoDashExplicitObjectWrapper; - } - - - // _.memoize - interface MemoizedFunction extends Function { - cache: MapCache; - } - - interface LoDashStatic { - /** - * Creates a function that memoizes the result of func. If resolver is provided it determines the cache key for - * storing the result based on the arguments provided to the memoized function. By default, the first argument - * provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with - * the this binding of the memoized function. - * @param func The function to have its output memoized. - * @param resolver The function to resolve the cache key. - * @return Returns the new memoizing function. - */ - memoize: { - (func: T, resolver?: Function): T & MemoizedFunction; - Cache: MapCache; - }; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.memoize - */ - memoize(resolver?: Function): LoDashImplicitObjectWrapper; - } - - // _.overArgs (was _.modArgs) - interface LoDashStatic { - /** - * Creates a function that runs each argument through a corresponding transform function. - * - * @param func The function to wrap. - * @param transforms The functions to transform arguments, specified as individual functions or arrays - * of functions. - * @return Returns the new function. - */ - overArgs( - func: T, - ...transforms: Function[] - ): TResult; - - /** - * @see _.overArgs - */ - overArgs( - func: T, - transforms: Function[] - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.overArgs - */ - overArgs(...transforms: Function[]): LoDashImplicitObjectWrapper; - - /** - * @see _.overArgs - */ - overArgs(transforms: Function[]): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.overArgs - */ - overArgs(...transforms: Function[]): LoDashExplicitObjectWrapper; - - /** - * @see _.overArgs - */ - overArgs(transforms: Function[]): LoDashExplicitObjectWrapper; - } - - // _.negate - interface LoDashStatic { - /** - * Creates a function that negates the result of the predicate func. The func predicate is invoked with - * the this binding and arguments of the created function. - * - * @param predicate The predicate to negate. - * @return Returns the new function. - */ - negate(predicate: T): (...args: any[]) => boolean; - - /** - * @see _.negate - */ - negate(predicate: T): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.negate - */ - negate(): LoDashImplicitObjectWrapper<(...args: any[]) => boolean>; - - /** - * @see _.negate - */ - negate(): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.negate - */ - negate(): LoDashExplicitObjectWrapper<(...args: any[]) => boolean>; - - /** - * @see _.negate - */ - negate(): LoDashExplicitObjectWrapper; - } - - // _.once - interface LoDashStatic { - /** - * Creates a function that is restricted to invoking func once. Repeat calls to the function return the value - * of the first call. The func is invoked with the this binding and arguments of the created function. - * - * @param func The function to restrict. - * @return Returns the new restricted function. - */ - once(func: T): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.once - */ - once(): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.once - */ - once(): LoDashExplicitObjectWrapper; - } - - // _.partial - interface LoDashStatic { - /** - * Creates a function that, when called, invokes func with any additional partial arguments - * prepended to those provided to the new function. This method is similar to _.bind except - * it does not alter the this binding. - * @param func The function to partially apply arguments to. - * @param args Arguments to be partially applied. - * @return The new partially applied function. - */ - partial: Partial; - } - - type PH = LoDashStatic; - - interface Function0 { - (): R; - } - interface Function1 { - (t1: T1): R; - } - interface Function2 { - (t1: T1, t2: T2): R; - } - interface Function3 { - (t1: T1, t2: T2, t3: T3): R; - } - interface Function4 { - (t1: T1, t2: T2, t3: T3, t4: T4): R; - } - - interface Partial { - // arity 0 - (func: Function0): Function0; - // arity 1 - (func: Function1): Function1; - (func: Function1, arg1: T1): Function0; - // arity 2 - (func: Function2): Function2; - (func: Function2, arg1: T1): Function1; - (func: Function2, plc1: PH, arg2: T2): Function1; - (func: Function2, arg1: T1, arg2: T2): Function0; - // arity 3 - (func: Function3): Function3; - (func: Function3, arg1: T1): Function2; - (func: Function3, plc1: PH, arg2: T2): Function2; - (func: Function3, arg1: T1, arg2: T2): Function1; - (func: Function3, plc1: PH, plc2: PH, arg3: T3): Function2; - (func: Function3, arg1: T1, plc2: PH, arg3: T3): Function1; - (func: Function3, plc1: PH, arg2: T2, arg3: T3): Function1; - (func: Function3, arg1: T1, arg2: T2, arg3: T3): Function0; - // arity 4 - (func: Function4): Function4; - (func: Function4, arg1: T1): Function3; - (func: Function4, plc1: PH, arg2: T2): Function3; - (func: Function4, arg1: T1, arg2: T2): Function2; - (func: Function4, plc1: PH, plc2: PH, arg3: T3): Function3; - (func: Function4, arg1: T1, plc2: PH, arg3: T3): Function2; - (func: Function4, plc1: PH, arg2: T2, arg3: T3): Function2; - (func: Function4, arg1: T1, arg2: T2, arg3: T3): Function1; - (func: Function4, plc1: PH, plc2: PH, plc3: PH, arg4: T4): Function3; - (func: Function4, arg1: T1, plc2: PH, plc3: PH, arg4: T4): Function2; - (func: Function4, plc1: PH, arg2: T2, plc3: PH, arg4: T4): Function2; - (func: Function4, arg1: T1, arg2: T2, plc3: PH, arg4: T4): Function1; - (func: Function4, plc1: PH, plc2: PH, arg3: T3, arg4: T4): Function2; - (func: Function4, arg1: T1, plc2: PH, arg3: T3, arg4: T4): Function1; - (func: Function4, plc1: PH, arg2: T2, arg3: T3, arg4: T4): Function1; - (func: Function4, arg1: T1, arg2: T2, arg3: T3, arg4: T4): Function0; - // catch-all - (func: Function, ...args: any[]): Function; - } - - // _.partialRight - interface LoDashStatic { - /** - * This method is like _.partial except that partial arguments are appended to those provided - * to the new function. - * @param func The function to partially apply arguments to. - * @param args Arguments to be partially applied. - * @return The new partially applied function. - */ - partialRight: PartialRight; - } - - interface PartialRight { - // arity 0 - (func: Function0): Function0; - // arity 1 - (func: Function1): Function1; - (func: Function1, arg1: T1): Function0; - // arity 2 - (func: Function2): Function2; - (func: Function2, arg1: T1, plc2: PH): Function1; - (func: Function2, arg2: T2): Function1; - (func: Function2, arg1: T1, arg2: T2): Function0; - // arity 3 - (func: Function3): Function3; - (func: Function3, arg1: T1, plc2: PH, plc3: PH): Function2; - (func: Function3, arg2: T2, plc3: PH): Function2; - (func: Function3, arg1: T1, arg2: T2, plc3: PH): Function1; - (func: Function3, arg3: T3): Function2; - (func: Function3, arg1: T1, plc2: PH, arg3: T3): Function1; - (func: Function3, arg2: T2, arg3: T3): Function1; - (func: Function3, arg1: T1, arg2: T2, arg3: T3): Function0; - // arity 4 - (func: Function4): Function4; - (func: Function4, arg1: T1, plc2: PH, plc3: PH, plc4: PH): Function3; - (func: Function4, arg2: T2, plc3: PH, plc4: PH): Function3; - (func: Function4, arg1: T1, arg2: T2, plc3: PH, plc4: PH): Function2; - (func: Function4, arg3: T3, plc4: PH): Function3; - (func: Function4, arg1: T1, plc2: PH, arg3: T3, plc4: PH): Function2; - (func: Function4, arg2: T2, arg3: T3, plc4: PH): Function2; - (func: Function4, arg1: T1, arg2: T2, arg3: T3, plc4: PH): Function1; - (func: Function4, arg4: T4): Function3; - (func: Function4, arg1: T1, plc2: PH, plc3: PH, arg4: T4): Function2; - (func: Function4, arg2: T2, plc3: PH, arg4: T4): Function2; - (func: Function4, arg1: T1, arg2: T2, plc3: PH, arg4: T4): Function1; - (func: Function4, arg3: T3, arg4: T4): Function2; - (func: Function4, arg1: T1, plc2: PH, arg3: T3, arg4: T4): Function1; - (func: Function4, arg2: T2, arg3: T3, arg4: T4): Function1; - (func: Function4, arg1: T1, arg2: T2, arg3: T3, arg4: T4): Function0; - // catch-all - (func: Function, ...args: any[]): Function; - } - - // _.rearg - interface LoDashStatic { - /** - * Creates a function that invokes func with arguments arranged according to the specified indexes where the - * argument value at the first index is provided as the first argument, the argument value at the second index - * is provided as the second argument, and so on. - * @param func The function to rearrange arguments for. - * @param indexes The arranged argument indexes, specified as individual indexes or arrays of indexes. - * @return Returns the new function. - */ - rearg(func: Function, indexes: number[]): TResult; - - /** - * @see _.rearg - */ - rearg(func: Function, ...indexes: number[]): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.rearg - */ - rearg(indexes: number[]): LoDashImplicitObjectWrapper; - - /** - * @see _.rearg - */ - rearg(...indexes: number[]): LoDashImplicitObjectWrapper; - } - - // _.rest - interface LoDashStatic { - /** - * Creates a function that invokes func with the this binding of the created function and arguments from start - * and beyond provided as an array. - * - * Note: This method is based on the rest parameter. - * - * @param func The function to apply a rest parameter to. - * @param start The start position of the rest parameter. - * @return Returns the new function. - */ - rest( - func: Function, - start?: number - ): TResult; - - /** - * @see _.rest - */ - rest( - func: TFunc, - start?: number - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.rest - */ - rest(start?: number): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.rest - */ - rest(start?: number): LoDashExplicitObjectWrapper; - } - - // _.spread - interface LoDashStatic { - /** - * Creates a function that invokes func with the this binding of the created function and an array of arguments - * much like Function#apply. - * - * Note: This method is based on the spread operator. - * - * @param func The function to spread arguments over. - * @return Returns the new function. - */ - spread(func: F): T; - - /** - * @see _.spread - */ - spread(func: Function): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.spread - */ - spread(): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.spread - */ - spread(): LoDashExplicitObjectWrapper; - } - - // _.throttle - interface ThrottleSettings { - /** - * If you'd like to disable the leading-edge call, pass this as false. - */ - leading?: boolean; - - /** - * If you'd like to disable the execution on the trailing-edge, pass false. - */ - trailing?: boolean; - } - - interface LoDashStatic { - /** - * Creates a throttled function that only invokes func at most once per every wait milliseconds. The throttled - * function comes with a cancel method to cancel delayed invocations. Provide an options object to indicate - * that func should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls to - * the throttled function return the result of the last func call. - * - * Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only if - * the the throttled function is invoked more than once during the wait timeout. - * - * @param func The function to throttle. - * @param wait The number of milliseconds to throttle invocations to. - * @param options The options object. - * @param options.leading Specify invoking on the leading edge of the timeout. - * @param options.trailing Specify invoking on the trailing edge of the timeout. - * @return Returns the new throttled function. - */ - throttle( - func: T, - wait?: number, - options?: ThrottleSettings - ): T & Cancelable; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.throttle - */ - throttle( - wait?: number, - options?: ThrottleSettings - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.throttle - */ - throttle( - wait?: number, - options?: ThrottleSettings - ): LoDashExplicitObjectWrapper; - } - - // _.unary - interface LoDashStatic { - /** - * Creates a function that accepts up to one argument, ignoring any - * additional arguments. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to cap arguments for. - * @returns {Function} Returns the new function. - * @example - * - * _.map(['6', '8', '10'], _.unary(parseInt)); - * // => [6, 8, 10] - */ - unary(func: T): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.unary - */ - unary(): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.unary - */ - unary(): LoDashExplicitObjectWrapper; - } - - // _.wrap - interface LoDashStatic { - /** - * Creates a function that provides value to the wrapper function as its first argument. Any additional - * arguments provided to the function are appended to those provided to the wrapper function. The wrapper is - * invoked with the this binding of the created function. - * - * @param value The value to wrap. - * @param wrapper The wrapper function. - * @return Returns the new function. - */ - wrap( - value: V, - wrapper: W - ): R; - - /** - * @see _.wrap - */ - wrap( - value: V, - wrapper: Function - ): R; - - /** - * @see _.wrap - */ - wrap( - value: any, - wrapper: Function - ): R; - } - - interface LoDashImplicitWrapper { - /** - * @see _.wrap - */ - wrap(wrapper: W): LoDashImplicitObjectWrapper; - - /** - * @see _.wrap - */ - wrap(wrapper: Function): LoDashImplicitObjectWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.wrap - */ - wrap(wrapper: W): LoDashImplicitObjectWrapper; - - /** - * @see _.wrap - */ - wrap(wrapper: Function): LoDashImplicitObjectWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.wrap - */ - wrap(wrapper: W): LoDashImplicitObjectWrapper; - - /** - * @see _.wrap - */ - wrap(wrapper: Function): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.wrap - */ - wrap(wrapper: W): LoDashExplicitObjectWrapper; - - /** - * @see _.wrap - */ - wrap(wrapper: Function): LoDashExplicitObjectWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.wrap - */ - wrap(wrapper: W): LoDashExplicitObjectWrapper; - - /** - * @see _.wrap - */ - wrap(wrapper: Function): LoDashExplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.wrap - */ - wrap(wrapper: W): LoDashExplicitObjectWrapper; - - /** - * @see _.wrap - */ - wrap(wrapper: Function): LoDashExplicitObjectWrapper; - } - - /******** - * Lang * - *******/ - - // _.castArray - interface LoDashStatic { - /** - * Casts value as an array if it’s not one. - * - * @param value The value to inspect. - * @return Returns the cast array. - */ - castArray(value: T): T[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.castArray - */ - castArray(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.castArray - */ - castArray(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.castArray - */ - castArray(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.castArray - */ - castArray(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.castArray - */ - castArray(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.castArray - */ - castArray(): LoDashExplicitArrayWrapper; - } - - // _.clone - interface LoDashStatic { - /** - * Creates a shallow clone of `value`. - * - * **Note:** This method is loosely based on the - * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) - * and supports cloning arrays, array buffers, booleans, date objects, maps, - * numbers, `Object` objects, regexes, sets, strings, symbols, and typed - * arrays. The own enumerable properties of `arguments` objects are cloned - * as plain objects. An empty object is returned for uncloneable values such - * as error objects, functions, DOM nodes, and WeakMaps. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to clone. - * @returns {*} Returns the cloned value. - * @example - * - * var objects = [{ 'a': 1 }, { 'b': 2 }]; - * - * var shallow = _.clone(objects); - * console.log(shallow[0] === objects[0]); - * // => true - */ - clone(value: T): T; - } - - interface LoDashImplicitWrapper { - /** - * @see _.clone - */ - clone(): T; - } - - interface LoDashImplicitArrayWrapper { - - /** - * @see _.clone - */ - clone(): T[]; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.clone - */ - clone(): T; - } - - // _.cloneDeep - interface LoDashStatic { - /** - * This method is like `_.clone` except that it recursively clones `value`. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to recursively clone. - * @returns {*} Returns the deep cloned value. - * @example - * - * var objects = [{ 'a': 1 }, { 'b': 2 }]; - * - * var deep = _.cloneDeep(objects); - * console.log(deep[0] === objects[0]); - * // => false - */ - cloneDeep(value: T): T; - } - - interface LoDashImplicitWrapper { - /** - * @see _.cloneDeep - */ - cloneDeep(): T; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.cloneDeep - */ - cloneDeep(): T[]; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.cloneDeep - */ - cloneDeep(): T; - } - - // _.cloneWith - interface LoDashStatic { - /** - * Creates a shallow clone of `value`. - * - * **Note:** This method is loosely based on the - * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) - * and supports cloning arrays, array buffers, booleans, date objects, maps, - * numbers, `Object` objects, regexes, sets, strings, symbols, and typed - * arrays. The own enumerable properties of `arguments` objects are cloned - * as plain objects. An empty object is returned for uncloneable values such - * as error objects, functions, DOM nodes, and WeakMaps. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to clone. - * @returns {*} Returns the cloned value. - * @example - * - * var objects = [{ 'a': 1 }, { 'b': 2 }]; - * - * var shallow = _.clone(objects); - * console.log(shallow[0] === objects[0]); - * // => true - */ - cloneWith( - value: T, - customizer: (value: any) => any): T; - } - - interface LoDashImplicitWrapper { - /** - * @see _.clone - */ - cloneWith(customizer: (value: any) => any): T; - } - - interface LoDashImplicitArrayWrapper { - - /** - * @see _.clone - */ - cloneWith(customizer: (value: any) => any): T[]; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.clone - */ - cloneWith(customizer: (value: any) => any): T; - } - - // _.cloneDeepWith - interface LoDashStatic { - /** - * Creates a deep clone of value. If customizer is provided it’s invoked to produce the cloned values. If - * customizer returns undefined cloning is handled by the method instead. The customizer is bound to thisArg - * and invoked with up to three argument; (value [, index|key, object]). - * Note: This method is loosely based on the structured clone algorithm. The enumerable properties of arguments - * objects and objects created by constructors other than Object are cloned to plain Object objects. An empty - * object is returned for uncloneable values such as functions, DOM nodes, Maps, Sets, and WeakMaps. - * @param value The value to deep clone. - * @param customizer The function to customize cloning values. - * @param thisArg The this binding of customizer. - * @return Returns the deep cloned value. - */ - cloneDeepWith( - value: T, - customizer: (value: any) => any): T; - } - - interface LoDashImplicitWrapper { - /** - * @see _.cloneDeep - */ - cloneDeepWith(customizer: (value: any) => any): T; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.cloneDeep - */ - cloneDeepWith(customizer: (value: any) => any): T[]; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.cloneDeep - */ - cloneDeepWith(customizer: (value: any) => any): T; - } - - // _.eq - interface LoDashStatic { - /** - * Performs a [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'user': 'fred' }; - * var other = { 'user': 'fred' }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false - * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false - * - * _.eq(NaN, NaN); - * // => true - */ - eq( - value: any, - other: any - ): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isEqual - */ - eq( - other: any - ): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isEqual - */ - eq( - other: any - ): LoDashExplicitWrapper; - } - - // _.gt - interface LoDashStatic { - /** - * Checks if value is greater than other. - * - * @param value The value to compare. - * @param other The other value to compare. - * @return Returns true if value is greater than other, else false. - */ - gt( - value: any, - other: any - ): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.gt - */ - gt(other: any): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.gt - */ - gt(other: any): LoDashExplicitWrapper; - } - - // _.gte - interface LoDashStatic { - /** - * Checks if value is greater than or equal to other. - * - * @param value The value to compare. - * @param other The other value to compare. - * @return Returns true if value is greater than or equal to other, else false. - */ - gte( - value: any, - other: any - ): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.gte - */ - gte(other: any): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.gte - */ - gte(other: any): LoDashExplicitWrapper; - } - - // _.isArguments - interface LoDashStatic { - /** - * Checks if value is classified as an arguments object. - * - * @param value The value to check. - * @return Returns true if value is correctly classified, else false. - */ - isArguments(value?: any): value is IArguments; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isArguments - */ - isArguments(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isArguments - */ - isArguments(): LoDashExplicitWrapper; - } - - // _.isArray - interface LoDashStatic { - /** - * Checks if value is classified as an Array object. - * @param value The value to check. - * - * @return Returns true if value is correctly classified, else false. - */ - isArray(value?: any): value is T[]; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isArray - */ - isArray(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isArray - */ - isArray(): LoDashExplicitWrapper; - } - - // _.isArrayBuffer - interface LoDashStatic { - /** - * Checks if value is classified as an ArrayBuffer object. - * - * @param value The value to check. - * @return Returns true if value is correctly classified, else false. - */ - isArrayBuffer(value?: any): value is ArrayBuffer; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isArrayBuffer - */ - isArrayBuffer(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isArrayBuffer - */ - isArrayBuffer(): LoDashExplicitWrapper; - } - - // _.isArrayLike - interface LoDashStatic { - /** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @type Function - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true - * - * _.isArrayLike(_.noop); - * // => false - */ - isArrayLike(value?: any): value is T[]; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isArrayLike - */ - isArrayLike(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isArrayLike - */ - isArrayLike(): LoDashExplicitWrapper; - } - - // _.isArrayLikeObject - interface LoDashStatic { - /** - * This method is like `_.isArrayLike` except that it also checks if `value` - * is an object. - * - * @static - * @memberOf _ - * @type Function - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, else `false`. - * @example - * - * _.isArrayLikeObject([1, 2, 3]); - * // => true - * - * _.isArrayLikeObject(document.body.children); - * // => true - * - * _.isArrayLikeObject('abc'); - * // => false - * - * _.isArrayLikeObject(_.noop); - * // => false - */ - isArrayLikeObject(value?: any): value is T[]; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isArrayLikeObject - */ - isArrayLikeObject(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isArrayLikeObject - */ - isArrayLikeObject(): LoDashExplicitWrapper; - } - - // _.isBoolean - interface LoDashStatic { - /** - * Checks if value is classified as a boolean primitive or object. - * - * @param value The value to check. - * @return Returns true if value is correctly classified, else false. - */ - isBoolean(value?: any): value is boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isBoolean - */ - isBoolean(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isBoolean - */ - isBoolean(): LoDashExplicitWrapper; - } - - // _.isBuffer - interface LoDashStatic { - /** - * Checks if value is a buffer. - * - * @param value The value to check. - * @return Returns true if value is a buffer, else false. - */ - isBuffer(value?: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isBuffer - */ - isBuffer(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isBuffer - */ - isBuffer(): LoDashExplicitWrapper; - } - - // _.isDate - interface LoDashStatic { - /** - * Checks if value is classified as a Date object. - * @param value The value to check. - * - * @return Returns true if value is correctly classified, else false. - */ - isDate(value?: any): value is Date; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isDate - */ - isDate(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isDate - */ - isDate(): LoDashExplicitWrapper; - } - - // _.isElement - interface LoDashStatic { - /** - * Checks if value is a DOM element. - * - * @param value The value to check. - * @return Returns true if value is a DOM element, else false. - */ - isElement(value?: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isElement - */ - isElement(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isElement - */ - isElement(): LoDashExplicitWrapper; - } - - // _.isEmpty - interface LoDashStatic { - /** - * Checks if value is empty. A value is considered empty unless it’s an arguments object, array, string, or - * jQuery-like collection with a length greater than 0 or an object with own enumerable properties. - * - * @param value The value to inspect. - * @return Returns true if value is empty, else false. - */ - isEmpty(value?: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isEmpty - */ - isEmpty(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isEmpty - */ - isEmpty(): LoDashExplicitWrapper; - } - - // _.isEqual - interface LoDashStatic { - /** - * Performs a deep comparison between two values to determine if they are - * equivalent. - * - * **Note:** This method supports comparing arrays, array buffers, booleans, - * date objects, error objects, maps, numbers, `Object` objects, regexes, - * sets, strings, symbols, and typed arrays. `Object` objects are compared - * by their own, not inherited, enumerable properties. Functions and DOM - * nodes are **not** supported. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'user': 'fred' }; - * var other = { 'user': 'fred' }; - * - * _.isEqual(object, other); - * // => true - * - * object === other; - * // => false - */ - isEqual( - value: any, - other: any - ): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isEqual - */ - isEqual( - other: any - ): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isEqual - */ - isEqual( - other: any - ): LoDashExplicitWrapper; - } - - // _.isEqualWith - interface IsEqualCustomizer { - (value: any, other: any, indexOrKey?: number | string): boolean; - } - - interface LoDashStatic { - /** - * This method is like `_.isEqual` except that it accepts `customizer` which is - * invoked to compare values. If `customizer` returns `undefined` comparisons are - * handled by the method instead. The `customizer` is invoked with up to seven arguments: - * (objValue, othValue [, index|key, object, other, stack]). - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * function isGreeting(value) { - * return /^h(?:i|ello)$/.test(value); - * } - * - * function customizer(objValue, othValue) { - * if (isGreeting(objValue) && isGreeting(othValue)) { - * return true; - * } - * } - * - * var array = ['hello', 'goodbye']; - * var other = ['hi', 'goodbye']; - * - * _.isEqualWith(array, other, customizer); - * // => true - */ - isEqualWith( - value: any, - other: any, - customizer: IsEqualCustomizer - ): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isEqualWith - */ - isEqualWith( - other: any, - customizer: IsEqualCustomizer - ): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isEqualWith - */ - isEqualWith( - other: any, - customizer: IsEqualCustomizer - ): LoDashExplicitWrapper; - } - - // _.isError - interface LoDashStatic { - /** - * Checks if value is an Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, or URIError - * object. - * - * @param value The value to check. - * @return Returns true if value is an error object, else false. - */ - isError(value: any): value is Error; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isError - */ - isError(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isError - */ - isError(): LoDashExplicitWrapper; - } - - // _.isFinite - interface LoDashStatic { - /** - * Checks if value is a finite primitive number. - * - * Note: This method is based on Number.isFinite. - * - * @param value The value to check. - * @return Returns true if value is a finite number, else false. - */ - isFinite(value?: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isFinite - */ - isFinite(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isFinite - */ - isFinite(): LoDashExplicitWrapper; - } - - // _.isFunction - interface LoDashStatic { - /** - * Checks if value is classified as a Function object. - * - * @param value The value to check. - * @return Returns true if value is correctly classified, else false. - */ - isFunction(value?: any): value is Function; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isFunction - */ - isFunction(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isFunction - */ - isFunction(): LoDashExplicitWrapper; - } - - // _.isInteger - interface LoDashStatic { - /** - * Checks if `value` is an integer. - * - * **Note:** This method is based on [`Number.isInteger`](https://mdn.io/Number/isInteger). - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an integer, else `false`. - * @example - * - * _.isInteger(3); - * // => true - * - * _.isInteger(Number.MIN_VALUE); - * // => false - * - * _.isInteger(Infinity); - * // => false - * - * _.isInteger('3'); - * // => false - */ - isInteger(value?: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isInteger - */ - isInteger(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isInteger - */ - isInteger(): LoDashExplicitWrapper; - } - - // _.isLength - interface LoDashStatic { - /** - * Checks if `value` is a valid array-like length. - * - * **Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false - * - * _.isLength('3'); - * // => false - */ - isLength(value?: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isLength - */ - isLength(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isLength - */ - isLength(): LoDashExplicitWrapper; - } - - // _.isMap - interface LoDashStatic { - /** - * Checks if value is classified as a Map object. - * - * @param value The value to check. - * @returns Returns true if value is correctly classified, else false. - */ - isMap(value?: any): value is Map; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isMap - */ - isMap(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isMap - */ - isMap(): LoDashExplicitWrapper; - } - - // _.isMatch - interface isMatchCustomizer { - (value: any, other: any, indexOrKey?: number | string): boolean; - } - - interface LoDashStatic { - /** - * Performs a deep comparison between `object` and `source` to determine if - * `object` contains equivalent property values. - * - * **Note:** This method supports comparing the same values as `_.isEqual`. - * - * @static - * @memberOf _ - * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - * @example - * - * var object = { 'user': 'fred', 'age': 40 }; - * - * _.isMatch(object, { 'age': 40 }); - * // => true - * - * _.isMatch(object, { 'age': 36 }); - * // => false - */ - isMatch(object: Object, source: Object): boolean; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.isMatch - */ - isMatch(source: Object): boolean; - } - - // _.isMatchWith - interface isMatchWithCustomizer { - (value: any, other: any, indexOrKey?: number | string): boolean; - } - - interface LoDashStatic { - /** - * This method is like `_.isMatch` except that it accepts `customizer` which - * is invoked to compare values. If `customizer` returns `undefined` comparisons - * are handled by the method instead. The `customizer` is invoked with three - * arguments: (objValue, srcValue, index|key, object, source). - * - * @static - * @memberOf _ - * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - * @example - * - * function isGreeting(value) { - * return /^h(?:i|ello)$/.test(value); - * } - * - * function customizer(objValue, srcValue) { - * if (isGreeting(objValue) && isGreeting(srcValue)) { - * return true; - * } - * } - * - * var object = { 'greeting': 'hello' }; - * var source = { 'greeting': 'hi' }; - * - * _.isMatchWith(object, source, customizer); - * // => true - */ - isMatchWith(object: Object, source: Object, customizer: isMatchWithCustomizer): boolean; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.isMatchWith - */ - isMatchWith(source: Object, customizer: isMatchWithCustomizer): boolean; - } - - // _.isNaN - interface LoDashStatic { - /** - * Checks if value is NaN. - * - * Note: This method is not the same as isNaN which returns true for undefined and other non-numeric values. - * - * @param value The value to check. - * @return Returns true if value is NaN, else false. - */ - isNaN(value?: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.isNaN - */ - isNaN(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.isNaN - */ - isNaN(): LoDashExplicitWrapper; - } - - // _.isNative - interface LoDashStatic { - /** - * Checks if value is a native function. - * @param value The value to check. - * - * @retrun Returns true if value is a native function, else false. - */ - isNative(value: any): value is Function; - } - - interface LoDashImplicitWrapperBase { - /** - * see _.isNative - */ - isNative(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * see _.isNative - */ - isNative(): LoDashExplicitWrapper; - } - - // _.isNil - interface LoDashStatic { - /** - * Checks if `value` is `null` or `undefined`. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is nullish, else `false`. - * @example - * - * _.isNil(null); - * // => true - * - * _.isNil(void 0); - * // => true - * - * _.isNil(NaN); - * // => false - */ - isNil(value?: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * see _.isNil - */ - isNil(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * see _.isNil - */ - isNil(): LoDashExplicitWrapper; - } - - // _.isNull - interface LoDashStatic { - /** - * Checks if value is null. - * - * @param value The value to check. - * @return Returns true if value is null, else false. - */ - isNull(value?: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * see _.isNull - */ - isNull(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * see _.isNull - */ - isNull(): LoDashExplicitWrapper; - } - - // _.isNumber - interface LoDashStatic { - /** - * Checks if value is classified as a Number primitive or object. - * - * Note: To exclude Infinity, -Infinity, and NaN, which are classified as numbers, use the _.isFinite method. - * - * @param value The value to check. - * @return Returns true if value is correctly classified, else false. - */ - isNumber(value?: any): value is number; - } - - interface LoDashImplicitWrapperBase { - /** - * see _.isNumber - */ - isNumber(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * see _.isNumber - */ - isNumber(): LoDashExplicitWrapper; - } - - // _.isObject - interface LoDashStatic { - /** - * Checks if value is the language type of Object. (e.g. arrays, functions, objects, regexes, new Number(0), - * and new String('')) - * - * @param value The value to check. - * @return Returns true if value is an object, else false. - */ - isObject(value?: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * see _.isObject - */ - isObject(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * see _.isObject - */ - isObject(): LoDashExplicitWrapper; - } - - // _.isObjectLike - interface LoDashStatic { - /** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ - isObjectLike(value?: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * see _.isObjectLike - */ - isObjectLike(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * see _.isObjectLike - */ - isObjectLike(): LoDashExplicitWrapper; - } - - // _.isPlainObject - interface LoDashStatic { - /** - * Checks if value is a plain object, that is, an object created by the Object constructor or one with a - * [[Prototype]] of null. - * - * Note: This method assumes objects created by the Object constructor have no inherited enumerable properties. - * - * @param value The value to check. - * @return Returns true if value is a plain object, else false. - */ - isPlainObject(value?: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * see _.isPlainObject - */ - isPlainObject(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * see _.isPlainObject - */ - isPlainObject(): LoDashExplicitWrapper; - } - - // _.isRegExp - interface LoDashStatic { - /** - * Checks if value is classified as a RegExp object. - * @param value The value to check. - * - * @return Returns true if value is correctly classified, else false. - */ - isRegExp(value?: any): value is RegExp; - } - - interface LoDashImplicitWrapperBase { - /** - * see _.isRegExp - */ - isRegExp(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * see _.isRegExp - */ - isRegExp(): LoDashExplicitWrapper; - } - - // _.isSafeInteger - interface LoDashStatic { - /** - * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 - * double precision number which isn't the result of a rounded unsafe integer. - * - * **Note:** This method is based on [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. - * @example - * - * _.isSafeInteger(3); - * // => true - * - * _.isSafeInteger(Number.MIN_VALUE); - * // => false - * - * _.isSafeInteger(Infinity); - * // => false - * - * _.isSafeInteger('3'); - * // => false - */ - isSafeInteger(value: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * see _.isSafeInteger - */ - isSafeInteger(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * see _.isSafeInteger - */ - isSafeInteger(): LoDashExplicitWrapper; - } - - // _.isString - interface LoDashStatic { - /** - * Checks if value is classified as a String primitive or object. - * - * @param value The value to check. - * @return Returns true if value is correctly classified, else false. - */ - isString(value?: any): value is string; - } - - interface LoDashImplicitWrapperBase { - /** - * see _.isString - */ - isString(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * see _.isString - */ - isString(): LoDashExplicitWrapper; - } - - // _.isSymbol - interface LoDashStatic { - /** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false - */ - isSymbol(value: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * see _.isSymbol - */ - isSymbol(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * see _.isSymbol - */ - isSymbol(): LoDashExplicitWrapper; - } - - // _.isTypedArray - interface LoDashStatic { - /** - * Checks if value is classified as a typed array. - * - * @param value The value to check. - * @return Returns true if value is correctly classified, else false. - */ - isTypedArray(value: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * see _.isTypedArray - */ - isTypedArray(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * see _.isTypedArray - */ - isTypedArray(): LoDashExplicitWrapper; - } - - // _.isUndefined - interface LoDashStatic { - /** - * Checks if value is undefined. - * - * @param value The value to check. - * @return Returns true if value is undefined, else false. - */ - isUndefined(value: any): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * see _.isUndefined - */ - isUndefined(): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * see _.isUndefined - */ - isUndefined(): LoDashExplicitWrapper; - } - - // _.lt - interface LoDashStatic { - /** - * Checks if value is less than other. - * - * @param value The value to compare. - * @param other The other value to compare. - * @return Returns true if value is less than other, else false. - */ - lt( - value: any, - other: any - ): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.lt - */ - lt(other: any): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.lt - */ - lt(other: any): LoDashExplicitWrapper; - } - - // _.lte - interface LoDashStatic { - /** - * Checks if value is less than or equal to other. - * - * @param value The value to compare. - * @param other The other value to compare. - * @return Returns true if value is less than or equal to other, else false. - */ - lte( - value: any, - other: any - ): boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.lte - */ - lte(other: any): boolean; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.lte - */ - lte(other: any): LoDashExplicitWrapper; - } - - // _.toArray - interface LoDashStatic { - /** - * Converts value to an array. - * - * @param value The value to convert. - * @return Returns the converted array. - */ - toArray(value: List | Dictionary | NumericDictionary): T[]; - - /** - * @see _.toArray - */ - toArray(value: TValue): TResult[]; - - /** - * @see _.toArray - */ - toArray(value?: any): TResult[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.toArray - */ - toArray(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.toArray - */ - toArray(): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.toArray - */ - toArray(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.toArray - */ - toArray(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.toArray - */ - toArray(): LoDashExplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.toArray - */ - toArray(): LoDashExplicitArrayWrapper; - } - - // _.toPlainObject - interface LoDashStatic { - /** - * Converts value to a plain object flattening inherited enumerable properties of value to own properties - * of the plain object. - * - * @param value The value to convert. - * @return Returns the converted plain object. - */ - toPlainObject(value?: any): TResult; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.toPlainObject - */ - toPlainObject(): LoDashImplicitObjectWrapper; - } - - // _.toInteger - interface LoDashStatic { - /** - * Converts `value` to an integer. - * - * **Note:** This function is loosely based on [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. - * @example - * - * _.toInteger(3); - * // => 3 - * - * _.toInteger(Number.MIN_VALUE); - * // => 0 - * - * _.toInteger(Infinity); - * // => 1.7976931348623157e+308 - * - * _.toInteger('3'); - * // => 3 - */ - toInteger(value: any): number; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.toInteger - */ - toInteger(): LoDashImplicitWrapper; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.toInteger - */ - toInteger(): LoDashExplicitWrapper; - } - - // _.toLength - interface LoDashStatic { - /** - * Converts `value` to an integer suitable for use as the length of an - * array-like object. - * - * **Note:** This method is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to convert. - * @return {number} Returns the converted integer. - * @example - * - * _.toLength(3); - * // => 3 - * - * _.toLength(Number.MIN_VALUE); - * // => 0 - * - * _.toLength(Infinity); - * // => 4294967295 - * - * _.toLength('3'); - * // => 3 - */ - toLength(value: any): number; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.toLength - */ - toLength(): LoDashImplicitWrapper; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.toLength - */ - toLength(): LoDashExplicitWrapper; - } - - // _.toNumber - interface LoDashStatic { - /** - * Converts `value` to a number. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to process. - * @returns {number} Returns the number. - * @example - * - * _.toNumber(3); - * // => 3 - * - * _.toNumber(Number.MIN_VALUE); - * // => 5e-324 - * - * _.toNumber(Infinity); - * // => Infinity - * - * _.toNumber('3'); - * // => 3 - */ - toNumber(value: any): number; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.toNumber - */ - toNumber(): LoDashImplicitWrapper; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.toNumber - */ - toNumber(): LoDashExplicitWrapper; - } - - // _.toSafeInteger - interface LoDashStatic { - /** - * Converts `value` to a safe integer. A safe integer can be compared and - * represented correctly. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. - * @example - * - * _.toSafeInteger(3); - * // => 3 - * - * _.toSafeInteger(Number.MIN_VALUE); - * // => 0 - * - * _.toSafeInteger(Infinity); - * // => 9007199254740991 - * - * _.toSafeInteger('3'); - * // => 3 - */ - toSafeInteger(value: any): number; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.toSafeInteger - */ - toSafeInteger(): LoDashImplicitWrapper; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.toSafeInteger - */ - toSafeInteger(): LoDashExplicitWrapper; - } - - // _.toString DUMMY - interface LoDashStatic { - /** - * Converts `value` to a string if it's not one. An empty string is returned - * for `null` and `undefined` values. The sign of `-0` is preserved. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to process. - * @returns {string} Returns the string. - * @example - * - * _.toString(null); - * // => '' - * - * _.toString(-0); - * // => '-0' - * - * _.toString([1, 2, 3]); - * // => '1,2,3' - */ - toString(value: any): string; - } - - /******** - * Math * - *******/ - - // _.add - interface LoDashStatic { - /** - * Adds two numbers. - * - * @param augend The first number to add. - * @param addend The second number to add. - * @return Returns the sum. - */ - add( - augend: number, - addend: number - ): number; - } - - interface LoDashImplicitWrapper { - /** - * @see _.add - */ - add(addend: number): number; - } - - interface LoDashExplicitWrapper { - /** - * @see _.add - */ - add(addend: number): LoDashExplicitWrapper; - } - - // _.ceil - interface LoDashStatic { - /** - * Calculates n rounded up to precision. - * - * @param n The number to round up. - * @param precision The precision to round up to. - * @return Returns the rounded up number. - */ - ceil( - n: number, - precision?: number - ): number; - } - - interface LoDashImplicitWrapper { - /** - * @see _.ceil - */ - ceil(precision?: number): number; - } - - interface LoDashExplicitWrapper { - /** - * @see _.ceil - */ - ceil(precision?: number): LoDashExplicitWrapper; - } - - // _.floor - interface LoDashStatic { - /** - * Calculates n rounded down to precision. - * - * @param n The number to round down. - * @param precision The precision to round down to. - * @return Returns the rounded down number. - */ - floor( - n: number, - precision?: number - ): number; - } - - interface LoDashImplicitWrapper { - /** - * @see _.floor - */ - floor(precision?: number): number; - } - - interface LoDashExplicitWrapper { - /** - * @see _.floor - */ - floor(precision?: number): LoDashExplicitWrapper; - } - - // _.max - interface LoDashStatic { - /** - * Computes the maximum value of `array`. If `array` is empty or falsey - * `undefined` is returned. - * - * @static - * @memberOf _ - * @category Math - * @param {Array} array The array to iterate over. - * @returns {*} Returns the maximum value. - */ - max( - collection: List - ): T; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.max - */ - max(): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.max - */ - max(): T; - } - - // _.maxBy - interface LoDashStatic { - /** - * This method is like `_.max` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the criterion by which - * the value is ranked. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. - * @returns {*} Returns the maximum value. - * @example - * - * var objects = [{ 'n': 1 }, { 'n': 2 }]; - * - * _.maxBy(objects, function(o) { return o.a; }); - * // => { 'n': 2 } - * - * // using the `_.property` iteratee shorthand - * _.maxBy(objects, 'n'); - * // => { 'n': 2 } - */ - maxBy( - collection: List, - iteratee?: ListIterator - ): T; - - /** - * @see _.maxBy - */ - maxBy( - collection: Dictionary, - iteratee?: DictionaryIterator - ): T; - - /** - * @see _.maxBy - */ - maxBy( - collection: List | Dictionary, - iteratee?: string - ): T; - - /** - * @see _.maxBy - */ - maxBy( - collection: List | Dictionary, - whereValue?: TObject - ): T; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.maxBy - */ - maxBy( - iteratee?: ListIterator - ): T; - - /** - * @see _.maxBy - */ - maxBy( - iteratee?: string - ): T; - - /** - * @see _.maxBy - */ - maxBy( - whereValue?: TObject - ): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.maxBy - */ - maxBy( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): T; - - /** - * @see _.maxBy - */ - maxBy( - iteratee?: string, - thisArg?: any - ): T; - - /** - * @see _.maxBy - */ - maxBy( - whereValue?: TObject - ): T; - } - - // _.mean - interface LoDashStatic { - /** - * Computes the mean of the values in `array`. - * - * @static - * @memberOf _ - * @category Math - * @param {Array} array The array to iterate over. - * @returns {number} Returns the mean. - * @example - * - * _.mean([4, 2, 8, 6]); - * // => 5 - */ - mean( - collection: List - ): number; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.mean - */ - mean(): number; - - /** - * @see _.mean - */ - mean(): number; - } - - // _.min - interface LoDashStatic { - /** - * Computes the minimum value of `array`. If `array` is empty or falsey - * `undefined` is returned. - * - * @static - * @memberOf _ - * @category Math - * @param {Array} array The array to iterate over. - * @returns {*} Returns the minimum value. - */ - min( - collection: List - ): T; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.min - */ - min(): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.min - */ - min(): T; - } - - // _.minBy - interface LoDashStatic { - /** - * This method is like `_.min` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the criterion by which - * the value is ranked. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. - * @returns {*} Returns the minimum value. - * @example - * - * var objects = [{ 'n': 1 }, { 'n': 2 }]; - * - * _.minBy(objects, function(o) { return o.a; }); - * // => { 'n': 1 } - * - * // using the `_.property` iteratee shorthand - * _.minBy(objects, 'n'); - * // => { 'n': 1 } - */ - minBy( - collection: List, - iteratee?: ListIterator - ): T; - - /** - * @see _.minBy - */ - minBy( - collection: Dictionary, - iteratee?: DictionaryIterator - ): T; - - /** - * @see _.minBy - */ - minBy( - collection: List | Dictionary, - iteratee?: string - ): T; - - /** - * @see _.minBy - */ - minBy( - collection: List | Dictionary, - whereValue?: TObject - ): T; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.minBy - */ - minBy( - iteratee?: ListIterator - ): T; - - /** - * @see _.minBy - */ - minBy( - iteratee?: string - ): T; - - /** - * @see _.minBy - */ - minBy( - whereValue?: TObject - ): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.minBy - */ - minBy( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): T; - - /** - * @see _.minBy - */ - minBy( - iteratee?: string, - thisArg?: any - ): T; - - /** - * @see _.minBy - */ - minBy( - whereValue?: TObject - ): T; - } - - // _.round - interface LoDashStatic { - /** - * Calculates n rounded to precision. - * - * @param n The number to round. - * @param precision The precision to round to. - * @return Returns the rounded number. - */ - round( - n: number, - precision?: number - ): number; - } - - interface LoDashImplicitWrapper { - /** - * @see _.round - */ - round(precision?: number): number; - } - - interface LoDashExplicitWrapper { - /** - * @see _.round - */ - round(precision?: number): LoDashExplicitWrapper; - } - - // _.sum - interface LoDashStatic { - /** - * Computes the sum of the values in `array`. - * - * @static - * @memberOf _ - * @category Math - * @param {Array} array The array to iterate over. - * @returns {number} Returns the sum. - * @example - * - * _.sum([4, 2, 8, 6]); - * // => 20 - */ - sum(collection: List): number; - - /** - * @see _.sum - */ - sum(collection: List | Dictionary): number; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.sum - */ - sum(): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.sum - */ - sum(): number; - - /** - * @see _.sum - */ - sum(): number; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.sum - */ - sum(): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.sum - */ - sum(): LoDashExplicitWrapper; - - /** - * @see _.sum - */ - sum(): LoDashExplicitWrapper; - } - - // _.sumBy - interface LoDashStatic { - /** - * This method is like `_.sum` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the value to be summed. - * The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the sum. - * @example - * - * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; - * - * _.sumBy(objects, function(o) { return o.n; }); - * // => 20 - * - * // using the `_.property` iteratee shorthand - * _.sumBy(objects, 'n'); - * // => 20 - */ - sumBy( - collection: List, - iteratee: ListIterator - ): number; - - /** - * @see _.sumBy - */ - sumBy( - collection: Dictionary, - iteratee: DictionaryIterator - ): number; - - /** - * @see _.sumBy - */ - sumBy( - collection: List | Dictionary, - iteratee: string - ): number; - - /** - * @see _.sumBy - */ - sumBy(collection: List | Dictionary): number; - - /** - * @see _.sumBy - */ - sumBy(collection: List | Dictionary): number; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.sumBy - */ - sumBy( - iteratee: ListIterator - ): number; - - /** - * @see _.sumBy - */ - sumBy(iteratee: string): number; - - /** - * @see _.sumBy - */ - sumBy(): number; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.sumBy - */ - sumBy( - iteratee: ListIterator | DictionaryIterator - ): number; - - /** - * @see _.sumBy - */ - sumBy(iteratee: string): number; - - /** - * @see _.sumBy - */ - sumBy(): number; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.sumBy - */ - sumBy( - iteratee: ListIterator - ): LoDashExplicitWrapper; - - /** - * @see _.sumBy - */ - sumBy(iteratee: string): LoDashExplicitWrapper; - - /** - * @see _.sumBy - */ - sumBy(): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.sumBy - */ - sumBy( - iteratee: ListIterator | DictionaryIterator - ): LoDashExplicitWrapper; - - /** - * @see _.sumBy - */ - sumBy(iteratee: string): LoDashExplicitWrapper; - - /** - * @see _.sumBy - */ - sumBy(): LoDashExplicitWrapper; - } - - /********** - * Number * - *********/ - - // _.subtract - interface LoDashStatic { - /** - * Subtract two numbers. - * - * @static - * @memberOf _ - * @category Math - * @param {number} minuend The first number in a subtraction. - * @param {number} subtrahend The second number in a subtraction. - * @returns {number} Returns the difference. - * @example - * - * _.subtract(6, 4); - * // => 2 - */ - subtract( - minuend: number, - subtrahend: number - ): number; - } - - interface LoDashImplicitWrapper { - /** - * @see _.subtract - */ - subtract( - subtrahend: number - ): number; - } - - interface LoDashExplicitWrapper { - /** - * @see _.subtract - */ - subtract( - subtrahend: number - ): LoDashExplicitWrapper; - } - - // _.clamp - interface LoDashStatic { - /** - * Clamps `number` within the inclusive `lower` and `upper` bounds. - * - * @static - * @memberOf _ - * @category Number - * @param {number} number The number to clamp. - * @param {number} [lower] The lower bound. - * @param {number} upper The upper bound. - * @returns {number} Returns the clamped number. - * @example - * - * _.clamp(-10, -5, 5); - * // => -5 - * - * _.clamp(10, -5, 5); - * // => 5 - */ - clamp( - number: number, - lower: number, - upper: number - ): number; - } - - interface LoDashImplicitWrapper { - /** - * @see _.clamp - */ - clamp( - lower: number, - upper: number - ): number; - } - - interface LoDashExplicitWrapper { - /** - * @see _.clamp - */ - clamp( - lower: number, - upper: number - ): LoDashExplicitWrapper; - } - - // _.inRange - interface LoDashStatic { - /** - * Checks if n is between start and up to but not including, end. If end is not specified it’s set to start - * with start then set to 0. - * - * @param n The number to check. - * @param start The start of the range. - * @param end The end of the range. - * @return Returns true if n is in the range, else false. - */ - inRange( - n: number, - start: number, - end: number - ): boolean; - - - /** - * @see _.inRange - */ - inRange( - n: number, - end: number - ): boolean; - } - - interface LoDashImplicitWrapper { - /** - * @see _.inRange - */ - inRange( - start: number, - end: number - ): boolean; - - /** - * @see _.inRange - */ - inRange(end: number): boolean; - } - - interface LoDashExplicitWrapper { - /** - * @see _.inRange - */ - inRange( - start: number, - end: number - ): LoDashExplicitWrapper; - - /** - * @see _.inRange - */ - inRange(end: number): LoDashExplicitWrapper; - } - - // _.random - interface LoDashStatic { - /** - * Produces a random number between min and max (inclusive). If only one argument is provided a number between - * 0 and the given number is returned. If floating is true, or either min or max are floats, a floating-point - * number is returned instead of an integer. - * - * @param min The minimum possible value. - * @param max The maximum possible value. - * @param floating Specify returning a floating-point number. - * @return Returns the random number. - */ - random( - min?: number, - max?: number, - floating?: boolean - ): number; - - /** - * @see _.random - */ - random( - min?: number, - floating?: boolean - ): number; - - /** - * @see _.random - */ - random(floating?: boolean): number; - } - - interface LoDashImplicitWrapper { - /** - * @see _.random - */ - random( - max?: number, - floating?: boolean - ): number; - - /** - * @see _.random - */ - random(floating?: boolean): number; - } - - interface LoDashExplicitWrapper { - /** - * @see _.random - */ - random( - max?: number, - floating?: boolean - ): LoDashExplicitWrapper; - - /** - * @see _.random - */ - random(floating?: boolean): LoDashExplicitWrapper; - } - - /********** - * Object * - *********/ - - // _.assign - interface LoDashStatic { - /** - * Assigns own enumerable properties of source objects to the destination - * object. Source objects are applied from left to right. Subsequent sources - * overwrite property assignments of previous sources. - * - * **Note:** This method mutates `object` and is loosely based on - * [`Object.assign`](https://mdn.io/Object/assign). - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @example - * - * function Foo() { - * this.c = 3; - * } - * - * function Bar() { - * this.e = 5; - * } - * - * Foo.prototype.d = 4; - * Bar.prototype.f = 6; - * - * _.assign({ 'a': 1 }, new Foo, new Bar); - * // => { 'a': 1, 'c': 3, 'e': 5 } - */ - assign( - object: TObject, - source: TSource - ): TResult; - - /** - * @see assign - */ - assign( - object: TObject, - source1: TSource1, - source2: TSource2 - ): TResult; - - /** - * @see assign - */ - assign( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3 - ): TResult; - - /** - * @see assign - */ - assign - ( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4 - ): TResult; - - /** - * @see _.assign - */ - assign(object: TObject): TObject; - - /** - * @see _.assign - */ - assign( - object: TObject, ...otherArgs: any[] - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.assign - */ - assign( - source: TSource - ): LoDashImplicitObjectWrapper; - - /** - * @see assign - */ - assign( - source1: TSource1, - source2: TSource2 - ): LoDashImplicitObjectWrapper; - - /** - * @see assign - */ - assign( - source1: TSource1, - source2: TSource2, - source3: TSource3 - ): LoDashImplicitObjectWrapper; - - /** - * @see assign - */ - assign( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4 - ): LoDashImplicitObjectWrapper; - - /** - * @see _.assign - */ - assign(): LoDashImplicitObjectWrapper; - - /** - * @see _.assign - */ - assign(...otherArgs: any[]): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.assign - */ - assign( - source: TSource - ): LoDashExplicitObjectWrapper; - - /** - * @see assign - */ - assign( - source1: TSource1, - source2: TSource2 - ): LoDashExplicitObjectWrapper; - - /** - * @see assign - */ - assign( - source1: TSource1, - source2: TSource2, - source3: TSource3 - ): LoDashExplicitObjectWrapper; - - /** - * @see assign - */ - assign( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4 - ): LoDashExplicitObjectWrapper; - - /** - * @see _.assign - */ - assign(): LoDashExplicitObjectWrapper; - - /** - * @see _.assign - */ - assign(...otherArgs: any[]): LoDashExplicitObjectWrapper; - } - - // _.assignWith - interface AssignCustomizer { - (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}): any; - } - - interface LoDashStatic { - /** - * This method is like `_.assign` except that it accepts `customizer` which - * is invoked to produce the assigned values. If `customizer` returns `undefined` - * assignment is handled by the method instead. The `customizer` is invoked - * with five arguments: (objValue, srcValue, key, object, source). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @example - * - * function customizer(objValue, srcValue) { - * return _.isUndefined(objValue) ? srcValue : objValue; - * } - * - * var defaults = _.partialRight(_.assignWith, customizer); - * - * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); - * // => { 'a': 1, 'b': 2 } - */ - assignWith( - object: TObject, - source: TSource, - customizer: AssignCustomizer - ): TResult; - - /** - * @see assignWith - */ - assignWith( - object: TObject, - source1: TSource1, - source2: TSource2, - customizer: AssignCustomizer - ): TResult; - - /** - * @see assignWith - */ - assignWith( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3, - customizer: AssignCustomizer - ): TResult; - - /** - * @see assignWith - */ - assignWith - ( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer: AssignCustomizer - ): TResult; - - /** - * @see _.assignWith - */ - assignWith(object: TObject): TObject; - - /** - * @see _.assignWith - */ - assignWith( - object: TObject, ...otherArgs: any[] - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.assignWith - */ - assignWith( - source: TSource, - customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see assignWith - */ - assignWith( - source1: TSource1, - source2: TSource2, - customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see assignWith - */ - assignWith( - source1: TSource1, - source2: TSource2, - source3: TSource3, - customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see assignWith - */ - assignWith( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see _.assignWith - */ - assignWith(): LoDashImplicitObjectWrapper; - - /** - * @see _.assignWith - */ - assignWith(...otherArgs: any[]): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.assignWith - */ - assignWith( - source: TSource, - customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; - - /** - * @see assignWith - */ - assignWith( - source1: TSource1, - source2: TSource2, - customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; - - /** - * @see assignWith - */ - assignWith( - source1: TSource1, - source2: TSource2, - source3: TSource3, - customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; - - /** - * @see assignWith - */ - assignWith( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; - - /** - * @see _.assignWith - */ - assignWith(): LoDashExplicitObjectWrapper; - - /** - * @see _.assignWith - */ - assignWith(...otherArgs: any[]): LoDashExplicitObjectWrapper; - } - - // _.assignIn - interface LoDashStatic { - /** - * This method is like `_.assign` except that it iterates over own and - * inherited source properties. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @alias extend - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @example - * - * function Foo() { - * this.b = 2; - * } - * - * function Bar() { - * this.d = 4; - * } - * - * Foo.prototype.c = 3; - * Bar.prototype.e = 5; - * - * _.assignIn({ 'a': 1 }, new Foo, new Bar); - * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 } - */ - assignIn( - object: TObject, - source: TSource - ): TResult; - - /** - * @see assignIn - */ - assignIn( - object: TObject, - source1: TSource1, - source2: TSource2 - ): TResult; - - /** - * @see assignIn - */ - assignIn( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3 - ): TResult; - - /** - * @see assignIn - */ - assignIn - ( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4 - ): TResult; - - /** - * @see _.assignIn - */ - assignIn(object: TObject): TObject; - - /** - * @see _.assignIn - */ - assignIn( - object: TObject, ...otherArgs: any[] - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.assignIn - */ - assignIn( - source: TSource - ): LoDashImplicitObjectWrapper; - - /** - * @see assignIn - */ - assignIn( - source1: TSource1, - source2: TSource2 - ): LoDashImplicitObjectWrapper; - - /** - * @see assignIn - */ - assignIn( - source1: TSource1, - source2: TSource2, - source3: TSource3 - ): LoDashImplicitObjectWrapper; - - /** - * @see assignIn - */ - assignIn( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4 - ): LoDashImplicitObjectWrapper; - - /** - * @see _.assignIn - */ - assignIn(): LoDashImplicitObjectWrapper; - - /** - * @see _.assignIn - */ - assignIn(...otherArgs: any[]): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.assignIn - */ - assignIn( - source: TSource - ): LoDashExplicitObjectWrapper; - - /** - * @see assignIn - */ - assignIn( - source1: TSource1, - source2: TSource2 - ): LoDashExplicitObjectWrapper; - - /** - * @see assignIn - */ - assignIn( - source1: TSource1, - source2: TSource2, - source3: TSource3 - ): LoDashExplicitObjectWrapper; - - /** - * @see assignIn - */ - assignIn( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4 - ): LoDashExplicitObjectWrapper; - - /** - * @see _.assignIn - */ - assignIn(): LoDashExplicitObjectWrapper; - - /** - * @see _.assignIn - */ - assignIn(...otherArgs: any[]): LoDashExplicitObjectWrapper; - } - - // _.assignInWith - interface AssignCustomizer { - (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}): any; - } - - interface LoDashStatic { - /** - * This method is like `_.assignIn` except that it accepts `customizer` which - * is invoked to produce the assigned values. If `customizer` returns `undefined` - * assignment is handled by the method instead. The `customizer` is invoked - * with five arguments: (objValue, srcValue, key, object, source). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @alias extendWith - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @example - * - * function customizer(objValue, srcValue) { - * return _.isUndefined(objValue) ? srcValue : objValue; - * } - * - * var defaults = _.partialRight(_.assignInWith, customizer); - * - * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); - * // => { 'a': 1, 'b': 2 } - */ - assignInWith( - object: TObject, - source: TSource, - customizer: AssignCustomizer - ): TResult; - - /** - * @see assignInWith - */ - assignInWith( - object: TObject, - source1: TSource1, - source2: TSource2, - customizer: AssignCustomizer - ): TResult; - - /** - * @see assignInWith - */ - assignInWith( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3, - customizer: AssignCustomizer - ): TResult; - - /** - * @see assignInWith - */ - assignInWith - ( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer: AssignCustomizer - ): TResult; - - /** - * @see _.assignInWith - */ - assignInWith(object: TObject): TObject; - - /** - * @see _.assignInWith - */ - assignInWith( - object: TObject, ...otherArgs: any[] - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.assignInWith - */ - assignInWith( - source: TSource, - customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see assignInWith - */ - assignInWith( - source1: TSource1, - source2: TSource2, - customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see assignInWith - */ - assignInWith( - source1: TSource1, - source2: TSource2, - source3: TSource3, - customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see assignInWith - */ - assignInWith( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer: AssignCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see _.assignInWith - */ - assignInWith(): LoDashImplicitObjectWrapper; - - /** - * @see _.assignInWith - */ - assignInWith(...otherArgs: any[]): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.assignInWith - */ - assignInWith( - source: TSource, - customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; - - /** - * @see assignInWith - */ - assignInWith( - source1: TSource1, - source2: TSource2, - customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; - - /** - * @see assignInWith - */ - assignInWith( - source1: TSource1, - source2: TSource2, - source3: TSource3, - customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; - - /** - * @see assignInWith - */ - assignInWith( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer: AssignCustomizer - ): LoDashExplicitObjectWrapper; - - /** - * @see _.assignInWith - */ - assignInWith(): LoDashExplicitObjectWrapper; - - /** - * @see _.assignInWith - */ - assignInWith(...otherArgs: any[]): LoDashExplicitObjectWrapper; - } - - // _.create - interface LoDashStatic { - /** - * Creates an object that inherits from the given prototype object. If a properties object is provided its own - * enumerable properties are assigned to the created object. - * - * @param prototype The object to inherit from. - * @param properties The properties to assign to the object. - * @return Returns the new object. - */ - create( - prototype: T, - properties?: U - ): T & U; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.create - */ - create(properties?: U): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.create - */ - create(properties?: U): LoDashExplicitObjectWrapper; - } - - // _.defaults - interface LoDashStatic { - /** - * Assigns own enumerable properties of source object(s) to the destination object for all destination - * properties that resolve to undefined. Once a property is set, additional values of the same property are - * ignored. - * - * Note: This method mutates object. - * - * @param object The destination object. - * @param sources The source objects. - * @return The destination object. - */ - defaults( - object: Obj, - ...sources: {}[] - ): TResult; - - /** - * @see _.defaults - */ - defaults( - object: Obj, - source1: S1, - ...sources: {}[] - ): TResult; - - /** - * @see _.defaults - */ - defaults( - object: Obj, - source1: S1, - source2: S2, - ...sources: {}[] - ): TResult; - - /** - * @see _.defaults - */ - defaults( - object: Obj, - source1: S1, - source2: S2, - source3: S3, - ...sources: {}[] - ): TResult; - - /** - * @see _.defaults - */ - defaults( - object: Obj, - source1: S1, - source2: S2, - source3: S3, - source4: S4, - ...sources: {}[] - ): TResult; - - /** - * @see _.defaults - */ - defaults( - object: {}, - ...sources: {}[] - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.defaults - */ - defaults( - source1: S1, - ...sources: {}[] - ): LoDashImplicitObjectWrapper; - - /** - * @see _.defaults - */ - defaults( - source1: S1, - source2: S2, - ...sources: {}[] - ): LoDashImplicitObjectWrapper; - - /** - * @see _.defaults - */ - defaults( - source1: S1, - source2: S2, - source3: S3, - ...sources: {}[] - ): LoDashImplicitObjectWrapper; - - /** - * @see _.defaults - */ - defaults( - source1: S1, - source2: S2, - source3: S3, - source4: S4, - ...sources: {}[] - ): LoDashImplicitObjectWrapper; - - /** - * @see _.defaults - */ - defaults(): LoDashImplicitObjectWrapper; - - /** - * @see _.defaults - */ - defaults(...sources: {}[]): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.defaults - */ - defaults( - source1: S1, - ...sources: {}[] - ): LoDashExplicitObjectWrapper; - - /** - * @see _.defaults - */ - defaults( - source1: S1, - source2: S2, - ...sources: {}[] - ): LoDashExplicitObjectWrapper; - - /** - * @see _.defaults - */ - defaults( - source1: S1, - source2: S2, - source3: S3, - ...sources: {}[] - ): LoDashExplicitObjectWrapper; - - /** - * @see _.defaults - */ - defaults( - source1: S1, - source2: S2, - source3: S3, - source4: S4, - ...sources: {}[] - ): LoDashExplicitObjectWrapper; - - /** - * @see _.defaults - */ - defaults(): LoDashExplicitObjectWrapper; - - /** - * @see _.defaults - */ - defaults(...sources: {}[]): LoDashExplicitObjectWrapper; - } - - // _.defaultsDeep - interface LoDashStatic { - /** - * This method is like _.defaults except that it recursively assigns default properties. - * @param object The destination object. - * @param sources The source objects. - * @return Returns object. - */ - defaultsDeep( - object: T, - ...sources: any[]): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.defaultsDeep - */ - defaultsDeep(...sources: any[]): LoDashImplicitObjectWrapper; - } - - // _.extend - interface LoDashStatic { - /** - * @see assign - */ - extend( - object: TObject, - source: TSource, - customizer?: AssignCustomizer, - thisArg?: any - ): TResult; - - /** - * @see assign - */ - extend( - object: TObject, - source1: TSource1, - source2: TSource2, - customizer?: AssignCustomizer, - thisArg?: any - ): TResult; - - /** - * @see assign - */ - extend( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3, - customizer?: AssignCustomizer, - thisArg?: any - ): TResult; - - /** - * @see assign - */ - extend - ( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer?: AssignCustomizer, - thisArg?: any - ): TResult; - - /** - * @see _.assign - */ - extend(object: TObject): TObject; - - /** - * @see _.assign - */ - extend( - object: TObject, ...otherArgs: any[] - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.assign - */ - extend( - source: TSource, - customizer?: AssignCustomizer, - thisArg?: any - ): LoDashImplicitObjectWrapper; - - /** - * @see assign - */ - extend( - source1: TSource1, - source2: TSource2, - customizer?: AssignCustomizer, - thisArg?: any - ): LoDashImplicitObjectWrapper; - - /** - * @see assign - */ - extend( - source1: TSource1, - source2: TSource2, - source3: TSource3, - customizer?: AssignCustomizer, - thisArg?: any - ): LoDashImplicitObjectWrapper; - - /** - * @see assign - */ - extend( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer?: AssignCustomizer, - thisArg?: any - ): LoDashImplicitObjectWrapper; - - /** - * @see _.assign - */ - extend(): LoDashImplicitObjectWrapper; - - /** - * @see _.assign - */ - extend(...otherArgs: any[]): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.assign - */ - extend( - source: TSource, - customizer?: AssignCustomizer, - thisArg?: any - ): LoDashExplicitObjectWrapper; - - /** - * @see assign - */ - extend( - source1: TSource1, - source2: TSource2, - customizer?: AssignCustomizer, - thisArg?: any - ): LoDashExplicitObjectWrapper; - - /** - * @see assign - */ - extend( - source1: TSource1, - source2: TSource2, - source3: TSource3, - customizer?: AssignCustomizer, - thisArg?: any - ): LoDashExplicitObjectWrapper; - - /** - * @see assign - */ - extend( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer?: AssignCustomizer, - thisArg?: any - ): LoDashExplicitObjectWrapper; - - /** - * @see _.assign - */ - extend(): LoDashExplicitObjectWrapper; - - /** - * @see _.assign - */ - extend(...otherArgs: any[]): LoDashExplicitObjectWrapper; - } - - // _.findKey - interface LoDashStatic { - /** - * This method is like _.find except that it returns the key of the first element predicate returns truthy for - * instead of the element itself. - * - * If a property name is provided for predicate the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for predicate the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * @param object The object to search. - * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. - * @return Returns the key of the matched element, else undefined. - */ - findKey( - object: TObject, - predicate?: DictionaryIterator, - thisArg?: any - ): string; - - /** - * @see _.findKey - */ - findKey( - object: TObject, - predicate?: ObjectIterator, - thisArg?: any - ): string; - - /** - * @see _.findKey - */ - findKey( - object: TObject, - predicate?: string, - thisArg?: any - ): string; - - /** - * @see _.findKey - */ - findKey, TObject>( - object: TObject, - predicate?: TWhere - ): string; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.findKey - */ - findKey( - predicate?: DictionaryIterator, - thisArg?: any - ): string; - - /** - * @see _.findKey - */ - findKey( - predicate?: ObjectIterator, - thisArg?: any - ): string; - - /** - * @see _.findKey - */ - findKey( - predicate?: string, - thisArg?: any - ): string; - - /** - * @see _.findKey - */ - findKey>( - predicate?: TWhere - ): string; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.findKey - */ - findKey( - predicate?: DictionaryIterator, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findKey - */ - findKey( - predicate?: ObjectIterator, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findKey - */ - findKey( - predicate?: string, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findKey - */ - findKey>( - predicate?: TWhere - ): LoDashExplicitWrapper; - } - - // _.findLastKey - interface LoDashStatic { - /** - * This method is like _.findKey except that it iterates over elements of a collection in the opposite order. - * - * If a property name is provided for predicate the created _.property style callback returns the property - * value of the given element. - * - * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for - * elements that have a matching property value, else false. - * - * If an object is provided for predicate the created _.matches style callback returns true for elements that - * have the properties of the given object, else false. - * - * @param object The object to search. - * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. - * @return Returns the key of the matched element, else undefined. - */ - findLastKey( - object: TObject, - predicate?: DictionaryIterator, - thisArg?: any - ): string; - - /** - * @see _.findLastKey - */ - findLastKey( - object: TObject, - predicate?: ObjectIterator, - thisArg?: any - ): string; - - /** - * @see _.findLastKey - */ - findLastKey( - object: TObject, - predicate?: string, - thisArg?: any - ): string; - - /** - * @see _.findLastKey - */ - findLastKey, TObject>( - object: TObject, - predicate?: TWhere - ): string; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.findLastKey - */ - findLastKey( - predicate?: DictionaryIterator, - thisArg?: any - ): string; - - /** - * @see _.findLastKey - */ - findLastKey( - predicate?: ObjectIterator, - thisArg?: any - ): string; - - /** - * @see _.findLastKey - */ - findLastKey( - predicate?: string, - thisArg?: any - ): string; - - /** - * @see _.findLastKey - */ - findLastKey>( - predicate?: TWhere - ): string; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.findLastKey - */ - findLastKey( - predicate?: DictionaryIterator, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findLastKey - */ - findLastKey( - predicate?: ObjectIterator, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findLastKey - */ - findLastKey( - predicate?: string, - thisArg?: any - ): LoDashExplicitWrapper; - - /** - * @see _.findLastKey - */ - findLastKey>( - predicate?: TWhere - ): LoDashExplicitWrapper; - } - - // _.forIn - interface LoDashStatic { - /** - * Iterates over own and inherited enumerable properties of an object invoking iteratee for each property. The - * iteratee is bound to thisArg and invoked with three arguments: (value, key, object). Iteratee functions may - * exit iteration early by explicitly returning false. - * - * @param object The object to iterate over. - * @param iteratee The function invoked per iteration. - * @param thisArg The this binding of iteratee. - * @return Returns object. - */ - forIn( - object: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.forIn - */ - forIn( - object: T, - iteratee?: ObjectIterator, - thisArg?: any - ): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.forIn - */ - forIn( - iteratee?: DictionaryIterator, - thisArg?: any - ): _.LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.forIn - */ - forIn( - iteratee?: DictionaryIterator, - thisArg?: any - ): _.LoDashExplicitObjectWrapper; - } - - // _.forInRight - interface LoDashStatic { - /** - * This method is like _.forIn except that it iterates over properties of object in the opposite order. - * - * @param object The object to iterate over. - * @param iteratee The function invoked per iteration. - * @param thisArg The this binding of iteratee. - * @return Returns object. - */ - forInRight( - object: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.forInRight - */ - forInRight( - object: T, - iteratee?: ObjectIterator, - thisArg?: any - ): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.forInRight - */ - forInRight( - iteratee?: DictionaryIterator, - thisArg?: any - ): _.LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.forInRight - */ - forInRight( - iteratee?: DictionaryIterator, - thisArg?: any - ): _.LoDashExplicitObjectWrapper; - } - - // _.forOwn - interface LoDashStatic { - /** - * Iterates over own enumerable properties of an object invoking iteratee for each property. The iteratee is - * bound to thisArg and invoked with three arguments: (value, key, object). Iteratee functions may exit - * iteration early by explicitly returning false. - * - * @param object The object to iterate over. - * @param iteratee The function invoked per iteration. - * @param thisArg The this binding of iteratee. - * @return Returns object. - */ - forOwn( - object: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.forOwn - */ - forOwn( - object: T, - iteratee?: ObjectIterator, - thisArg?: any - ): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.forOwn - */ - forOwn( - iteratee?: DictionaryIterator, - thisArg?: any - ): _.LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.forOwn - */ - forOwn( - iteratee?: DictionaryIterator, - thisArg?: any - ): _.LoDashExplicitObjectWrapper; - } - - // _.forOwnRight - interface LoDashStatic { - /** - * This method is like _.forOwn except that it iterates over properties of object in the opposite order. - * - * @param object The object to iterate over. - * @param iteratee The function invoked per iteration. - * @param thisArg The this binding of iteratee. - * @return Returns object. - */ - forOwnRight( - object: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.forOwnRight - */ - forOwnRight( - object: T, - iteratee?: ObjectIterator, - thisArg?: any - ): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.forOwnRight - */ - forOwnRight( - iteratee?: DictionaryIterator, - thisArg?: any - ): _.LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.forOwnRight - */ - forOwnRight( - iteratee?: DictionaryIterator, - thisArg?: any - ): _.LoDashExplicitObjectWrapper; - } - - // _.functions - interface LoDashStatic { - /** - * Creates an array of function property names from own enumerable properties - * of `object`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to inspect. - * @returns {Array} Returns the new array of property names. - * @example - * - * function Foo() { - * this.a = _.constant('a'); - * this.b = _.constant('b'); - * } - * - * Foo.prototype.c = _.constant('c'); - * - * _.functions(new Foo); - * // => ['a', 'b'] - */ - functions(object: any): string[]; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.functions - */ - functions(): _.LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.functions - */ - functions(): _.LoDashExplicitArrayWrapper; - } - - // _.functionsIn - interface LoDashStatic { - /** - * Creates an array of function property names from own and inherited - * enumerable properties of `object`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to inspect. - * @returns {Array} Returns the new array of property names. - * @example - * - * function Foo() { - * this.a = _.constant('a'); - * this.b = _.constant('b'); - * } - * - * Foo.prototype.c = _.constant('c'); - * - * _.functionsIn(new Foo); - * // => ['a', 'b', 'c'] - */ - functionsIn(object: any): string[]; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.functionsIn - */ - functionsIn(): _.LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.functionsIn - */ - functionsIn(): _.LoDashExplicitArrayWrapper; - } - - // _.get - interface LoDashStatic { - /** - * Gets the property value at path of object. If the resolved - * value is undefined the defaultValue is used in its place. - * @param object The object to query. - * @param path The path of the property to get. - * @param defaultValue The value returned if the resolved value is undefined. - * @return Returns the resolved value. - */ - get(object: Object, - path: string | number | boolean | Array, - defaultValue?: TResult - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.get - */ - get(path: string | number | boolean | Array, - defaultValue?: TResult - ): TResult; - } - - // _.has - interface LoDashStatic { - /** - * Checks if `path` is a direct property of `object`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - * @example - * - * var object = { 'a': { 'b': { 'c': 3 } } }; - * var other = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) }); - * - * _.has(object, 'a'); - * // => true - * - * _.has(object, 'a.b.c'); - * // => true - * - * _.has(object, ['a', 'b', 'c']); - * // => true - * - * _.has(other, 'a'); - * // => false - */ - has( - object: T, - path: StringRepresentable | StringRepresentable[] - ): boolean; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.has - */ - has(path: StringRepresentable | StringRepresentable[]): boolean; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.has - */ - has(path: StringRepresentable | StringRepresentable[]): LoDashExplicitWrapper; - } - - // _.hasIn - interface LoDashStatic { - /** - * Checks if `path` is a direct or inherited property of `object`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - * @example - * - * var object = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) }); - * - * _.hasIn(object, 'a'); - * // => true - * - * _.hasIn(object, 'a.b.c'); - * // => true - * - * _.hasIn(object, ['a', 'b', 'c']); - * // => true - * - * _.hasIn(object, 'b'); - * // => false - */ - hasIn( - object: T, - path: StringRepresentable | StringRepresentable[] - ): boolean; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.hasIn - */ - hasIn(path: StringRepresentable | StringRepresentable[]): boolean; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.hasIn - */ - hasIn(path: StringRepresentable | StringRepresentable[]): LoDashExplicitWrapper; - } - - // _.invert - interface LoDashStatic { - /** - * Creates an object composed of the inverted keys and values of object. If object contains duplicate values, - * subsequent values overwrite property assignments of previous values unless multiValue is true. - * - * @param object The object to invert. - * @param multiValue Allow multiple values per key. - * @return Returns the new inverted object. - */ - invert( - object: T, - multiValue?: boolean - ): TResult; - - /** - * @see _.invert - */ - invert( - object: Object, - multiValue?: boolean - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.invert - */ - invert(multiValue?: boolean): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.invert - */ - invert(multiValue?: boolean): LoDashExplicitObjectWrapper; - } - - // _.inverBy - interface InvertByIterator { - (value: T): any; - } - - interface LoDashStatic { - /** - * This method is like _.invert except that the inverted object is generated from the results of running each - * element of object through iteratee. The corresponding inverted value of each inverted key is an array of - * keys responsible for generating the inverted value. The iteratee is invoked with one argument: (value). - * - * @param object The object to invert. - * @param interatee The iteratee invoked per element. - * @return Returns the new inverted object. - */ - invertBy( - object: Object, - interatee?: InvertByIterator | string - ): Dictionary; - - /** - * @see _.invertBy - */ - invertBy( - object: _.Dictionary | _.NumericDictionary, - interatee?: InvertByIterator | string - ): Dictionary; - - /** - * @see _.invertBy - */ - invertBy( - object: Object, - interatee?: W - ): Dictionary; - - /** - * @see _.invertBy - */ - invertBy( - object: _.Dictionary, - interatee?: W - ): Dictionary; - } - - interface LoDashImplicitWrapper { - /** - * @see _.invertBy - */ - invertBy( - interatee?: InvertByIterator - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.invertBy - */ - invertBy( - interatee?: InvertByIterator | string - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.invertBy - */ - invertBy( - interatee?: W - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.invertBy - */ - invertBy( - interatee?: InvertByIterator | string - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.invertBy - */ - invertBy( - interatee?: W - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashExplicitWrapper { - /** - * @see _.invertBy - */ - invertBy( - interatee?: InvertByIterator - ): LoDashExplicitObjectWrapper>; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.invertBy - */ - invertBy( - interatee?: InvertByIterator | string - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.invertBy - */ - invertBy( - interatee?: W - ): LoDashExplicitObjectWrapper>; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.invertBy - */ - invertBy( - interatee?: InvertByIterator | string - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.invertBy - */ - invertBy( - interatee?: W - ): LoDashExplicitObjectWrapper>; - } - - // _.keys - interface LoDashStatic { - /** - * Creates an array of the own enumerable property names of object. - * - * Note: Non-object values are coerced to objects. See the ES spec for more details. - * - * @param object The object to query. - * @return Returns the array of property names. - */ - keys(object?: any): string[]; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.keys - */ - keys(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.keys - */ - keys(): LoDashExplicitArrayWrapper; - } - - // _.keysIn - interface LoDashStatic { - /** - * Creates an array of the own and inherited enumerable property names of object. - * - * Note: Non-object values are coerced to objects. - * - * @param object The object to query. - * @return An array of property names. - */ - keysIn(object?: any): string[]; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.keysIn - */ - keysIn(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.keysIn - */ - keysIn(): LoDashExplicitArrayWrapper; - } - - // _.mapKeys - interface LoDashStatic { - /** - * The opposite of _.mapValues; this method creates an object with the same values as object and keys generated - * by running each own enumerable property of object through iteratee. - * - * @param object The object to iterate over. - * @param iteratee The function invoked per iteration. - * @param thisArg The this binding of iteratee. - * @return Returns the new mapped object. - */ - mapKeys( - object: List, - iteratee?: ListIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.mapKeys - */ - mapKeys( - object: Dictionary, - iteratee?: DictionaryIterator, - thisArg?: any - ): Dictionary; - - /** - * @see _.mapKeys - */ - mapKeys( - object: List | Dictionary, - iteratee?: TObject - ): Dictionary; - - /** - * @see _.mapKeys - */ - mapKeys( - object: List | Dictionary, - iteratee?: string, - thisArg?: any - ): Dictionary; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.mapKeys - */ - mapKeys( - iteratee?: ListIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.mapKeys - */ - mapKeys( - iteratee?: TObject - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.mapKeys - */ - mapKeys( - iteratee?: string, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.mapKeys - */ - mapKeys( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.mapKeys - */ - mapKeys( - iteratee?: TObject - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.mapKeys - */ - mapKeys( - iteratee?: string, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.mapKeys - */ - mapKeys( - iteratee?: ListIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.mapKeys - */ - mapKeys( - iteratee?: TObject - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.mapKeys - */ - mapKeys( - iteratee?: string, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.mapKeys - */ - mapKeys( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.mapKeys - */ - mapKeys( - iteratee?: TObject - ): LoDashExplicitObjectWrapper>; - - /** - * @see _.mapKeys - */ - mapKeys( - iteratee?: string, - thisArg?: any - ): LoDashExplicitObjectWrapper>; - } - - // _.mapValues - interface LoDashStatic { - /** - * Creates an object with the same keys as object and values generated by running each own - * enumerable property of object through iteratee. The iteratee function is bound to thisArg - * and invoked with three arguments: (value, key, object). - * - * If a property name is provided iteratee the created "_.property" style callback returns - * the property value of the given element. - * - * If a value is also provided for thisArg the creted "_.matchesProperty" style callback returns - * true for elements that have a matching property value, else false;. - * - * If an object is provided for iteratee the created "_.matches" style callback returns true - * for elements that have the properties of the given object, else false. - * - * @param {Object} object The object to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. - * @param {Object} [thisArg] The `this` binding of `iteratee`. - * @return {Object} Returns the new mapped object. - */ - mapValues(obj: Dictionary, callback: ObjectIterator, thisArg?: any): Dictionary; - mapValues(obj: Dictionary, where: Dictionary): Dictionary; - mapValues(obj: T, pluck: string): TMapped; - mapValues(obj: T, callback: ObjectIterator, thisArg?: any): T; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.mapValues - * TValue is the type of the property values of T. - * TResult is the type output by the ObjectIterator function - */ - mapValues(callback: ObjectIterator, thisArg?: any): LoDashImplicitObjectWrapper>; - - /** - * @see _.mapValues - * TResult is the type of the property specified by pluck. - * T should be a Dictionary> - */ - mapValues(pluck: string): LoDashImplicitObjectWrapper>; - - /** - * @see _.mapValues - * TResult is the type of the properties on the object specified by pluck. - * T should be a Dictionary>> - */ - mapValues(pluck: string, where: Dictionary): LoDashImplicitArrayWrapper>; - - /** - * @see _.mapValues - * TResult is the type of the properties of each object in the values of T - * T should be a Dictionary> - */ - mapValues(where: Dictionary): LoDashImplicitArrayWrapper; - } - - // _.merge - interface LoDashStatic { - /** - * Recursively merges own and inherited enumerable properties of source - * objects into the destination object, skipping source properties that resolve - * to `undefined`. Array and plain object properties are merged recursively. - * Other objects and value types are overridden by assignment. Source objects - * are applied from left to right. Subsequent sources overwrite property - * assignments of previous sources. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @example - * - * var users = { - * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }] - * }; - * - * var ages = { - * 'data': [{ 'age': 36 }, { 'age': 40 }] - * }; - * - * _.merge(users, ages); - * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] } - */ - merge( - object: TObject, - source: TSource - ): TObject & TSource; - - /** - * @see _.merge - */ - merge( - object: TObject, - source1: TSource1, - source2: TSource2 - ): TObject & TSource1 & TSource2; - - /** - * @see _.merge - */ - merge( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3 - ): TObject & TSource1 & TSource2 & TSource3; - - /** - * @see _.merge - */ - merge( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4 - ): TObject & TSource1 & TSource2 & TSource3 & TSource4; - - /** - * @see _.merge - */ - merge( - object: any, - ...otherArgs: any[] - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.merge - */ - merge( - source: TSource - ): LoDashImplicitObjectWrapper; - - /** - * @see _.merge - */ - merge( - source1: TSource1, - source2: TSource2 - ): LoDashImplicitObjectWrapper; - - /** - * @see _.merge - */ - merge( - source1: TSource1, - source2: TSource2, - source3: TSource3 - ): LoDashImplicitObjectWrapper; - - /** - * @see _.merge - */ - merge( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4 - ): LoDashImplicitObjectWrapper; - - /** - * @see _.merge - */ - merge( - ...otherArgs: any[] - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.merge - */ - merge( - source: TSource - ): LoDashExplicitObjectWrapper; - - /** - * @see _.merge - */ - merge( - source1: TSource1, - source2: TSource2 - ): LoDashExplicitObjectWrapper; - - /** - * @see _.merge - */ - merge( - source1: TSource1, - source2: TSource2, - source3: TSource3 - ): LoDashExplicitObjectWrapper; - - /** - * @see _.merge - */ - merge( - ): LoDashExplicitObjectWrapper; - - /** - * @see _.merge - */ - merge( - ...otherArgs: any[] - ): LoDashExplicitObjectWrapper; - } - - // _.mergeWith - interface MergeWithCustomizer { - (value: any, srcValue: any, key?: string, object?: Object, source?: Object): any; - } - - interface LoDashStatic { - /** - * This method is like `_.merge` except that it accepts `customizer` which - * is invoked to produce the merged values of the destination and source - * properties. If `customizer` returns `undefined` merging is handled by the - * method instead. The `customizer` is invoked with seven arguments: - * (objValue, srcValue, key, object, source, stack). - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} customizer The function to customize assigned values. - * @returns {Object} Returns `object`. - * @example - * - * function customizer(objValue, srcValue) { - * if (_.isArray(objValue)) { - * return objValue.concat(srcValue); - * } - * } - * - * var object = { - * 'fruits': ['apple'], - * 'vegetables': ['beet'] - * }; - * - * var other = { - * 'fruits': ['banana'], - * 'vegetables': ['carrot'] - * }; - * - * _.merge(object, other, customizer); - * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] } - */ - mergeWith( - object: TObject, - source: TSource, - customizer: MergeWithCustomizer - ): TObject & TSource; - - /** - * @see _.mergeWith - */ - mergeWith( - object: TObject, - source1: TSource1, - source2: TSource2, - customizer: MergeWithCustomizer - ): TObject & TSource1 & TSource2; - - /** - * @see _.mergeWith - */ - mergeWith( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3, - customizer: MergeWithCustomizer - ): TObject & TSource1 & TSource2 & TSource3; - - /** - * @see _.mergeWith - */ - mergeWith( - object: TObject, - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer: MergeWithCustomizer - ): TObject & TSource1 & TSource2 & TSource3 & TSource4; - - /** - * @see _.mergeWith - */ - mergeWith( - object: any, - ...otherArgs: any[] - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.mergeWith - */ - mergeWith( - source: TSource, - customizer: MergeWithCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see _.mergeWith - */ - mergeWith( - source1: TSource1, - source2: TSource2, - customizer: MergeWithCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see _.mergeWith - */ - mergeWith( - source1: TSource1, - source2: TSource2, - source3: TSource3, - customizer: MergeWithCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see _.mergeWith - */ - mergeWith( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4, - customizer: MergeWithCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see _.mergeWith - */ - mergeWith( - ...otherArgs: any[] - ): LoDashImplicitObjectWrapper; - } - - // _.omit - interface LoDashStatic { - /** - * The opposite of `_.pick`; this method creates an object composed of the - * own and inherited enumerable properties of `object` that are not omitted. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {...(string|string[])} [props] The property names to omit, specified - * individually or in arrays.. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; - * - * _.omit(object, ['a', 'c']); - * // => { 'b': '2' } - */ - - omit( - object: T, - ...predicate: (StringRepresentable | StringRepresentable[])[] - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - - /** - * @see _.omit - */ - omit( - ...predicate: (StringRepresentable | StringRepresentable[])[] - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - - /** - * @see _.omit - */ - omit( - ...predicate: (StringRepresentable | StringRepresentable[])[] - ): LoDashExplicitObjectWrapper; - } - - // _.omitBy - interface LoDashStatic { - /** - * The opposite of `_.pickBy`; this method creates an object composed of the - * own and inherited enumerable properties of `object` that `predicate` - * doesn't return truthy for. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per property. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; - * - * _.omitBy(object, _.isNumber); - * // => { 'b': '2' } - */ - omitBy( - object: T, - predicate: ObjectIterator - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.omitBy - */ - omitBy( - predicate: ObjectIterator - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.omitBy - */ - omitBy( - predicate: ObjectIterator - ): LoDashExplicitObjectWrapper; - } - - // _.pick - interface LoDashStatic { - /** - * Creates an object composed of the picked `object` properties. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {...(string|string[])} [props] The property names to pick, specified - * individually or in arrays. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; - * - * _.pick(object, ['a', 'c']); - * // => { 'a': 1, 'c': 3 } - */ - pick( - object: T, - ...predicate: (StringRepresentable | StringRepresentable[])[] - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.pick - */ - pick( - ...predicate: (StringRepresentable | StringRepresentable[])[] - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.pick - */ - pick( - ...predicate: (StringRepresentable | StringRepresentable[])[] - ): LoDashExplicitObjectWrapper; - } - - // _.pickBy - interface LoDashStatic { - /** - * Creates an object composed of the `object` properties `predicate` returns - * truthy for. The predicate is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {Function|Object|string} [predicate=_.identity] The function invoked per property. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; - * - * _.pickBy(object, _.isNumber); - * // => { 'a': 1, 'c': 3 } - */ - pickBy( - object: T, - predicate: ObjectIterator - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.pickBy - */ - pickBy( - predicate: ObjectIterator - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.pickBy - */ - pickBy( - predicate: ObjectIterator - ): LoDashExplicitObjectWrapper; - } - - // _.result - interface LoDashStatic { - /** - * This method is like _.get except that if the resolved value is a function it’s invoked with the this binding - * of its parent object and its result is returned. - * - * @param object The object to query. - * @param path The path of the property to resolve. - * @param defaultValue The value returned if the resolved value is undefined. - * @return Returns the resolved value. - */ - result( - object: TObject, - path: number | string | boolean | Array, - defaultValue?: TResult - ): TResult; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.result - */ - result( - path: number | string | boolean | Array, - defaultValue?: TResult - ): TResult; - } - - // _.set - interface LoDashStatic { - /** - * Sets the value at path of object. If a portion of path doesn’t exist it’s created. Arrays are created for - * missing index properties while objects are created for all other missing properties. Use _.setWith to - * customize path creation. - * - * @param object The object to modify. - * @param path The path of the property to set. - * @param value The value to set. - * @return Returns object. - */ - set( - object: Object, - path: StringRepresentable | StringRepresentable[], - value: any - ): TResult; - - /** - * @see _.set - */ - set( - object: Object, - path: StringRepresentable | StringRepresentable[], - value: V - ): TResult; - - /** - * @see _.set - */ - set( - object: O, - path: StringRepresentable | StringRepresentable[], - value: V - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.set - */ - set( - path: StringRepresentable | StringRepresentable[], - value: any - ): LoDashImplicitObjectWrapper; - - /** - * @see _.set - */ - set( - path: StringRepresentable | StringRepresentable[], - value: V - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.set - */ - set( - path: StringRepresentable | StringRepresentable[], - value: any - ): LoDashExplicitObjectWrapper; - - /** - * @see _.set - */ - set( - path: StringRepresentable | StringRepresentable[], - value: V - ): LoDashExplicitObjectWrapper; - } - - // _.setWith - interface SetWithCustomizer { - (nsValue: any, key: string, nsObject: T): any; - } - - interface LoDashStatic { - /** - * This method is like _.set except that it accepts customizer which is invoked to produce the objects of - * path. If customizer returns undefined path creation is handled by the method instead. The customizer is - * invoked with three arguments: (nsValue, key, nsObject). - * - * @param object The object to modify. - * @param path The path of the property to set. - * @param value The value to set. - * @parem customizer The function to customize assigned values. - * @return Returns object. - */ - setWith( - object: Object, - path: StringRepresentable | StringRepresentable[], - value: any, - customizer?: SetWithCustomizer - ): TResult; - - /** - * @see _.setWith - */ - setWith( - object: Object, - path: StringRepresentable | StringRepresentable[], - value: V, - customizer?: SetWithCustomizer - ): TResult; - - /** - * @see _.setWith - */ - setWith( - object: O, - path: StringRepresentable | StringRepresentable[], - value: V, - customizer?: SetWithCustomizer - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.setWith - */ - setWith( - path: StringRepresentable | StringRepresentable[], - value: any, - customizer?: SetWithCustomizer - ): LoDashImplicitObjectWrapper; - - /** - * @see _.setWith - */ - setWith( - path: StringRepresentable | StringRepresentable[], - value: V, - customizer?: SetWithCustomizer - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.setWith - */ - setWith( - path: StringRepresentable | StringRepresentable[], - value: any, - customizer?: SetWithCustomizer - ): LoDashExplicitObjectWrapper; - - /** - * @see _.setWith - */ - setWith( - path: StringRepresentable | StringRepresentable[], - value: V, - customizer?: SetWithCustomizer - ): LoDashExplicitObjectWrapper; - } - - // _.toPairs - interface LoDashStatic { - /** - * Creates an array of own enumerable key-value pairs for object. - * - * @param object The object to query. - * @return Returns the new array of key-value pairs. - */ - toPairs(object?: T): any[][]; - - toPairs(object?: T): TResult[][]; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.toPairs - */ - toPairs(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.toPairs - */ - toPairs(): LoDashExplicitArrayWrapper; - } - - // _.toPairsIn - interface LoDashStatic { - /** - * Creates an array of own and inherited enumerable key-value pairs for object. - * - * @param object The object to query. - * @return Returns the new array of key-value pairs. - */ - toPairsIn(object?: T): any[][]; - - toPairsIn(object?: T): TResult[][]; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.toPairsIn - */ - toPairsIn(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.toPairsIn - */ - toPairsIn(): LoDashExplicitArrayWrapper; - } - - // _.transform - interface LoDashStatic { - /** - * An alternative to _.reduce; this method transforms object to a new accumulator object which is the result of - * running each of its own enumerable properties through iteratee, with each invocation potentially mutating - * the accumulator object. The iteratee is bound to thisArg and invoked with four arguments: (accumulator, - * value, key, object). Iteratee functions may exit iteration early by explicitly returning false. - * - * @param object The object to iterate over. - * @param iteratee The function invoked per iteration. - * @param accumulator The custom accumulator value. - * @param thisArg The this binding of iteratee. - * @return Returns the accumulated value. - */ - transform( - object: T[], - iteratee?: MemoVoidArrayIterator, - accumulator?: TResult[], - thisArg?: any - ): TResult[]; - - /** - * @see _.transform - */ - transform( - object: T[], - iteratee?: MemoVoidArrayIterator>, - accumulator?: Dictionary, - thisArg?: any - ): Dictionary; - - /** - * @see _.transform - */ - transform( - object: Dictionary, - iteratee?: MemoVoidDictionaryIterator>, - accumulator?: Dictionary, - thisArg?: any - ): Dictionary; - - /** - * @see _.transform - */ - transform( - object: Dictionary, - iteratee?: MemoVoidDictionaryIterator, - accumulator?: TResult[], - thisArg?: any - ): TResult[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.transform - */ - transform( - iteratee?: MemoVoidArrayIterator, - accumulator?: TResult[], - thisArg?: any - ): LoDashImplicitArrayWrapper; - - /** - * @see _.transform - */ - transform( - iteratee?: MemoVoidArrayIterator>, - accumulator?: Dictionary, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.transform - */ - transform( - iteratee?: MemoVoidDictionaryIterator>, - accumulator?: Dictionary, - thisArg?: any - ): LoDashImplicitObjectWrapper>; - - /** - * @see _.transform - */ - transform( - iteratee?: MemoVoidDictionaryIterator, - accumulator?: TResult[], - thisArg?: any - ): LoDashImplicitArrayWrapper; - } - - // _.unset - interface LoDashStatic { - /** - * Removes the property at path of object. - * - * Note: This method mutates object. - * - * @param object The object to modify. - * @param path The path of the property to unset. - * @return Returns true if the property is deleted, else false. - */ - unset( - object: T, - path: StringRepresentable | StringRepresentable[] - ): boolean; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.unset - */ - unset(path: StringRepresentable | StringRepresentable[]): LoDashImplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.unset - */ - unset(path: StringRepresentable | StringRepresentable[]): LoDashExplicitWrapper; - } - - // _.values - interface LoDashStatic { - /** - * Creates an array of the own enumerable property values of object. - * - * @param object The object to query. - * @return Returns an array of property values. - */ - values(object?: any): T[]; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.values - */ - values(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.values - */ - values(): LoDashExplicitArrayWrapper; - } - - // _.valuesIn - interface LoDashStatic { - /** - * Creates an array of the own and inherited enumerable property values of object. - * - * @param object The object to query. - * @return Returns the array of property values. - */ - valuesIn(object?: any): T[]; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.valuesIn - */ - valuesIn(): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.valuesIn - */ - valuesIn(): LoDashExplicitArrayWrapper; - } - - /********** - * String * - *********/ - - // _.camelCase - interface LoDashStatic { - /** - * Converts string to camel case. - * - * @param string The string to convert. - * @return Returns the camel cased string. - */ - camelCase(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.camelCase - */ - camelCase(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.camelCase - */ - camelCase(): LoDashExplicitWrapper; - } - - // _.capitalize - interface LoDashStatic { - /** - * Converts the first character of string to upper case and the remaining to lower case. - * - * @param string The string to capitalize. - * @return Returns the capitalized string. - */ - capitalize(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.capitalize - */ - capitalize(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.capitalize - */ - capitalize(): LoDashExplicitWrapper; - } - - // _.deburr - interface LoDashStatic { - /** - * Deburrs string by converting latin-1 supplementary letters to basic latin letters and removing combining - * diacritical marks. - * - * @param string The string to deburr. - * @return Returns the deburred string. - */ - deburr(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.deburr - */ - deburr(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.deburr - */ - deburr(): LoDashExplicitWrapper; - } - - // _.endsWith - interface LoDashStatic { - /** - * Checks if string ends with the given target string. - * - * @param string The string to search. - * @param target The string to search for. - * @param position The position to search from. - * @return Returns true if string ends with target, else false. - */ - endsWith( - string?: string, - target?: string, - position?: number - ): boolean; - } - - interface LoDashImplicitWrapper { - /** - * @see _.endsWith - */ - endsWith( - target?: string, - position?: number - ): boolean; - } - - interface LoDashExplicitWrapper { - /** - * @see _.endsWith - */ - endsWith( - target?: string, - position?: number - ): LoDashExplicitWrapper; - } - - // _.escape - interface LoDashStatic { - /** - * Converts the characters "&", "<", ">", '"', "'", and "`" in string to their corresponding HTML entities. - * - * Note: No other characters are escaped. To escape additional characters use a third-party library like he. - * - * hough the ">" character is escaped for symmetry, characters like ">" and "/" don’t need escaping in HTML - * and have no special meaning unless they're part of a tag or unquoted attribute value. See Mathias Bynens’s - * article (under "semi-related fun fact") for more details. - * - * Backticks are escaped because in IE < 9, they can break out of attribute values or HTML comments. See #59, - * #102, #108, and #133 of the HTML5 Security Cheatsheet for more details. - * - * When working with HTML you should always quote attribute values to reduce XSS vectors. - * - * @param string The string to escape. - * @return Returns the escaped string. - */ - escape(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.escape - */ - escape(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.escape - */ - escape(): LoDashExplicitWrapper; - } - - // _.escapeRegExp - interface LoDashStatic { - /** - * Escapes the RegExp special characters "^", "$", "\", ".", "*", "+", "?", "(", ")", "[", "]", - * "{", "}", and "|" in string. - * - * @param string The string to escape. - * @return Returns the escaped string. - */ - escapeRegExp(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.escapeRegExp - */ - escapeRegExp(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.escapeRegExp - */ - escapeRegExp(): LoDashExplicitWrapper; - } - - // _.kebabCase - interface LoDashStatic { - /** - * Converts string to kebab case. - * - * @param string The string to convert. - * @return Returns the kebab cased string. - */ - kebabCase(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.kebabCase - */ - kebabCase(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.kebabCase - */ - kebabCase(): LoDashExplicitWrapper; - } - - // _.lowerCase - interface LoDashStatic { - /** - * Converts `string`, as space separated words, to lower case. - * - * @param string The string to convert. - * @return Returns the lower cased string. - */ - lowerCase(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.lowerCase - */ - lowerCase(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.lowerCase - */ - lowerCase(): LoDashExplicitWrapper; - } - - // _.lowerFirst - interface LoDashStatic { - /** - * Converts the first character of `string` to lower case. - * - * @param string The string to convert. - * @return Returns the converted string. - */ - lowerFirst(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.lowerFirst - */ - lowerFirst(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.lowerFirst - */ - lowerFirst(): LoDashExplicitWrapper; - } - - // _.pad - interface LoDashStatic { - /** - * Pads string on the left and right sides if it’s shorter than length. Padding characters are truncated if - * they can’t be evenly divided by length. - * - * @param string The string to pad. - * @param length The padding length. - * @param chars The string used as padding. - * @return Returns the padded string. - */ - pad( - string?: string, - length?: number, - chars?: string - ): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.pad - */ - pad( - length?: number, - chars?: string - ): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.pad - */ - pad( - length?: number, - chars?: string - ): LoDashExplicitWrapper; - } - - // _.padEnd - interface LoDashStatic { - /** - * Pads string on the right side if it’s shorter than length. Padding characters are truncated if they exceed - * length. - * - * @param string The string to pad. - * @param length The padding length. - * @param chars The string used as padding. - * @return Returns the padded string. - */ - padEnd( - string?: string, - length?: number, - chars?: string - ): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.padEnd - */ - padEnd( - length?: number, - chars?: string - ): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.padEnd - */ - padEnd( - length?: number, - chars?: string - ): LoDashExplicitWrapper; - } - - // _.padStart - interface LoDashStatic { - /** - * Pads string on the left side if it’s shorter than length. Padding characters are truncated if they exceed - * length. - * - * @param string The string to pad. - * @param length The padding length. - * @param chars The string used as padding. - * @return Returns the padded string. - */ - padStart( - string?: string, - length?: number, - chars?: string - ): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.padStart - */ - padStart( - length?: number, - chars?: string - ): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.padStart - */ - padStart( - length?: number, - chars?: string - ): LoDashExplicitWrapper; - } - - // _.parseInt - interface LoDashStatic { - /** - * Converts string to an integer of the specified radix. If radix is undefined or 0, a radix of 10 is used - * unless value is a hexadecimal, in which case a radix of 16 is used. - * - * Note: This method aligns with the ES5 implementation of parseInt. - * - * @param string The string to convert. - * @param radix The radix to interpret value by. - * @return Returns the converted integer. - */ - parseInt( - string: string, - radix?: number - ): number; - } - - interface LoDashImplicitWrapper { - /** - * @see _.parseInt - */ - parseInt(radix?: number): number; - } - - interface LoDashExplicitWrapper { - /** - * @see _.parseInt - */ - parseInt(radix?: number): LoDashExplicitWrapper; - } - - // _.repeat - interface LoDashStatic { - /** - * Repeats the given string n times. - * - * @param string The string to repeat. - * @param n The number of times to repeat the string. - * @return Returns the repeated string. - */ - repeat( - string?: string, - n?: number - ): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.repeat - */ - repeat(n?: number): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.repeat - */ - repeat(n?: number): LoDashExplicitWrapper; - } - - // _.replace - interface LoDashStatic { - /** - * Replaces matches for pattern in string with replacement. - * - * Note: This method is based on String#replace. - * - * @param string - * @param pattern - * @param replacement - * @return Returns the modified string. - */ - replace( - string: string, - pattern: RegExp | string, - replacement: Function | string - ): string; - - /** - * @see _.replace - */ - replace( - pattern?: RegExp | string, - replacement?: Function | string - ): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.replace - */ - replace( - pattern?: RegExp | string, - replacement?: Function | string - ): string; - - /** - * @see _.replace - */ - replace( - replacement?: Function | string - ): string; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.replace - */ - replace( - pattern?: RegExp | string, - replacement?: Function | string - ): string; - - /** - * @see _.replace - */ - replace( - replacement?: Function | string - ): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.replace - */ - replace( - pattern?: RegExp | string, - replacement?: Function | string - ): LoDashExplicitWrapper; - - /** - * @see _.replace - */ - replace( - replacement?: Function | string - ): LoDashExplicitWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.replace - */ - replace( - pattern?: RegExp | string, - replacement?: Function | string - ): LoDashExplicitWrapper; - - /** - * @see _.replace - */ - replace( - replacement?: Function | string - ): LoDashExplicitWrapper; - } - - // _.snakeCase - interface LoDashStatic { - /** - * Converts string to snake case. - * - * @param string The string to convert. - * @return Returns the snake cased string. - */ - snakeCase(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.snakeCase - */ - snakeCase(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.snakeCase - */ - snakeCase(): LoDashExplicitWrapper; - } - - // _.split - interface LoDashStatic { - /** - * Splits string by separator. - * - * Note: This method is based on String#split. - * - * @param string - * @param separator - * @param limit - * @return Returns the new array of string segments. - */ - split( - string: string, - separator?: RegExp | string, - limit?: number - ): string[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.split - */ - split( - separator?: RegExp | string, - limit?: number - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.split - */ - split( - separator?: RegExp | string, - limit?: number - ): LoDashExplicitArrayWrapper; - } - - // _.startCase - interface LoDashStatic { - /** - * Converts string to start case. - * - * @param string The string to convert. - * @return Returns the start cased string. - */ - startCase(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.startCase - */ - startCase(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.startCase - */ - startCase(): LoDashExplicitWrapper; - } - - // _.startsWith - interface LoDashStatic { - /** - * Checks if string starts with the given target string. - * - * @param string The string to search. - * @param target The string to search for. - * @param position The position to search from. - * @return Returns true if string starts with target, else false. - */ - startsWith( - string?: string, - target?: string, - position?: number - ): boolean; - } - - interface LoDashImplicitWrapper { - /** - * @see _.startsWith - */ - startsWith( - target?: string, - position?: number - ): boolean; - } - - interface LoDashExplicitWrapper { - /** - * @see _.startsWith - */ - startsWith( - target?: string, - position?: number - ): LoDashExplicitWrapper; - } - - // _.template - interface TemplateOptions extends TemplateSettings { - /** - * The sourceURL of the template's compiled source. - */ - sourceURL?: string; - } - - interface TemplateExecutor { - (data?: Object): string; - source: string; - } - - interface LoDashStatic { - /** - * Creates a compiled template function that can interpolate data properties in "interpolate" delimiters, - * HTML-escape interpolated data properties in "escape" delimiters, and execute JavaScript in "evaluate" - * delimiters. Data properties may be accessed as free variables in the template. If a setting object is - * provided it takes precedence over _.templateSettings values. - * - * Note: In the development build _.template utilizes - * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) for easier - * debugging. - * - * For more information on precompiling templates see - * [lodash's custom builds documentation](https://lodash.com/custom-builds). - * - * For more information on Chrome extension sandboxes see - * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). - * - * @param string The template string. - * @param options The options object. - * @param options.escape The HTML "escape" delimiter. - * @param options.evaluate The "evaluate" delimiter. - * @param options.imports An object to import into the template as free variables. - * @param options.interpolate The "interpolate" delimiter. - * @param options.sourceURL The sourceURL of the template's compiled source. - * @param options.variable The data object variable name. - * @return Returns the compiled template function. - */ - template( - string: string, - options?: TemplateOptions - ): TemplateExecutor; - } - - interface LoDashImplicitWrapper { - /** - * @see _.template - */ - template(options?: TemplateOptions): TemplateExecutor; - } - - interface LoDashExplicitWrapper { - /** - * @see _.template - */ - template(options?: TemplateOptions): LoDashExplicitObjectWrapper; - } - - // _.toLower - interface LoDashStatic { - /** - * Converts `string`, as a whole, to lower case. - * - * @param string The string to convert. - * @return Returns the lower cased string. - */ - toLower(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.toLower - */ - toLower(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.toLower - */ - toLower(): LoDashExplicitWrapper; - } - - // _.toUpper - interface LoDashStatic { - /** - * Converts `string`, as a whole, to upper case. - * - * @param string The string to convert. - * @return Returns the upper cased string. - */ - toUpper(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.toUpper - */ - toUpper(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.toUpper - */ - toUpper(): LoDashExplicitWrapper; - } - - // _.trim - interface LoDashStatic { - /** - * Removes leading and trailing whitespace or specified characters from string. - * - * @param string The string to trim. - * @param chars The characters to trim. - * @return Returns the trimmed string. - */ - trim( - string?: string, - chars?: string - ): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.trim - */ - trim(chars?: string): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.trim - */ - trim(chars?: string): LoDashExplicitWrapper; - } - - // _.trimEnd - interface LoDashStatic { - /** - * Removes trailing whitespace or specified characters from string. - * - * @param string The string to trim. - * @param chars The characters to trim. - * @return Returns the trimmed string. - */ - trimEnd( - string?: string, - chars?: string - ): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.trimEnd - */ - trimEnd(chars?: string): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.trimEnd - */ - trimEnd(chars?: string): LoDashExplicitWrapper; - } - - // _.trimStart - interface LoDashStatic { - /** - * Removes leading whitespace or specified characters from string. - * - * @param string The string to trim. - * @param chars The characters to trim. - * @return Returns the trimmed string. - */ - trimStart( - string?: string, - chars?: string - ): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.trimStart - */ - trimStart(chars?: string): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.trimStart - */ - trimStart(chars?: string): LoDashExplicitWrapper; - } - - // _.truncate - interface TruncateOptions { - /** The maximum string length. */ - length?: number; - /** The string to indicate text is omitted. */ - omission?: string; - /** The separator pattern to truncate to. */ - separator?: string | RegExp; - } - - interface LoDashStatic { - /** - * Truncates string if it’s longer than the given maximum string length. The last characters of the truncated - * string are replaced with the omission string which defaults to "…". - * - * @param string The string to truncate. - * @param options The options object or maximum string length. - * @return Returns the truncated string. - */ - truncate( - string?: string, - options?: TruncateOptions - ): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.truncate - */ - truncate(options?: TruncateOptions): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.truncate - */ - truncate(options?: TruncateOptions): LoDashExplicitWrapper; - } - - // _.unescape - interface LoDashStatic { - /** - * The inverse of _.escape; this method converts the HTML entities &, <, >, ", ', and ` - * in string to their corresponding characters. - * - * Note: No other HTML entities are unescaped. To unescape additional HTML entities use a third-party library - * like he. - * - * @param string The string to unescape. - * @return Returns the unescaped string. - */ - unescape(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.unescape - */ - unescape(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.unescape - */ - unescape(): LoDashExplicitWrapper; - } - - // _.upperCase - interface LoDashStatic { - /** - * Converts `string`, as space separated words, to upper case. - * - * @param string The string to convert. - * @return Returns the upper cased string. - */ - upperCase(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.upperCase - */ - upperCase(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.upperCase - */ - upperCase(): LoDashExplicitWrapper; - } - - // _.upperFirst - interface LoDashStatic { - /** - * Converts the first character of `string` to upper case. - * - * @param string The string to convert. - * @return Returns the converted string. - */ - upperFirst(string?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.upperFirst - */ - upperFirst(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.upperFirst - */ - upperFirst(): LoDashExplicitWrapper; - } - - // _.words - interface LoDashStatic { - /** - * Splits `string` into an array of its words. - * - * @param string The string to inspect. - * @param pattern The pattern to match words. - * @return Returns the words of `string`. - */ - words( - string?: string, - pattern?: string | RegExp - ): string[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.words - */ - words(pattern?: string | RegExp): string[]; - } - - interface LoDashExplicitWrapper { - /** - * @see _.words - */ - words(pattern?: string | RegExp): LoDashExplicitArrayWrapper; - } - - /*********** - * Utility * - **********/ - - // _.attempt - interface LoDashStatic { - /** - * Attempts to invoke func, returning either the result or the caught error object. Any additional arguments - * are provided to func when it’s invoked. - * - * @param func The function to attempt. - * @return Returns the func result or error object. - */ - attempt(func: (...args: any[]) => TResult, ...args: any[]): TResult | Error; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.attempt - */ - attempt(...args: any[]): TResult | Error; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.attempt - */ - attempt(...args: any[]): LoDashExplicitObjectWrapper; - } - - // _.constant - interface LoDashStatic { - /** - * Creates a function that returns value. - * - * @param value The value to return from the new function. - * @return Returns the new function. - */ - constant(value: T): () => T; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.constant - */ - constant(): LoDashImplicitObjectWrapper<() => TResult>; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.constant - */ - constant(): LoDashExplicitObjectWrapper<() => TResult>; - } - - // _.identity - interface LoDashStatic { - /** - * This method returns the first argument provided to it. - * @param value Any value. - * @return Returns value. - */ - identity(value?: T): T; - } - - interface LoDashImplicitWrapper { - /** - * @see _.identity - */ - identity(): T; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.identity - */ - identity(): T[]; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.identity - */ - identity(): T; - } - - // _.iteratee - interface LoDashStatic { - /** - * Creates a function that invokes `func` with the arguments of the created - * function. If `func` is a property name the created callback returns the - * property value for a given element. If `func` is an object the created - * callback returns `true` for elements that contain the equivalent object properties, otherwise it returns `false`. - * - * @static - * @memberOf _ - * @category Util - * @param {*} [func=_.identity] The value to convert to a callback. - * @returns {Function} Returns the callback. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; - * - * // create custom iteratee shorthands - * _.iteratee = _.wrap(_.iteratee, function(callback, func) { - * var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func); - * return !p ? callback(func) : function(object) { - * return (p[2] == '>' ? object[p[1]] > p[3] : object[p[1]] < p[3]); - * }; - * }); - * - * _.filter(users, 'age > 36'); - * // => [{ 'user': 'fred', 'age': 40 }] - */ - iteratee( - func: Function, - thisArg?: any - ): (...args: any[]) => TResult; - - /** - * @see _.iteratee - */ - iteratee( - func: string, - thisArg?: any - ): (object: any) => TResult; - - /** - * @see _.iteratee - */ - iteratee( - func: Object, - thisArg?: any - ): (object: any) => boolean; - - /** - * @see _.iteratee - */ - iteratee(): (value: TResult) => TResult; - } - - interface LoDashImplicitWrapper { - /** - * @see _.iteratee - */ - iteratee(thisArg?: any): LoDashImplicitObjectWrapper<(object: any) => TResult>; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.iteratee - */ - iteratee(thisArg?: any): LoDashImplicitObjectWrapper<(object: any) => boolean>; - - /** - * @see _.iteratee - */ - iteratee(thisArg?: any): LoDashImplicitObjectWrapper<(...args: any[]) => TResult>; - } - - interface LoDashExplicitWrapper { - /** - * @see _.iteratee - */ - iteratee(thisArg?: any): LoDashExplicitObjectWrapper<(object: any) => TResult>; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.iteratee - */ - iteratee(thisArg?: any): LoDashExplicitObjectWrapper<(object: any) => boolean>; - - /** - * @see _.iteratee - */ - iteratee(thisArg?: any): LoDashExplicitObjectWrapper<(...args: any[]) => TResult>; - } - - // _.matches - interface LoDashStatic { - /** - * Creates a function that performs a deep comparison between a given object and source, returning true if the - * given object has equivalent property values, else false. - * - * Note: This method supports comparing arrays, booleans, Date objects, numbers, Object objects, regexes, and - * strings. Objects are compared by their own, not inherited, enumerable properties. For comparing a single own - * or inherited property value see _.matchesProperty. - * - * @param source The object of property values to match. - * @return Returns the new function. - */ - matches(source: T): (value: any) => boolean; - - /** - * @see _.matches - */ - matches(source: T): (value: V) => boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.matches - */ - matches(): LoDashImplicitObjectWrapper<(value: V) => boolean>; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.matches - */ - matches(): LoDashExplicitObjectWrapper<(value: V) => boolean>; - } - - // _.matchesProperty - interface LoDashStatic { - /** - * Creates a function that compares the property value of path on a given object to value. - * - * Note: This method supports comparing arrays, booleans, Date objects, numbers, Object objects, regexes, and - * strings. Objects are compared by their own, not inherited, enumerable properties. - * - * @param path The path of the property to get. - * @param srcValue The value to match. - * @return Returns the new function. - */ - matchesProperty( - path: StringRepresentable | StringRepresentable[], - srcValue: T - ): (value: any) => boolean; - - /** - * @see _.matchesProperty - */ - matchesProperty( - path: StringRepresentable | StringRepresentable[], - srcValue: T - ): (value: V) => boolean; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.matchesProperty - */ - matchesProperty( - srcValue: SrcValue - ): LoDashImplicitObjectWrapper<(value: any) => boolean>; - - /** - * @see _.matchesProperty - */ - matchesProperty( - srcValue: SrcValue - ): LoDashImplicitObjectWrapper<(value: Value) => boolean>; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.matchesProperty - */ - matchesProperty( - srcValue: SrcValue - ): LoDashExplicitObjectWrapper<(value: any) => boolean>; - - /** - * @see _.matchesProperty - */ - matchesProperty( - srcValue: SrcValue - ): LoDashExplicitObjectWrapper<(value: Value) => boolean>; - } - - // _.method - interface LoDashStatic { - /** - * Creates a function that invokes the method at path on a given object. Any additional arguments are provided - * to the invoked method. - * - * @param path The path of the method to invoke. - * @param args The arguments to invoke the method with. - * @return Returns the new function. - */ - method( - path: string | StringRepresentable[], - ...args: any[] - ): (object: TObject) => TResult; - - /** - * @see _.method - */ - method( - path: string | StringRepresentable[], - ...args: any[] - ): (object: any) => TResult; - } - - interface LoDashImplicitWrapper { - /** - * @see _.method - */ - method(...args: any[]): LoDashImplicitObjectWrapper<(object: TObject) => TResult>; - - /** - * @see _.method - */ - method(...args: any[]): LoDashImplicitObjectWrapper<(object: any) => TResult>; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.method - */ - method(...args: any[]): LoDashImplicitObjectWrapper<(object: TObject) => TResult>; - - /** - * @see _.method - */ - method(...args: any[]): LoDashImplicitObjectWrapper<(object: any) => TResult>; - } - - interface LoDashExplicitWrapper { - /** - * @see _.method - */ - method(...args: any[]): LoDashExplicitObjectWrapper<(object: TObject) => TResult>; - - /** - * @see _.method - */ - method(...args: any[]): LoDashExplicitObjectWrapper<(object: any) => TResult>; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.method - */ - method(...args: any[]): LoDashExplicitObjectWrapper<(object: TObject) => TResult>; - - /** - * @see _.method - */ - method(...args: any[]): LoDashExplicitObjectWrapper<(object: any) => TResult>; - } - - // _.methodOf - interface LoDashStatic { - /** - * The opposite of _.method; this method creates a function that invokes the method at a given path on object. - * Any additional arguments are provided to the invoked method. - * - * @param object The object to query. - * @param args The arguments to invoke the method with. - * @return Returns the new function. - */ - methodOf( - object: TObject, - ...args: any[] - ): (path: StringRepresentable | StringRepresentable[]) => TResult; - - /** - * @see _.methodOf - */ - methodOf( - object: {}, - ...args: any[] - ): (path: StringRepresentable | StringRepresentable[]) => TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.methodOf - */ - methodOf( - ...args: any[] - ): LoDashImplicitObjectWrapper<(path: StringRepresentable | StringRepresentable[]) => TResult>; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.methodOf - */ - methodOf( - ...args: any[] - ): LoDashExplicitObjectWrapper<(path: StringRepresentable | StringRepresentable[]) => TResult>; - } - - // _.mixin - interface MixinOptions { - chain?: boolean; - } - - interface LoDashStatic { - /** - * Adds all own enumerable function properties of a source object to the destination object. If object is a - * function then methods are added to its prototype as well. - * - * Note: Use _.runInContext to create a pristine lodash function to avoid conflicts caused by modifying - * the original. - * - * @param object The destination object. - * @param source The object of functions to add. - * @param options The options object. - * @param options.chain Specify whether the functions added are chainable. - * @return Returns object. - */ - mixin( - object: TObject, - source: Dictionary, - options?: MixinOptions - ): TResult; - - /** - * @see _.mixin - */ - mixin( - source: Dictionary, - options?: MixinOptions - ): TResult; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.mixin - */ - mixin( - source: Dictionary, - options?: MixinOptions - ): LoDashImplicitObjectWrapper; - - /** - * @see _.mixin - */ - mixin( - options?: MixinOptions - ): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.mixin - */ - mixin( - source: Dictionary, - options?: MixinOptions - ): LoDashExplicitObjectWrapper; - - /** - * @see _.mixin - */ - mixin( - options?: MixinOptions - ): LoDashExplicitObjectWrapper; - } - - // _.noConflict - interface LoDashStatic { - /** - * Reverts the _ variable to its previous value and returns a reference to the lodash function. - * - * @return Returns the lodash function. - */ - noConflict(): typeof _; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.noConflict - */ - noConflict(): typeof _; - } - - // _.noop - interface LoDashStatic { - /** - * A no-operation function that returns undefined regardless of the arguments it receives. - * - * @return undefined - */ - noop(...args: any[]): void; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.noop - */ - noop(...args: any[]): void; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.noop - */ - noop(...args: any[]): _.LoDashExplicitWrapper; - } - - // _.nthArg - interface LoDashStatic { - /** - * Creates a function that returns its nth argument. - * - * @param n The index of the argument to return. - * @return Returns the new function. - */ - nthArg(n?: number): TResult; - } - - interface LoDashImplicitWrapper { - /** - * @see _.nthArg - */ - nthArg(): LoDashImplicitObjectWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.nthArg - */ - nthArg(): LoDashExplicitObjectWrapper; - } - - // _.over - interface LoDashStatic { - /** - * Creates a function that invokes iteratees with the arguments provided to the created function and returns - * their results. - * - * @param iteratees The iteratees to invoke. - * @return Returns the new function. - */ - over(...iteratees: (Function | Function[])[]): (...args: any[]) => TResult[]; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.over - */ - over(...iteratees: (Function | Function[])[]): LoDashImplicitObjectWrapper<(...args: any[]) => TResult[]>; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.over - */ - over(...iteratees: (Function | Function[])[]): LoDashImplicitObjectWrapper<(...args: any[]) => TResult[]>; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.over - */ - over(...iteratees: (Function | Function[])[]): LoDashExplicitObjectWrapper<(...args: any[]) => TResult[]>; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.over - */ - over(...iteratees: (Function | Function[])[]): LoDashExplicitObjectWrapper<(...args: any[]) => TResult[]>; - } - - // _.overEvery - interface LoDashStatic { - /** - * Creates a function that checks if all of the predicates return truthy when invoked with the arguments - * provided to the created function. - * - * @param predicates The predicates to check. - * @return Returns the new function. - */ - overEvery(...predicates: (Function | Function[])[]): (...args: any[]) => boolean; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.overEvery - */ - overEvery(...predicates: (Function | Function[])[]): LoDashImplicitObjectWrapper<(...args: any[]) => boolean>; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.overEvery - */ - overEvery(...predicates: (Function | Function[])[]): LoDashImplicitObjectWrapper<(...args: any[]) => boolean>; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.overEvery - */ - overEvery(...predicates: (Function | Function[])[]): LoDashExplicitObjectWrapper<(...args: any[]) => boolean>; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.overEvery - */ - overEvery(...predicates: (Function | Function[])[]): LoDashExplicitObjectWrapper<(...args: any[]) => boolean>; - } - - // _.overSome - interface LoDashStatic { - /** - * Creates a function that checks if any of the predicates return truthy when invoked with the arguments - * provided to the created function. - * - * @param predicates The predicates to check. - * @return Returns the new function. - */ - overSome(...predicates: (Function | Function[])[]): (...args: any[]) => boolean; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.overSome - */ - overSome(...predicates: (Function | Function[])[]): LoDashImplicitObjectWrapper<(...args: any[]) => boolean>; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.overSome - */ - overSome(...predicates: (Function | Function[])[]): LoDashImplicitObjectWrapper<(...args: any[]) => boolean>; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.overSome - */ - overSome(...predicates: (Function | Function[])[]): LoDashExplicitObjectWrapper<(...args: any[]) => boolean>; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.overSome - */ - overSome(...predicates: (Function | Function[])[]): LoDashExplicitObjectWrapper<(...args: any[]) => boolean>; - } - - // _.property - interface LoDashStatic { - /** - * Creates a function that returns the property value at path on a given object. - * - * @param path The path of the property to get. - * @return Returns the new function. - */ - property(path: StringRepresentable | StringRepresentable[]): (obj: TObj) => TResult; - } - - interface LoDashImplicitWrapper { - /** - * @see _.property - */ - property(): LoDashImplicitObjectWrapper<(obj: TObj) => TResult>; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.property - */ - property(): LoDashImplicitObjectWrapper<(obj: TObj) => TResult>; - } - - interface LoDashExplicitWrapper { - /** - * @see _.property - */ - property(): LoDashExplicitObjectWrapper<(obj: TObj) => TResult>; - } - - interface LoDashExplicitArrayWrapper { - /** - * @see _.property - */ - property(): LoDashExplicitObjectWrapper<(obj: TObj) => TResult>; - } - - // _.propertyOf - interface LoDashStatic { - /** - * The opposite of _.property; this method creates a function that returns the property value at a given path - * on object. - * - * @param object The object to query. - * @return Returns the new function. - */ - propertyOf(object: T): (path: string | string[]) => any; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.propertyOf - */ - propertyOf(): LoDashImplicitObjectWrapper<(path: string | string[]) => any>; - } - - interface LoDashExplicitObjectWrapper { - /** - * @see _.propertyOf - */ - propertyOf(): LoDashExplicitObjectWrapper<(path: string | string[]) => any>; - } - - // _.range - interface LoDashStatic { - /** - * Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end. - * If end is not specified it’s set to start with start then set to 0. If end is less than start a zero-length - * range is created unless a negative step is specified. - * - * @param start The start of the range. - * @param end The end of the range. - * @param step The value to increment or decrement by. - * @return Returns a new range array. - */ - range( - start: number, - end: number, - step?: number - ): number[]; - - /** - * @see _.range - */ - range( - end: number, - step?: number - ): number[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.range - */ - range( - end?: number, - step?: number - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.range - */ - range( - end?: number, - step?: number - ): LoDashExplicitArrayWrapper; - } - - // _.rangeRight - interface LoDashStatic { - /** - * This method is like `_.range` except that it populates values in - * descending order. - * - * @static - * @memberOf _ - * @category Util - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @param {number} [step=1] The value to increment or decrement by. - * @returns {Array} Returns the new array of numbers. - * @example - * - * _.rangeRight(4); - * // => [3, 2, 1, 0] - * - * _.rangeRight(-4); - * // => [-3, -2, -1, 0] - * - * _.rangeRight(1, 5); - * // => [4, 3, 2, 1] - * - * _.rangeRight(0, 20, 5); - * // => [15, 10, 5, 0] - * - * _.rangeRight(0, -4, -1); - * // => [-3, -2, -1, 0] - * - * _.rangeRight(1, 4, 0); - * // => [1, 1, 1] - * - * _.rangeRight(0); - * // => [] - */ - rangeRight( - start: number, - end: number, - step?: number - ): number[]; - - /** - * @see _.rangeRight - */ - rangeRight( - end: number, - step?: number - ): number[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.rangeRight - */ - rangeRight( - end?: number, - step?: number - ): LoDashImplicitArrayWrapper; - } - - interface LoDashExplicitWrapper { - /** - * @see _.rangeRight - */ - rangeRight( - end?: number, - step?: number - ): LoDashExplicitArrayWrapper; - } - - // _.runInContext - interface LoDashStatic { - /** - * Create a new pristine lodash function using the given context object. - * - * @param context The context object. - * @return Returns a new lodash function. - */ - runInContext(context?: Object): typeof _; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.runInContext - */ - runInContext(): typeof _; - } - - // _.times - interface LoDashStatic { - /** - * Invokes the iteratee function n times, returning an array of the results of each invocation. The iteratee - * is invoked with one argument; (index). - * - * @param n The number of times to invoke iteratee. - * @param iteratee The function invoked per iteration. - * @return Returns the array of results. - */ - times( - n: number, - iteratee: (num: number) => TResult - ): TResult[]; - - /** - * @see _.times - */ - times(n: number): number[]; - } - - interface LoDashImplicitWrapper { - /** - * @see _.times - */ - times( - iteratee: (num: number) => TResult - ): TResult[]; - - /** - * @see _.times - */ - times(): number[]; - } - - interface LoDashExplicitWrapper { - /** - * @see _.times - */ - times( - iteratee: (num: number) => TResult - ): LoDashExplicitArrayWrapper; - - /** - * @see _.times - */ - times(): LoDashExplicitArrayWrapper; - } - - // _.toPath - interface LoDashStatic { - /** - * Converts `value` to a property path array. - * - * @static - * @memberOf _ - * @category Util - * @param {*} value The value to convert. - * @returns {Array} Returns the new property path array. - * @example - * - * _.toPath('a.b.c'); - * // => ['a', 'b', 'c'] - * - * _.toPath('a[0].b.c'); - * // => ['a', '0', 'b', 'c'] - * - * var path = ['a', 'b', 'c'], - * newPath = _.toPath(path); - * - * console.log(newPath); - * // => ['a', 'b', 'c'] - * - * console.log(path === newPath); - * // => false - */ - toPath(value: any): string[]; - } - - interface LoDashImplicitWrapperBase { - /** - * @see _.toPath - */ - toPath(): LoDashImplicitWrapper; - } - - interface LoDashExplicitWrapperBase { - /** - * @see _.toPath - */ - toPath(): LoDashExplicitWrapper; - } - - // _.uniqueId - interface LoDashStatic { - /** - * Generates a unique ID. If prefix is provided the ID is appended to it. - * - * @param prefix The value to prefix the ID with. - * @return Returns the unique ID. - */ - uniqueId(prefix?: string): string; - } - - interface LoDashImplicitWrapper { - /** - * @see _.uniqueId - */ - uniqueId(): string; - } - - interface LoDashExplicitWrapper { - /** - * @see _.uniqueId - */ - uniqueId(): LoDashExplicitWrapper; - } - - interface ListIterator { - (value: T, index: number, collection: List): TResult; - } - - interface DictionaryIterator { - (value: T, key?: string, collection?: Dictionary): TResult; - } - - interface NumericDictionaryIterator { - (value: T, key?: number, collection?: Dictionary): TResult; - } - - interface ObjectIterator { - (element: T, key?: string, collection?: any): TResult; - } - - interface StringIterator { - (char: string, index?: number, string?: string): TResult; - } - - interface MemoVoidIterator { - (prev: TResult, curr: T, indexOrKey?: any, list?: T[]): void; - } - interface MemoIterator { - (prev: TResult, curr: T, indexOrKey?: any, list?: T[]): TResult; - } - - interface MemoVoidArrayIterator { - (acc: TResult, curr: T, index?: number, arr?: T[]): void; - } - interface MemoVoidDictionaryIterator { - (acc: TResult, curr: T, key?: string, dict?: Dictionary): void; - } - - // interface Collection {} - - // Common interface between Arrays and jQuery objects - interface List { - [index: number]: T; - length: number; - } - - interface Dictionary { - [index: string]: T; - } - - interface NumericDictionary { - [index: number]: T; - } - - interface StringRepresentable { - toString(): string; - } - - interface Cancelable { - cancel(): void; - } -} - -export = _; - -// Backward compatibility with --target es5 -interface Map { } -} -declare module 'lodash/index' { -import alias = require('~lodash/index'); -export = alias; -} -declare module 'lodash' { -import alias = require('~lodash/index'); -export = alias; -} diff --git a/typings/modules/lodash/typings.json b/typings/modules/lodash/typings.json deleted file mode 100644 index efd118e..0000000 --- a/typings/modules/lodash/typings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "resolution": "main", - "tree": { - "src": "https://raw.githubusercontent.com/typed-typings/npm-lodash/7ccf9dc406a792d702067f4eab0fa8df4109fcaa/typings.json", - "raw": "registry:npm/lodash#4.0.0+20160416211519", - "main": "index.d.ts", - "version": "4.0.0", - "global": false, - "name": "lodash", - "type": "typings" - } -} diff --git a/typings/modules/mongodb/index.d.ts b/typings/modules/mongodb/index.d.ts deleted file mode 100644 index ae419a2..0000000 --- a/typings/modules/mongodb/index.d.ts +++ /dev/null @@ -1,1440 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/typed-typings/npm-es6-promise/fb04188767acfec1defd054fc8024fafa5cd4de7/dist/es6-promise.d.ts -declare module '~mongodb~es6-promise/dist/es6-promise' { -export interface Thenable { - then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; - then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Thenable; -} - -export class Promise implements Thenable { - /** - * If you call resolve in the body of the callback passed to the constructor, - * your promise is fulfilled with result object passed to resolve. - * If you call reject your promise is rejected with the object passed to resolve. - * For consistency and debugging (eg stack traces), obj should be an instanceof Error. - * Any errors thrown in the constructor callback will be implicitly passed to reject(). - */ - constructor (callback: (resolve : (value?: R | Thenable) => void, reject: (error?: any) => void) => void); - - /** - * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. - * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. - * Both callbacks have a single parameter , the fulfillment value or rejection reason. - * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. - * If an error is thrown in the callback, the returned promise rejects with that error. - * - * @param onFulfilled called when/if "promise" resolves - * @param onRejected called when/if "promise" rejects - */ - then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise; - then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Promise; - - /** - * Sugar for promise.then(undefined, onRejected) - * - * @param onRejected called when/if "promise" rejects - */ - catch (onRejected?: (error: any) => U | Thenable): Promise; - - /** - * Make a new promise from the thenable. - * A thenable is promise-like in as far as it has a "then" method. - */ - static resolve (): Promise; - static resolve (value: R | Thenable): Promise; - - /** - * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error - */ - static reject (error: any): Promise; - - /** - * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. - * the array passed to all can be a mixture of promise-like objects and other objects. - * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. - */ - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable, T10 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable]): Promise<[T1, T2, T3, T4, T5]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable ]): Promise<[T1, T2, T3, T4]>; - static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable]): Promise<[T1, T2, T3]>; - static all(values: [T1 | Thenable, T2 | Thenable]): Promise<[T1, T2]>; - static all(values: [T1 | Thenable]): Promise<[T1]>; - static all(values: Array>): Promise; - - /** - * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. - */ - static race (promises: (R | Thenable)[]): Promise; -} - -/** - * The polyfill method will patch the global environment (in this case to the Promise name) when called. - */ -export function polyfill (): void; -} -declare module '~mongodb~es6-promise' { -import alias = require('~mongodb~es6-promise/dist/es6-promise'); -export = alias; -} - -// Generated by typings -// Source: https://raw.githubusercontent.com/Think7/typings-mongodb/d4269a9c672ab28a7865b38c8614673e8aecc8e5/mongodb.d.ts -declare module '~mongodb/mongodb' { -// Type definitions for MongoDB v2.1 -// Project: https://github.com/mongodb/node-mongodb-native/tree/2.1 -// Definitions by: Andrew -// Federico Caselli -// Definitions: https://github.com/Think7/typings-mongodb - -// Documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/ - -// Use typings to install this type definition https://github.com/typings/typings - -import {EventEmitter} from 'events'; -import {Promise} from '~mongodb~es6-promise'; - -// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/MongoClient.html -export class MongoClient { - constructor(); - - static connect(uri: string, callback: MongoCallback): void; - static connect(uri: string, options?: MongoClientOptions): Promise; - static connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; - - connect(uri: string, callback: MongoCallback): void; - connect(uri: string, options?: MongoClientOptions): Promise; - connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; -} - -export interface MongoCallback { - (error: MongoError, result: T): void; -} - -// http://mongodb.github.io/node-mongodb-native/2.1/api/MongoError.html -export class MongoError extends Error { - constructor(message: string); - static create(options: Object): MongoError; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/MongoClient.html#.connect -export interface MongoClientOptions { - uri_decode_auth?: boolean; - db?: DbCreateOptions; - server?: ServerOptions; - replSet?: ReplSetOptions; - mongos?: MongosOptions; - promiseLibrary?: Object; -} - -// See : http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html -export interface DbCreateOptions { - authSource?: string; - // the write concern for the operation where < 1 is no acknowlegement of write and w >= 1, w = ‘majority’ or tag acknowledges the write. - w?: number | string; - // set the timeout for waiting for write concern to finish (combines with w option). - wtimeout?: number; - j?: boolean; - // use c++ bson parser. default:false. - native_parser?: boolean; - // force server to create _id fields instead of client. default:false. - forceServerObjectId?: boolean; - serializeFunctions?: boolean; - ignoreUndefined?: boolean; - // peform operations using raw bson buffers. default:false. - raw?: boolean; - // when deserializing a Long will fit it into a Number if it’s smaller than 53 bits. default:true. - promoteLongs?: boolean; - bufferMaxEntries?: number; - // the prefered read preference. use 'ReadPreference' class. - readPreference?: ReadPreference | string; - // custom primary key factory to generate _id values (see Custom primary keys). - pkFactory?: Object; - promiseLibrary?: Object; - readConcern?: { level?: Object }; -} - -// See http://mongodb.github.io/node-mongodb-native/2.1/api/ReadPreference.html -export class ReadPreference { - constructor(mode: string, tags: Object); - mode: string; - tags: any; - static PRIMARY: string; - static PRIMARY_PREFERRED: string; - static SECONDARY: string; - static SECONDARY_PREFERRED: string; - static NEAREST: string; - isValid(mode: string): boolean; - static isValid(mode: string): boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html -export interface SocketOptions { - // Reconnect on error. default:false - autoReconnect?: boolean; - // TCP Socket NoDelay option. default:true - noDelay?: boolean; - // TCP KeepAlive on the socket with a X ms delay before start. default:0 - keepAlive?: number; - // TCP Connection timeout setting. default 0 - connectTimeoutMS?: number; - // TCP Socket timeout setting. default 0 - socketTimeoutMS?: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html -export interface ServerOptions { - // - specify the number of connections in the pool default:5 - poolSize?: number; - ssl?: boolean; - sslValidate?: Object; - checkServerIdentity?: boolean | Function; - sslCA?: Array; - sslCert?: Buffer | string; - sslKey?: Buffer | string; - sslPass?: Buffer | string; - socketOptions?: SocketOptions; - reconnectTries?: number; - reconnectInterval?: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html -export interface ReplSetOptions { - ha?: boolean; - haInterval?: number; - replicaSet?: string; - secondaryAcceptableLatencyMS?: number; - connectWithNoPrimary?: boolean; - // - specify the number of connections in the pool default:5 - poolSize?: number; - ssl?: boolean; - sslValidate?: Object; - checkServerIdentity?: boolean | Function; - sslCA?: Array; - sslCert?: Buffer | string; - sslKey?: Buffer | string; - sslPass?: Buffer | string; - socketOptions?: SocketOptions; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Mongos.html -export interface MongosOptions { - ha?: boolean; - haInterval?: number; - // - specify the number of connections in the pool default:5 - poolSize?: number; - ssl?: boolean; - sslValidate?: Object; - checkServerIdentity?: boolean | Function; - sslCA?: Array; - sslCert?: Buffer | string; - sslKey?: Buffer | string; - sslPass?: Buffer | string; - socketOptions?: SocketOptions; -} - -// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html -export class Db extends EventEmitter { - constructor(databaseName: string, serverConfig: Server | ReplSet | Mongos, options?: DbCreateOptions); - - serverConfig: Server | ReplSet | Mongos; - bufferMaxEntries: number; - databaseName: string; - options: any; - native_parser: boolean; - slaveOk: boolean; - writeConcern: any; - - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser - addUser(username: string, password: string, callback: MongoCallback): void; - addUser(username: string, password: string, options?: DbAddUserOptions): Promise; - addUser(username: string, password: string, options: DbAddUserOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#admin - admin(): Admin; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#authenticate - authenticate(userName: string, password: string, callback: MongoCallback): void; - authenticate(userName: string, password: string, options?: { authMechanism: string }): Promise; - authenticate(userName: string, password: string, options: { authMechanism: string }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#close - close(callback: MongoCallback): void; - close(forceClose?: boolean): Promise; - close(forceClose: boolean, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection - collection(name: string): Collection; - collection(name: string, callback: MongoCallback): Collection; - collection(name: string, options: DbCollectionOptions, callback: MongoCallback): Collection; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collections - collections(): Promise; - collections(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#command - command(command: Object, callback: MongoCallback): void; - command(command: Object, options?: { readPreference: ReadPreference | string }): Promise; - command(command: Object, options: { readPreference: ReadPreference | string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection - createCollection(name: string, callback: MongoCallback): void; - createCollection(name: string, options?: CollectionCreateOptions): Promise; - createCollection(name: string, options: CollectionCreateOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createIndex - createIndex(name: string, fieldOrSpec: string | Object, callback: MongoCallback): void; - createIndex(name: string, fieldOrSpec: string | Object, options?: IndexOptions): Promise; - createIndex(name: string, fieldOrSpec: string | Object, options: IndexOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#db - db(dbName: string): Db; - db(dbName: string, options: { noListener?: boolean, returnNonCachedInstance?: boolean }): Db; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropCollection - dropCollection(name: string): Promise; - dropCollection(name: string, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropDatabase - dropDatabase(): Promise; - dropDatabase(callback: MongoCallback): void; - - //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#ensureIndex - // ensureIndex(collectionName: any, fieldOrSpec: any, options: IndexOptions, callback: Function): void; - //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#eval - // eval(code: any, parameters: any[], options?: any, callback?: MongoCallback): void; - - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#executeDbAdminCommand - executeDbAdminCommand(command: Object, callback: MongoCallback): void; - executeDbAdminCommand(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise; - executeDbAdminCommand(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#indexInformation - indexInformation(name: string, callback: MongoCallback): void; - indexInformation(name: string, options?: { full?: boolean, readPreference?: ReadPreference | string }): Promise; - indexInformation(name: string, options: { full?: boolean, readPreference?: ReadPreference | string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#listCollections - listCollections(filter: { name?: string }, options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#logout - logout(callback: MongoCallback): void; - logout(options?: { dbName?: string }): Promise; - logout(options: { dbName?: string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#open - open(): Promise; - open(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#removeUser - removeUser(username: string, callback: MongoCallback): void; - removeUser(username: string, options?: { w?: number | string, wtimeout?: number, j?: boolean }): Promise; - removeUser(username: string, options: { w?: number | string, wtimeout?: number, j?: boolean }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#renameCollection - renameCollection(fromCollection: string, toCollection: string, callback: MongoCallback): void; - renameCollection(fromCollection: string, toCollection: string, options?: { dropTarget?: boolean }): Promise; - renameCollection(fromCollection: string, toCollection: string, options: { dropTarget?: boolean }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#stats - stats(callback: MongoCallback): void; - stats(options?: { scale?: number }): Promise; - stats(options: { scale?: number }, callback: MongoCallback): void; -} - - - -// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html -export class Server extends EventEmitter { - constructor(host: string, port: number, options?: ServerOptions); - - connections(): Array; -} - -// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html -export class ReplSet extends EventEmitter { - constructor(servers: Array, options?: ReplSetOptions); - - connections(): Array; -} - -// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html -export class Mongos extends EventEmitter { - constructor(servers: Array, options?: MongosOptions); - - connections(): Array; -} -// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser -export interface DbAddUserOptions { - w?: string | number; - wtimeout?: number; - j?: boolean; - customData?: Object; - roles?: Object[]; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection -export interface CollectionCreateOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; - raw?: boolean; - pkFactory?: Object; - readPreference?: ReadPreference | string; - serializeFunctions?: boolean; - strict?: boolean; - capped?: boolean; - size?: number; - max?: number; - autoIndexId?: boolean; -} - -// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection -export interface DbCollectionOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; - raw?: boolean; - pkFactory?: Object; - readPreference?: ReadPreference | string; - serializeFunctions?: boolean; - strict?: boolean; - readConcern?: { level: Object }; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createIndex -export interface IndexOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; - // Creates an unique index. - unique?: boolean; - // Creates a sparse index. - sparse?: boolean; - // Creates the index in the background, yielding whenever possible. - background?: boolean; - // A unique index cannot be created on a key that has pre-existing duplicate values. - // If you would like to create the index anyway, keeping the first document the database indexes and - // deleting all subsequent documents that have duplicate value - dropDups?: boolean; - // For geo spatial indexes set the lower bound for the co-ordinates. - min?: number; - // For geo spatial indexes set the high bound for the co-ordinates. - max?: number; - // Specify the format version of the indexes. - v?: number; - // Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) - expireAfterSeconds?: number; - // Override the auto generated index name (useful if the resulting name is larger than 128 bytes) - name?: string; -} - -// http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html -export interface Admin { - // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser - addUser(username: string, password: string, callback: MongoCallback): void; - addUser(username: string, password: string, options?: AddUserOptions): Promise; - addUser(username: string, password: string, options: AddUserOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#authenticate - authenticate(username: string, callback: MongoCallback): void; - authenticate(username: string, password?: string): Promise; - authenticate(username: string, password: string, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#buildInfo - buildInfo(): Promise; - buildInfo(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#command - command(command: Object, callback: MongoCallback): void; - command(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise; - command(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#listDatabases - listDatabases(): Promise; - listDatabases(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#logout - logout(): Promise; - logout(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#ping - ping(): Promise; - ping(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingInfo - profilingInfo(): Promise; - profilingInfo(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingLevel - profilingLevel(): Promise; - profilingLevel(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser - removeUser(username: string, callback: MongoCallback): void; - removeUser(username: string, options?: FSyncOptions): Promise; - removeUser(username: string, options: FSyncOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#replSetGetStatus - replSetGetStatus(): Promise; - replSetGetStatus(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverInfo - serverInfo(): Promise; - serverInfo(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverStatus - serverStatus(): Promise; - serverStatus(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#setProfilingLevel - setProfilingLevel(level: string): Promise; - setProfilingLevel(level: string, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#validateCollection - validateCollection(collectionNme: string, callback: MongoCallback): void; - validateCollection(collectionNme: string, options?: Object): Promise; - validateCollection(collectionNme: string, options: Object, callback: MongoCallback): void; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser -export interface AddUserOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; - fsync: boolean; - customData?: Object; - roles?: Object[] -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser -export interface FSyncOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; - fsync?: boolean -} - -// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/ObjectID.html -export class ObjectID { - constructor(s?: string | number); - - generationTime: number; - - // Creates an ObjectID from a hex string representation of an ObjectID. - // hexString – create a ObjectID from a passed in 24 byte hexstring. - static createFromHexString(hexString: string): ObjectID; - // Creates an ObjectID from a second based number, with the rest of the ObjectID zeroed out. Used for comparisons or sorting the ObjectID. - // time – an integer number representing a number of seconds. - static createFromTime(time: number): ObjectID; - // Checks if a value is a valid bson ObjectId - // id - Value to be checked - static isValid(id: string | number): boolean; - //Compares the equality of this ObjectID with otherID. - equals(otherID: ObjectID): boolean; - // Generate a 12 byte id string used in ObjectID's - // time - optional parameter allowing to pass in a second based timestamp - generate(time?: number): string; - // Returns the generation date (accurate up to the second) that this ID was generated. - getTimestamp(): Date; - // Returns the ObjectID id as a 24 byte hex string representation - toHexString(): string; -} - -// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Binary.html -export class Binary { - constructor(buffer: Buffer, subType?: number); - - static SUBTYPE_BYTE_ARRAY: number; - static SUBTYPE_DEFAULT: number; - static SUBTYPE_FUNCTION: number; - static SUBTYPE_MD5: number; - static SUBTYPE_USER_DEFINED: number; - static SUBTYPE_UUID: number; - static SUBTYPE_UUID_OLD: number; - - // The length of the binary. - length(): number; - // Updates this binary with byte_value - put(byte_value: number | string): void; - // Reads length bytes starting at position. - read(position: number, length: number): Buffer; - // Returns the value of this binary as a string. - value(): string; - // Writes a buffer or string to the binary - write(buffer: Buffer | string, offset: number): void; -} -//http://mongodb.github.io/node-mongodb-native/2.1/api/Double.html -export class Double { - constructor(value: number); - - valueOf(): number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Long.html -export class Long { - constructor(low: number, high: number); - - static MAX_VALUE: Long; - static MIN_VALUE: Long; - static NEG_ONE: Long; - static ONE: Long; - static ZERO: Long; - - static fromBits(lowBits: number, highBits: number): Long; - static fromInt(value: number): Long; - static fromNumber(value: number): Long; - static fromString(str: string, radix?: number): Long; - - add(other: Long): Long; - and(other: Long): Long; - compare(other: Long): number; - div(other: Long): Long; - equals(other: Long): boolean; - getHighBits(): number; - getLowBits(): number; - getLowBitsUnsigned(): number; - getNumBitsAbs(): number; - greaterThan(other: Long): number; - greaterThanOrEqual(other: Long): number; - isNegative(): boolean; - isOdd(): boolean; - isZero(): boolean; - lessThan(other: Long): boolean; - lessThanOrEqual(other: Long): boolean; - modulo(other: Long): Long; - multiply(other: Long): Long; - negate(): Long; - not(): Long; - notEquals(other: Long): boolean; - or(other: Long): Long; - shiftLeft(other: number): Long; - shiftRight(other: number): Long; - shiftRightUnsigned(other: number): Long; - subtract(other: Long): Long; - toInt(): number; - toJSON(): string; - toNumber(): number; - toString(radix?: number): string; - xor(other: Long): Long; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/MaxKey.html -export class MaxKey { } - -//http://mongodb.github.io/node-mongodb-native/2.1/api/MinKey.html -export class MinKey { } - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Timestamp.html -export class Timestamp { - constructor(low: number, high: number); - - static MAX_VALUE: Timestamp; - static MIN_VALUE: Timestamp; - static NEG_ONE: Timestamp; - static ONE: Timestamp; - static ZERO: Timestamp; - - static fromBits(lowBits: number, highBits: number): Timestamp; - static fromInt(value: number): Timestamp; - static fromNumber(value: number): Timestamp; - static fromString(str: string, radix?: number): Timestamp; - - add(other: Timestamp): Timestamp; - and(other: Timestamp): Timestamp; - compare(other: Timestamp): number; - div(other: Timestamp): Timestamp; - equals(other: Timestamp): boolean; - getHighBits(): number; - getLowBits(): number; - getLowBitsUnsigned(): number; - getNumBitsAbs(): number; - greaterThan(other: Timestamp): number; - greaterThanOrEqual(other: Timestamp): number; - isNegative(): boolean; - isOdd(): boolean; - isZero(): boolean; - lessThan(other: Timestamp): boolean; - lessThanOrEqual(other: Timestamp): boolean; - modulo(other: Timestamp): Timestamp; - multiply(other: Timestamp): Timestamp; - negate(): Timestamp; - not(): Timestamp; - notEquals(other: Timestamp): boolean; - or(other: Timestamp): Timestamp; - shiftLeft(other: number): Timestamp; - shiftRight(other: number): Timestamp; - shiftRightUnsigned(other: number): Timestamp; - subtract(other: Timestamp): Timestamp; - toInt(): number; - toJSON(): string; - toNumber(): number; - toString(radix?: number): string; - xor(other: Timestamp): Timestamp; -} - -// Documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html -export interface Collection { - // Get the collection name. - collectionName: string; - // Get the full collection namespace. - namespace: string; - // The current write concern values. - writeConcern: any; - // The current read concern values. - readConcern: any; - // Get current index hint for collection. - hint: any; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate - aggregate(pipeline: Object[], callback: MongoCallback): AggregationCursor; - aggregate(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite - bulkWrite(operations: Object[], callback: MongoCallback): void; - bulkWrite(operations: Object[], options?: CollectionBluckWriteOptions): Promise; - bulkWrite(operations: Object[], options: CollectionBluckWriteOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#count - count(query: Object, callback: MongoCallback): void; - count(query: Object, options?: MongoCountPreferences): Promise; - count(query: Object, options: MongoCountPreferences, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndex - createIndex(fieldOrSpec: string | any, callback: MongoCallback): void; - createIndex(fieldOrSpec: string | any, options?: IndexOptions): Promise; - createIndex(fieldOrSpec: string | any, options: IndexOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndexes and http://docs.mongodb.org/manual/reference/command/createIndexes/ - createIndexes(indexSpecs: Object[]): Promise; - createIndexes(indexSpecs: Object[], callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany - deleteMany(filter: Object, callback: MongoCallback): void; - deleteMany(filter: Object, options?: CollectionOptions): Promise; - deleteMany(filter: Object, options: CollectionOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteOne - deleteOne(filter: Object, callback: MongoCallback): void; - deleteOne(filter: Object, options?: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }): Promise; - deleteOne(filter: Object, options: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#distinct - distinct(key: string, query: Object, callback: MongoCallback): void; - distinct(key: string, query: Object, options?: { readPreference?: ReadPreference | string }): Promise; - distinct(key: string, query: Object, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#drop - drop(): Promise; - drop(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndex - dropIndex(indexName: string, callback: MongoCallback): void; - dropIndex(indexName: string, options?: CollectionOptions): Promise; - dropIndex(indexName: string, options: CollectionOptions, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndexes - dropIndexes(): Promise; - dropIndexes(callback?: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#find - find(query?: Object): Cursor; - /** @deprecated */ - find(query: Object, fields?: Object, skip?: number, limit?: number, timeout?: number): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne - /** @deprecated use find().limit(1).next(function(err, doc){}) */ - findOne(filter: Object, callback: MongoCallback): void; - /** @deprecated use find().limit(1).next(function(err, doc){}) */ - findOne(filter: Object, options?: FindOneOptions): Promise; - /** @deprecated use find().limit(1).next(function(err, doc){}) */ - findOne(filter: Object, options: FindOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete - findOneAndDelete(filter: Object, callback: MongoCallback): void; - findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number }): Promise; - findOneAndDelete(filter: Object, options: { projection?: Object, sort?: Object, maxTimeMS?: number }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace - findOneAndReplace(filter: Object, replacement: Object, callback: MongoCallback): void; - findOneAndReplace(filter: Object, replacement: Object, options?: FindOneAndReplaceOption): Promise; - findOneAndReplace(filter: Object, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndUpdate - findOneAndUpdate(filter: Object, update: Object, callback: MongoCallback): void; - findOneAndUpdate(filter: Object, update: Object, options?: FindOneAndReplaceOption): Promise; - findOneAndUpdate(filter: Object, update: Object, options: FindOneAndReplaceOption, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch - geoHaystackSearch(x: number, y: number, callback: MongoCallback): void; - geoHaystackSearch(x: number, y: number, options?: GeoHaystackSearchOptions): Promise; - geoHaystackSearch(x: number, y: number, options: GeoHaystackSearchOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoNear - geoNear(x: number, y: number, callback: MongoCallback): void; - geoNear(x: number, y: number, options?: GeoNearOptions): Promise; - geoNear(x: number, y: number, options: GeoNearOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#group - group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, callback: MongoCallback): void; - group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options?: { readPreference?: ReadPreference | string }): Promise; - group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexes - indexes(): Promise; - indexes(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexExists - indexExists(indexes: string | string[]): Promise; - indexExists(indexes: string | string[], callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexInformation - indexInformation(callback: MongoCallback): void; - indexInformation(options?: { full: boolean }): Promise; - indexInformation(options: { full: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeOrderedBulkOp - initializeOrderedBulkOp(options?: CollectionOptions): OrderedBulkOperation; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeUnorderedBulkOp - initializeUnorderedBulkOp(options?: CollectionOptions): UnorderedBulkOperation; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne - /** @deprecated Use insertOne, insertMany or bulkWrite */ - insert(docs: Object, callback: MongoCallback): void; - /** @deprecated Use insertOne, insertMany or bulkWrite */ - insert(docs: Object, options?: CollectionInsertOneOptions): Promise; - /** @deprecated Use insertOne, insertMany or bulkWrite */ - insert(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany - insertMany(docs: Object[], callback: MongoCallback): void; - insertMany(docs: Object[], options?: CollectionInsertManyOptions): Promise; - insertMany(docs: Object[], options: CollectionInsertManyOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne - insertOne(docs: Object, callback: MongoCallback): void; - insertOne(docs: Object, options?: CollectionInsertOneOptions): Promise; - insertOne(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#isCapped - isCapped(): Promise; - isCapped(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#listIndexes - listIndexes(options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce - mapReduce(map: Function | string, reduce: Function | string, callback: MongoCallback): void; - mapReduce(map: Function | string, reduce: Function | string, options?: MapReduceOptions): Promise; - mapReduce(map: Function | string, reduce: Function | string, options: MapReduceOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#options - options(): Promise; - options(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan - parallelCollectionScan(callback: MongoCallback): void; - parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise; - parallelCollectionScan(options: ParallelCollectionScanOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#reIndex - reIndex(): Promise; - reIndex(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#rename - rename(newName: string, callback: MongoCallback): void; - rename(newName: string, options?: { dropTarget?: boolean }): Promise; - rename(newName: string, options: { dropTarget?: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#replaceOne - replaceOne(filter: Object, doc: Object, callback: MongoCallback): void; - replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise; - replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#save - /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ - save(doc: Object, callback: MongoCallback): void; - save(doc: Object, options?: CollectionOptions): Promise; - save(doc: Object, options: CollectionOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#stats - stats(callback: MongoCallback): void; - stats(options?: { scale: number }): Promise; - stats(options: { scale: number }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#update - /** @deprecated use updateOne, updateMany or bulkWrite */ - update(filter: Object, update: Object, callback: MongoCallback): void; - /** @deprecated use updateOne, updateMany or bulkWrite */ - update(filter: Object, update: Object, options?: ReplaceOneOptions & { multi?: boolean }): Promise; - /** @deprecated use updateOne, updateMany or bulkWrite */ - update(filter: Object, update: Object, options: ReplaceOneOptions & { multi?: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateMany - updateMany(filter: Object, update: Object, callback: MongoCallback): void; - updateMany(filter: Object, update: Object, options?: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }): Promise; - updateMany(filter: Object, update: Object, options: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateOne - updateOne(filter: Object, update: Object, callback: MongoCallback): void; - updateOne(filter: Object, update: Object, options?: ReplaceOneOptions): Promise; - updateOne(filter: Object, update: Object, options: ReplaceOneOptions, callback: MongoCallback): void; -} - -// Documentation: http://docs.mongodb.org/manual/reference/command/collStats/ -//TODO complete this -export interface CollStats { - // Namespace. - ns: string; - // Number of documents. - count: number; - // Collection size in bytes. - size: number; - // Average object size in bytes. - avgObjSize: number; - // (Pre)allocated space for the collection in bytes. - storageSize: number; - // Number of extents (contiguously allocated chunks of datafile space). - numExtents: number; - // Number of indexes. - nindexes: number; - // Size of the most recently created extent in bytes. - lastExtentSize: number; - // Padding can speed up updates if documents grow. - paddingFactor: number; - userFlags: number; - // Total index size in bytes. - totalIndexSize: number; - // Size of specific indexes in bytes. - indexSizes: { - _id_: number; - username: number; - }; - capped: boolean; - maxSize: boolean; - wiredTiger: any; - indexDetails: any; - ok: number -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate -export interface CollectionAggregationOptions { - readPreference?: ReadPreference | string; - // Return the query as cursor, on 2.6 > it returns as a real cursor - // on pre 2.6 it returns as an emulated cursor. - cursor?: { batchSize: number }; - // Explain returns the aggregation execution plan (requires mongodb 2.6 >). - explain?: boolean; - // lets the server know if it can use disk to store - // temporary results for the aggregation (requires mongodb 2.6 >). - allowDiskUse?: boolean; - // specifies a cumulative time limit in milliseconds for processing operations - // on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. - maxTimeMS?: boolean; - // Allow driver to bypass schema validation in MongoDB 3.2 or higher. - bypassDocumentValidation?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany -export interface CollectionInsertManyOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; - // Serialize functions on any object. - serializeFunctions?: boolean; - //Force server to assign _id values instead of driver. - forceServerObjectId?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite -export interface CollectionBluckWriteOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; - // Serialize functions on any object. - serializeFunctions?: boolean; - // Execute write operation in ordered or unordered fashion. - ordered?: boolean; - // Allow driver to bypass schema validation in MongoDB 3.2 or higher. - bypassDocumentValidation?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~BulkWriteOpResult -export interface BulkWriteOpResultObject { - insertedCount?: number; - matchedCount?: number; - modifiedCount?: number; - deletedCount?: number; - upsertedCount?: number; - insertedIds?: any; - upsertedIds?: any; - result?: any; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#count -export interface MongoCountPreferences { - // The limit of documents to count. - limit?: number; - // The number of documents to skip for the count. - skip?: boolean; - // An index name hint for the query. - hint?: string; - // The preferred read preference - readPreference?: ReadPreference | string; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~deleteWriteOpResult -export interface DeleteWriteOpResultObject { - //The raw result returned from MongoDB, field will vary depending on server version. - result: { - //Is 1 if the command executed correctly. - ok?: number; - //The total count of documents deleted. - n?: number; - } - //The connection object used for the operation. - connection?: any; - //The number of documents deleted. - deletedCount?: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~findAndModifyWriteOpResult -export interface FindAndModifyWriteOpResultObject { - //Document returned from findAndModify command. - value?: any; - //The raw lastErrorObject returned from the command. - lastErrorObject?: any; - //Is 1 if the command executed correctly. - ok?: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace -export interface FindOneAndReplaceOption { - projection?: Object; - sort?: Object; - maxTimeMS?: number; - upsert?: boolean; - returnOriginal?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch -export interface GeoHaystackSearchOptions { - readPreference?: ReadPreference | string; - maxDistance?: number; - search?: Object; - limit?: number; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoNear -export interface GeoNearOptions { - readPreference?: ReadPreference | string; - num?: number; - minDistance?: number; - maxDistance?: number; - distanceMultiplier?: number; - query?: Object; - spherical?: boolean; - uniqueDocs?: boolean; - includeLocs?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Code.html -export class Code { - constructor(code: string | Function, scope?: Object) - code: string | Function; - scope: any; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany -export interface CollectionOptions { - //The write concern. - w?: number | string; - //The write concern timeout. - wtimeout?: number; - //Specify a journal write concern. - j?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html -export interface OrderedBulkOperation { - length: number; - //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#execute - execute(callback: MongoCallback): void; - execute(options?: FSyncOptions): Promise; - execute(options: FSyncOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#find - find(selector: Object): FindOperatorsOrdered; - //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#insert - insert(doc: Object): OrderedBulkOperation; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/BulkWriteResult.html -export interface BulkWriteResult { - ok: number; - nInserted: number; - nUpdated: number; - nUpserted: number; - nModified: number; - nRemoved: number; - - getInsertedIds(): Array; - getLastOp(): Object; - getRawResponse(): Object; - getUpsertedIdAt(index: number): Object; - getUpsertedIds(): Array; - getWriteConcernError(): WriteConcernError; - getWriteErrorAt(index: number): WriteError; - getWriteErrorCount(): number; - getWriteErrors(): Array; - hasWriteErrors(): boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/WriteError.html -export interface WriteError { - //Write concern error code. - code: number; - //Write concern error original bulk operation index. - index: number; - //Write concern error message. - errmsg: string; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/WriteConcernError.html -export interface WriteConcernError { - //Write concern error code. - code: number; - //Write concern error message. - errmsg: string; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/FindOperatorsOrdered.html -export interface FindOperatorsOrdered { - delete(): OrderedBulkOperation; - deleteOne(): OrderedBulkOperation; - replaceOne(doc: Object): OrderedBulkOperation; - update(doc: Object): OrderedBulkOperation; - updateOne(doc: Object): OrderedBulkOperation; - upsert(): FindOperatorsOrdered; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html -export interface UnorderedBulkOperation { - //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#execute - execute(callback: MongoCallback): void; - execute(options?: FSyncOptions): Promise; - execute(options: FSyncOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#find - find(selector: Object): FindOperatorsUnordered; - //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#insert - insert(doc: Object): UnorderedBulkOperation; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/FindOperatorsUnordered.html -export interface FindOperatorsUnordered { - length: number; - remove(): UnorderedBulkOperation; - removeOne(): UnorderedBulkOperation; - replaceOne(doc: Object): UnorderedBulkOperation; - update(doc: Object): UnorderedBulkOperation; - updateOne(doc: Object): UnorderedBulkOperation; - upsert(): FindOperatorsUnordered; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne -export interface FindOneOptions { - limit?: number, - sort?: Array | Object, - fields?: Object, - skip?: number, - hint?: Object, - explain?: boolean, - snapshot?: boolean, - timeout?: boolean, - tailable?: boolean, - batchSize?: number, - returnKey?: boolean, - maxScan?: number, - min?: number, - max?: number, - showDiskLoc?: boolean, - comment?: string, - raw?: boolean, - readPreference?: ReadPreference | string, - partial?: boolean, - maxTimeMs?: number -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~insertWriteOpResult -export interface InsertWriteOpResult { - insertedCount: number; - ops: Array; - insertedIds: Array; - connection: any; - result: { ok: number, n: number } -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne -export interface CollectionInsertOneOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; - // Serialize functions on any object. - serializeFunctions?: boolean; - //Force server to assign _id values instead of driver. - forceServerObjectId?: boolean; - //Allow driver to bypass schema validation in MongoDB 3.2 or higher. - bypassDocumentValidation?: boolean -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~insertOneWriteOpResult -export interface InsertOneWriteOpResult { - insertedCount: number; - ops: Array; - insertedId: ObjectID; - connection: any; - result: { ok: number, n: number } -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan -export interface ParallelCollectionScanOptions { - readPreference?: ReadPreference | string; - batchSize?: number; - numCursors?: number; - raw?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#replaceOne -export interface ReplaceOneOptions { - upsert?: boolean; - w?: number | string; - wtimeout?: number; - j?: boolean; - bypassDocumentValidation?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~updateWriteOpResult -export interface UpdateWriteOpResult { - result: { ok: number, n: number, nModified: number }; - connection: any; - matchedCount: number; - modifiedCount: number; - upsertedCount: number; - upsertedId: { _id: ObjectID }; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce -export interface MapReduceOptions { - readPreference?: ReadPreference | string; - out?: Object; - query?: Object; - sort?: Object; - limit?: number; - keeptemp?: boolean; - finalize?: Function | string; - scope?: Object; - jsMode?: boolean; - verbose?: boolean; - bypassDocumentValidation?: boolean -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~WriteOpResult -export interface WriteOpResult { - ops: Array; - connection: any; - result: any; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/external-Readable.html -export interface Readable { - pause(): void; - pipe(destination: Writable, options?: Object): void; - read(size: number): string | Buffer | void; - resume(): void; - setEncoding(encoding: string): void; - unpipe(destination?: Writable): void; - unshift(stream: Buffer | string): void; - wrap(stream: Stream): void; -} - -export interface Writable { } -export interface Stream { } - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~resultCallback -export type CursorResult = any | void | boolean; - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html -export interface Cursor extends Readable, NodeJS.EventEmitter { - - sortValue: string; - timeout: boolean; - readPreference: ReadPreference; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html - addCursorFlag(flag: string, value: boolean): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#addQueryModifier - addQueryModifier(name: string, value: boolean): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#batchSize - batchSize(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#clone - clone(): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#close - close(): Promise; - close(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#comment - comment(value: string): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#count - count(applySkipLimit: boolean, callback: MongoCallback): void; - count(applySkipLimit: boolean, options?: CursorCommentOptions): Promise; - count(applySkipLimit: boolean, options: CursorCommentOptions, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#explain - explain(): Promise; - explain(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#filter - filter(filter: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#forEach - forEach(iterator: IteratorCallback, callback: EndCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#hasNext - hasNext(): Promise; - hasNext(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#hint - hint(hint: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#isClosed - isClosed(): boolean; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#limit - limit(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#map - map(transform: Function): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#max - max(max: number): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxAwaitTimeMS - maxAwaitTimeMS(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxScan - maxScan(maxScan: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxTimeMS - maxTimeMS(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#min - min(min: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#next - next(): Promise; - next(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#pause - pause(): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#pipe - pipe(destination: Writable, options?: Object): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#project - project(value: Object): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#read - read(size: number): string | Buffer | void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#resume - resume(): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#next - returnKey(returnKey: Object): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#rewind - rewind(): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setCursorOption - setCursorOption(field: string, value: Object): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setEncoding - setEncoding(encoding: string): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setReadPreference - setReadPreference(readPreference: string | ReadPreference): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#showRecordId - showRecordId(showRecordId: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#skip - skip(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#snapshot - snapshot(snapshot: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#sort - sort(keyOrList: string | Object[] | Object | Object, direction?: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#stream - stream(options?: { transform?: Function }): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#toArray - toArray(): Promise; - toArray(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#unpipe - unpipe(destination?: Writable): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#unshift - unshift(stream: Buffer | string): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#wrap - wrap(stream: Stream): void; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#count -export interface CursorCommentOptions { - skip?: number; - limit?: number; - maxTimeMS?: number; - hint?: string; - readPreference?: ReadPreference | string; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~iteratorCallback -export interface IteratorCallback { - (doc: any): void; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~endCallback -export interface EndCallback { - (error: MongoError): void; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#~resultCallback -export type AggregationCursorResult = any | void; - -//http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html -export interface AggregationCursor extends Readable, NodeJS.EventEmitter { - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#batchSize - batchSize(value: number): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#clone - clone(): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#close - close(): Promise; - close(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#each - each(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#explain - explain(): Promise; - explain(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#geoNear - geoNear(document: Object): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#group - group(document: Object): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#isClosed - isClosed(): boolean; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#limit - limit(value: number): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#match - match(document: Object): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#maxTimeMS - maxTimeMS(value: number): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#next - next(): Promise; - next(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#out - out(destination: string): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#pause - pause(): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#pipe - pipe(destination: Writable, options?: Object): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#project - project(document: Object): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#read - read(size: number): string | Buffer | void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#redact - redact(document: Object): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#resume - resume(): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#rewind - rewind(): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#setEncoding - setEncoding(encoding: string): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#skip - skip(value: number): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#sort - sort(document: Object): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#toArray - toArray(): Promise; - toArray(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unpipe - unpipe(destination?: Writable): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unshift - unshift(stream: Buffer | string): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unwind - unwind(field: string): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#wrap - wrap(stream: Stream): void; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html -export interface CommandCursor extends Readable, NodeJS.EventEmitter { - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#batchSize - batchSize(value: number): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#clone - clone(): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#close - close(): Promise; - close(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#each - each(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#isClosed - isClosed(): boolean; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#maxTimeMS - maxTimeMS(value: number): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#next - next(): Promise; - next(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#pause - pause(): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#pipe - pipe(destination: Writable, options?: Object): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#read - read(size: number): string | Buffer | void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#resume - resume(): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#rewind - rewind(): CommandCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#setEncoding - setEncoding(encoding: string): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#setReadPreference - setReadPreference(readPreference: string | ReadPreference): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#toArray - toArray(): Promise; - toArray(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#unpipe - unpipe(destination?: Writable): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#unshift - unshift(stream: Buffer | string): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#wrap - wrap(stream: Stream): void; -} -} -declare module 'mongodb/mongodb' { -import alias = require('~mongodb/mongodb'); -export = alias; -} -declare module 'mongodb' { -import alias = require('~mongodb/mongodb'); -export = alias; -} diff --git a/typings/modules/mongodb/typings.json b/typings/modules/mongodb/typings.json deleted file mode 100644 index 02c5a8a..0000000 --- a/typings/modules/mongodb/typings.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "resolution": "main", - "tree": { - "src": "https://raw.githubusercontent.com/Think7/typings-mongodb/d4269a9c672ab28a7865b38c8614673e8aecc8e5/typings.json", - "raw": "registry:npm/mongodb#2.1.0+20160422172506", - "main": "mongodb.d.ts", - "global": false, - "dependencies": { - "es6-promise": { - "src": "https://raw.githubusercontent.com/typed-typings/npm-es6-promise/fb04188767acfec1defd054fc8024fafa5cd4de7/typings.json", - "raw": "registry:npm/es6-promise#3.0.0+20160211003958", - "main": "dist/es6-promise.d.ts", - "global": false, - "name": "es6-promise", - "type": "typings" - } - }, - "name": "mongodb", - "type": "typings" - } -} diff --git a/typings/modules/skmatc/index.d.ts b/typings/modules/skmatc/index.d.ts deleted file mode 100644 index 24bbb19..0000000 --- a/typings/modules/skmatc/index.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/sierrasoftworks/skmatc/master/index.d.ts -declare module '~skmatc/index' { -export function scope(schema: any): Skmatc; - -export var validators: Validator[]; -export function create(handles: (schema: any) => boolean, validate: (schema: any, data: any, path: string) => Result, options?: { name?: string }): Validator; -export function validate(validators: Validator[], schema: any, data: any, path?: string): Result; -export function register(validator: Validator); - -export class Skmatc { - schema: any; - validators: Validator[]; - validate(data: any, path?: string): Result; - register(validator: Validator); -} - -export class Validator { - constructor(skmatc: Skmatc, options?: any); - static create(handles: (schema: any) => boolean, validate: (schema: any, data: any, path: string) => Result, options?: { name?: string }): Validator; - static module(handles: (schema: any) => boolean, validate: (schema: any, data: any, path: string) => Result, options?: { name?: string }): Validator; - - name: string; - skmatc: Skmatc; - handles(schema: any): boolean; - validate(schema: any, data: any, path: string): Result; - assert(schema: any, data: any, path: string, test: boolean, message?: string): Result; - fail(schema: any, data: any, path: string, message?: string): Result; -} - -export class Result { - constructor(failures: Failure[]); - static compound(results: Result[]): Result; - - failures: Failure[]; - success: boolean; - failed: boolean; - message: string; - messages: string[]; - error: Error; -} - -export class Failure { - constructor(validator: Validator, schema: any, data: any, path: string, message?: string); - validator: Validator; - schema: any; - data: any; - path: string; - message: string; -} - -export interface IValidationHandler { - (thisArg: { - validator: IValidationHandler; - skmatc: Skmatc; - fail(message?: string); - assert(test: boolean, message?: string); - }, schema: any, data: any, path: string): Result; -} -} -declare module 'skmatc/index' { -import alias = require('~skmatc/index'); -export = alias; -} -declare module 'skmatc' { -import alias = require('~skmatc/index'); -export = alias; -} diff --git a/typings/modules/skmatc/typings.json b/typings/modules/skmatc/typings.json deleted file mode 100644 index 6279096..0000000 --- a/typings/modules/skmatc/typings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "resolution": "main", - "tree": { - "src": "https://raw.githubusercontent.com/sierrasoftworks/skmatc/master/typings.json", - "raw": "github:sierrasoftworks/skmatc#master", - "main": "index.d.ts", - "version": false, - "global": false, - "name": "skmatc", - "type": "typings" - } -}