diff --git a/examples/handlers/set_alarm.js b/examples/handlers/set_alarm.js index 9beb76d..5010b72 100644 --- a/examples/handlers/set_alarm.js +++ b/examples/handlers/set_alarm.js @@ -1,13 +1,14 @@ -module.exports = function (session, next, data) { +module.exports = (session, next, data) => { - var intent = session.privateConversationData[data.source]; + var intent = session.dialogData.data[data.source]; var alarmTime = null; if (intent.actions[0].parameters[0].name == "time") { // alarmTime = intent.entities... - // use intent.entities to extract relevant information - // assuming extracted alarmTime - alarmTime = '2016-10-10 10:10'; + // use intent.entities to extract relevant information + // assuming extracted alarmTime + + alarmTime = '2016-10-10 10:10'; } if (data.target && alarmTime) { @@ -15,5 +16,5 @@ module.exports = function (session, next, data) { } session.send('Alarm set for ' + alarmTime); - next(); + return next(); } \ No newline at end of file diff --git a/examples/handlers/summary.js b/examples/handlers/summary.js index 6ec7667..454386f 100644 --- a/examples/handlers/summary.js +++ b/examples/handlers/summary.js @@ -1,9 +1,9 @@ -module.exports = function (session, next) { +module.exports = (session, next) => { var summary = "Summary: "; for (var prop in session.dialogData.data) { summary += prop + ': [' + session.dialogData.data[prop] + ']; '; } session.send(summary); - next(); + return next(); } \ No newline at end of file diff --git a/lib/Action.js b/lib/Action.js deleted file mode 100644 index 22eef54..0000000 --- a/lib/Action.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; -var CustomNodeTypeHandler = (function () { - function CustomNodeTypeHandler(name, execute) { - this.name = name; - this.execute = execute; - } - return CustomNodeTypeHandler; -}()); -exports.CustomNodeTypeHandler = CustomNodeTypeHandler; diff --git a/lib/GraphDialog.js b/lib/GraphDialog.js old mode 100644 new mode 100755 index 2f5967c..80c4359 --- a/lib/GraphDialog.js +++ b/lib/GraphDialog.js @@ -1,292 +1,388 @@ "use strict"; -var Parser_1 = require('./Parser'); -var Navigator_1 = require('./Navigator'); -var Node_1 = require('./Node'); -var IntentScorer_1 = require('./IntentScorer'); -var Common_1 = require('./Common'); -var Validator_1 = require('./Validator'); + +var util = require('util'); var builder = require('botbuilder'); var strformat = require('strformat'); var uuid = require('uuid'); -var GraphDialog = (function () { - function GraphDialog(options) { - if (options === void 0) { options = {}; } - this.options = options; - this.validateCurrentNode = false; - this.parser = null; - if (!options.bot) - throw new Error('please provide the bot object'); - this.intentScorer = new IntentScorer_1.IntentScorer(); - options.customTypeHandlers = options.customTypeHandlers || new Array(); - this.internalPath = '/_' + uuid.v4(); - this.setBotDialog(); - this.customTypeHandlers = new Common_1.Map(); - for (var i = 0; i < options.customTypeHandlers.length; i++) { - var handler = options.customTypeHandlers[i]; - this.customTypeHandlers.add(handler.name, handler); - } + +var Parser = require('./Parser'); +var Navigator = require('./Navigator'); +var Node = require('./Node'); +var IntentScorer = require('./IntentScorer'); +var Common = require('./Common'); +var Validator = require('./Validator'); + +// the GraphDialog class manages the dialog's state +class GraphDialog { + + constructor(options) { + this.options = options = options || {}; + if (!options.bot) throw new Error('please provide the bot object'); + + // if set to true, will not travel to next step as the current step needs to be validated + this.validateCurrentNode = false; + + this.parser = null; + + // initialize custom handlers + options.customTypeHandlers = options.customTypeHandlers || []; + this.internalPath = '/_' + uuid.v4(); + + this.setBotDialog(); + + this.customTypeHandlers = new Common.Map(); + for (let handler of options.customTypeHandlers) { + this.customTypeHandlers.add(handler.name, handler); } - GraphDialog.prototype.getDialogVersion = function () { - return this.parser ? this.parser.version : null; - }; - GraphDialog.prototype.getDialogId = function () { - return this.parser ? this.parser.root.id : null; - }; - GraphDialog.prototype.init = function () { - var _this = this; - return new Promise(function (resolve, reject) { - _this.parser = new Parser_1.Parser(_this.options); - _this.parser.init().then(function () { - console.log('parser is ready'); - _this.nav = new Navigator_1.Navigator(_this.parser); - return resolve(_this); - }).catch(function (e) { return reject(e); }); - }); - }; - GraphDialog.fromScenario = function (options) { - if (options === void 0) { options = {}; } - var graphDialog = new GraphDialog(options); - return graphDialog.init(); - }; - GraphDialog.prototype.reload = function () { - return this.init(); - }; - GraphDialog.prototype.restartDialog = function (session) { - session.privateConversationData = {}; - console.log('calling loop function after restarting dialog'); - var dialogIndex = -1; - var callstack = session.sessionState.callstack || []; - for (var i = callstack.length - 1; i >= 0; i--) { - var item = callstack[i]; - var path_1 = item.id.split('*:')[1]; - if (path_1 === this.internalPath) { - dialogIndex = i; - break; - } - } - ; - session.cancelDialog(dialogIndex, this.internalPath); - }; - GraphDialog.prototype.getDialog = function () { - var _this = this; - console.log('get dialog'); - return function (session, results, next) { - console.log('calling loop function for the first time'); - session.beginDialog(_this.internalPath); - }; - }; - GraphDialog.prototype.setBotDialog = function () { - var _this = this; - this.options.bot.dialog(this.internalPath, [ - function (session, args, next) { - session.dialogData.data = args || {}; - if (_this.options.onBeforeProcessingStep) - return _this.options.onBeforeProcessingStep.call(_this, session, args, next); - else - return next(); - }, - function (session, args, next) { - return _this.stepInteractionHandler(session, args, next); - }, - function (session, args, next) { - return _this.stepResultCollectionHandler(session, args, next); - }, - function (session, args, next) { - return _this.setNextStepHandler(session, args, next); - }, - function (session, args, next) { - if (_this.options.onAfterProcessingStep) - return _this.options.onAfterProcessingStep.call(_this, session, args, next); - else - return next(); - }, - function (session, args, next) { - console.log('calling loop function'); - session.replaceDialog(_this.internalPath, session.dialogData.data); - } - ]); - }; - GraphDialog.prototype.stepInteractionHandler = function (session, results, next) { - var _this = this; - session.privateConversationData._lastMessage = session.message && session.message.text; - var currentNode = this.nav.getCurrentNode(session); - console.log("perform action: " + currentNode.id + ", " + currentNode.type); - switch (currentNode.type) { - case Node_1.NodeType.text: - var text = strformat(currentNode.data.text, session.dialogData.data); - console.log("sending text for node " + currentNode.id + ", text: '" + text + "'"); - session.send(text); - return next(); - case Node_1.NodeType.prompt: - console.log("builder.ListStyle.button: " + builder.ListStyle["button"]); - var promptType = currentNode.data.type || 'text'; - builder.Prompts[promptType](session, currentNode.data.text, currentNode.data.options, { - listStyle: currentNode.data.config && currentNode.data.config.listStyle && builder.ListStyle[currentNode.data.config.listStyle] || builder.ListStyle.button - }); - break; - case Node_1.NodeType.score: - var botModels = currentNode.data.models.map(function (model) { return _this.nav.models.get(model); }); - var score_text = session.dialogData.data[currentNode.data.source] || session.privateConversationData._lastMessage; - console.log("LUIS scoring for node: " + currentNode.id + ", text: '" + score_text + "' LUIS models: " + botModels); - this.intentScorer.collectIntents(botModels, score_text, currentNode.data.threashold) - .then(function (intents) { - if (intents && intents.length) { - _this.stepResultCollectionHandler(session, { response: intents[0] }, next); - } - }, function (err) { - throw error; - }); - break; - case Node_1.NodeType.handler: - var handlerName = currentNode.data.name; - var handler = this.nav.handlers.get(handlerName); - console.log('calling handler: ', currentNode.id, handlerName); - handler(session, next, currentNode.data); - break; - case Node_1.NodeType.sequence: - return next(); - case Node_1.NodeType.end: - console.log('ending dialog, node:', currentNode.id); - session.send(currentNode.data.text || 'Bye bye!'); - session.endConversation(); - break; - case Node_1.NodeType.heroCard: - session.send(this.generateHeroCardMessage(session, currentNode)); - return next(); - case Node_1.NodeType.carousel: - session.send(this.generateCarouselMessage(session, currentNode)); - return next(); - default: - var customHandler = this.customTypeHandlers.get(currentNode.typeName); - if (customHandler) { - console.log("invoking custom node type handler: " + currentNode.typeName); - return customHandler.execute(session, next, currentNode.data); - } - var msg = 'Node type ' + currentNode.type + ' is not recognized'; - console.error(msg); - var error = new Error(msg); - console.error(error); - throw error; - } - }; - GraphDialog.prototype.generateHeroCard = function (session, data) { - var hero = new builder.HeroCard(session); - if (data.title) { - hero.title(data.title); - } - if (data.subtitle) { - hero.subtitle(data.subtitle); - } - if (data.text) { - hero.text(data.text); - } - if (data.images && data.images.length > 0) { - hero.images([ - builder.CardImage.create(session, data.images[0]) - ]); - } - if (data.tap) { - switch (data.tap.action) { - case "openUrl": - hero.tap(builder.CardAction.openUrl(session, data.tap.value)); - break; - } - } - if (data.buttons) { - var buttons = []; - data.buttons.forEach(function (item, index) { - switch (item.action) { - case "openUrl": - buttons.push(builder.CardAction.openUrl(session, item.value, item.label)); - break; - case "imBack": - buttons.push(builder.CardAction.imBack(session, item.value, item.label)); - break; - } - }); - if (buttons.length > 0) { - hero.buttons(buttons); - } - } - return hero; + } + + getDialogVersion() { + return this.parser ? this.parser.version : null; + } + + getDialogId() { + return this.parser ? this.parser.root.id : null; + } + + // initialize a graph based on graph options like a predefined JSON schema + async init() { + this.nav = this.options.navigator; + this.proxyMode = this.options.proxyMode; + if (!this.nav) { + try { + this.parser = new Parser(this.options); + await this.parser.init(); + console.log('parser is ready'); + this.nav = new Navigator(this.parser); + } + catch(err) { + throw new Error(`error initializing parser. options: ${util.inspect(this.options)}, error: ${err.message}`); + } + } + + return this; + } + + // generate a new graph dialog constructed based on a scenario name + static async create(options = {}) { + var graphDialog = new GraphDialog(options); + return await graphDialog.init(); + } + + // reload instance, for example in case that it was updated in the backend + async reload() { + return this.init(); + } + + // restart dialog + restartDialog(session) { + console.log('calling loop function after restarting dialog'); + + session.privateConversationData = {}; + var dialogIndex = -1; + var callstack = session.sessionState.callstack || []; + + for (var i = callstack.length - 1; i >= 0; i--) { + var item = callstack[i]; + var path = item.id.split('*:')[1]; + if (path === this.internalPath) { + dialogIndex = i; + break; + } }; - GraphDialog.prototype.generateHeroCardMessage = function (session, node) { - var hero = this.generateHeroCard(session, node.data); - return new builder.Message(session) - .textFormat(builder.TextFormat.xml) - .attachments([hero]); + + session.cancelDialog(dialogIndex, this.internalPath); + } + + // returns the dialog steps to bind to the bot object + getDialog() { + console.log('get dialog'); + return (session, results, next) => { + console.log('calling loop function for the first time'); + session.beginDialog(this.internalPath); }; - GraphDialog.prototype.generateCarouselMessage = function (session, node) { - var _this = this; - var data = node.data; - if (data.text) { - var text = strformat(data.text, session.dialogData.data); - session.send(text); - } - if (data.cards && data.cards.length > 0) { - var cards = []; - data.cards.forEach(function (item, index) { - cards.push(_this.generateHeroCard(session, item.data)); - }); - return new builder.Message(session) - .textFormat(builder.TextFormat.xml) - .attachmentLayout(builder.AttachmentLayout.carousel) - .attachments(cards); - } - }; - GraphDialog.prototype.stepResultCollectionHandler = function (session, results, next) { - var currentNode = this.nav.getCurrentNode(session); - var varname = currentNode.varname; - if (!(results.response && varname)) - return next(); - if (currentNode.data.validation && currentNode.data.validation.type) { - var invalidMsg = currentNode.data.validation.setup.invalid_msg ? currentNode.data.validation.setup.invalid_msg : 'Invalid value'; - var isValid = Validator_1.Validator.validate(currentNode.data.validation.type, results.response, currentNode.data.validation.setup); - if (!isValid) { - session.send(invalidMsg); - this.validateCurrentNode = true; - return next(); - } - } - var value = null; - switch (currentNode.type) { - case Node_1.NodeType.prompt: - switch (currentNode.data.type) { - case 'time': - value = builder.EntityRecognizer.resolveTime([results.response]); - break; - case 'choice': - value = results.response.entity; - break; - default: - value = results.response; - } - break; - default: - value = results.response; - } - session.dialogData.data[varname] = value; - console.log('collecting response for node: %s, variable: %s, value: %s', currentNode.id, varname, value); + } + + // this is where the magic happens. loops this list of steps for each node. + setBotDialog() { + var _this = this; + this.options.bot.dialog(this.internalPath, [ + async (session, args, next) => { + session.dialogData.data = args || {}; + if (typeof _this.options.onBeforeProcessingStep === 'function') + return await _this.options.onBeforeProcessingStep.call(_this, session, args, next); + else + return next(); + }, + async (session, args, next) => { + return await _this.stepInteractionHandler(session, args, next); + }, + async (session, args, next) => { + return await _this.stepResultCollectionHandler(session, args, next); + }, + async (session, args, next) => { + return await _this.setNextStepHandler(session, args, next); + }, + async (session, args, next) => { + if (typeof _this.options.onAfterProcessingStep === 'function') + return await _this.options.onAfterProcessingStep.call(_this, session, args, next); + else + return next(); + }, + (session, args, next) => { + console.log('calling loop function'); + session.replaceDialog(_this.internalPath, session.dialogData.data); + } + ]); + } + + // this is where the bot interacts with the user + async stepInteractionHandler(session, results, next) { + session.privateConversationData._lastMessage = session.message && session.message.text; + var currentNode = await this.normalizeNode(await this.nav.getCurrentNode(session)); + console.log("perform action: " + currentNode.id + ", " + currentNode.type); + + switch (currentNode.type) { + + case Node.NodeType.text: + var text = strformat(currentNode.data.text, session.dialogData.data); + console.log("sending text for node " + currentNode.id + ", text: '" + text + "'"); + session.send(text); return next(); - }; - GraphDialog.prototype.setNextStepHandler = function (session, args, next) { - var nextNode = null; - if (this.validateCurrentNode) { - nextNode = this.nav.getCurrentNode(session); - this.validateCurrentNode = false; + + case Node.NodeType.prompt: + console.log("builder.ListStyle.button: " + builder.ListStyle["button"]); + var promptType = currentNode.data.type || 'text'; + currentNode.data.options = currentNode.data.options || {}; + + var listStyle = (currentNode.data.config + && currentNode.data.config.listStyle + && builder.ListStyle[currentNode.data.config.listStyle]) + || builder.ListStyle.button; + + if (promptType === 'confirm' && !currentNode.data.options.listStyle) { + currentNode.data.options.listStyle = listStyle; } - else { - nextNode = this.nav.getNextNode(session); + + builder.Prompts[promptType](session, currentNode.data.text, currentNode.data.options, { listStyle }); + break; + + case Node.NodeType.score: + var botModels = currentNode.data.models.map(model => this.nav.models.get(model)); + var score_text = session.dialogData.data[currentNode.data.source] || session.privateConversationData._lastMessage; + console.log("LUIS scoring for node: " + currentNode.id + ", text: '" + score_text + "' LUIS models: " + util.inspect(botModels)); + var intents = await IntentScorer.collectIntents(botModels, score_text, currentNode.data.threashold); + if (intents && intents.length) { + this.stepResultCollectionHandler(session, { response: intents[0] }, next); } - if (nextNode) { - console.log("step handler node: " + nextNode.id); + break; + + case Node.NodeType.handler: + var handlerName = currentNode.data.name; + var handler = this.nav.handlers.get(handlerName); + console.log('calling handler: ', currentNode.id, handlerName); + handler(session, next, currentNode.data); + break; + + case Node.NodeType.sequence: + return next(); + + case Node.NodeType.end: + console.log('ending dialog, node:', currentNode.id); + session.send(currentNode.data.text || 'Bye bye!'); + session.endConversation(); + break; + + case Node.NodeType.heroCard: + session.send(this.generateHeroCardMessage(session, currentNode)); + return next(); + + case Node.NodeType.carousel: + session.send(this.generateCarouselMessage(session, currentNode)); + return next(); + + default: + var customHandler = this.customTypeHandlers.get(currentNode.typeName); + + if (customHandler) { + console.log("invoking custom node type handler: " + currentNode.typeName); + return customHandler.execute(session, next, currentNode.data); } - else { - console.log('ending dialog'); - return session.endConversation(); + + var msg = 'Node type ' + currentNode.type + ' is not recognized'; + console.error(msg); + throw new Error(msg); + + } + } + + // generates a HeroCard (to be attached to a Message) + generateHeroCard(session, data) { + var hero = new builder.HeroCard(session); + + if (data.title) hero.title(data.title); + if (data.subtitle) hero.subtitle(data.subtitle); + if (data.text) hero.text(data.text); + + if (data.images && data.images.length > 0) { + hero.images([ + builder.CardImage.create(session, data.images[0]) + ]); + } + + if (data.tap) { + switch (data.tap.action) { + case "openUrl": + hero.tap(builder.CardAction.openUrl(session, data.tap.value)); + break; + } + } + + if (data.buttons) { + var buttons = []; + for (let item of data.buttons) { + switch (item.action) { + case "openUrl": + buttons.push(builder.CardAction.openUrl(session, item.value, item.label)); + break; + case "imBack": + buttons.push(builder.CardAction.imBack(session, item.value, item.label)); + break; + case "postBack": + buttons.push(builder.CardAction.postBack(session, item.value, item.label)); + break; } + } + + if (buttons.length > 0) { + hero.buttons(buttons); + } + } + return hero; + } + + // generates a HeroCard Message + generateHeroCardMessage(session, node) { + var hero = this.generateHeroCard(session, node.data); + return new builder.Message(session) + .textFormat(builder.TextFormat.xml) + .attachments([hero]); + }; + + // generates a Carousel Message + generateCarouselMessage(session, node) { + //var _this = this; + var data = node.data; + + if (data.text) { + var text = strformat(data.text, session.dialogData.data); + session.send(text); + } + + if (data.cards && data.cards.length > 0) { + var cards = []; + for (let item of data.cards) { + cards.push(this.generateHeroCard(session, item.data)); + } + + return new builder.Message(session) + .textFormat(builder.TextFormat.xml) + .attachmentLayout(builder.AttachmentLayout.carousel) + .attachments(cards); + } + } + + // handling collection of the user input + async stepResultCollectionHandler(session, results, next) { + + if (this.proxyMode) { + return next(); + } + + delete session.privateConversationData._lastResolvedResult; + var currentNode = await this.normalizeNode(await this.nav.getCurrentNode(session)); + var varname = currentNode.varname; + + if (!(results.response && varname)) return next(); - }; - return GraphDialog; -}()); -exports.GraphDialog = GraphDialog; + + if (currentNode.data.validation && currentNode.data.validation.type) { + var invalidMsg = currentNode.data.validation.setup.invalid_msg ? currentNode.data.validation.setup.invalid_msg : 'Invalid value'; + var isValid = Validator.validate(currentNode.data.validation.type, results.response, currentNode.data.validation.setup); + if (!isValid) { + session.send(invalidMsg); + this.validateCurrentNode = true; + return next(); + } + } + + var value = null; + switch (currentNode.type) { + case Node.NodeType.prompt: + switch (currentNode.data.type) { + case 'time': + value = builder.EntityRecognizer.resolveTime([results.response]); + break; + case 'choice': + value = results.response.entity; + break; + default: + value = results.response; + } + break; + default: + value = results.response; + } + + session.dialogData.data[varname] = value; + session.privateConversationData._lastResolvedResult = value; + + console.log('collecting response for node: %s, variable: %s, value: %s', currentNode.id, varname, value); + return next(); + }; + + // resolves next node on the graph + async setNextStepHandler(session, args, next) { + var nextNode = null; + + var currentNode = await this.normalizeNode(await this.nav.getCurrentNode(session)); + + if (currentNode.stop) { + return session.endConversation(); + } + + if (this.validateCurrentNode) { + nextNode = currentNode; + this.validateCurrentNode = false; + } + else { + nextNode = await this.normalizeNode(await this.nav.getNextNode(session)); + } + + if (nextNode) { + console.log("step handler node: " + nextNode.id); + } + else { + console.log('ending dialog'); + return session.endConversation(); + } + + return next(); + } + + async normalizeNode(node) { + + if (!node) return; + + if (node._customType_) { + return node; + } + + var parser = new Parser({ graph: node }); + await parser.init(); + return parser.root + } + +} + +module.exports = GraphDialog; diff --git a/lib/Luis.js b/lib/Luis.js old mode 100644 new mode 100755 index 7bcf407..ed9d863 --- a/lib/Luis.js +++ b/lib/Luis.js @@ -1,18 +1,26 @@ "use strict"; -var LuisModel = (function () { - function LuisModel(name, url) { - this.name = name; - this.url = url; - } - return LuisModel; -}()); -exports.LuisModel = LuisModel; -var IntentScore = (function () { - function IntentScore(name, model, score) { - this.name = name; - this.model = model; - this.score = score; - } - return IntentScore; -}()); -exports.IntentScore = IntentScore; + +// wrapper class for a LuisModel details +exports.LuisModel = class { + constructor(name, url) { + if (!name) throw new Error(`param 'name' was not provided`); + if (!url) throw new Error(`param 'url' was not provided`); + + this.name = name; + this.url = url; + } +} + +// wrapper class for an intent score +exports.IntentScore = class { + constructor(name, model, score) { + if (!name) throw new Error(`param 'name' was not provided`); + if (!model) throw new Error(`param 'model' was not provided`); + if (!score) throw new Error(`param 'score' was not provided`); + + this.name = name; + this.model = model; + this.score = score; + } +} + diff --git a/lib/Navigator.js b/lib/Navigator.js old mode 100644 new mode 100755 index 3295144..1b0624e --- a/lib/Navigator.js +++ b/lib/Navigator.js @@ -1,45 +1,63 @@ "use strict"; -var ConditionHandler_1 = require('./ConditionHandler'); -var Navigator = (function () { - function Navigator(parser, options) { - if (options === void 0) { options = {}; } - this.parser = parser; - this.options = options; - this.models = parser.models; - this.handlers = parser.handlers; + +var ConditionHandler = require('./ConditionHandler'); + +// helper class to navigate the dialog graph +class Navigator { + + constructor(parser, options = {}) { + this.parser = parser; + this.options = options; + this.models = parser.models; + this.handlers = parser.handlers; + } + + // returns the current node of the dialog + getCurrentNode(session) { + console.log('getCurrentNode'); + var currNodeId = session.privateConversationData._currentNodeId; + if (!currNodeId || !this.parser.getNodeInstanceById(currNodeId)) { + var root = this.parser.root; + session.privateConversationData._currentNodeId = root && root.id; + return root; } - Navigator.prototype.getCurrentNode = function (session) { - console.log('getCurrentNode'); - var currNodeId = session.privateConversationData._currentNodeId; - if (!currNodeId) { - var root = this.parser.root; - session.privateConversationData._currentNodeId = root && root.id; - return root; - } - var current = this.parser.getNodeInstanceById(currNodeId); - return current; - }; - Navigator.prototype.getNextNode = function (session) { - console.log('getNextNode'); - var next = null; - var current = this.parser.getNodeInstanceById(session.privateConversationData._currentNodeId); - var scenarios = current.scenarios; - for (var i = 0; i < current.scenarios.size(); i++) { - var scenario = current.scenarios.get(i); - if (ConditionHandler_1.ConditionHandler.evaluateExpression(session.dialogData.data, scenario.condition)) { - next = scenario.node || scenario.steps.get(0); - } - } - next = next || current.steps.get(0); - var nodeNavigator = current; - while (!next && nodeNavigator) { - next = nodeNavigator.next; - nodeNavigator = nodeNavigator.parent; - } - console.log("getNextNode: [current: " + current.id + ", next: " + (next && next.id) + "]"); - session.privateConversationData._currentNodeId = next && next.id; - return next; - }; - return Navigator; -}()); -exports.Navigator = Navigator; + var current = this.parser.getNodeInstanceById(currNodeId); + return current; + }; + + // resolves the next node in the dialog + getNextNode(session) { + console.log('getNextNode'); + + var next = null; + var current = this.parser.getNodeInstanceById(session.privateConversationData._currentNodeId); + + // if there are child scenarios, see if one of them answers a condition. + // in case it is, choose the first step in that scenario to as the next step. + var scenarios = current.scenarios; + for (var i = 0; i < current.scenarios.size(); i++) { + var scenario = current.scenarios.get(i); + if (ConditionHandler.evaluateExpression(session.dialogData.data, scenario.condition)) { + next = scenario.node || scenario.steps.get(0); + } + } + + // if no next yet, get the first step + next = next || current.steps.get(0); + + // if no next yet, travel the graph, look for next at parents... + // if there is no selected scenario, move to the next node. + // if there is no next node, look recursively for next on parent nodes. + var nodeNavigator = current; + while (!next && nodeNavigator) { + next = nodeNavigator.next; + nodeNavigator = nodeNavigator.parent; + } + + console.log("getNextNode: [current: " + current.id + ", next: " + (next && next.id) + "]"); + session.privateConversationData._currentNodeId = next && next.id; + return next; + }; +} + +module.exports = Navigator; diff --git a/lib/Node.js b/lib/Node.js old mode 100644 new mode 100755 index c6cac55..3d3d81d --- a/lib/Node.js +++ b/lib/Node.js @@ -1,5 +1,36 @@ "use strict"; -var Common_1 = require('./Common'); + +var Common = require('./Common'); + +// the Node class representing a node in the dialog graph +class Node { + + constructor(node, type) { + if (!node.id) throw new Error(`node does not have an 'id'`); + this.id = node.id; + + // resolve node type + if (typeof type === 'string') { + this.type = NodeType[type]; + this.typeName = type; + } + else + this.type = type; + + this.varname = node.varname || this.id; + this.steps = new Common.List(); + this.scenarios = new Common.List(); + this.body = node; + this.data = node.data; + this.stop = node.stop; + + this._customType_ = true; + } + +} + +// types of nodes currently supported natively +var NodeType = {}; (function (NodeType) { NodeType[NodeType["text"] = 0] = "text"; NodeType[NodeType["prompt"] = 1] = "prompt"; @@ -9,23 +40,8 @@ var Common_1 = require('./Common'); NodeType[NodeType["end"] = 5] = "end"; NodeType[NodeType["heroCard"] = 6] = "heroCard"; NodeType[NodeType["carousel"] = 7] = "carousel"; -})(exports.NodeType || (exports.NodeType = {})); -var NodeType = exports.NodeType; -var Node = (function () { - function Node(node, type) { - this.id = node.id; - if (typeof type === 'string') { - this.type = NodeType[type]; - this.typeName = type; - } - else - this.type = type; - this.varname = node.varname || this.id; - this.steps = new Common_1.List(); - this.scenarios = new Common_1.List(); - this.body = node; - this.data = node.data; - } - return Node; -}()); -exports.Node = Node; +})(NodeType); + +Node.NodeType = NodeType; + +module.exports = Node; diff --git a/lib/Parser.js b/lib/Parser.js old mode 100644 new mode 100755 index 6efed74..10fb92f --- a/lib/Parser.js +++ b/lib/Parser.js @@ -1,213 +1,243 @@ "use strict"; -var Node_1 = require('./Node'); -var Scenario_1 = require('./Scenario'); -var Luis_1 = require('./Luis'); -var Common_1 = require('./Common'); + +var util = require('util'); +var Node = require('./Node'); +var Scenario = require('./Scenario'); +var Luis = require('./Luis'); +var Common = require('./Common'); var extend = require('extend'); -var Promise = require('bluebird'); var crypto = require('crypto'); -var Parser = (function () { - function Parser(options) { - this.options = options; - this.uniqueNodeId = 1; - this.root = null; - this.version = null; - this.nodes = new Common_1.Map(); - this.models = new Common_1.Map(); - this.handlers = new Common_1.Map(); + +// parses a json based scenario +class Parser { + + constructor (options) { + this.options = options; + this.uniqueNodeId = 1; + this.root = null; + this.version = null; + this.nodes = {}; + this.models = new Common.Map(); + this.handlers = new Common.Map(); + } + + // loads and parses a scenario + async init() { + if (!this.options.graph) { + try { + var graph = await this.options.loadScenario(this.options.scenario); + return await this.normalizeGraph(graph); + } + catch(err) { + console.error(`error loading scenario. options: ${util.inspect(this.options)}, error: ${util.inspect(err)}`); + throw new Error(`Error loading scenario '${this.options.scenario}': ${err.message}`); + } } - Parser.prototype.init = function () { - var _this = this; - return new Promise(function (resolve, reject) { - _this.options.loadScenario(_this.options.scenario) - .then(function (graph) { - return _this.normalizeGraph(graph).then(function () { - return resolve(); - }).catch(function (e) { return reject(e); }); - }) - .catch(function (e) { - console.error("error loading scenario: " + _this.options + ": " + e.message); - return reject(e); - }); - }); - }; - Parser.prototype.getNodeInstanceById = function (id) { - var node = this.nodes[id]; - return (node && node._instance); - }; - Parser.prototype.normalizeGraph = function (origGraph) { - var _this = this; - return new Promise(function (resolve, reject) { - var graph = {}; - extend(true, graph, origGraph); - console.log('loading scenario:', graph.id); - _this.updateModels(graph.models); - _this.recursive(graph).then(function () { - var nodes = _this.nodes; - for (var nodeId in nodes) { - var node = nodes[nodeId]; - var inst = new Node_1.Node(node, node.type); - node._instance = inst; - } - var _loop_1 = function(nodeId) { - var node = nodes[nodeId]; - var inst = node._instance; - if (node._parent) - inst.parent = node._parent._instance; - if (node._prev) - inst.prev = node._prev._instance; - if (node._next) - inst.next = node._next._instance; - (node.steps || []).forEach(function (step) { - inst.steps.add(step._instance); - }); - (node.scenarios || []).forEach(function (scenario) { - var scenarioNode = null; - if (scenario.nodeId) { - scenarioNode = _this.nodes[scenario.nodeId]._instance; - } - var scene = new Scenario_1.Scenario(scenario.condition, scenarioNode); - (scenario.steps || []).forEach(function (step) { - scene.steps.add(step._instance); - }); - inst.scenarios.add(scene); - }); - }; - for (var nodeId in nodes) { - _loop_1(nodeId); - } - for (var nodeId in nodes) { - var node = nodes[nodeId]; - var inst = node._instance; - delete node._visited; - delete node._parent; - delete node._prev; - delete node._next; - } - _this.root = graph._instance; - _this.version = graph.version || _this.calculateHash(JSON.stringify(origGraph)); - return resolve(); - }).catch(function (e) { return reject(e); }); - }); - }; - Parser.prototype.initNode = function (parent, nodes, nodeItem, index) { - var _this = this; - if (nodeItem._visited) - return Promise.resolve(); - nodeItem._visited = true; - if (!nodeItem.id) { - nodeItem.id = '_node_' + (this.uniqueNodeId++); + + // graph was provided + return await this.normalizeGraph(this.options.graph); + } + + // gets a node instance by its Id + getNodeInstanceById(id) { + var node = this.nodes[id]; + return node && node._instance; + } + + // normalize the graph + async normalizeGraph(origGraph) { + + try { + + // create a copy of the graph object + var graph = {}; + extend(true, graph, origGraph); + + console.log('loading scenario:', graph.id); + this.updateModels(graph.models); + + await this.recursive(graph); + + // first iteration- create Node instances + var nodes = this.nodes; + for (var nodeId in nodes) { + var node = nodes[nodeId]; + var inst = new Node(node, node.type); + node._instance = inst; + } + + // second iteration- connect reference to Node instances + for (var nodeId in nodes) { + + var node = nodes[nodeId]; + var inst = node._instance; + if (node._parent) inst.parent = node._parent._instance; + if (node._prev) inst.prev = node._prev._instance; + if (node._next) inst.next = node._next._instance; + + for (let step of node.steps || []) { + inst.steps.add(step._instance); } - if (parent) - nodeItem._parent = parent; - if (index > 0) - nodeItem._prev = nodes[index - 1]; - if (nodes.length > index + 1) - nodeItem._next = nodes[index + 1]; - if (this.isSubScenario(nodeItem)) { - console.log("sub-scenario for node: " + nodeItem.id + " [embedding sub scenario: " + nodeItem.subScenario + "]"); - return new Promise(function (resolve, reject) { - _this.options.loadScenario(nodeItem.subScenario) - .then(function (scenarioObj) { - extend(true, nodeItem, scenarioObj); - _this.updateModels(scenarioObj.models); - console.log('node:', nodeItem.id, nodeItem._parent && nodeItem._parent.id ? '[parent: ' + nodeItem._parent.id + ']' : '', nodeItem._next && nodeItem._next.id ? '[next: ' + nodeItem._next.id + ']' : '', nodeItem._prev && nodeItem._prev.id ? '[prev: ' + nodeItem._prev.id + ']' : ''); - return _this.recursive(nodeItem).then(function () { - return resolve(); - }).catch(function (e) { return reject(e); }); - }).catch(function (e) { return reject(e); }); - }); - } - else if (nodeItem.type === 'handler') { - var handler = nodeItem.data.name || ''; - console.log("loading handler for node: " + nodeItem.id + " [embedding sub scenario: " + handler + "]"); - if (nodeItem.data.js) { - var content = nodeItem.data.js; - if (Array.isArray(content)) - content = content.join('\n'); - var func = this.getHandlerFunc(content); - if (!func) { - console.error("error loading handler " + handler); - } - this.handlers.add(handler, func); - } - else { - return new Promise(function (resolve, reject) { - _this.options.loadHandler(handler) - .then(function (text) { - var func = _this.getHandlerFunc(text); - if (!func) { - console.error("error loading handler " + handler); - return reject(new Error("error loading handler " + handler)); - } - _this.handlers.add(handler, func); - console.log('node:', nodeItem.id, nodeItem._parent && nodeItem._parent.id ? '[parent: ' + nodeItem._parent.id + ']' : '', nodeItem._next && nodeItem._next.id ? '[next: ' + nodeItem._next.id + ']' : '', nodeItem._prev && nodeItem._prev.id ? '[prev: ' + nodeItem._prev.id + ']' : ''); - return _this.recursive(nodeItem).then(function () { - return resolve(); - }).catch(function (e) { return reject(e); }); - }).catch(function (e) { return reject(e); }); - }); - } + + for (let scenario of node.scenarios || []) { + var scene = new Scenario( scenario.condition, + scenario.nodeId ? this.nodes[scenario.nodeId]._instance : null); + + for (let step of scenario.steps || []) { + scene.steps.add(step._instance); + }; + + inst.scenarios.add(scene); } + } + + // third iteration- remove unneccessary data/references + for (var nodeId in nodes) { + var node = nodes[nodeId]; + var inst = node._instance; + delete node._visited; + delete node._parent; + delete node._prev; + delete node._next; + } + + this.root = graph._instance; + this.version = graph.version || this.calculateHash(JSON.stringify(origGraph)); + } + catch(err) { + console.error(`error normalizing graph: ${util.inspect(origGraph)}, error: ${util.inspect(err)}`); + throw new Error(`Error normalizing graph '${util.inspect(origGraph)}': ${err.message}`); + } + } + + // initialize a node in the graph + async initNode(parent, nodes, nodeItem, index) { + try { + + if (nodeItem._visited) return; + + nodeItem._visited = true; + nodeItem.id = nodeItem.id || `_node_${this.uniqueNodeId++}`; + + if (parent) nodeItem._parent = parent; + if (index > 0) nodeItem._prev = nodes[index - 1]; + if (nodes.length > index + 1) nodeItem._next = nodes[index + 1]; + + if (this.isSubScenario(nodeItem)) { + console.log("sub-scenario for node: " + nodeItem.id + " [embedding sub scenario: " + nodeItem.subScenario + "]"); + var scenarioObj = await this.options.loadScenario(nodeItem.subScenario); + extend(true, nodeItem, scenarioObj); + this.updateModels(scenarioObj.models); console.log('node:', nodeItem.id, nodeItem._parent && nodeItem._parent.id ? '[parent: ' + nodeItem._parent.id + ']' : '', nodeItem._next && nodeItem._next.id ? '[next: ' + nodeItem._next.id + ']' : '', nodeItem._prev && nodeItem._prev.id ? '[prev: ' + nodeItem._prev.id + ']' : ''); - return this.recursive(nodeItem); - }; - Parser.prototype.initNodes = function (parent, nodes) { - var _this = this; - return Promise.all((nodes || []).map(function (item, index) { return _this.initNode(parent, nodes, item, index); })); - }; - Parser.prototype.recursive = function (node) { - var _this = this; - return new Promise(function (resolve, reject) { - if (!node.id) { - node.id = '_node_' + (_this.uniqueNodeId++); - } - _this.initNodes(node, node.steps).then(function () { - var promises = (node.scenarios || []).map(function (scenario) { return _this.initNodes(node, scenario.steps); }); - return Promise.all(promises).then(function () { - if (node.type === 'sequence') { - return _this.initNodes(node, node.steps).then(function () { - _this.nodes[node.id] = node; - return resolve(); - }).catch(function (e) { return reject(e); }); - } - else { - _this.nodes[node.id] = node; - return resolve(); - } - }).catch(function (e) { return reject(e); }); - }).catch(function (e) { return reject(e); }); - }); - }; - Parser.prototype.isSubScenario = function (nodeItem) { - if (!nodeItem.subScenario) - return false; - var parent = nodeItem._parent; - while (parent) { - if (nodeItem.subScenario === parent.id) { - console.error('recursive subScenario found: ', nodeItem.subScenario); - throw new Error('recursive subScenario found ' + nodeItem.subScenario); - } - parent = parent._parent; + return this.recursive(nodeItem); + } + + if (nodeItem.type === 'handler') { + var handler = nodeItem.data.name || ''; + console.log("loading handler for node: " + nodeItem.id + " [embedding sub scenario: " + handler + "]"); + + var jsCode = null; + if (nodeItem.data.js) { + var content = nodeItem.data.js; + + if (Array.isArray(content)) + jsCode = content.join('\n'); + } + else { + try { + jsCode = await this.options.loadHandler(handler); + } + catch(err) { + console.error(`error loading handler: ${handler}: error: ${err.message}`); + } + } + + var func = this.getHandlerFunc(jsCode); + if (!func) { + console.error(`error loading handler ${handler}: js code: ${jsCode}`); + throw new Error(`error loading handler ${handler}: js code: ${jsCode}`); } - return true; - }; - Parser.prototype.getHandlerFunc = function (funcText) { - var text = "(function(){\n return function(module) { \n " + funcText + "\n }\n })()\n "; - var wrapperFunc = eval(text); - var m = {}; - wrapperFunc(m); - return typeof m.exports === 'function' ? m.exports : null; - }; - Parser.prototype.updateModels = function (models) { - var _this = this; - (models || []).forEach(function (model) { - _this.models.add(model.name, new Luis_1.LuisModel(model.name, model.url)); - }); - }; - Parser.prototype.calculateHash = function (text) { - return crypto.createHash('md5').update(text).digest('hex'); - }; - return Parser; -}()); -exports.Parser = Parser; + + this.handlers.add(handler, func); + } + + console.log('node:', nodeItem.id, nodeItem._parent && nodeItem._parent.id ? '[parent: ' + nodeItem._parent.id + ']' : '', nodeItem._next && nodeItem._next.id ? '[next: ' + nodeItem._next.id + ']' : '', nodeItem._prev && nodeItem._prev.id ? '[prev: ' + nodeItem._prev.id + ']' : ''); + await this.recursive(nodeItem); + + } + catch(err) { + console.error(`error initNode: ${util.inspect(arguments)}, error: ${util.inspect(err)}`); + throw new Error(`Error initNode'${util.inspect(node)}': ${err.message}`); + } + } + + // initialize a collecton of nodes + async initNodes(parent, nodes = []) { + for (var i=0; i await this.initNodes(node, scenario.steps))); + // it keeps the order of the calls such that it waits for a call the end before invoking the next one. + // this is what we want to do, since the order is important. + for (let scenario of node.scenarios || []) { + await this.initNodes(node, scenario.steps); + } + + this.nodes[node.id] = node; + } + + // checks if this is a sub-scenario node + isSubScenario(nodeItem) { + if (!nodeItem.subScenario) return false; + + var parent = nodeItem._parent; + while (parent) { + if (nodeItem.subScenario === parent.id) { + console.error(`recursive subScenario found: ${nodeItem.subScenario}`); + throw new Error(`recursive subScenario found: ${nodeItem.subScenario}`); + } + parent = parent._parent; + } + + return true; + } + + // gets a handler function from a string + getHandlerFunc(funcText) { + var text = `(() => { + return module => { + ${funcText} + } + })()`; + var wrapperFunc = eval(text); + var m = {}; + wrapperFunc(m); + return typeof m.exports === 'function' ? m.exports : null; + } + + // updates the internal LUIS models collection + updateModels(models = []) { + for (let model of models) { + this.models.add(model.name, new Luis.LuisModel(model.name, model.url)); + } + } + + // calculates hash of an input text + calculateHash(text) { + return crypto.createHash('md5').update(text).digest('hex'); + } + +} + +module.exports = Parser; diff --git a/lib/Scenario.js b/lib/Scenario.js old mode 100644 new mode 100755 index d0431f3..2c7acf8 --- a/lib/Scenario.js +++ b/lib/Scenario.js @@ -1,12 +1,20 @@ "use strict"; -var Common_1 = require('./Common'); -var Scenario = (function () { - function Scenario(condition, node) { - if (node === void 0) { node = null; } - this.condition = condition; - this.node = node; - this.steps = new Common_1.List(); - } - return Scenario; -}()); -exports.Scenario = Scenario; + +var Common = require('./Common'); + +// a scenario class +class Scenario { + + constructor(condition, node) { + + if (!condition) throw new Error(`param 'condition' was not provided`); + // node is optional, no need to validate + + this.condition = condition; + this.node = node; + this.steps = new Common.List(); + } + +} + +module.exports = Scenario; diff --git a/lib/Validator.js b/lib/Validator.js old mode 100644 new mode 100755 index dc8c2bf..62ac323 --- a/lib/Validator.js +++ b/lib/Validator.js @@ -1,38 +1,45 @@ "use strict"; -var Validator; -(function (Validator) { - function validate(type, value, configuration) { - var result = false; - switch (type) { - case 'date': - result = this.validateDate(value, configuration); - break; - case 'regex': - result = this.validateRegex(value, configuration); - break; - } - return result; + +class Validator { + + constructor() { + } + + // validates a value against given type rule + static validate(type, value, configuration) { + switch (type) { + case 'date': + return Validator.validateDate(value, configuration); + case 'regex': + return Validator.validateRegex(value, configuration); + default: + return false; } - Validator.validate = validate; - function validateDate(value, configuration) { - var date = value.resolution.start.getTime(); - if (configuration.min_date) { - var dateMin = new Date(configuration.min_date).getTime(); - if (date < dateMin) - return false; - } - if (configuration.max_date) { - var dateMax = new Date(configuration.max_date).getTime(); - if (date > dateMax) - return false; - } - return true; + } + + // validates a date + static validateDate(value, configuration) { + var date = value.resolution.start.getTime(); + + if (configuration.min_date) { + var dateMin = new Date(configuration.min_date).getTime(); + if (date < dateMin) return false; } - Validator.validateDate = validateDate; - function validateRegex(value, configuration) { - var regex = new RegExp(configuration.pattern); - var isValid = regex.test(value); - return isValid; + + if (configuration.max_date) { + var dateMax = new Date(configuration.max_date).getTime(); + if (date > dateMax) return false; } - Validator.validateRegex = validateRegex; -})(Validator = exports.Validator || (exports.Validator = {})); + + return true; + } + + static validateRegex(value, configuration) { + var regex = new RegExp(configuration.pattern); + var isValid = regex.test(value); + return isValid; + } + +} + +module.exports = Validator; diff --git a/lib/common.js b/lib/common.js old mode 100644 new mode 100755 index e4864e0..a08c39b --- a/lib/common.js +++ b/lib/common.js @@ -1,40 +1,48 @@ "use strict"; -var List = (function () { - function List() { - this.items = []; - } - List.prototype.size = function () { - return this.items.length; - }; - List.prototype.add = function (value) { - this.items.push(value); - }; - List.prototype.get = function (index) { - return index < this.size() ? this.items[index] : null; - }; - return List; -}()); -exports.List = List; -var Map = (function () { - function Map() { - this.items = {}; - } - Map.prototype.add = function (key, value) { - this.items[key] = value; - }; - Map.prototype.has = function (key) { - return key in this.items; - }; - Map.prototype.get = function (key) { - return this.items[key]; - }; - Map.prototype.keys = function () { - return Object.keys(this.items); - }; - Map.prototype.values = function () { - var _this = this; - return Object.keys(this.items).map(function (key) { return _this.items[key]; }); - }; - return Map; -}()); -exports.Map = Map; + +exports.List = class { + + constructor() { + this.items = []; + } + + size() { + return this.items.length; + }; + + add(value) { + this.items.push(value); + }; + + get(index) { + return index < this.size() ? this.items[index] : null; + }; +} + +exports.Map = class { + + constructor() { + this.items = {}; + } + + add(key, value) { + this.items[key] = value; + }; + + has(key) { + return key in this.items; + }; + + get(key) { + return this.items[key]; + }; + + keys() { + return Object.keys(this.items); + }; + + values() { + var items = this.items; + return Object.keys(this.items).map(key => items[key]); + }; +} diff --git a/lib/conditionHandler.js b/lib/conditionHandler.js old mode 100644 new mode 100755 index 27a31f1..b5b232e --- a/lib/conditionHandler.js +++ b/lib/conditionHandler.js @@ -1,74 +1,92 @@ "use strict"; var jsep = require('jsep'); -var ConditionHandler; -(function (ConditionHandler) { - function evaluateExpression(object, expression) { - var exp = null; - if (typeof expression == 'string') { - exp = jsep(expression); - } - else { - exp = expression; - } - switch (exp.type) { - case 'BinaryExpression': - var bexp = exp; - var value1 = this.evaluateExpression(object, bexp.left); - var value2 = this.evaluateExpression(object, bexp.right); - return this.calculateExpression(bexp.operator, value1, value2); - case 'UnaryExpression': - var uexp = exp; - var value = this.evaluateExpression(object, uexp.argument); - return this.calculateExpression(uexp.operator, value); - case 'Identifier': - return object[exp.name]; - case 'MemberExpression': - var mexp = exp; - var parent = this.evaluateExpression(object, mexp.object); - return this.evaluateExpression(parent, mexp.property); - case 'Literal': - return exp.value; - default: - throw new Error('condition type ' + exp.type + ' is not recognized'); - } + +/** + * Parsing and calculating conditional expressions from strings + * i.e.: age >= 30 & (age * 2) < 40 + */ +class ConditionHandler { + + /** + * Recursively perform an evaluation of an expression + * @param {any} object + * @param {string|jsep.IExpression} expression + * @returns any + */ + static evaluateExpression(object, expression) { + var exp = typeof expression === 'string' ? jsep(expression) : expression; + + switch (exp.type) { + case 'BinaryExpression': + var bexp = exp; + var value1 = this.evaluateExpression(object, bexp.left); + var value2 = this.evaluateExpression(object, bexp.right); + return this.calculateExpression(bexp.operator, value1, value2); + + case 'UnaryExpression': + var uexp = exp; + var value = this.evaluateExpression(object, uexp.argument); + return this.calculateExpression(uexp.operator, value); + + case 'Identifier': + return object[exp.name]; + + case 'MemberExpression': + var mexp = exp; + var parent = this.evaluateExpression(object, mexp.object); + return this.evaluateExpression(parent, mexp.property); + + case 'Literal': + return exp.value; + + default: + throw new Error('condition type ' + exp.type + ' is not recognized'); } - ConditionHandler.evaluateExpression = evaluateExpression; - function calculateExpression(operator, value1, value2) { - if (value2 === void 0) { value2 = null; } - switch (operator) { - case '!': - return !value1; - case '<': - return value1 < value2; - case '>': - return value1 > value2; - case '<=': - return value1 <= value2; - case '>=': - return value1 >= value2; - case '=': - case '==': - return value1 == value2; - case '===': - return value1 === value2; - case '!=': - case '<>': - return value1 != value2; - case '!==': - return value1 !== value2; - case '-': - return value1 - value2; - case '+': - return value1 + value2; - case '*': - return value1 * value2; - case '/': - return value1 / value2; - case '%': - return value1 % value2; - default: - break; - } + } + + /** + * Calculate an expression accoring to the operator + * @param {any} operator + * @param {any} value1 + * @param {any=null} value2 + * @returns any + */ + static calculateExpression(operator, value1, value2) { + switch (operator) { + case '!': + return !value1; + case '<': + return value1 < value2; + case '>': + return value1 > value2; + case '<=': + return value1 <= value2; + case '>=': + return value1 >= value2; + case '=': + case '==': + return value1 == value2; + case '===': + return value1 === value2; + case '!=': + case '<>': + return value1 != value2; + case '!==': + return value1 !== value2; + case '-': + return value1 - value2; + case '+': + return value1 + value2; + case '*': + return value1 * value2; + case '/': + return value1 / value2; + case '%': + return value1 % value2; + default: + break; } - ConditionHandler.calculateExpression = calculateExpression; -})(ConditionHandler = exports.ConditionHandler || (exports.ConditionHandler = {})); + } +} + +module.exports = ConditionHandler; diff --git a/lib/intentScorer.js b/lib/intentScorer.js old mode 100644 new mode 100755 index dcc9caa..acf159f --- a/lib/intentScorer.js +++ b/lib/intentScorer.js @@ -1,47 +1,48 @@ "use strict"; + var request = require('request-promise'); -var Promise = require('bluebird'); var _ = require('underscore'); -var IntentScorer = (function () { - function IntentScorer() { + +// score intents from a single or multiple intent scoring APIs +class IntentScorer { + + constructor() { + } + + // collect response from all models + static async collectIntents(models, text, threashold = 0) { + if (!models) throw new Error('Please provide models array'); + if (!text) throw new Error('Please provide text'); + + var intents = await Promise.all(models.map(async model => await IntentScorer.scoreIntent(model, text, threashold))); + var sortedIntents = _.sortBy(_.compact(intents), 'score').reverse(); + return sortedIntents; + } + + // scores a specific intent, invoke actual request to LUIS + static async scoreIntent(model, text, threashold = 0) { + var url = model.url + encodeURIComponent(text); + try { + var json = await request(url, { json: true }); } - IntentScorer.prototype.collectIntents = function (models, text, threashold) { - var _this = this; - if (threashold === void 0) { threashold = 0; } - var promises = models.map(function (model) { - return _this.scoreIntent(model, text, threashold); - }); - return new Promise(function (resolve, reject) { - if (!models) - return reject('Please provide models array'); - if (!text) - return reject('Please provide text'); - Promise.all(promises) - .then(function (intents) { - var sortedIntents = _.sortBy(_.compact(intents), 'score').reverse(); - resolve(sortedIntents); - }) - .catch(reject); - }); - }; - IntentScorer.prototype.scoreIntent = function (model, text, threashold) { - if (threashold === void 0) { threashold = 0; } - return new Promise(function (resolve, reject) { - return request(model.url + encodeURIComponent(text)) - .then(function (result) { - var json = JSON.parse(result); - if (!json || !json.intents || !json.intents.length) - return resolve(); - if (json.intents[0].score < threashold) - return resolve(); - var intent = json.intents[0]; - intent.entities = json.entities; - intent.model = model.name; - return resolve(intent); - }) - .catch(reject); - }); - }; - return IntentScorer; -}()); -exports.IntentScorer = IntentScorer; + catch(err) { + var msg = `error calling LUIS: url: ${url}, error: ${err.message}`; + console.error(msg); + throw new Error(msg); + } + + if (!json || !json.intents || !json.intents.length) + return; + + if (json.intents[0].score < threashold) + return; + + var intent = json.intents[0]; + intent.entities = json.entities; + intent.model = model.name; + return intent; + } +} + +module.exports = IntentScorer; + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..61b37ac --- /dev/null +++ b/package-lock.json @@ -0,0 +1,597 @@ +{ + "name": "bot-graph-dialog", + "version": "3.4.5", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ajv": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" + }, + "asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" + }, + "assert-plus": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=" + }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "aws-sign2": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=" + }, + "aws4": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", + "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" + }, + "base64url": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/base64url/-/base64url-2.0.0.tgz", + "integrity": "sha1-6sFuA+oUOO/5Qj1puqNiYu0fcLs=" + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", + "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "bluebird": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz", + "integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=" + }, + "boom": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", + "requires": { + "hoek": "2.16.3" + } + }, + "botbuilder": { + "version": "3.8.4", + "resolved": "https://registry.npmjs.org/botbuilder/-/botbuilder-3.8.4.tgz", + "integrity": "sha1-/O3EK5J+zwUMJL5SDBKAgkQ3pwg=", + "requires": { + "async": "1.5.2", + "base64url": "2.0.0", + "chrono-node": "1.3.4", + "jsonwebtoken": "7.4.1", + "promise": "7.3.1", + "request": "2.81.0", + "rsa-pem-from-mod-exp": "0.8.4", + "sprintf-js": "1.1.1", + "url-join": "1.1.0" + } + }, + "buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=" + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "chrono-node": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/chrono-node/-/chrono-node-1.3.4.tgz", + "integrity": "sha1-/CqSCGNuCdb9exLZSuJECTfeJL0=", + "requires": { + "moment": "2.18.1" + } + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, + "combined-stream": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "requires": { + "delayed-stream": "1.0.0" + } + }, + "cryptiles": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", + "requires": { + "boom": "2.10.1" + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "ecc-jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", + "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "ecdsa-sig-formatter": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.9.tgz", + "integrity": "sha1-S8kmJ07Dtau1AW5+HWCSGsJisqE=", + "requires": { + "base64url": "2.0.0", + "safe-buffer": "5.1.1" + } + }, + "extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", + "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" + }, + "extsprintf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", + "integrity": "sha1-4QgOBljjALBilJkMxw4VAiNf1VA=" + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", + "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.15" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "har-schema": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", + "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=" + }, + "har-validator": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", + "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } + }, + "hawk": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "hoek": { + "version": "2.16.3", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=" + }, + "http-signature": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.0", + "sshpk": "1.13.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "isemail": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/isemail/-/isemail-1.2.0.tgz", + "integrity": "sha1-vgPfjMPineTSxd9lASY/H6RZXpo=" + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "joi": { + "version": "6.10.1", + "resolved": "https://registry.npmjs.org/joi/-/joi-6.10.1.tgz", + "integrity": "sha1-TVDDGAeRIgAP5fFq8f+OGRe3fgY=", + "requires": { + "hoek": "2.16.3", + "isemail": "1.2.0", + "moment": "2.18.1", + "topo": "1.1.0" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "optional": true + }, + "jsep": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/jsep/-/jsep-0.3.1.tgz", + "integrity": "sha512-faJGoKcyoHF5aqEI67U85HNhnPmfVD4hZLt5Ko/ieFRl4tHQ/zcSz1RdvLGlM1R4u53Sso25a9AtDeL/LGBDXw==" + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=" + }, + "jsonwebtoken": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-7.4.1.tgz", + "integrity": "sha1-fKMk9SFfi+A5zTWmxFu4y3SkSPs=", + "requires": { + "joi": "6.10.1", + "jws": "3.1.4", + "lodash.once": "4.1.1", + "ms": "2.0.0", + "xtend": "4.0.1" + } + }, + "jsprim": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", + "integrity": "sha1-o7h+QCmNjDgFUtjMdiigu5WiKRg=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.0.2", + "json-schema": "0.2.3", + "verror": "1.3.6" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "jwa": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.1.5.tgz", + "integrity": "sha1-oFUs4CIHQs1S4VN3SjKQXDDnVuU=", + "requires": { + "base64url": "2.0.0", + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.9", + "safe-buffer": "5.1.1" + } + }, + "jws": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.1.4.tgz", + "integrity": "sha1-+ei5M46KhHJ31kRLFGT2GIDgUKI=", + "requires": { + "base64url": "2.0.0", + "jwa": "1.1.5", + "safe-buffer": "5.1.1" + } + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + }, + "lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=" + }, + "mime-db": { + "version": "1.27.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", + "integrity": "sha1-gg9XIpa70g7CXtVeW13oaeVDbrE=" + }, + "mime-types": { + "version": "2.1.15", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", + "integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=", + "requires": { + "mime-db": "1.27.0" + } + }, + "moment": { + "version": "2.18.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.18.1.tgz", + "integrity": "sha1-w2GT3Tzhwu7SrbfIAtu8d6gbHA8=" + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "oauth-sign": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" + }, + "performance-now": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", + "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=" + }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "requires": { + "asap": "2.0.6" + } + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + }, + "qs": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", + "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=" + }, + "request": { + "version": "2.81.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", + "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.15", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.1.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.2", + "tunnel-agent": "0.6.0", + "uuid": "3.1.0" + }, + "dependencies": { + "uuid": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" + } + } + }, + "request-promise": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/request-promise/-/request-promise-4.2.1.tgz", + "integrity": "sha1-fuxWyJMXqCLL/qmbA5zlQ8LhX2c=", + "requires": { + "bluebird": "3.5.0", + "request-promise-core": "1.1.1", + "stealthy-require": "1.1.1", + "tough-cookie": "2.3.2" + } + }, + "request-promise-core": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz", + "integrity": "sha1-Pu4AssWqgyOc+wTFcA2jb4HNCLY=", + "requires": { + "lodash": "4.17.4" + } + }, + "rsa-pem-from-mod-exp": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/rsa-pem-from-mod-exp/-/rsa-pem-from-mod-exp-0.8.4.tgz", + "integrity": "sha1-NipCxtMEBW1JOz8SvOq7LGV2ptQ=" + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "sntp": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", + "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", + "requires": { + "hoek": "2.16.3" + } + }, + "sprintf-js": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.1.tgz", + "integrity": "sha1-Nr54Mgr+WAH2zqPueLblqrlA6gw=" + }, + "sshpk": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", + "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "stealthy-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", + "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=" + }, + "strformat": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/strformat/-/strformat-0.0.7.tgz", + "integrity": "sha1-i2O+wZlXaLuaW8YAdPTN3/BEpMQ=" + }, + "stringstream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", + "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=" + }, + "topo": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/topo/-/topo-1.1.0.tgz", + "integrity": "sha1-6ddRYV0buH3IZdsYL6HKCl71NtU=", + "requires": { + "hoek": "2.16.3" + } + }, + "tough-cookie": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", + "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=", + "requires": { + "punycode": "1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "optional": true + }, + "underscore": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", + "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=" + }, + "url-join": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/url-join/-/url-join-1.1.0.tgz", + "integrity": "sha1-dBxsL0WWxIMNZxhGCSDQySIC3Hg=" + }, + "uuid": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", + "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" + }, + "verror": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", + "integrity": "sha1-z/XfEpRtKX0rqu+qJoniW+AcAFw=", + "requires": { + "extsprintf": "1.0.2" + } + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + } + } +} diff --git a/package.json b/package.json index 98abde7..9eeec76 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bot-graph-dialog", - "version": "3.4.6", + "version": "3.8.4", "description": "bot graph dialog", "main": "index.js", "scripts": { @@ -22,13 +22,38 @@ }, "homepage": "https://github.com/CatalystCode/bot-graph-dialog#readme", "dependencies": { - "bluebird": "^3.4.6", - "botbuilder": "3.4.4", + "botbuilder": "^3.8.4", "extend": "^3.0.0", "jsep": "^0.3.0", "request-promise": "^4.1.1", "strformat": "0.0.7", "underscore": "^1.8.3", "uuid": "^2.0.3" - } + }, + "gitHead": "01fd40b70f7e84c71806785dd3fe54500956403f", + "_id": "bot-graph-dialog@3.4.5", + "_shasum": "695bc3b0e10a8147dd8e1bbce2f26868807f5fde", + "_from": "bot-graph-dialog@3.4.5", + "_npmVersion": "2.15.1", + "_nodeVersion": "4.4.4", + "_npmUser": { + "name": "amiturgman", + "email": "ami.turgman@microsoft.com" + }, + "dist": { + "shasum": "695bc3b0e10a8147dd8e1bbce2f26868807f5fde", + "tarball": "https://registry.npmjs.org/bot-graph-dialog/-/bot-graph-dialog-3.4.5.tgz" + }, + "maintainers": [ + { + "name": "amiturgman", + "email": "ami.turgman@microsoft.com" + } + ], + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/bot-graph-dialog-3.4.5.tgz_1481033480636_0.8297735422383994" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/bot-graph-dialog/-/bot-graph-dialog-3.4.5.tgz" } diff --git a/src/Action.ts b/src/Action.ts deleted file mode 100644 index 6a932cc..0000000 --- a/src/Action.ts +++ /dev/null @@ -1,45 +0,0 @@ -import * as builder from 'botbuilder'; - -/** - * Interface for a custom handler callback - */ -export interface IExecute { - /** - * @param {builder.Session} session - * @param {} next - * @param {} data - * @returns void - */ - (session: builder.Session, next, data): void -} - -/** - * Interface for providing a custom node handler - */ -export interface ICustomNodeTypeHandler { - - /** - * the name - */ - name: string, - - /** - * the handler - */ - execute: IExecute -} - -/** - * Wrapper for a custom node handler - */ -export class CustomNodeTypeHandler implements ICustomNodeTypeHandler { - - /** - * @param {string} name the name for the handler - * @param {IExecute} execute the handler callback - */ - constructor(public name: string, public execute: IExecute) { - - } - -} \ No newline at end of file diff --git a/src/ConditionHandler.ts b/src/ConditionHandler.ts deleted file mode 100644 index 2a470eb..0000000 --- a/src/ConditionHandler.ts +++ /dev/null @@ -1,111 +0,0 @@ -import * as jsep from 'jsep'; - -/** - * Parsing and calculating conditional expressions from strings - * i.e.: age >= 30 & (age * 2) < 40 - */ -export module ConditionHandler { - - /** - * Recursively perform an evaluation of an expression - * @param {any} object - * @param {string|jsep.IExpression} expression - * @returns any - */ - export function evaluateExpression(object: any, expression: string | jsep.IExpression): any { - var exp: jsep.IExpression = null; - if (typeof expression == 'string') { - exp = jsep(expression); - } else { - exp = expression; - } - - // Analyze the expression according to its type - switch (exp.type) { - case 'BinaryExpression': - var bexp = exp as jsep.IBinaryExpression; - var value1 = this.evaluateExpression(object, bexp.left); - var value2 = this.evaluateExpression(object, bexp.right); - return this.calculateExpression(bexp.operator, value1, value2); - - case 'UnaryExpression': - var uexp = exp as jsep.IUnaryExpression; - var value = this.evaluateExpression(object, uexp.argument); - return this.calculateExpression(uexp.operator, value); - - case 'Identifier': - return object[(exp as jsep.IIdentifier).name]; - - case 'MemberExpression': - var mexp = exp as jsep.IMemberExpression; - var parent = this.evaluateExpression(object, mexp.object); - return this.evaluateExpression(parent, mexp.property); - - case 'Literal': - return (exp as jsep.ILiteral).value; - - default: - throw new Error('condition type ' + exp.type + ' is not recognized'); - } - } - - - /** - * Calculate an expression accoring to the operator - * @param {any} operator - * @param {any} value1 - * @param {any=null} value2 - * @returns any - */ - export function calculateExpression(operator: any, value1: any, value2: any = null) : any { - switch (operator) { - - case '!': - return !value1; - - case '<': - return value1 < value2; - - case '>': - return value1 > value2; - - case '<=': - return value1 <= value2; - - case '>=': - return value1 >= value2; - - case '=': - case '==': - return value1 == value2; - - case '===': - return value1 === value2; - - case '!=': - case '<>': - return value1 != value2; - - case '!==': - return value1 !== value2; - - case '-': - return value1 - value2; - - case '+': - return value1 + value2; - - case '*': - return value1 * value2; - - case '/': - return value1 / value2; - - case '%': - return value1 % value2; - - default: - break; - } - } -} diff --git a/src/GraphDialog.ts b/src/GraphDialog.ts deleted file mode 100644 index 795bfeb..0000000 --- a/src/GraphDialog.ts +++ /dev/null @@ -1,611 +0,0 @@ - -import { Parser } from './Parser'; -import { INavigatorOptions, Navigator } from './Navigator'; -import { NodeType, INode } from './Node'; -import { IIntentScorer, IntentScorer } from './IntentScorer'; -import { ICustomNodeTypeHandler, CustomNodeTypeHandler } from './Action'; -import { Map, List } from './Common'; -import { Validator } from './Validator'; -import * as builder from 'botbuilder'; -import * as path from 'path'; -import * as extend from 'extend'; -import * as strformat from 'strformat'; - - -var uuid = require('uuid'); - - -/** - * Interface for {IGraphDialog} options object - * - * @export - * @interface IGraphDialogOptions - * @extends {INavigatorOptions} - */ -export interface IGraphDialogOptions extends INavigatorOptions { - /** - * The bot object - * - * @type {builder.UniversalBot} - * @memberOf IGraphDialogOptions - */ - bot?: builder.UniversalBot; - /** - * list of {ICustomNodeTypeHandler} objects - * - * @type {ICustomNodeTypeHandler[]} - * @memberOf IGraphDialogOptions - */ - customTypeHandlers?: ICustomNodeTypeHandler[]; - /** - * a {IHandler} objects for custom logics before a step is being processed - * - * @type {IHandler} - * @memberOf IGraphDialogOptions - */ - onBeforeProcessingStep?: IHandler; - /** - * a {IHandler} objects for custom logics after a step is being processed - * - * @type {IHandler} - * @memberOf IGraphDialogOptions - */ - onAfterProcessingStep?: IHandler; -} - -/** - * Interface to define a custom node handler - * - * @export - * @interface IHandler - */ -export interface IHandler { - (session: builder.Session, results, next): void -} - -/** - * Interface to define a step function - * - * @interface IStepFunction - */ -interface IStepFunction { - (session: builder.Session, results, next): void; -} - -/** - * Interface for {GraphDialog} class - * - * @export - * @interface IGraphDialog - */ -export interface IGraphDialog { - /** - * Init graph dialog - * - * @returns {Promise} - * - * @memberOf IGraphDialog - */ - init(): Promise; - /** - * Gets the resulting dialog to attach on the bot - * - * @returns {IStepFunction} - * - * @memberOf IGraphDialog - */ - getDialog(): IStepFunction; - /** - * Gets the dialog version from the scenario's json - * - * @returns {string} - * - * @memberOf IGraphDialog - */ - getDialogVersion(): string; - /** - * Gets the the dialog id from the scenario's json - * - * @returns {string} - * - * @memberOf IGraphDialog - */ - getDialogId(): string; - /** - * Cancel the flow of the existing dialog and starts a new one - * - * @returns {void} - * - * @memberOf IGraphDialog - */ - restartDialog(session: builder.Session): void; - /** - * Reloads scenarios for this instance. - * Use this when the scenarios were updated on the remote data source. - * After calling this method you'll probably want to call the restartDialog API to restart the updated dialog. - * - * @returns {Promise} - * - * @memberOf IGraphDialog - */ - reload(): Promise; -} - - -/** - * The Graph Dialog class manages the dialog's state - * - * @export - * @class GraphDialog - * @implements {IGraphDialog} - */ -export class GraphDialog implements IGraphDialog { - - /** - * - * - * @private - * @type {Navigator} - * @memberOf GraphDialog - */ - private nav: Navigator; - /** - * - * - * @private - * @type {IIntentScorer} - * @memberOf GraphDialog - */ - private intentScorer: IIntentScorer; - /** - * - * - * @private - * - * @memberOf GraphDialog - */ - private done: () => any; - /** - * - * - * @private - * @type {Map} - * @memberOf GraphDialog - */ - private customTypeHandlers: Map; - - /** - * If set to true, will not travel to next step as the current step needs to be validated - * - * @private - * @type {boolean} - */ - private validateCurrentNode: boolean = false; - - private parser: Parser = null; - private internalPath: string; - - /** - * Creates an instance of GraphDialog. - * - * @param {IGraphDialogOptions} [options={}] - * - * @memberOf GraphDialog - */ - constructor(private options: IGraphDialogOptions = {}) { - if (!options.bot) throw new Error('please provide the bot object'); - this.intentScorer = new IntentScorer(); - - // Initialize custom handlers - options.customTypeHandlers = options.customTypeHandlers || new Array(); - this.internalPath = '/_' + uuid.v4(); - this.setBotDialog(); - - this.customTypeHandlers = new Map(); - for (let i=0; i < options.customTypeHandlers.length; i++) { - let handler = options.customTypeHandlers[i]; - this.customTypeHandlers.add(handler.name, handler); - } - } - - public getDialogVersion(): string { - return this.parser ? this.parser.version : null; - } - - public getDialogId(): string { - return this.parser ? this.parser.root.id : null; - } - - /** - * Initialize a graph based on graph options like a predefined JSON schema - * - * @returns {Promise} - * - * @memberOf GraphDialog - */ - public init(): Promise { - return new Promise((resolve, reject) => { - this.parser = new Parser(this.options); - this.parser.init().then(() => { - console.log('parser is ready'); - this.nav = new Navigator(this.parser); - return resolve(this); - }).catch(e => reject(e)); - }); - } - - /** - * Generate a new graph dialog constructed based on a scenario name - * - * @static - * @param {IGraphDialogOptions} [options={}] - * @returns {Promise} - * - * @memberOf GraphDialog - */ - public static fromScenario(options: IGraphDialogOptions = {}): Promise { - let graphDialog = new GraphDialog(options); - return graphDialog.init(); - } - - public reload(): Promise { - return this.init(); - } - - public restartDialog(session: builder.Session): void { - - session.privateConversationData = {}; - console.log('calling loop function after restarting dialog'); - - // find this dialog on the callstack - let dialogIndex = -1; - let callstack = session.sessionState.callstack || []; - - for (let i=callstack.length-1; i>=0; i--) { - let item = callstack[i]; - let path = item.id.split('*:')[1]; - if (path === this.internalPath) { - dialogIndex = i; - break; - } - }; - - session.cancelDialog(dialogIndex, this.internalPath); - } - - /** - * Returns the dialog steps to bind to the bot object - * - * @returns {IStepFunction} - * - * @memberOf GraphDialog - */ - public getDialog(): IStepFunction { - console.log('get dialog'); - return (session: builder.Session, results, next) => { - console.log('calling loop function for the first time'); - session.beginDialog(this.internalPath); - }; - } - - /** - * This is where the magic happens. Loops this list of steps for each node. - * - * @private - * - * @memberOf GraphDialog - */ - private setBotDialog(): void { - - this.options.bot.dialog(this.internalPath, [ - (session, args, next) => { - session.dialogData.data = args || {}; - if (this.options.onBeforeProcessingStep) - return this.options.onBeforeProcessingStep.call(this, session, args, next); - else return next(); - }, - (session, args, next) => { - return this.stepInteractionHandler(session, args, next); - }, - (session, args, next) => { - return this.stepResultCollectionHandler(session, args, next); - }, - (session, args, next) => { - return this.setNextStepHandler(session, args, next); - }, - (session, args, next) => { - if (this.options.onAfterProcessingStep) - return this.options.onAfterProcessingStep.call(this, session, args, next); - else return next(); - }, - (session, args, next) => { - console.log('calling loop function'); - session.replaceDialog(this.internalPath, session.dialogData.data); - } - ]); - } - - /** - * This is where the bot interacts with the user - * - * @private - * @param {builder.Session} session - * @param {any} results - * @param {any} next - * @returns {void} - * - * @memberOf GraphDialog - */ - private stepInteractionHandler(session: builder.Session, results, next): void { - session.privateConversationData._lastMessage = session.message && session.message.text; - let currentNode = this.nav.getCurrentNode(session); - console.log(`perform action: ${currentNode.id}, ${currentNode.type}`); - - switch (currentNode.type) { - - case NodeType.text: - var text = strformat(currentNode.data.text, session.dialogData.data); - console.log(`sending text for node ${currentNode.id}, text: \'${text}\'`); - session.send(text); - return next(); - - case NodeType.prompt: - console.log(`builder.ListStyle.button: ${builder.ListStyle["button"]}`); - var promptType = currentNode.data.type || 'text'; - builder.Prompts[promptType]( - session, - currentNode.data.text, - currentNode.data.options, - { - listStyle: currentNode.data.config && currentNode.data.config.listStyle && builder.ListStyle[currentNode.data.config.listStyle] || builder.ListStyle.button - }); - break; - - case NodeType.score: - /** - * gets list of models - * - * @param {any} model - */ - var botModels = currentNode.data.models.map(model => this.nav.models.get(model)); - - var score_text = session.dialogData.data[currentNode.data.source] || session.privateConversationData._lastMessage; - console.log(`LUIS scoring for node: ${currentNode.id}, text: \'${score_text}\' LUIS models: ${botModels}`); - - this.intentScorer.collectIntents(botModels, score_text, currentNode.data.threashold) - .then(intents => { - if (intents && intents.length) { - this.stepResultCollectionHandler(session, { response: intents[0] }, next); - } - }, - function (err) { - throw error; - } - ); - - break; - - case NodeType.handler: - var handlerName = currentNode.data.name; - let handler: IHandler = this.nav.handlers.get(handlerName); - console.log('calling handler: ', currentNode.id, handlerName); - handler(session, next, currentNode.data); - break; - - case NodeType.sequence: - return next(); - - case NodeType.end: - console.log('ending dialog, node:', currentNode.id); - session.send(currentNode.data.text || 'Bye bye!'); - session.endConversation(); // this will also clear the privateConversationData - break; - - case NodeType.heroCard: - session.send(this.generateHeroCardMessage(session, currentNode)); - return next(); - - case NodeType.carousel: - session.send(this.generateCarouselMessage(session, currentNode)); - return next(); - - default: - - let customHandler: ICustomNodeTypeHandler = this.customTypeHandlers.get(currentNode.typeName); - if (customHandler) { - console.log(`invoking custom node type handler: ${currentNode.typeName}`); - return customHandler.execute(session, next, currentNode.data); - } - - var msg = 'Node type ' + currentNode.type + ' is not recognized'; - console.error(msg); - var error = new Error(msg); - console.error(error); - throw error; - } - } - - - /** - * Generates a HeroCard (to be attached to a Message) - * - * @param session - * @param data - * @returns {HeroCard} - */ - private generateHeroCard(session: builder.Session, data: any) { - var hero = new builder.HeroCard(session); - - if (data.title) { - hero.title(data.title); - } - if (data.subtitle) { - hero.subtitle(data.subtitle); - } - if (data.text) { - hero.text(data.text); - } - if (data.images && data.images.length > 0) { - hero.images([ - builder.CardImage.create(session, data.images[0]) - ]); - } - if (data.tap) { - switch (data.tap.action) { - case "openUrl": - hero.tap(builder.CardAction.openUrl(session, data.tap.value)); - break; - } - } - - if (data.buttons) { - var buttons = []; - data.buttons.forEach((item, index) => { - switch (item.action) { - case "openUrl": - buttons.push(builder.CardAction.openUrl(session, item.value, item.label)); - break; - case "imBack": - buttons.push(builder.CardAction.imBack(session, item.value, item.label)); - break; - } - }); - if (buttons.length > 0) { - hero.buttons(buttons); - } - } - - return hero; - } - - /** - * Generates a HeroCard Message - * - * @param session - * @param node - * @returns {Message} - */ - private generateHeroCardMessage(session: builder.Session, node: INode) { - var hero = this.generateHeroCard(session, node.data); - - return new builder.Message(session) - .textFormat(builder.TextFormat.xml) - .attachments([hero]); - } - - /** - * Generates a Carousel Message - * - * @param session - * @param node - * @returns {Message} - */ - private generateCarouselMessage(session: builder.Session, node: INode) { - var data = node.data; - - if (data.text) { - var text = strformat(data.text, session.dialogData.data); - session.send(text); - } - - if (data.cards && data.cards.length > 0) { - var cards = []; - data.cards.forEach((item, index) => { - cards.push(this.generateHeroCard(session, item.data)); - }); - - return new builder.Message(session) - .textFormat(builder.TextFormat.xml) - .attachmentLayout(builder.AttachmentLayout.carousel) - .attachments(cards); - } - } - - /** - * Handling collection of the user input - * - * @private - * @param {builder.Session} session - * @param {any} results - * @param {any} next - * @returns - * - * @memberOf GraphDialog - */ - private stepResultCollectionHandler(session: builder.Session, results, next) { - let currentNode = this.nav.getCurrentNode(session); - let varname = currentNode.varname; - - if (!(results.response && varname)) - return next(); - - if (currentNode.data.validation && currentNode.data.validation.type) - { - // Perform validations - var invalidMsg = currentNode.data.validation.setup.invalid_msg ? currentNode.data.validation.setup.invalid_msg : 'Invalid value'; - var isValid = Validator.validate(currentNode.data.validation.type, results.response, currentNode.data.validation.setup); - if (!isValid) - { - session.send(invalidMsg); - this.validateCurrentNode = true; - return next(); - } - } - - let value: any = null; - switch (currentNode.type) { - case NodeType.prompt: - - // TODO switch to enum - switch (currentNode.data.type) { - case 'time': - value = builder.EntityRecognizer.resolveTime([results.response]); - break; - case 'choice': - value = results.response.entity; - break; - default: - value = results.response; - } - break; - default: - value = results.response; - } - - session.dialogData.data[varname] = value; - console.log('collecting response for node: %s, variable: %s, value: %s', currentNode.id, varname, value); - return next(); - } - - /** - * Evaluates and moves to the next node in the graph - * - * @private - * @param {builder.Session} session - * @param {any} args - * @param {any} next - * @returns {*} - * - * @memberOf GraphDialog - */ - private setNextStepHandler(session: builder.Session, args, next): any { - - let nextNode: INode = null; - if (this.validateCurrentNode) { - nextNode = this.nav.getCurrentNode(session); - this.validateCurrentNode = false; - } else { - nextNode = this.nav.getNextNode(session); - } - - if (nextNode) { - console.log(`step handler node: ${nextNode.id}`); - } - else { - console.log('ending dialog'); - return session.endConversation(); - } - - return next(); - } -} \ No newline at end of file diff --git a/src/IntentScorer.ts b/src/IntentScorer.ts deleted file mode 100644 index d7a008d..0000000 --- a/src/IntentScorer.ts +++ /dev/null @@ -1,98 +0,0 @@ - -import { ILuisModel, LuisModel, IIntentScore, IntentScore } from './Luis'; -import * as request from 'request-promise'; -import * as Promise from 'bluebird'; -import * as _ from 'underscore'; - -/** - * Interface for Intent Scorer - * - * @export - * @interface IIntentScorer - */ -export interface IIntentScorer { - /** - * Collect response from all models - * - * @param {ILuisModel[]} models - * @param {string} text - * @param {number} threashold - * @returns {Promise} - * - * @memberOf IIntentScorer - */ - collectIntents(models: ILuisModel[], text: string, threashold: number): Promise; -} - - -/** - * Score intents from a single or multiple intent scoring APIs - * - * @export - * @class IntentScorer - * @implements {IIntentScorer} - */ -export class IntentScorer implements IIntentScorer { - - /** - * Collect response from all models - * - * @param {ILuisModel[]} models - * @param {string} text - * @param {number} [threashold=0] - * @returns {Promise} - * - * @memberOf IntentScorer - */ - public collectIntents(models: ILuisModel[], text: string, threashold: number = 0): Promise { - - let promises: Promise[] = models.map(model => { - return this.scoreIntent(model, text, threashold); - }); - - return new Promise(function (resolve, reject) { - if (!models) return reject('Please provide models array'); - if (!text) return reject('Please provide text'); - - Promise.all(promises) - .then(intents => { - var sortedIntents = _.sortBy(_.compact(intents), 'score').reverse(); - resolve(sortedIntents); - }) - .catch(reject); - }); - } - - /** - * Scores a specific intent, invoke actual request to LUIS - * - * @private - * @param {ILuisModel} model - * @param {string} text - * @param {number} [threashold=0] - * @returns {Promise} - * - * @memberOf IntentScorer - */ - private scoreIntent(model: ILuisModel, text: string, threashold: number = 0): Promise { - return new Promise(function (resolve, reject) { - return request(model.url + encodeURIComponent(text)) - .then(result => { - let json = JSON.parse(result); - if (!json || !json.intents || !json.intents.length) return resolve(); - - // In case when minumum score is required, enforce minimum score - if (json.intents[0].score < threashold) return resolve(); - - let intent = json.intents[0]; - intent.entities = json.entities; - intent.model = model.name; - - return resolve(intent); - }) - .catch(reject); - }); - } - -} - diff --git a/src/Luis.ts b/src/Luis.ts deleted file mode 100644 index a4ece4a..0000000 --- a/src/Luis.ts +++ /dev/null @@ -1,94 +0,0 @@ - -/** - * Interface for a Luis model - * - * @export - * @interface ILuisModel - */ -export interface ILuisModel { - /** - * name of the model - * - * @type {string} - * @memberOf ILuisModel - */ - name: string; - /** - * Url for the model - * - * @type {string} - * @memberOf ILuisModel - */ - url: string; -} - -/** - * Interface for an intent score - * - * @export - * @interface IIntentScore - */ -export interface IIntentScore { - /** - * model name - * - * @type {string} - * @memberOf IIntentScore - */ - name: string; - /** - * model - * - * @type {string} - * @memberOf IIntentScore - */ - model: string; - /** - * the score - * - * @type {number} - * @memberOf IIntentScore - */ - score: number; -} - -/** - * Wrapper class for a LuisModel details - * - * @export - * @class LuisModel - * @implements {ILuisModel} - */ -export class LuisModel implements ILuisModel { - /** - * Creates an instance of LuisModel. - * - * @param {string} name - * @param {string} url - * - * @memberOf LuisModel - */ - constructor(public name: string, public url: string) { - } -} - -/** - * Wrapper class for an intent score - * - * @export - * @class IntentScore - * @implements {IIntentScore} - */ -export class IntentScore implements IIntentScore { - /** - * Creates an instance of IntentScore. - * - * @param {string} name - * @param {string} model - * @param {number} score - * - * @memberOf IntentScore - */ - constructor(public name: string, public model: string, public score: number) { - } -} diff --git a/src/Navigator.ts b/src/Navigator.ts deleted file mode 100644 index 4847ed0..0000000 --- a/src/Navigator.ts +++ /dev/null @@ -1,123 +0,0 @@ -import { NodeType, INode } from './Node'; -import { IScenario, Scenario } from './Scenario'; -import { ConditionHandler } from './ConditionHandler'; -import { ILuisModel } from './Luis'; -import { Map, List } from './Common'; -import { Parser, IParserOptions } from './Parser'; -import * as builder from 'botbuilder'; -import * as path from 'path'; -import * as extend from 'extend'; -import * as strformat from 'strformat'; - -/** - * Interface for the Navigator constructor options object - * - * @export - * @interface INavigatorOptions - * @extends {IParserOptions} - */ -export interface INavigatorOptions extends IParserOptions { - -} - -/** - * Helper class to navigate the dialog graph - * - * @export - * @class Navigator - */ -export class Navigator { - - /** - * Collection of Luis models - * - * @type {Map} - * @memberOf Navigator - */ - public models: Map; - /** - * Collection of custom handlers - * - * @type {Map} - * @memberOf Navigator - */ - public handlers: Map; - - /** - * Creates an instance of Navigator. - * - * @param {Parser} parser - * @param {INavigatorOptions} [options={}] - * - * @memberOf Navigator - */ - constructor(private parser: Parser, private options: INavigatorOptions = {}) { - this.models = parser.models; - this.handlers = parser.handlers; - } - - - /** - * Returns the current node of the dialog - * - * @param {builder.Session} session - * @returns {INode} - * - * @memberOf Navigator - */ - public getCurrentNode(session: builder.Session): INode { - console.log('getCurrentNode'); - let currNodeId = session.privateConversationData._currentNodeId; - if (!currNodeId) { - let root = this.parser.root; - session.privateConversationData._currentNodeId = root && root.id; - return root; - } - - let current = this.parser.getNodeInstanceById(currNodeId); - return current; - } - - /** - * Retreives the next node in the dialog - * - * @param {builder.Session} session - * @returns {INode} - * - * @memberOf Navigator - */ - public getNextNode(session: builder.Session) : INode { - console.log('getNextNode'); - let next : INode = null; - let current = this.parser.getNodeInstanceById(session.privateConversationData._currentNodeId); - - // If there are child scenarios, see if one of them answers a condition - // In case it is, choose the first step in that scenario to as the next step - let scenarios: List = current.scenarios; - for (var i=0; i} - * @memberOf INode - */ - steps?: List, - /** - * Scenarios nodes in case of a condition node - * - * @type {List} - * @memberOf INode - */ - scenarios?: List -} - - -/** - * The Node class representing a node in the dialog graph - * - * @export - * @class Node - * @implements {INode} - */ -export class Node implements INode { - - /** - * The tree- the head node of this dialog - * - * @private - * @type {any[]} - * @memberOf Node - */ - private tree: any[]; - - /** - * - * - * @type {string} - * @memberOf Node - */ - public id: string; - /** - * - * - * @type {string} - * @memberOf Node - */ - public varname: string; - /** - * - * - * @type {NodeType} - * @memberOf Node - */ - public type: NodeType; - /** - * - * - * @type {string} - * @memberOf Node - */ - public typeName: string; - /** - * - * - * @type {*} - * @memberOf Node - */ - public body: any; - /** - * - * - * @type {*} - * @memberOf Node - */ - public data: any; - /** - * - * - * @type {List} - * @memberOf Node - */ - public steps: List; - /** - * - * - * @type {List} - * @memberOf Node - */ - public scenarios: List; - /** - * - * - * @type {INode} - * @memberOf Node - */ - public parent: INode; - /** - * - * - * @type {INode} - * @memberOf Node - */ - public prev: INode; - /** - * - * - * @type {INode} - * @memberOf Node - */ - public next: INode; - - /** - * Creates an instance of Node. - * - * @param {INode} node - * @param {(string | NodeType)} type - * - * @memberOf Node - */ - constructor(node: INode, type: string | NodeType) { - - this.id = node.id; - if (typeof type === 'string') { - this.type = NodeType[type]; - this.typeName = type; - } - else - this.type = type; - - this.varname = node.varname || this.id; - this.steps = new List(); - this.scenarios = new List(); - - this.body = node; - this.data = node.data; - } -} \ No newline at end of file diff --git a/src/Parser.ts b/src/Parser.ts deleted file mode 100644 index 4d7bc32..0000000 --- a/src/Parser.ts +++ /dev/null @@ -1,437 +0,0 @@ -import { NodeType, INode, Node } from './Node'; -import { Scenario } from './Scenario'; -import { ConditionHandler } from './ConditionHandler'; -import { ILuisModel, LuisModel } from './Luis'; -import { Map, List } from './Common'; -import * as builder from 'botbuilder'; -import * as path from 'path'; -import * as extend from 'extend'; -import * as strformat from 'strformat'; -import * as Promise from 'bluebird'; -import * as crypto from 'crypto'; - -/** - * Interface for the IParser options object - * - * @export - * @interface IParserOptions - */ -export interface IParserOptions { - /** - * The name of the scenario for this dialog - * - * @type {string} - * @memberOf IParserOptions - */ - scenario?: string; - /** - * A callback for loading a scenario - * - * @param {string} name The scenario name - * @returns {Promise} - * - * @memberOf IParserOptions - */ - loadScenario?(name: string): Promise; - /** - * A callback for loading a custom handler - * - * @param {string} name The custom handler name - * @returns {Promise} - * - * @memberOf IParserOptions - */ - loadHandler?(name: string): Promise; -} - - -/** - * Parses a json based scenario - * - * @export - * @class Parser - */ -export class Parser { - - /** - * - * - * @private - * @type {number} - * @memberOf Parser - */ - private uniqueNodeId: number = 1; - - /** - * - * - * @type {INode} - * @memberOf Parser - */ - public root: INode = null; - /** - * - * - * @type {string} - * @memberOf Parser - */ - public version: string = null; - /** - * - * - * @private - * - * @memberOf Parser - */ - private nodes = new Map(); - /** - * - * - * - * @memberOf Parser - */ - public models = new Map(); - /** - * - * - * - * @memberOf Parser - */ - public handlers = new Map(); - /** - * A callback to be called when parsing is completed - * - * @private - * - * @memberOf Parser - */ - private done: () => any; - - /** - * Creates an instance of Parser. - * - * @param {IParserOptions} options - * - * @memberOf Parser - */ - constructor(private options: IParserOptions) { - - } - - /** - * Start loading and parsing scenario - * - * @returns {Promise} - * - * @memberOf Parser - */ - public init(): Promise { - return new Promise((resolve, reject) => { - this.options.loadScenario(this.options.scenario) - .then((graph) => { - return this.normalizeGraph(graph).then(() => { - return resolve(); - }).catch(e => reject(e)); - }) - .catch(e => { - console.error(`error loading scenario: ${this.options}: ${e.message}`); - return reject(e); - }); - }); - } - - /** - * Gets a node instance by its Id - * - * @param {string} id - * @returns {INode} - * - * @memberOf Parser - */ - public getNodeInstanceById(id: string) : INode { - //let node = this.nodes.get(id); - let node = this.nodes[id]; // TODO: check why above line doesn't work - return (node && node._instance); - } - - /** - * Normalize the graph - * - * @private - * @param {*} origGraph - * @returns {Promise} - * - * @memberOf Parser - */ - private normalizeGraph(origGraph: any): Promise { - return new Promise((resolve, reject) => { - - // create a copy of the graph object - var graph: any = {}; - extend(true, graph, origGraph); - - console.log('loading scenario:', graph.id); - this.updateModels(graph.models); - - this.recursive(graph).then(() => { - - let nodes = this.nodes; - - // first iteration- create Node instances - for (let nodeId in nodes) { - let node = nodes[nodeId]; - let inst = new Node(node, node.type); - node._instance = inst; - } - - // second iteration- connect reference to Node instances - for (let nodeId in nodes) { - let node = nodes[nodeId]; - let inst = node._instance; - if (node._parent) inst.parent = node._parent._instance; - if (node._prev) inst.prev = node._prev._instance; - if (node._next) inst.next = node._next._instance; - (node.steps || []).forEach((step: any) => { - inst.steps.add(step._instance); - }); - (node.scenarios || []).forEach((scenario: any) => { - let scenarioNode: INode = null; - if (scenario.nodeId) { - scenarioNode = this.nodes[scenario.nodeId]._instance; - } - let scene = new Scenario(scenario.condition, scenarioNode); - (scenario.steps || []).forEach((step: any) => { - scene.steps.add(step._instance); - }); - inst.scenarios.add(scene); - }); - } - - // third iteration- remove un-neccessary data/references - for (let nodeId in nodes) { - let node = nodes[nodeId]; - let inst = node._instance; - - delete node._visited; - delete node._parent; - delete node._prev; - delete node._next; - } - - this.root = graph._instance; - this.version = graph.version || this.calculateHash(JSON.stringify(origGraph)); - - return resolve(); - }).catch(e => reject(e)); - }); - } - - /** - * Init a node in the graph - * - * @private - * @param {*} parent - * @param {any[]} nodes - * @param {*} nodeItem - * @param {number} index - * @returns {Promise} - * - * @memberOf Parser - */ - private initNode(parent: any, nodes: any[], nodeItem: any, index: number): Promise { - - if (nodeItem._visited) - return Promise.resolve(); - nodeItem._visited = true; - - if (!nodeItem.id) { nodeItem.id = '_node_' + (this.uniqueNodeId++); } - - if (parent) nodeItem._parent = parent; - if (index > 0) nodeItem._prev = nodes[index - 1]; - if (nodes.length > index + 1) nodeItem._next = nodes[index + 1]; - - if (this.isSubScenario(nodeItem)) { - console.log(`sub-scenario for node: ${nodeItem.id} [embedding sub scenario: ${nodeItem.subScenario}]`); - - return new Promise((resolve, reject) => { - this.options.loadScenario(nodeItem.subScenario) - .then(scenarioObj => { - extend(true, nodeItem, scenarioObj); - this.updateModels(scenarioObj.models); - - console.log('node:', nodeItem.id, - nodeItem._parent && nodeItem._parent.id ? '[parent: ' + nodeItem._parent.id + ']' : '', - nodeItem._next && nodeItem._next.id ? '[next: ' + nodeItem._next.id + ']' : '', - nodeItem._prev && nodeItem._prev.id ? '[prev: ' + nodeItem._prev.id + ']' : ''); - - return this.recursive(nodeItem).then(() => { - return resolve(); - }).catch(e => reject(e)); - }).catch(e => reject(e)); - }); - } - else if (nodeItem.type === 'handler') { - var handler = nodeItem.data.name || ''; - console.log(`loading handler for node: ${nodeItem.id} [embedding sub scenario: ${handler}]`); - - if (nodeItem.data.js) { - // handler code is embeded in the json in a multiline format (array) or a string - var content = nodeItem.data.js; - if (Array.isArray(content)) - content = content.join('\n'); - var func = this.getHandlerFunc(content); - if (!func) { - console.error(`error loading handler ${handler}`); - } - this.handlers.add(handler, func); - } - else { - // handler code should be fethced using the loadHandler callback - return new Promise((resolve, reject) => { - this.options.loadHandler(handler) - .then(text => { - var func = this.getHandlerFunc(text); - if (!func) { - console.error(`error loading handler ${handler}`); - return reject(new Error(`error loading handler ${handler}`)); - } - this.handlers.add(handler, func); - - console.log('node:', nodeItem.id, - nodeItem._parent && nodeItem._parent.id ? '[parent: ' + nodeItem._parent.id + ']' : '', - nodeItem._next && nodeItem._next.id ? '[next: ' + nodeItem._next.id + ']' : '', - nodeItem._prev && nodeItem._prev.id ? '[prev: ' + nodeItem._prev.id + ']' : ''); - - return this.recursive(nodeItem).then(() => { - return resolve(); - }).catch(e => reject(e)); - }).catch(e => reject(e)); - }); - } - } - - console.log('node:', nodeItem.id, - nodeItem._parent && nodeItem._parent.id ? '[parent: ' + nodeItem._parent.id + ']' : '', - nodeItem._next && nodeItem._next.id ? '[next: ' + nodeItem._next.id + ']' : '', - nodeItem._prev && nodeItem._prev.id ? '[prev: ' + nodeItem._prev.id + ']' : ''); - - return this.recursive(nodeItem); - - } - - /** - * Init a collecton of nodes - * - * @private - * @param {*} parent - * @param {any[]} nodes - * @returns {Promise} - * - * @memberOf Parser - */ - private initNodes(parent: any, nodes: any[]) : Promise { - return Promise.all((nodes || []).map((item, index) => this.initNode(parent, nodes, item, index))); - } - - - /** - * Recursively init a node and its childrens - * - * @private - * @param {*} node - * @returns {Promise} - * - * @memberOf Parser - */ - private recursive(node: any) : Promise { - - return new Promise((resolve, reject) => { - if (!node.id) { node.id = '_node_' + (this.uniqueNodeId++); } - - this.initNodes(node, node.steps).then(() => { - - var promises = (node.scenarios || []).map(scenario => this.initNodes(node, scenario.steps)); - return Promise.all(promises).then(() => { - - if (node.type === 'sequence') { - return this.initNodes(node, node.steps).then(()=> { - this.nodes[node.id] = node; - return resolve(); - }).catch(e => reject(e)); - - } - else { - this.nodes[node.id] = node; - return resolve(); - } - }).catch(e => reject(e)); - }).catch(e => reject(e)); - }); - } - - /** - * Checks if this is a sub-scenario node, and if so- load it - * - * @private - * @param {*} nodeItem - * @returns {boolean} - * - * @memberOf Parser - */ - private isSubScenario(nodeItem: any) : boolean { - if (!nodeItem.subScenario) return false; - - var parent = nodeItem._parent; - while (parent) { - if (nodeItem.subScenario === parent.id) { - console.error('recursive subScenario found: ', nodeItem.subScenario); - throw new Error('recursive subScenario found ' + nodeItem.subScenario); - } - parent = parent._parent; - } - - return true; - } - - /** - * Get handler function from a string - * - * @private - * @param {string} funcText - * @returns {*} - * - * @memberOf Parser - */ - private getHandlerFunc(funcText: string): any { - let text = `(function(){ - return function(module) { - ${funcText} - } - })() - `; - - var wrapperFunc = eval(text); - var m: any = {}; - wrapperFunc(m); - - return typeof m.exports === 'function' ? m.exports : null; - } - - /** - * Updates the internal models collection - * - * @private - * @param {any[]} models - * - * @memberOf Parser - */ - private updateModels(models: any[]): void { - (models || []).forEach(model => { - this.models.add(model.name, new LuisModel(model.name, model.url)); - }); - } - - private calculateHash(text: string) { - return crypto.createHash('md5').update(text).digest('hex'); - } -} diff --git a/src/Scenario.ts b/src/Scenario.ts deleted file mode 100644 index e383313..0000000 --- a/src/Scenario.ts +++ /dev/null @@ -1,79 +0,0 @@ - -import { List } from './Common'; -import { INode } from './Node'; - -/** - * An interface for a scenario - * - * @export - * @interface IScenario - */ -export interface IScenario { - /** - * The condition for this scenario - * - * @type {string} - * @memberOf IScenario - */ - condition: string; - /** - * List of steps - * - * @type {List} - * @memberOf IScenario - */ - steps?: List; - /** - * A node to jump to if a condition is met - * - * @type {INode} - * @memberOf IScenario - */ - node: INode; -} - -/** - * A scenario class - * - * @export - * @class Scenario - * @implements {IScenario} - */ -export class Scenario implements IScenario { - - /** - * - * - * @type {string} - * @memberOf Scenario - */ - public condition: string; - /** - * - * - * @type {List} - * @memberOf Scenario - */ - public steps: List; - /** - * - * - * @type {INode} - * @memberOf Scenario - */ - public node: INode; - - /** - * Creates an instance of Scenario. - * - * @param {string} condition - * @param {INode} [node=null] - * - * @memberOf Scenario - */ - constructor(condition: string, node: INode = null) { - this.condition = condition; - this.node = node; - this.steps = new List() - } -} diff --git a/src/Validator.ts b/src/Validator.ts deleted file mode 100644 index ca58104..0000000 --- a/src/Validator.ts +++ /dev/null @@ -1,64 +0,0 @@ -export module Validator { - - /** - * Validates a value against given type rule - * - * @param {string} type - * @param {string} value - * @param {Object} configuration - */ - export function validate(type: string, value: string|Date, configuration: any): any { - - let result = false; - - switch (type) { - // @TODO: maybe enum this.. - case 'date': - result = this.validateDate(value, configuration); - break; - case 'regex': - result = this.validateRegex(value, configuration); - break; - - } - - return result; - } - - /** - * - * @param value - * @param configuration - * @returns {boolean} - */ - export function validateDate(value: any, configuration: any): boolean { - - let date = value.resolution.start.getTime(); - - if (configuration.min_date) { - var dateMin = new Date(configuration.min_date).getTime(); - if (date < dateMin) return false; - } - - if (configuration.max_date) { - var dateMax = new Date(configuration.max_date).getTime(); - if (date > dateMax) return false; - } - - return true; - } - - /** - * - * @param value - * @param configuration - * @returns {boolean} - */ - export function validateRegex(value: string, configuration: any): boolean { - var regex = new RegExp(configuration.pattern); - var isValid = regex.test(value); - return isValid; - } - - -} \ No newline at end of file diff --git a/src/common.ts b/src/common.ts deleted file mode 100644 index b6c519f..0000000 --- a/src/common.ts +++ /dev/null @@ -1,56 +0,0 @@ -// This file contains common helper classes - -/** - * A generic list to help with operations on arrays - */ -export class List { - private items: Array; - - constructor() { - this.items = []; - } - - size(): number { - return this.items.length; - } - - add(value: T): void { - this.items.push(value); - } - - get(index: number): T { - return index < this.size() ? this.items[index] : null; - } -} - -/** - * A generic class to manage mapping on arrays from string to a generic type - */ -export class Map { - private items: { [key: string]: T }; - - constructor() { - this.items = {}; - } - - add(key: string, value: T): void { - this.items[key] = value; - } - - has(key: string): boolean { - return key in this.items; - } - - get(key: string): T { - return this.items[key]; - } - - keys() : string[] { - return Object.keys(this.items); - } - - values(): T[] { - return Object.keys(this.items).map(key => this.items[key]); - } - -} diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index f63096b..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "sourceMap": false, - "noImplicitAny": false, - "outDir": "./lib", - "noEmitOnError": true, - "removeComments": true - }, - "exclude": [ - "botbuilder.d.ts" - ] -} diff --git a/tsd.json b/tsd.json deleted file mode 100644 index c33331c..0000000 --- a/tsd.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "version": "v4", - "repo": "borisyankov/DefinitelyTyped", - "ref": "master", - "path": "typings", - "bundle": "typings/tsd.d.ts", - "installed": { - "uuid/UUID.d.ts": { - "commit": "44be13ae844ec0721109542d5902e41438d72855" - }, - "extend/extend.d.ts": { - "commit": "44be13ae844ec0721109542d5902e41438d72855" - }, - "request/request.d.ts": { - "commit": "44be13ae844ec0721109542d5902e41438d72855" - }, - "request-promise/request-promise.d.ts": { - "commit": "44be13ae844ec0721109542d5902e41438d72855" - }, - "form-data/form-data.d.ts": { - "commit": "44be13ae844ec0721109542d5902e41438d72855" - }, - "bluebird/bluebird-2.0.d.ts": { - "commit": "44be13ae844ec0721109542d5902e41438d72855" - }, - "node/node.d.ts": { - "commit": "44be13ae844ec0721109542d5902e41438d72855" - }, - "promise/promise.d.ts": { - "commit": "44be13ae844ec0721109542d5902e41438d72855" - }, - "underscore/underscore.d.ts": { - "commit": "44be13ae844ec0721109542d5902e41438d72855" - } - } -} diff --git a/typings/bluebird/bluebird-2.0.d.ts b/typings/bluebird/bluebird-2.0.d.ts deleted file mode 100644 index 3465985..0000000 --- a/typings/bluebird/bluebird-2.0.d.ts +++ /dev/null @@ -1,773 +0,0 @@ -// Type definitions for bluebird 2.0.0 -// Project: https://github.com/petkaantonov/bluebird -// Definitions by: Bart van der Schoor , falsandtru -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -// ES6 model with generics overload was sourced and trans-multiplied from es6-promises.d.ts -// By: Campredon - -// Warning: recommended to use `tsc > v0.9.7` (critical bugs in earlier generic code): -// - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/1563 - -// Note: replicate changes to all overloads in both definition and test file -// Note: keep both static and instance members inline (so similar) - -// TODO fix remaining TODO annotations in both definition and test - -// TODO verify support to have no return statement in handlers to get a Promise (more overloads?) - -declare var Promise: PromiseConstructor; - -interface PromiseCancelHandlerSetter { - (handler: () => void): void; -} - -interface PromiseConstructor { - /** - * 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. - * - * If configured appropriately, it will also receive an `onCancel` - * function that can be used to configure a promise cancellation handler. - */ - new (callback: ( - resolve: (thenableOrResult?: T | PromiseLike) => void, - reject: (error: any) => void, - onCancel?: PromiseCancelHandlerSetter - ) => void): Promise; - - config(options: { - warnings?: boolean | {wForgottenReturn?: boolean}; - longStackTraces?: boolean; - cancellation?: boolean; - monitoring?: boolean; - }): void; - - // Ideally, we'd define e.g. "export class RangeError extends Error {}", - // but as Error is defined as an interface (not a class), TypeScript doesn't - // allow extending Error, only implementing it. - // However, if we want to catch() only a specific error type, we need to pass - // a constructor function to it. So, as a workaround, we define them here as such. - RangeError(): RangeError; - CancellationError(): Promise.CancellationError; - TimeoutError(): Promise.TimeoutError; - TypeError(): Promise.TypeError; - RejectionError(): Promise.RejectionError; - OperationalError(): Promise.OperationalError; - - /** - * Changes how bluebird schedules calls a-synchronously. - * - * @param scheduler Should be a function that asynchronously schedules - * the calling of the passed in function - */ - setScheduler(scheduler: (callback: (...args: any[]) => void) => void): void; - - /** - * 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. - */ - try(fn: () => T | PromiseLike, args?: any[], ctx?: any): Promise; - - attempt(fn: () => T | PromiseLike, args?: any[], ctx?: any): Promise; - - /** - * 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. - */ - 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. - */ - resolve(value: T | PromiseLike): Promise; - resolve(): Promise; - - /** - * Create a promise that is rejected with the given `reason`. - */ - reject(reason: any): Promise; - reject(reason: any): Promise; - - /** - * Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?: Promise(#promise-resolution). - */ - defer(): Promise.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. - */ - cast(value: T | PromiseLike): Promise; - - /** - * Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`. - */ - bind(thisArg: any): Promise; - - /** - * See if `value` is a trusted Promise. - */ - 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 alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency. - */ - longStackTraces(): void; - - /** - * Returns a promise that will be fulfilled 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. - */ - // TODO enable more overloads - delay(ms: number, value: T | PromiseLike): Promise; - delay(ms: number): Promise; - - /** - * 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`. - */ - promisify(func: (callback: (err: any, result: T) => void) => void, receiver?: any): () => Promise; - promisify(func: (arg1: A1, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1) => Promise; - promisify(func: (arg1: A1, arg2: A2, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2) => Promise; - promisify(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2, arg3: A3) => Promise; - promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Promise; - promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result: T) => void) => void, receiver?: any): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Promise; - promisify(nodeFunction: Function, receiver?: any): 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? - promisifyAll(target: Object, options?: Promise.PromisifyAllOptions): any; - - - /** - * Returns a promise that is resolved by a node style callback function. - */ - fromNode(resolver: (callback: (err: any, result?: any) => void) => void, options? : {multiArgs? : boolean}): Promise; - fromCallback(resolver: (callback: (err: any, result?: any) => void) => void, options? : {multiArgs? : boolean}): Promise; - - /** - * 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 - coroutine(generatorFunction: Function): Function; - - /** - * Spawn a coroutine which may yield promises 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 spawn GeneratorFunction - spawn(generatorFunction: Function): Promise; - - /** - * This is relevant to browser environments with no module loader. - * - * Release control of the `Promise` namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else. - */ - noConflict(): typeof Promise; - - /** - * 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. - */ - 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 - // promise of array with promises of value - all(values: PromiseLike[]>): Promise; - // promise of array with values - all(values: PromiseLike): Promise; - // array with promises of value - all(values: PromiseLike[]): Promise; - // array with promises of different types - all(values: [PromiseLike, PromiseLike, PromiseLike, PromiseLike, PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; - all(values: [PromiseLike, PromiseLike, PromiseLike, PromiseLike]): Promise<[T1, T2, T3, T4]>; - all(values: [PromiseLike, PromiseLike, PromiseLike]): Promise<[T1, T2, T3]>; - all(values: [PromiseLike, PromiseLike]): Promise<[T1, T2]>; - // array with values - all(values: T[]): Promise; - - /** - * 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 - props(object: Promise): Promise; - // object - props(object: Object): Promise; - - /** - * 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 either fulfilled or rejected. The fulfillment value is an array of ``PromiseInspection`` instances at respective positions in relation to the input array. - * - * *original: The array is not modified. The input array sparsity is retained in the resulting array.* - */ - // promise of array with promises of value - settle(values: PromiseLike[]>): Promise[]>; - // promise of array with values - settle(values: PromiseLike): Promise[]>; - // array with promises of value - settle(values: PromiseLike[]): Promise[]>; - // array with values - settle(values: T[]): Promise[]>; - - /** - * 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. - */ - // promise of array with promises of value - any(values: PromiseLike[]>): Promise; - // promise of array with values - any(values: PromiseLike): Promise; - // array with promises of value - any(values: PromiseLike[]): Promise; - // array with values - any(values: T[]): Promise; - - /** - * 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. - */ - // promise of array with promises of value - race(values: PromiseLike[]>): Promise; - // promise of array with values - race(values: PromiseLike): Promise; - // array with promises of value - race(values: PromiseLike[]): Promise; - // array with values - race(values: T[]): Promise; - - /** - * 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 - some(values: PromiseLike[]>, count: number): Promise; - // promise of array with values - some(values: PromiseLike, count: number): Promise; - // array with promises of value - some(values: PromiseLike[], count: number): Promise; - // array with values - some(values: T[], count: number): Promise; - - /** - * Like `Promise.all()` but instead of having to pass an array, the array is generated from the passed variadic arguments. - */ - // variadic array with promises of value - join(...values: PromiseLike[]): Promise; - // variadic array with values - join(...values: T[]): Promise; - - /** - * 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 - map(values: PromiseLike[]>, mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike, options?: Promise.ConcurrencyOption): Promise; - - // promise of array with values - map(values: PromiseLike, mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike, options?: Promise.ConcurrencyOption): Promise; - - // array with promises of value - map(values: PromiseLike[], mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike, options?: Promise.ConcurrencyOption): Promise; - - // array with values - map(values: T[], mapper: (item: T, index: number, arrayLength: number) => U | PromiseLike, options?: Promise.ConcurrencyOption): Promise; - - /** - * Similar to `map` with concurrency set to 1 but guaranteed to execute in sequential order - * - * 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 - mapSeries(values: PromiseLike[]>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike): Promise; - - // promise of array with values - mapSeries(values: PromiseLike, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike): Promise; - - // array with promises of value - mapSeries(values: PromiseLike[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike): Promise; - - // array with values - mapSeries(values: R[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike): Promise; - - - /** - * 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 - reduce(values: PromiseLike[]>, reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Promise; - - // promise of array with values - reduce(values: PromiseLike, reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Promise; - - // array with promises of value - reduce(values: PromiseLike[], reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Promise; - - // array with values - reduce(values: T[], reducer: (total: U, current: T, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Promise; - - /** - * 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 - filter(values: PromiseLike[]>, filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike, option?: Promise.ConcurrencyOption): Promise; - - // promise of array with values - filter(values: PromiseLike, filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike, option?: Promise.ConcurrencyOption): Promise; - - // array with promises of value - filter(values: PromiseLike[], filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike, option?: Promise.ConcurrencyOption): Promise; - - // array with values - filter(values: T[], filterer: (item: T, index: number, arrayLength: number) => boolean | PromiseLike, option?: Promise.ConcurrencyOption): Promise; - - /** - * 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 - each(values: PromiseLike[]>, iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike): Promise; - // array with promises of value - each(values: PromiseLike[], iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike): Promise; - // array with values OR promise of array with values - each(values: T[] | PromiseLike, iterator: (item: T, index: number, arrayLength: number) => U | PromiseLike): Promise; -} - -interface Promise extends PromiseLike, Promise.Inspection { - /** - * Promises/A+ `.then()` with progress handler. 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: T) => U | PromiseLike, onReject?: (error: any) => U | PromiseLike, onProgress?: (note: any) => any): Promise; - then(onFulfill: (value: T) => U | PromiseLike, onReject?: (error: any) => void | PromiseLike, onProgress?: (note: any) => any): Promise; - - /** - * 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) => T | PromiseLike | void | PromiseLike): Promise; - caught(onReject?: (error: any) => T | PromiseLike | void | PromiseLike): Promise; - - catch(onReject?: (error: any) => U | PromiseLike): Promise; - caught(onReject?: (error: any) => U | PromiseLike): Promise; - - /** - * 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) => T | PromiseLike | void | PromiseLike): Promise; - caught(predicate: (error: any) => boolean, onReject: (error: any) => T | PromiseLike | void | PromiseLike): Promise; - - catch(predicate: (error: any) => boolean, onReject: (error: any) => U | PromiseLike): Promise; - caught(predicate: (error: any) => boolean, onReject: (error: any) => U | PromiseLike): Promise; - - catch(ErrorClass: Function, onReject: (error: any) => T | PromiseLike | void | PromiseLike): Promise; - caught(ErrorClass: Function, onReject: (error: any) => T | PromiseLike | void | PromiseLike): Promise; - - catch(ErrorClass: Function, onReject: (error: any) => U | PromiseLike): Promise; - caught(ErrorClass: Function, onReject: (error: any) => U | PromiseLike): Promise; - - - /** - * 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) => PromiseLike): Promise; - error(onReject: (reason: any) => U): Promise; - - /** - * 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 | PromiseLike): Promise; - - lastly(handler: () => U | PromiseLike): Promise; - - /** - * 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): Promise; - - /** - * Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error. - */ - done(onFulfilled?: (value: T) => PromiseLike, onRejected?: (error: any) => U | PromiseLike, onProgress?: (note: any) => any): void; - done(onFulfilled?: (value: T) => U, onRejected?: (error: any) => U | PromiseLike, onProgress?: (note: any) => any): void; - - /** - * Like `.finally()`, but not called for rejections. - */ - tap(onFulFill: (value: T) => U | PromiseLike): Promise; - - /** - * Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise. - */ - progressed(handler: (note: any) => any): Promise; - - /** - * Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - delay(ms: number): Promise; - - /** - * 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 `Promise.TimeoutError` instance. - * - * You may specify a custom error message with the `message` parameter. - */ - timeout(ms: number, message?: string): Promise; - - /** - * 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. - * Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything. - */ - nodeify(callback: (err: any, value?: T) => void, options?: Promise.SpreadOption): Promise; - nodeify(...sink: any[]): Promise; - - /** - * Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise. - */ - cancellable(): Promise; - - /** - * Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending. - * - * That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason. - * - * In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`. - * - * Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable. - */ - // TODO what to do with this? - cancel(reason?: any): Promise; - - /** - * Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors. - */ - fork(onFulfilled?: (value: T) => U | PromiseLike, onRejected?: (error: any) => U | PromiseLike, onProgress?: (note: any) => any): Promise; - - /** - * Create an uncancellable promise based on this promise. - */ - uncancellable(): Promise; - - /** - * See if this promise can be cancelled. - */ - isCancellable(): boolean; - - /** - * 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(): T; - - /** - * 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 `.inspect()`. - */ - inspect(): Promise.Inspection; - - /** - * This is a convenience method for doing: - * - * - * promise.then(function(obj){ - * return obj[propertyName].call(obj, arg...); - * }); - * - */ - call(propertyName: string, ...args: any[]): Promise; - - /** - * This is a convenience method for doing: - * - * - * promise.then(function(obj){ - * return obj[propertyName]; - * }); - * - */ - // TODO find way to fix get() - // get(propertyName: string): Promise; - - /** - * 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(): Promise; - thenReturn(): Promise; - return(value: U): Promise; - thenReturn(value: U): Promise; - - /** - * Convenience method for: - * - * - * .then(function() { - * throw reason; - * }); - * - * Same limitations apply as with `.return()`. - * - * Alias `.thenThrow();` for compatibility with earlier ECMAScript version. - */ - throw(reason: Error): Promise; - thenThrow(reason: Error): Promise; - - /** - * 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. - */ - // TODO how to model instance.spread()? like Q? - spread(onFulfill: Function, onReject?: (reason: any) => U | PromiseLike): Promise; - /* - // TODO or something like this? - spread(onFulfill: (...values: W[]) => PromiseLike, onReject?: (reason: any) => PromiseLike): Promise; - spread(onFulfill: (...values: W[]) => PromiseLike, onReject?: (reason: any) => U): Promise; - spread(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => PromiseLike): Promise; - spread(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => U): Promise; - */ - /** - * 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(): Promise; - - /** - * 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(): Promise; - - /** - * Same as calling `Promise.settle(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? - settle(): Promise[]>; - - /** - * 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(): Promise; - - /** - * 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): Promise; - - /** - * 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(): Promise; - - /** - * Same as calling `Promise.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 | PromiseLike, options?: Promise.ConcurrencyOption): Promise; - - /** - * Same as `Promise.mapSeries(thisPromise, mapper)`. - */ - // TODO type inference from array-resolving promise? - mapSeries(mapper: (item: Q, index: number, arrayLength: number) => U | PromiseLike): Promise; - - /** - * 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 | PromiseLike, initialValue?: U): Promise; - - /** - * 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 | PromiseLike, options?: Promise.ConcurrencyOption): Promise; - - /** - * Same as calling ``Promise.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: T, index: number, arrayLength: number) => U | PromiseLike): Promise; -} - -/** - * Don't use variable namespace such as variables, functions, and classes. - * If you use this namespace, it will conflict in es6. - */ -declare namespace Promise { - export interface RangeError extends Error { - } - export interface CancellationError extends Error { - } - export interface TimeoutError extends Error { - } - export interface TypeError extends Error { - } - export interface RejectionError extends Error { - } - export interface OperationalError extends Error { - } - - export interface ConcurrencyOption { - concurrency: number; - } - export interface SpreadOption { - spread: boolean; - } - export interface PromisifyAllOptions { - 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) => () => PromiseLike; - } - - export interface Resolver { - /** - * Returns a reference to the controlled promise that can be passed to clients. - */ - promise: Promise; - - /** - * 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: T): void; - resolve(): void; - - /** - * Reject the underlying promise with `reason` as the rejection reason. - */ - reject(reason: any): void; - - /** - * Progress the underlying promise with `value` as the progression value. - */ - progress(value: 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: T, ...values: T[]) => 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(): T; - - /** - * 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; - } -} - -declare module 'bluebird' { - export = Promise; -} diff --git a/typings/extend/extend.d.ts b/typings/extend/extend.d.ts deleted file mode 100644 index cda9f07..0000000 --- a/typings/extend/extend.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Type definitions for extend v2.0.0 -// Project: https://www.npmjs.com/package/extend -// Definitions by: Stefan Steinhart -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module "extend" { - - function extend(deepOrObject:boolean | Object, ...objectN: Object[]): any; - namespace extend {} - export = extend; -} diff --git a/typings/form-data/form-data.d.ts b/typings/form-data/form-data.d.ts deleted file mode 100644 index e285d77..0000000 --- a/typings/form-data/form-data.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Type definitions for form-data -// Project: https://github.com/felixge/node-form-data -// Definitions by: Carlos Ballesteros Velasco , Leon Yu -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -// Imported from: https://github.com/soywiz/typescript-node-definitions/form-data.d.ts - -declare module "form-data" { - class FormData { - append(key: string, value: any, options?: any): void; - getHeaders(): FormData.Dictionary; - // TODO expand pipe - pipe(to: any): any; - submit(params: string | Object, callback: (error: any, response: any) => void): any; - getBoundary(): string; - } - - namespace FormData { - interface Dictionary { - [key: string]: T; - } - } - - export = FormData; -} \ No newline at end of file diff --git a/typings/jsep.d.ts b/typings/jsep.d.ts deleted file mode 100644 index 21daf99..0000000 --- a/typings/jsep.d.ts +++ /dev/null @@ -1,45 +0,0 @@ - -declare module 'jsep' { - - namespace jsep { - export interface IExpression { - type: string; - } - - export interface ILiteral extends IExpression { - type: "Literal"; - value: any; - raw: string; - } - - export interface IIdentifier extends IExpression { - type: 'Identifier' - name: string; - } - - export interface IBinaryExpression extends IExpression { - type: 'BinaryExpression'; - operator: string; - left: IExpression; - right: IExpression; - } - - export interface IUnaryExpression extends IExpression { - type: 'UnaryExpression'; - operator: string; - argument: IExpression; - prefix: boolean; - } - - export interface IMemberExpression extends IExpression { - type: 'MemberExpression'; - computed: boolean; - object: IExpression; - property: IExpression; - } - } - - function jsep(obj: string | jsep.IExpression): jsep.IExpression; - - export = jsep; -} \ No newline at end of file diff --git a/typings/node/node.d.ts b/typings/node/node.d.ts deleted file mode 100644 index 61132b9..0000000 --- a/typings/node/node.d.ts +++ /dev/null @@ -1,3947 +0,0 @@ -// Type definitions for Node.js v6.x -// Project: http://nodejs.org/ -// Definitions by: Microsoft TypeScript , DefinitelyTyped -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/************************************************ -* * -* Node.js v6.x API * -* * -************************************************/ - -interface Error { - stack?: string; -} - -interface ErrorConstructor { - captureStackTrace(targetObject: Object, constructorOpt?: Function): void; - stackTraceLimit: number; -} - -// 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: NodeModule; -} - -declare var require: NodeRequire; - -interface NodeModule { - exports: any; - require: NodeRequireFunction; - id: string; - filename: string; - loaded: boolean; - parent: NodeModule; - children: NodeModule[]; -} - -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; - /** - * Allocates a new buffer of {size} octets. - * - * @param size count of octets to allocate. - * @param fill if specified, buffer will be initialized by calling buf.fill(fill). - * If parameter is omitted, buffer will be filled with zeros. - * @param encoding encoding used for call to buf.fill while initalizing - */ - alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer; - /** - * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents - * of the newly created Buffer are unknown and may contain sensitive data. - * - * @param size count of octets to allocate - */ - allocUnsafe(size: number): Buffer; - /** - * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents - * of the newly created Buffer are unknown and may contain sensitive data. - * - * @param size count of octets to allocate - */ - allocUnsafeSlow(size: number): Buffer; -}; - -/************************************************ -* * -* GLOBAL INTERFACES * -* * -************************************************/ -declare namespace NodeJS { - export interface ErrnoException extends Error { - errno?: string; - code?: string; - path?: string; - syscall?: string; - stack?: string; - } - - export class EventEmitter { - addListener(event: string | symbol, listener: Function): this; - on(event: string | symbol, listener: Function): this; - once(event: string | symbol, listener: Function): this; - removeListener(event: string | symbol, listener: Function): this; - removeAllListeners(event?: string | symbol): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string | symbol): Function[]; - emit(event: string | symbol, ...args: any[]): boolean; - listenerCount(type: string | symbol): number; - // Added in Node 6... - prependListener(event: string | symbol, listener: Function): this; - prependOnceListener(event: string | symbol, listener: Function): this; - eventNames(): (string | symbol)[]; - } - - export interface ReadableStream extends EventEmitter { - readable: boolean; - read(size?: number): string | Buffer; - setEncoding(encoding: string): void; - pause(): ReadableStream; - resume(): ReadableStream; - 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 { - pause(): ReadWriteStream; - resume(): ReadWriteStream; - } - - 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 ProcessVersions { - http_parser: string; - node: string; - v8: string; - ares: string; - uv: string; - zlib: string; - modules: string; - openssl: string; - } - - export interface Process extends EventEmitter { - stdout: WritableStream; - stderr: WritableStream; - stdin: ReadableStream; - argv: string[]; - argv0: string; - execArgv: string[]; - execPath: string; - abort(): void; - chdir(directory: string): void; - cwd(): string; - env: any; - exit(code?: number): void; - exitCode: number; - getgid(): number; - setgid(id: number): void; - setgid(id: string): void; - getuid(): number; - setuid(id: number): void; - setuid(id: string): void; - version: string; - versions: ProcessVersions; - 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; - mainModule?: NodeModule; - memoryUsage(): MemoryUsage; - nextTick(callback: Function, ...args: any[]): 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; - } -} - -interface IterableIterator { } - -/** - * @deprecated - */ -interface NodeBuffer extends Uint8Array { - write(string: string, offset?: number, length?: number, encoding?: string): number; - toString(encoding?: string, start?: number, end?: number): string; - toJSON(): { type: 'Buffer', data: any[] }; - equals(otherBuffer: Buffer): boolean; - compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): 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; - swap16(): Buffer; - swap32(): Buffer; - swap64(): Buffer; - 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): this; - indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; - lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; - entries(): IterableIterator<[number, number]>; - includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean; - keys(): IterableIterator; - values(): IterableIterator; -} - -/************************************************ -* * -* 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 extends NodeJS.EventEmitter { - static EventEmitter: EventEmitter; - static listenerCount(emitter: EventEmitter, event: string | symbol): number; // deprecated - static defaultMaxListeners: number; - - addListener(event: string | symbol, listener: Function): this; - on(event: string | symbol, listener: Function): this; - once(event: string | symbol, listener: Function): this; - prependListener(event: string | symbol, listener: Function): this; - prependOnceListener(event: string | symbol, listener: Function): this; - removeListener(event: string | symbol, listener: Function): this; - removeAllListeners(event?: string | symbol): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string | symbol): Function[]; - emit(event: string | symbol, ...args: any[]): boolean; - eventNames(): (string | symbol)[]; - listenerCount(type: string | symbol): 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 net.Server { - setTimeout(msecs: number, callback: Function): void; - maxHeadersCount: number; - timeout: number; - listening: boolean; - } - /** - * @deprecated Use IncomingMessage - */ - export interface ServerRequest extends IncomingMessage { - connection: net.Socket; - } - export interface ServerResponse extends 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; - setTimeout(msecs: number, callback: Function): ServerResponse; - sendDate: boolean; - getHeader(name: string): string; - removeHeader(name: string): void; - write(chunk: any, encoding?: string): any; - addTrailers(headers: any): void; - finished: boolean; - - // 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 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 stream.Readable { - httpVersion: string; - httpVersionMajor: number; - httpVersionMinor: number; - connection: net.Socket; - 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; - destroy(error?: Error): void; - } - /** - * @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"; - import * as net from "net"; - - // interfaces - export interface ClusterSettings { - execArgv?: string[]; // default: process.execArgv - exec?: string; - args?: string[]; - silent?: boolean; - stdio?: any[]; - uid?: number; - gid?: number; - } - - export interface ClusterSetupMasterSettings { - exec?: string; // default: process.argv[1] - args?: string[]; // default: process.argv.slice(2) - silent?: boolean; // default: false - stdio?: any[]; - } - - export interface Address { - address: string; - port: number; - addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6" - } - - export class Worker extends events.EventEmitter { - id: string; - process: child.ChildProcess; - suicide: boolean; - send(message: any, sendHandle?: any): boolean; - kill(signal?: string): void; - destroy(signal?: string): void; - disconnect(): void; - isConnected(): boolean; - isDead(): boolean; - exitedAfterDisconnect: boolean; - - /** - * events.EventEmitter - * 1. disconnect - * 2. error - * 3. exit - * 4. listening - * 5. message - * 6. online - */ - addListener(event: string, listener: Function): this; - addListener(event: "disconnect", listener: () => void): this; - addListener(event: "error", listener: (code: number, signal: string) => void): this; - addListener(event: "exit", listener: (code: number, signal: string) => void): this; - addListener(event: "listening", listener: (address: Address) => void): this; - addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - addListener(event: "online", listener: () => void): this; - - emit(event: string, listener: Function): boolean - emit(event: "disconnect", listener: () => void): boolean - emit(event: "error", listener: (code: number, signal: string) => void): boolean - emit(event: "exit", listener: (code: number, signal: string) => void): boolean - emit(event: "listening", listener: (address: Address) => void): boolean - emit(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): boolean - emit(event: "online", listener: () => void): boolean - - on(event: string, listener: Function): this; - on(event: "disconnect", listener: () => void): this; - on(event: "error", listener: (code: number, signal: string) => void): this; - on(event: "exit", listener: (code: number, signal: string) => void): this; - on(event: "listening", listener: (address: Address) => void): this; - on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - on(event: "online", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "disconnect", listener: () => void): this; - once(event: "error", listener: (code: number, signal: string) => void): this; - once(event: "exit", listener: (code: number, signal: string) => void): this; - once(event: "listening", listener: (address: Address) => void): this; - once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - once(event: "online", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "disconnect", listener: () => void): this; - prependListener(event: "error", listener: (code: number, signal: string) => void): this; - prependListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependListener(event: "listening", listener: (address: Address) => void): this; - prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependListener(event: "online", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "disconnect", listener: () => void): this; - prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "listening", listener: (address: Address) => void): this; - prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependOnceListener(event: "online", listener: () => void): this; - } - - export interface Cluster extends events.EventEmitter { - Worker: Worker; - disconnect(callback?: Function): void; - fork(env?: any): Worker; - isMaster: boolean; - isWorker: boolean; - // TODO: cluster.schedulingPolicy - settings: ClusterSettings; - setupMaster(settings?: ClusterSetupMasterSettings): void; - worker: Worker; - workers: { - [index: string]: Worker - }; - - /** - * events.EventEmitter - * 1. disconnect - * 2. exit - * 3. fork - * 4. listening - * 5. message - * 6. online - * 7. setup - */ - addListener(event: string, listener: Function): this; - addListener(event: "disconnect", listener: (worker: Worker) => void): this; - addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - addListener(event: "fork", listener: (worker: Worker) => void): this; - addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; - addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - addListener(event: "online", listener: (worker: Worker) => void): this; - addListener(event: "setup", listener: (settings: any) => void): this; - - emit(event: string, listener: Function): boolean; - emit(event: "disconnect", listener: (worker: Worker) => void): boolean; - emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; - emit(event: "fork", listener: (worker: Worker) => void): boolean; - emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; - emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; - emit(event: "online", listener: (worker: Worker) => void): boolean; - emit(event: "setup", listener: (settings: any) => void): boolean; - - on(event: string, listener: Function): this; - on(event: "disconnect", listener: (worker: Worker) => void): this; - on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - on(event: "fork", listener: (worker: Worker) => void): this; - on(event: "listening", listener: (worker: Worker, address: Address) => void): this; - on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - on(event: "online", listener: (worker: Worker) => void): this; - on(event: "setup", listener: (settings: any) => void): this; - - once(event: string, listener: Function): this; - once(event: "disconnect", listener: (worker: Worker) => void): this; - once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - once(event: "fork", listener: (worker: Worker) => void): this; - once(event: "listening", listener: (worker: Worker, address: Address) => void): this; - once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - once(event: "online", listener: (worker: Worker) => void): this; - once(event: "setup", listener: (settings: any) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "disconnect", listener: (worker: Worker) => void): this; - prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - prependListener(event: "fork", listener: (worker: Worker) => void): this; - prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; - prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependListener(event: "online", listener: (worker: Worker) => void): this; - prependListener(event: "setup", listener: (settings: any) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this; - prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - prependOnceListener(event: "fork", listener: (worker: Worker) => void): this; - prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; - prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependOnceListener(event: "online", listener: (worker: Worker) => void): this; - prependOnceListener(event: "setup", listener: (settings: any) => void): this; - - } - - export function disconnect(callback?: Function): void; - export function fork(env?: any): Worker; - export var isMaster: boolean; - export var isWorker: boolean; - // TODO: cluster.schedulingPolicy - export var settings: ClusterSettings; - export function setupMaster(settings?: ClusterSetupMasterSettings): void; - export var worker: Worker; - export var workers: { - [index: string]: Worker - }; - - /** - * events.EventEmitter - * 1. disconnect - * 2. exit - * 3. fork - * 4. listening - * 5. message - * 6. online - * 7. setup - */ - export function addListener(event: string, listener: Function): Cluster; - export function addListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function addListener(event: "fork", listener: (worker: Worker) => void): Cluster; - export function addListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function addListener(event: "online", listener: (worker: Worker) => void): Cluster; - export function addListener(event: "setup", listener: (settings: any) => void): Cluster; - - export function emit(event: string, listener: Function): boolean; - export function emit(event: "disconnect", listener: (worker: Worker) => void): boolean; - export function emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; - export function emit(event: "fork", listener: (worker: Worker) => void): boolean; - export function emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; - export function emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; - export function emit(event: "online", listener: (worker: Worker) => void): boolean; - export function emit(event: "setup", listener: (settings: any) => void): boolean; - - export function on(event: string, listener: Function): Cluster; - export function on(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function on(event: "fork", listener: (worker: Worker) => void): Cluster; - export function on(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function on(event: "online", listener: (worker: Worker) => void): Cluster; - export function on(event: "setup", listener: (settings: any) => void): Cluster; - - export function once(event: string, listener: Function): Cluster; - export function once(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function once(event: "fork", listener: (worker: Worker) => void): Cluster; - export function once(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function once(event: "online", listener: (worker: Worker) => void): Cluster; - export function once(event: "setup", listener: (settings: any) => void): Cluster; - - export function removeListener(event: string, listener: Function): Cluster; - export function removeAllListeners(event?: string): Cluster; - export function setMaxListeners(n: number): Cluster; - export function getMaxListeners(): number; - export function listeners(event: string): Function[]; - export function listenerCount(type: string): number; - - export function prependListener(event: string, listener: Function): Cluster; - export function prependListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function prependListener(event: "fork", listener: (worker: Worker) => void): Cluster; - export function prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function prependListener(event: "online", listener: (worker: Worker) => void): Cluster; - export function prependListener(event: "setup", listener: (settings: any) => void): Cluster; - - export function prependOnceListener(event: string, listener: Function): Cluster; - export function prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function prependOnceListener(event: "fork", listener: (worker: Worker) => void): Cluster; - export function prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function prependOnceListener(event: "online", listener: (worker: Worker) => void): Cluster; - export function prependOnceListener(event: "setup", listener: (settings: any) => void): Cluster; - - export function eventNames(): string[]; -} - -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 hostname(): string; - export function loadavg(): number[]; - export function uptime(): number; - export function freemem(): number; - export function totalmem(): number; - export function cpus(): CpuInfo[]; - export function type(): string; - export function release(): string; - export function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] }; - export function homedir(): string; - export function userInfo(options?: { encoding: string }): { username: string, uid: number, gid: number, shell: any, homedir: string } - export var constants: { - UV_UDP_REUSEADDR: number, - errno: { - SIGHUP: number; - SIGINT: number; - SIGQUIT: number; - SIGILL: number; - SIGTRAP: number; - SIGABRT: number; - SIGIOT: number; - SIGBUS: number; - SIGFPE: number; - SIGKILL: number; - SIGUSR1: number; - SIGSEGV: number; - SIGUSR2: number; - SIGPIPE: number; - SIGALRM: number; - SIGTERM: number; - SIGCHLD: number; - SIGSTKFLT: number; - SIGCONT: number; - SIGSTOP: number; - SIGTSTP: number; - SIGTTIN: number; - SIGTTOU: number; - SIGURG: number; - SIGXCPU: number; - SIGXFSZ: number; - SIGVTALRM: number; - SIGPROF: number; - SIGWINCH: number; - SIGIO: number; - SIGPOLL: number; - SIGPWR: number; - SIGSYS: number; - SIGUNUSED: number; - }, - signals: { - E2BIG: number; - EACCES: number; - EADDRINUSE: number; - EADDRNOTAVAIL: number; - EAFNOSUPPORT: number; - EAGAIN: number; - EALREADY: number; - EBADF: number; - EBADMSG: number; - EBUSY: number; - ECANCELED: number; - ECHILD: number; - ECONNABORTED: number; - ECONNREFUSED: number; - ECONNRESET: number; - EDEADLK: number; - EDESTADDRREQ: number; - EDOM: number; - EDQUOT: number; - EEXIST: number; - EFAULT: number; - EFBIG: number; - EHOSTUNREACH: number; - EIDRM: number; - EILSEQ: number; - EINPROGRESS: number; - EINTR: number; - EINVAL: number; - EIO: number; - EISCONN: number; - EISDIR: number; - ELOOP: number; - EMFILE: number; - EMLINK: number; - EMSGSIZE: number; - EMULTIHOP: number; - ENAMETOOLONG: number; - ENETDOWN: number; - ENETRESET: number; - ENETUNREACH: number; - ENFILE: number; - ENOBUFS: number; - ENODATA: number; - ENODEV: number; - ENOENT: number; - ENOEXEC: number; - ENOLCK: number; - ENOLINK: number; - ENOMEM: number; - ENOMSG: number; - ENOPROTOOPT: number; - ENOSPC: number; - ENOSR: number; - ENOSTR: number; - ENOSYS: number; - ENOTCONN: number; - ENOTDIR: number; - ENOTEMPTY: number; - ENOTSOCK: number; - ENOTSUP: number; - ENOTTY: number; - ENXIO: number; - EOPNOTSUPP: number; - EOVERFLOW: number; - EPERM: number; - EPIPE: number; - EPROTO: number; - EPROTONOSUPPORT: number; - EPROTOTYPE: number; - ERANGE: number; - EROFS: number; - ESPIPE: number; - ESRCH: number; - ESTALE: number; - ETIME: number; - ETIMEDOUT: number; - ETXTBSY: number; - EWOULDBLOCK: number; - EXDEV: number; - }, - }; - export function arch(): string; - export function platform(): string; - export function tmpdir(): string; - export var EOL: string; - export function endianness(): "BE" | "LE"; -} - -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, cb: (err: Error, ctx: tls.SecureContext) => any) => 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 { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - ciphers?: string; - rejectUnauthorized?: boolean; - secureProtocol?: string; - 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 readline from "readline"; - - export interface ReplOptions { - prompt?: string; - input?: NodeJS.ReadableStream; - output?: NodeJS.WritableStream; - terminal?: boolean; - eval?: Function; - useColors?: boolean; - useGlobal?: boolean; - ignoreUndefined?: boolean; - writer?: Function; - completer?: Function; - replMode?: any; - breakEvalOnSigint?: any; - } - - export interface REPLServer extends readline.ReadLine { - defineCommand(keyword: string, cmd: Function | { help: string, action: Function }): void; - displayPrompt(preserveCursor?: boolean): void; - - /** - * events.EventEmitter - * 1. exit - * 2. reset - **/ - - addListener(event: string, listener: Function): this; - addListener(event: "exit", listener: () => void): this; - addListener(event: "reset", listener: Function): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "exit"): boolean; - emit(event: "reset", context: any): boolean; - - on(event: string, listener: Function): this; - on(event: "exit", listener: () => void): this; - on(event: "reset", listener: Function): this; - - once(event: string, listener: Function): this; - once(event: "exit", listener: () => void): this; - once(event: "reset", listener: Function): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "exit", listener: () => void): this; - prependListener(event: "reset", listener: Function): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "exit", listener: () => void): this; - prependOnceListener(event: "reset", listener: Function): this; - } - - export function start(options: ReplOptions): REPLServer; -} - -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; - - /** - * events.EventEmitter - * 1. close - * 2. line - * 3. pause - * 4. resume - * 5. SIGCONT - * 6. SIGINT - * 7. SIGTSTP - **/ - - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "line", listener: (input: any) => void): this; - addListener(event: "pause", listener: () => void): this; - addListener(event: "resume", listener: () => void): this; - addListener(event: "SIGCONT", listener: () => void): this; - addListener(event: "SIGINT", listener: () => void): this; - addListener(event: "SIGTSTP", listener: () => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "line", input: any): boolean; - emit(event: "pause"): boolean; - emit(event: "resume"): boolean; - emit(event: "SIGCONT"): boolean; - emit(event: "SIGINT"): boolean; - emit(event: "SIGTSTP"): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "line", listener: (input: any) => void): this; - on(event: "pause", listener: () => void): this; - on(event: "resume", listener: () => void): this; - on(event: "SIGCONT", listener: () => void): this; - on(event: "SIGINT", listener: () => void): this; - on(event: "SIGTSTP", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "line", listener: (input: any) => void): this; - once(event: "pause", listener: () => void): this; - once(event: "resume", listener: () => void): this; - once(event: "SIGCONT", listener: () => void): this; - once(event: "SIGINT", listener: () => void): this; - once(event: "SIGTSTP", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "line", listener: (input: any) => void): this; - prependListener(event: "pause", listener: () => void): this; - prependListener(event: "resume", listener: () => void): this; - prependListener(event: "SIGCONT", listener: () => void): this; - prependListener(event: "SIGINT", listener: () => void): this; - prependListener(event: "SIGTSTP", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "line", listener: (input: any) => void): this; - prependOnceListener(event: "pause", listener: () => void): this; - prependOnceListener(event: "resume", listener: () => void): this; - prependOnceListener(event: "SIGCONT", listener: () => void): this; - prependOnceListener(event: "SIGINT", listener: () => void): this; - prependOnceListener(event: "SIGTSTP", listener: () => void): this; - } - - 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"; - import * as net from "net"; - - 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): boolean; - connected: boolean; - disconnect(): void; - unref(): void; - ref(): void; - - /** - * events.EventEmitter - * 1. close - * 2. disconnet - * 3. error - * 4. exit - * 5. message - **/ - - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: (code: number, signal: string) => void): this; - addListener(event: "disconnet", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "exit", listener: (code: number, signal: string) => void): this; - addListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close", code: number, signal: string): boolean; - emit(event: "disconnet"): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "exit", code: number, signal: string): boolean; - emit(event: "message", message: any, sendHandle: net.Socket | net.Server): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: (code: number, signal: string) => void): this; - on(event: "disconnet", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "exit", listener: (code: number, signal: string) => void): this; - on(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: (code: number, signal: string) => void): this; - once(event: "disconnet", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "exit", listener: (code: number, signal: string) => void): this; - once(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: (code: number, signal: string) => void): this; - prependListener(event: "disconnet", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "disconnet", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - } - - 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 interface MxRecord { - exchange: string, - priority: number - } - - 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: MxRecord[]) => 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[]; - export function setServers(servers: string[]): void; - - //Error codes - export var NODATA: string; - export var FORMERR: string; - export var SERVFAIL: string; - export var NOTFOUND: string; - export var NOTIMP: string; - export var REFUSED: string; - export var BADQUERY: string; - export var BADNAME: string; - export var BADFAMILY: string; - export var BADRESP: string; - export var CONNREFUSED: string; - export var TIMEOUT: string; - export var EOF: string; - export var FILE: string; - export var NOMEM: string; - export var DESTRUCTION: string; - export var BADSTR: string; - export var BADFLAGS: string; - export var NONAME: string; - export var BADHINTS: string; - export var NOTINITIALIZED: string; - export var LOADIPHLPAPI: string; - export var ADDRGETNETWORKPARAMS: string; - export var CANCELLED: string; -} - -declare module "net" { - import * as stream from "stream"; - import * as events from "events"; - - 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(): Socket; - resume(): Socket; - 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; - - /** - * events.EventEmitter - * 1. close - * 2. connect - * 3. data - * 4. drain - * 5. end - * 6. error - * 7. lookup - * 8. timeout - */ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: (had_error: boolean) => void): this; - addListener(event: "connect", listener: () => void): this; - addListener(event: "data", listener: (data: Buffer) => void): this; - addListener(event: "drain", listener: () => void): this; - addListener(event: "end", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - addListener(event: "timeout", listener: () => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close", had_error: boolean): boolean; - emit(event: "connect"): boolean; - emit(event: "data", data: Buffer): boolean; - emit(event: "drain"): boolean; - emit(event: "end"): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean; - emit(event: "timeout"): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: (had_error: boolean) => void): this; - on(event: "connect", listener: () => void): this; - on(event: "data", listener: (data: Buffer) => void): this; - on(event: "drain", listener: () => void): this; - on(event: "end", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - on(event: "timeout", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: (had_error: boolean) => void): this; - once(event: "connect", listener: () => void): this; - once(event: "data", listener: (data: Buffer) => void): this; - once(event: "drain", listener: () => void): this; - once(event: "end", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - once(event: "timeout", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: (had_error: boolean) => void): this; - prependListener(event: "connect", listener: () => void): this; - prependListener(event: "data", listener: (data: Buffer) => void): this; - prependListener(event: "drain", listener: () => void): this; - prependListener(event: "end", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - prependListener(event: "timeout", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: (had_error: boolean) => void): this; - prependOnceListener(event: "connect", listener: () => void): this; - prependOnceListener(event: "data", listener: (data: Buffer) => void): this; - prependOnceListener(event: "drain", listener: () => void): this; - prependOnceListener(event: "end", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - prependOnceListener(event: "timeout", listener: () => void): this; - } - - 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 events.EventEmitter { - 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; - - /** - * events.EventEmitter - * 1. close - * 2. connection - * 3. error - * 4. listening - */ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "connection", listener: (socket: Socket) => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "listening", listener: () => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "connection", socket: Socket): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "listening"): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "connection", listener: (socket: Socket) => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "listening", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "connection", listener: (socket: Socket) => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "listening", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "connection", listener: (socket: Socket) => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "listening", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "connection", listener: (socket: Socket) => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "listening", listener: () => void): this; - } - 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; - family: string; - port: number; - } - - interface AddressInfo { - address: string; - family: string; - port: number; - } - - interface BindOptions { - port: number; - address?: string; - exclusive?: boolean; - } - - interface SocketOptions { - type: "udp4" | "udp6"; - reuseAddr?: boolean; - } - - export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; - export function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; - - export interface Socket extends events.EventEmitter { - send(msg: Buffer | String | any[], port: number, address: string, callback?: (error: Error, bytes: number) => void): void; - send(msg: Buffer | String | any[], offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; - bind(port?: number, address?: string, callback?: () => void): void; - bind(options: BindOptions, callback?: Function): void; - close(callback?: any): void; - address(): AddressInfo; - setBroadcast(flag: boolean): void; - setTTL(ttl: number): void; - setMulticastTTL(ttl: number): void; - setMulticastLoopback(flag: boolean): void; - addMembership(multicastAddress: string, multicastInterface?: string): void; - dropMembership(multicastAddress: string, multicastInterface?: string): void; - ref(): void; - unref(): void; - - /** - * events.EventEmitter - * 1. close - * 2. error - * 3. listening - * 4. message - **/ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "listening", listener: () => void): this; - addListener(event: "message", listener: (msg: string, rinfo: AddressInfo) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "listening"): boolean; - emit(event: "message", msg: string, rinfo: AddressInfo): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "listening", listener: () => void): this; - on(event: "message", listener: (msg: string, rinfo: AddressInfo) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "listening", listener: () => void): this; - once(event: "message", listener: (msg: string, rinfo: AddressInfo) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "listening", listener: () => void): this; - prependListener(event: "message", listener: (msg: string, rinfo: AddressInfo) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "listening", listener: () => void): this; - prependOnceListener(event: "message", listener: (msg: string, rinfo: AddressInfo) => void): this; - } -} - -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; - - /** - * events.EventEmitter - * 1. change - * 2. error - */ - addListener(event: string, listener: Function): this; - addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - addListener(event: "error", listener: (code: number, signal: string) => void): this; - - on(event: string, listener: Function): this; - on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - on(event: "error", listener: (code: number, signal: string) => void): this; - - once(event: string, listener: Function): this; - once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - once(event: "error", listener: (code: number, signal: string) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - prependListener(event: "error", listener: (code: number, signal: string) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; - } - - export interface ReadStream extends stream.Readable { - close(): void; - destroy(): void; - - /** - * events.EventEmitter - * 1. open - * 2. close - */ - addListener(event: string, listener: Function): this; - addListener(event: "open", listener: (fd: number) => void): this; - addListener(event: "close", listener: () => void): this; - - on(event: string, listener: Function): this; - on(event: "open", listener: (fd: number) => void): this; - on(event: "close", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "open", listener: (fd: number) => void): this; - once(event: "close", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "open", listener: (fd: number) => void): this; - prependListener(event: "close", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "open", listener: (fd: number) => void): this; - prependOnceListener(event: "close", listener: () => void): this; - } - - export interface WriteStream extends stream.Writable { - close(): void; - bytesWritten: number; - path: string | Buffer; - - /** - * events.EventEmitter - * 1. open - * 2. close - */ - addListener(event: string, listener: Function): this; - addListener(event: "open", listener: (fd: number) => void): this; - addListener(event: "close", listener: () => void): this; - - on(event: string, listener: Function): this; - on(event: "open", listener: (fd: number) => void): this; - on(event: "close", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "open", listener: (fd: number) => void): this; - once(event: "close", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "open", listener: (fd: number) => void): this; - prependListener(event: "close", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "open", listener: (fd: number) => void): this; - prependOnceListener(event: "close", listener: () => void): this; - } - - /** - * 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 | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncate(path: string | Buffer, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncateSync(path: string | Buffer, 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 | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chownSync(path: string | Buffer, 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 | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchownSync(path: string | Buffer, uid: number, gid: number): void; - export function chmod(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmodSync(path: string | Buffer, mode: number): void; - export function chmodSync(path: string | Buffer, 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 | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmodSync(path: string | Buffer, mode: number): void; - export function lchmodSync(path: string | Buffer, mode: string): void; - export function stat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function lstat(path: string | Buffer, 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 | Buffer): Stats; - export function lstatSync(path: string | Buffer): Stats; - export function fstatSync(fd: number): Stats; - export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function linkSync(srcpath: string | Buffer, dstpath: string | Buffer): void; - export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function symlinkSync(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): void; - export function readlink(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; - export function readlinkSync(path: string | Buffer): string; - export function realpath(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; - export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; - export function realpathSync(path: string | Buffer, 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 | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous unlink - deletes the file specified in {path} - * - * @param path - */ - export function unlinkSync(path: string | Buffer): 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 | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous rmdir - removes the directory specified in {path} - * - * @param path - */ - export function rmdirSync(path: string | Buffer): 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 | Buffer, 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 | Buffer, 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 | Buffer, 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 | Buffer, 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 | Buffer, 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 | Buffer, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; - export function readdirSync(path: string | Buffer): string[]; - export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function closeSync(fd: number): void; - export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; - export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; - export function openSync(path: string | Buffer, flags: string | number, mode?: number): number; - export function utimes(path: string | Buffer, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimesSync(path: string | Buffer, atime: number, mtime: number): void; - export function utimesSync(path: string | Buffer, 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, encoding: string, listener?: (event: string, filename: string | Buffer) => any): FSWatcher; - export function watch(filename: string, options: { persistent?: boolean; recursive?: boolean; encoding?: string }, listener?: (event: string, filename: string | Buffer) => any): FSWatcher; - export function exists(path: string | Buffer, callback?: (exists: boolean) => void): void; - export function existsSync(path: string | Buffer): boolean; - - export namespace constants { - // File Access Constants - - /** Constant for fs.access(). File is visible to the calling process. */ - export const F_OK: number; - - /** Constant for fs.access(). File can be read by the calling process. */ - export const R_OK: number; - - /** Constant for fs.access(). File can be written by the calling process. */ - export const W_OK: number; - - /** Constant for fs.access(). File can be executed by the calling process. */ - export const X_OK: number; - - // File Open Constants - - /** Constant for fs.open(). Flag indicating to open a file for read-only access. */ - export const O_RDONLY: number; - - /** Constant for fs.open(). Flag indicating to open a file for write-only access. */ - export const O_WRONLY: number; - - /** Constant for fs.open(). Flag indicating to open a file for read-write access. */ - export const O_RDWR: number; - - /** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */ - export const O_CREAT: number; - - /** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */ - export const O_EXCL: number; - - /** Constant for fs.open(). Flag indicating that if path identifies a terminal device, opening the path shall not cause that terminal to become the controlling terminal for the process (if the process does not already have one). */ - export const O_NOCTTY: number; - - /** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */ - export const O_TRUNC: number; - - /** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */ - export const O_APPEND: number; - - /** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */ - export const O_DIRECTORY: number; - - /** Constant for fs.open(). Flag indicating reading accesses to the file system will no longer result in an update to the atime information associated with the file. This flag is available on Linux operating systems only. */ - export const O_NOATIME: number; - - /** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */ - export const O_NOFOLLOW: number; - - /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */ - export const O_SYNC: number; - - /** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */ - export const O_SYMLINK: number; - - /** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */ - export const O_DIRECT: number; - - /** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */ - export const O_NONBLOCK: number; - - // File Type Constants - - /** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */ - export const S_IFMT: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */ - export const S_IFREG: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */ - export const S_IFDIR: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */ - export const S_IFCHR: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */ - export const S_IFBLK: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */ - export const S_IFIFO: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */ - export const S_IFLNK: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */ - export const S_IFSOCK: number; - - // File Mode Constants - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */ - export const S_IRWXU: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */ - export const S_IRUSR: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */ - export const S_IWUSR: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */ - export const S_IXUSR: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */ - export const S_IRWXG: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */ - export const S_IRGRP: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */ - export const S_IWGRP: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */ - export const S_IXGRP: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */ - export const S_IRWXO: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */ - export const S_IROTH: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */ - export const S_IWOTH: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */ - export const S_IXOTH: number; - } - - /** Tests a user's permissions for the file specified by path. */ - export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void; - export function access(path: string | Buffer, 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 | Buffer, mode?: number): void; - export function createReadStream(path: string | Buffer, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - autoClose?: boolean; - start?: number; - end?: number; - }): ReadStream; - export function createWriteStream(path: string | Buffer, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - autoClose?: boolean; - start?: number; - }): WriteStream; - export function fdatasync(fd: number, callback: Function): void; - export function fdatasyncSync(fd: number): void; -} - -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; - end(buffer?: Buffer): string; - } - 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 Certificate { - /** - * Country code. - */ - C: string; - /** - * Street. - */ - ST: string; - /** - * Locality. - */ - L: string; - /** - * Organization. - */ - O: string; - /** - * Organizational unit. - */ - OU: string; - /** - * Common name. - */ - CN: string; - } - - export interface CipherNameAndProtocol { - /** - * The cipher name. - */ - name: string; - /** - * SSL/TLS protocol version. - */ - version: string; - } - - export class TLSSocket extends stream.Duplex { - /** - * Construct a new tls.TLSSocket object from an existing TCP socket. - */ - constructor(socket:net.Socket, options?: { - /** - * An optional TLS context object from tls.createSecureContext() - */ - secureContext?: SecureContext, - /** - * If true the TLS socket will be instantiated in server-mode. - * Defaults to false. - */ - isServer?: boolean, - /** - * An optional net.Server instance. - */ - server?: net.Server, - /** - * If true the server will request a certificate from clients that - * connect and attempt to verify that certificate. Defaults to - * false. - */ - requestCert?: boolean, - /** - * If true the server will reject any connection which is not - * authorized with the list of supplied CAs. This option only has an - * effect if requestCert is true. Defaults to false. - */ - rejectUnauthorized?: boolean, - /** - * An array of strings or a Buffer naming possible NPN protocols. - * (Protocols should be ordered by their priority.) - */ - NPNProtocols?: string[] | Buffer, - /** - * An array of strings or a Buffer naming possible ALPN protocols. - * (Protocols should be ordered by their priority.) When the server - * receives both NPN and ALPN extensions from the client, ALPN takes - * precedence over NPN and the server does not send an NPN extension - * to the client. - */ - ALPNProtocols?: string[] | Buffer, - /** - * SNICallback(servername, cb) A function that will be - * called if the client supports SNI TLS extension. Two arguments - * will be passed when called: servername and cb. SNICallback should - * invoke cb(null, ctx), where ctx is a SecureContext instance. - * (tls.createSecureContext(...) can be used to get a proper - * SecureContext.) If SNICallback wasn't provided the default callback - * with high-level API will be used (see below). - */ - SNICallback?: Function, - /** - * An optional Buffer instance containing a TLS session. - */ - session?: Buffer, - /** - * If true, specifies that the OCSP status request extension will be - * added to the client hello and an 'OCSPResponse' event will be - * emitted on the socket before establishing a secure communication - */ - requestOCSP?: boolean - }); - /** - * Returns the bound address, the address family name and port of the underlying socket as reported by - * the operating system. - * @returns {any} - An object with three properties, e.g. { port: 12346, family: 'IPv4', address: '127.0.0.1' }. - */ - address(): { port: number; family: string; address: string }; - /** - * A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false. - */ - authorized: boolean; - /** - * The reason why the peer's certificate has not been verified. - * This property becomes available only when tlsSocket.authorized === false. - */ - authorizationError: Error; - /** - * Static boolean value, always true. - * May be used to distinguish TLS sockets from regular ones. - */ - encrypted: boolean; - /** - * Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection. - * @returns {CipherNameAndProtocol} - Returns an object representing the cipher name - * and the SSL/TLS protocol version of the current connection. - */ - getCipher(): CipherNameAndProtocol; - /** - * Returns an object representing the peer's certificate. - * The returned object has some properties corresponding to the field of the certificate. - * If detailed argument is true the full chain with issuer property will be returned, - * if false only the top certificate without issuer property. - * If the peer does not provide a certificate, it returns null or an empty object. - * @param {boolean} detailed - If true; the full chain with issuer property will be returned. - * @returns {any} - An object representing the peer's certificate. - */ - getPeerCertificate(detailed?: boolean): { - subject: Certificate; - issuerInfo: Certificate; - issuer: Certificate; - raw: any; - valid_from: string; - valid_to: string; - fingerprint: string; - serialNumber: string; - }; - /** - * Could be used to speed up handshake establishment when reconnecting to the server. - * @returns {any} - ASN.1 encoded TLS session or undefined if none was negotiated. - */ - getSession(): any; - /** - * NOTE: Works only with client TLS sockets. - * Useful only for debugging, for session reuse provide session option to tls.connect(). - * @returns {any} - TLS session ticket or undefined if none was negotiated. - */ - getTLSTicket(): any; - /** - * The string representation of the local IP address. - */ - localAddress: string; - /** - * The numeric representation of the local port. - */ - localPort: string; - /** - * The string representation of the remote IP address. - * For example, '74.125.127.100' or '2001:4860:a005::68'. - */ - remoteAddress: string; - /** - * The string representation of the remote IP family. 'IPv4' or 'IPv6'. - */ - remoteFamily: string; - /** - * The numeric representation of the remote port. For example, 443. - */ - remotePort: number; - /** - * Initiate TLS renegotiation process. - * - * NOTE: Can be used to request peer's certificate after the secure connection has been established. - * ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout. - * @param {TlsOptions} options - The options may contain the following fields: rejectUnauthorized, - * requestCert (See tls.createServer() for details). - * @param {Function} callback - callback(err) will be executed with null as err, once the renegotiation - * is successfully completed. - */ - renegotiate(options: TlsOptions, callback: (err: Error) => any): any; - /** - * Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512). - * Smaller fragment size decreases buffering latency on the client: large fragments are buffered by - * the TLS layer until the entire fragment is received and its integrity is verified; - * large fragments can span multiple roundtrips, and their processing can be delayed due to packet - * loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead, - * which may decrease overall server throughput. - * @param {number} size - TLS fragment size (default and maximum value is: 16384, minimum is: 512). - * @returns {boolean} - Returns true on success, false otherwise. - */ - setMaxSendFragment(size: number): boolean; - - /** - * events.EventEmitter - * 1. OCSPResponse - * 2. secureConnect - **/ - addListener(event: string, listener: Function): this; - addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; - addListener(event: "secureConnect", listener: () => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "OCSPResponse", response: Buffer): boolean; - emit(event: "secureConnect"): boolean; - - on(event: string, listener: Function): this; - on(event: "OCSPResponse", listener: (response: Buffer) => void): this; - on(event: "secureConnect", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "OCSPResponse", listener: (response: Buffer) => void): this; - once(event: "secureConnect", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; - prependListener(event: "secureConnect", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; - prependOnceListener(event: "secureConnect", listener: () => void): this; - } - - export interface TlsOptions { - host?: string; - port?: number; - pfx?: string | Buffer[]; - key?: string | string[] | Buffer | any[]; - passphrase?: string; - cert?: string | string[] | Buffer | Buffer[]; - ca?: string | string[] | Buffer | Buffer[]; - crl?: string | string[]; - ciphers?: string; - honorCipherOrder?: boolean; - requestCert?: boolean; - rejectUnauthorized?: boolean; - NPNProtocols?: string[] | Buffer; - SNICallback?: (servername: string, cb: (err: Error, ctx: SecureContext) => any) => any; - ecdhCurve?: string; - dhparam?: string | Buffer; - handshakeTimeout?: number; - ALPNProtocols?: string[] | Buffer; - sessionTimeout?: number; - ticketKeys?: any; - sessionIdContext?: string; - secureProtocol?: string; - } - - export interface ConnectionOptions { - host?: string; - port?: number; - socket?: net.Socket; - pfx?: string | Buffer - key?: string | string[] | Buffer | Buffer[]; - passphrase?: string; - cert?: string | string[] | Buffer | Buffer[]; - ca?: string | Buffer | (string | Buffer)[]; - rejectUnauthorized?: boolean; - NPNProtocols?: (string | Buffer)[]; - servername?: string; - path?: string; - ALPNProtocols?: (string | Buffer)[]; - checkServerIdentity?: (servername: string, cert: string | Buffer | (string | Buffer)[]) => any; - secureProtocol?: string; - secureContext?: Object; - session?: Buffer; - minDHSize?: number; - } - - 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; - - /** - * events.EventEmitter - * 1. tlsClientError - * 2. newSession - * 3. OCSPRequest - * 4. resumeSession - * 5. secureConnection - **/ - addListener(event: string, listener: Function): this; - addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - addListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - addListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - addListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - addListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "tlsClientError", err: Error, tlsSocket: TLSSocket): boolean; - emit(event: "newSession", sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void): boolean; - emit(event: "OCSPRequest", certificate: Buffer, issuer: Buffer, callback: Function): boolean; - emit(event: "resumeSession", sessionId: any, callback: (err: Error, sessionData: any) => void): boolean; - emit(event: "secureConnection", tlsSocket: TLSSocket): boolean; - - on(event: string, listener: Function): this; - on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - on(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - on(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - on(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - once(event: string, listener: Function): this; - once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - once(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - once(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - once(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - prependListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - prependListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - prependListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - prependOnceListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - prependOnceListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - prependOnceListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - prependOnceListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - } - - 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: ConnectionOptions, 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 Certificate { - exportChallenge(spkac: string | Buffer): Buffer; - exportPublicKey(spkac: string | Buffer): Buffer; - verifySpkac(spkac: Buffer): boolean; - } - export var Certificate: { - new (): Certificate; - (): Certificate; - } - - export var fips: boolean; - - 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 | Buffer): Hmac; - - type Utf8AsciiLatin1Encoding = "utf8" | "ascii" | "latin1"; - type HexBase64Latin1Encoding = "latin1" | "hex" | "base64"; - type Utf8AsciiBinaryEncoding = "utf8" | "ascii" | "binary"; - type HexBase64BinaryEncoding = "binary" | "base64" | "hex"; - type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid"; - - export interface Hash extends NodeJS.ReadWriteStream { - update(data: string | Buffer): Hash; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hash; - digest(): Buffer; - digest(encoding: HexBase64Latin1Encoding): string; - } - export interface Hmac extends NodeJS.ReadWriteStream { - update(data: string | Buffer): Hmac; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hmac; - digest(): Buffer; - digest(encoding: HexBase64Latin1Encoding): string; - } - 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: Utf8AsciiBinaryEncoding): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: HexBase64BinaryEncoding): string; - update(data: string, input_encoding: Utf8AsciiBinaryEncoding, output_encoding: HexBase64BinaryEncoding): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding?: boolean): void; - getAuthTag(): Buffer; - setAAD(buffer: Buffer): void; - } - 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: HexBase64BinaryEncoding): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: Utf8AsciiBinaryEncoding): string; - update(data: string, input_encoding: HexBase64BinaryEncoding, output_encoding: Utf8AsciiBinaryEncoding): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding?: boolean): void; - setAuthTag(tag: Buffer): void; - setAAD(buffer: Buffer): void; - } - export function createSign(algorithm: string): Signer; - export interface Signer extends NodeJS.WritableStream { - update(data: string | Buffer): Signer; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Signer; - sign(private_key: string | { key: string; passphrase: string }): Buffer; - sign(private_key: string | { key: string; passphrase: string }, output_format: HexBase64Latin1Encoding): string; - } - export function createVerify(algorith: string): Verify; - export interface Verify extends NodeJS.WritableStream { - update(data: string | Buffer): Verify; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Verify; - verify(object: string, signature: Buffer): boolean; - verify(object: string, signature: string, signature_format: HexBase64Latin1Encoding): boolean; - } - export function createDiffieHellman(prime_length: number, generator?: number): DiffieHellman; - export function createDiffieHellman(prime: Buffer): DiffieHellman; - export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman; - export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | Buffer): DiffieHellman; - export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: string, generator_encoding: HexBase64Latin1Encoding): DiffieHellman; - export interface DiffieHellman { - generateKeys(): Buffer; - generateKeys(encoding: HexBase64Latin1Encoding): string; - computeSecret(other_public_key: Buffer): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string; - getPrime(): Buffer; - getPrime(encoding: HexBase64Latin1Encoding): string; - getGenerator(): Buffer; - getGenerator(encoding: HexBase64Latin1Encoding): string; - getPublicKey(): Buffer; - getPublicKey(encoding: HexBase64Latin1Encoding): string; - getPrivateKey(): Buffer; - getPrivateKey(encoding: HexBase64Latin1Encoding): string; - setPublicKey(public_key: Buffer): void; - setPublicKey(public_key: string, encoding: string): void; - setPrivateKey(private_key: Buffer): void; - setPrivateKey(private_key: string, encoding: string): void; - verifyError: number; - } - export function getDiffieHellman(group_name: string): DiffieHellman; - 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, 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?: number; - } - export interface RsaPrivateKey { - key: string; - passphrase?: string, - padding?: number; - } - export function publicEncrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer - export function privateDecrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer - export function privateEncrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer - export function publicDecrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer - export function getCiphers(): string[]; - export function getCurves(): string[]; - export function getHashes(): string[]; - export interface ECDH { - generateKeys(): Buffer; - generateKeys(encoding: HexBase64Latin1Encoding): string; - generateKeys(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string; - computeSecret(other_public_key: Buffer): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string; - getPrivateKey(): Buffer; - getPrivateKey(encoding: HexBase64Latin1Encoding): string; - getPublicKey(): Buffer; - getPublicKey(encoding: HexBase64Latin1Encoding): string; - getPublicKey(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string; - setPrivateKey(private_key: Buffer): void; - setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void; - } - export function createECDH(curve_name: string): ECDH; - export function timingSafeEqual(a: Buffer, b: Buffer): boolean; - export var DEFAULT_ENCODING: string; -} - -declare module "stream" { - import * as events from "events"; - - class internal extends events.EventEmitter { - pipe(destination: T, options?: { end?: boolean; }): T; - } - namespace internal { - - export class Stream extends internal { } - - export interface ReadableOptions { - highWaterMark?: number; - encoding?: string; - objectMode?: boolean; - read?: (size?: number) => any; - } - - export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { - readable: boolean; - constructor(opts?: ReadableOptions); - protected _read(size: number): void; - read(size?: number): any; - setEncoding(encoding: string): void; - pause(): Readable; - resume(): Readable; - 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; - - /** - * Event emitter - * The defined events on documents including: - * 1. close - * 2. data - * 3. end - * 4. readable - * 5. error - **/ - addListener(event: string, listener: Function): this; - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "data", listener: (chunk: Buffer | string) => void): this; - addListener(event: "end", listener: () => void): this; - addListener(event: "readable", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "data", chunk: Buffer | string): boolean; - emit(event: "end"): boolean; - emit(event: "readable"): boolean; - emit(event: "error", err: Error): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "data", listener: (chunk: Buffer | string) => void): this; - on(event: "end", listener: () => void): this; - on(event: "readable", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "data", listener: (chunk: Buffer | string) => void): this; - once(event: "end", listener: () => void): this; - once(event: "readable", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "data", listener: (chunk: Buffer | string) => void): this; - prependListener(event: "end", listener: () => void): this; - prependListener(event: "readable", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this; - prependOnceListener(event: "end", listener: () => void): this; - prependOnceListener(event: "readable", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - - removeListener(event: string, listener: Function): this; - removeListener(event: "close", listener: () => void): this; - removeListener(event: "data", listener: (chunk: Buffer | string) => void): this; - removeListener(event: "end", listener: () => void): this; - removeListener(event: "readable", listener: () => void): this; - removeListener(event: "error", listener: (err: Error) => void): this; - } - - export interface WritableOptions { - highWaterMark?: number; - decodeStrings?: boolean; - objectMode?: boolean; - write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; - } - - export class Writable extends events.EventEmitter implements NodeJS.WritableStream { - writable: boolean; - constructor(opts?: WritableOptions); - protected _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; - - /** - * Event emitter - * The defined events on documents including: - * 1. close - * 2. drain - * 3. error - * 4. finish - * 5. pipe - * 6. unpipe - **/ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "drain", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "finish", listener: () => void): this; - addListener(event: "pipe", listener: (src: Readable) => void): this; - addListener(event: "unpipe", listener: (src: Readable) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "drain", chunk: Buffer | string): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "finish"): boolean; - emit(event: "pipe", src: Readable): boolean; - emit(event: "unpipe", src: Readable): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "drain", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "finish", listener: () => void): this; - on(event: "pipe", listener: (src: Readable) => void): this; - on(event: "unpipe", listener: (src: Readable) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "drain", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "finish", listener: () => void): this; - once(event: "pipe", listener: (src: Readable) => void): this; - once(event: "unpipe", listener: (src: Readable) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "drain", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "finish", listener: () => void): this; - prependListener(event: "pipe", listener: (src: Readable) => void): this; - prependListener(event: "unpipe", listener: (src: Readable) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "drain", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "finish", listener: () => void): this; - prependOnceListener(event: "pipe", listener: (src: Readable) => void): this; - prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this; - - removeListener(event: string, listener: Function): this; - removeListener(event: "close", listener: () => void): this; - removeListener(event: "drain", listener: () => void): this; - removeListener(event: "error", listener: (err: Error) => void): this; - removeListener(event: "finish", listener: () => void): this; - removeListener(event: "pipe", listener: (src: Readable) => void): this; - removeListener(event: "unpipe", listener: (src: Readable) => void): this; - } - - export interface DuplexOptions extends ReadableOptions, WritableOptions { - allowHalfOpen?: boolean; - readableObjectMode?: boolean; - writableObjectMode?: boolean; - } - - // Note: Duplex extends both Readable and Writable. - export class Duplex extends Readable implements NodeJS.ReadWriteStream { - // Readable - pause(): Duplex; - resume(): Duplex; - // Writeable - writable: boolean; - constructor(opts?: DuplexOptions); - protected _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 DuplexOptions { - transform?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - flush?: (callback: Function) => any; - } - - // 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); - protected _transform(chunk: any, encoding: string, callback: Function): void; - protected _flush(callback: Function): void; - read(size?: number): any; - setEncoding(encoding: string): void; - pause(): Transform; - resume(): Transform; - 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 { } - } - - export = internal; -} - -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; - export function isBoolean(object: any): boolean; - export function isBuffer(object: any): boolean; - export function isFunction(object: any): boolean; - export function isNull(object: any): boolean; - export function isNullOrUndefined(object: any): boolean; - export function isNumber(object: any): boolean; - export function isObject(object: any): boolean; - export function isPrimitive(object: any): boolean; - export function isString(object: any): boolean; - export function isSymbol(object: any): boolean; - export function isUndefined(object: any): boolean; - export function deprecate(fn: Function, message: string): Function; -} - -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; - members: any[]; - enter(): void; - exit(): 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_IFBLK: number; - export var S_IFIFO: number; - export var S_IFSOCK: number; - export var S_IRWXU: number; - export var S_IRUSR: number; - export var S_IWUSR: number; - export var S_IXUSR: number; - export var S_IRWXG: number; - export var S_IRGRP: number; - export var S_IWGRP: number; - export var S_IXGRP: number; - export var S_IRWXO: number; - export var S_IROTH: number; - export var S_IWOTH: number; - export var S_IXOTH: number; - export var S_IFLNK: number; - export var O_CREAT: number; - export var O_EXCL: number; - export var O_NOCTTY: number; - export var O_DIRECTORY: number; - export var O_NOATIME: number; - export var O_NOFOLLOW: number; - export var O_SYNC: number; - export var O_SYMLINK: number; - export var O_DIRECT: number; - export var O_NONBLOCK: 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; - export var SIGQUIT: number; - export var SIGTRAP: number; - export var SIGIOT: number; - export var SIGBUS: number; - export var SIGUSR1: number; - export var SIGUSR2: number; - export var SIGPIPE: number; - export var SIGALRM: number; - export var SIGCHLD: number; - export var SIGSTKFLT: number; - export var SIGCONT: number; - export var SIGSTOP: number; - export var SIGTSTP: number; - export var SIGTTIN: number; - export var SIGTTOU: number; - export var SIGURG: number; - export var SIGXCPU: number; - export var SIGXFSZ: number; - export var SIGVTALRM: number; - export var SIGPROF: number; - export var SIGIO: number; - export var SIGPOLL: number; - export var SIGPWR: number; - export var SIGSYS: number; - export var SIGUNUSED: number; - export var defaultCoreCipherList: string; - export var defaultCipherList: string; - export var ENGINE_METHOD_RSA: number; - export var ALPN_ENABLED: number; -} - -declare module "process" { - export = process; -} - -declare module "v8" { - interface HeapSpaceInfo { - space_name: string; - space_size: number; - space_used_size: number; - space_available_size: number; - physical_space_size: number; - } - export function getHeapStatistics(): { total_heap_size: number, total_heap_size_executable: number, total_physical_size: number, total_avaialble_size: number, used_heap_size: number, heap_size_limit: number }; - export function getHeapSpaceStatistics(): HeapSpaceInfo[]; - export function setFlagsFromString(flags: string): void; -} - -declare module "timers" { - export function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; - export function clearTimeout(timeoutId: NodeJS.Timer): void; - export function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; - export function clearInterval(intervalId: NodeJS.Timer): void; - export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; - export function clearImmediate(immediateId: any): void; -} - -declare module "console" { - export = console; -} diff --git a/typings/request-promise/request-promise.d.ts b/typings/request-promise/request-promise.d.ts deleted file mode 100644 index d266a51..0000000 --- a/typings/request-promise/request-promise.d.ts +++ /dev/null @@ -1,86 +0,0 @@ -// Type definitions for request-promise v4.1.0 -// Project: https://github.com/request/request-promise -// Definitions by: Christopher Glantschnig , Joe Skeen , Aya Morisawa -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// - -declare module 'request-promise' { - import request = require('request'); - import http = require('http'); - import errors = require('request-promise/errors'); - - namespace requestPromise { - interface RequestPromise extends request.Request { - then(onfulfilled?: (value: any) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; - then(onfulfilled?: (value: any) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; - catch(onrejected?: (reason: any) => any | PromiseLike): Promise; - catch(onrejected?: (reason: any) => void): Promise; - catch(type: errors.RequestErrorConstructor, onrejected?: (reason: errors.RequestError) => void): Promise; - catch(type: errors.StatusCodeErrorConstructor, onrejected?: (reason: errors.StatusCodeError) => void): Promise; - catch(type: errors.TransformErrorConstructor, onrejected?: (reason: errors.TransformError) => void): Promise; - finally(handler: () => PromiseLike): Promise; - finally(handler: () => TResult): Promise; - promise(): Promise; - cancel(): void; - } - - interface RequestPromiseOptions extends request.CoreOptions { - simple?: boolean; - transform?: (body: any, response: http.IncomingMessage, resolveWithFullResponse?: boolean) => any; - transform2xxOnly?: boolean; - resolveWithFullResponse?: boolean; - } - - export type OptionsWithUri = request.UriOptions & RequestPromiseOptions; - export type OptionsWithUrl = request.UrlOptions & RequestPromiseOptions; - export type Options = OptionsWithUri | OptionsWithUrl; - } - - var requestPromise: request.RequestAPI; - export = requestPromise; -} -declare module 'request-promise/errors' { - import rp = require('request-promise'); - import http = require('http'); - - export interface RequestError extends Error { - cause: any; - error: any; - options: rp.Options; - response: http.IncomingMessage; - } - export interface RequestErrorConstructor { - new (cause: any, options: rp.Options, response: http.IncomingMessage): RequestError; - (cause: any, options: rp.Options, response: http.IncomingMessage): RequestError; - prototype: RequestError; - } - export const RequestError: RequestErrorConstructor; - - export interface StatusCodeError extends Error { - statusCode: number; - error: any; - options: rp.Options; - response: http.IncomingMessage; - } - export interface StatusCodeErrorConstructor extends Error { - new (statusCode: number, body: any, options: rp.Options, response: http.IncomingMessage): StatusCodeError; - (statusCode: number, body: any, options: rp.Options, response: http.IncomingMessage): StatusCodeError; - prototype: StatusCodeError; - } - export const StatusCodeError: StatusCodeErrorConstructor; - - export interface TransformError extends Error { - cause: any; - error: any; - options: rp.Options; - response: http.IncomingMessage; - } - export interface TransformErrorConstructor extends Error { - new (cause: any, options: rp.Options, response: http.IncomingMessage): TransformError; - (cause: any, options: rp.Options, response: http.IncomingMessage): TransformError; - prototype: TransformError; - } - export const TransformError: TransformErrorConstructor; -} diff --git a/typings/request/request.d.ts b/typings/request/request.d.ts deleted file mode 100644 index 20be3dc..0000000 --- a/typings/request/request.d.ts +++ /dev/null @@ -1,262 +0,0 @@ -// Type definitions for request -// Project: https://github.com/request/request -// Definitions by: Carlos Ballesteros Velasco , bonnici , Bart van der Schoor , Joe Skeen , Christopher Currens -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -// Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts - -/// -/// - -declare module 'request' { - import stream = require('stream'); - import http = require('http'); - import https = require('https'); - import url = require('url'); - import fs = require('fs'); - import FormData = require('form-data'); - - namespace request { - export interface RequestAPI { - - defaults(options: TOptions): RequestAPI; - defaults(options: RequiredUriUrl & TOptions): DefaultUriUrlRequestApi; - - (uri: string, options?: TOptions, callback?: RequestCallback): TRequest; - (uri: string, callback?: RequestCallback): TRequest; - (options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; - - get(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; - get(uri: string, callback?: RequestCallback): TRequest; - get(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; - - post(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; - post(uri: string, callback?: RequestCallback): TRequest; - post(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; - - put(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; - put(uri: string, callback?: RequestCallback): TRequest; - put(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; - - head(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; - head(uri: string, callback?: RequestCallback): TRequest; - head(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; - - patch(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; - patch(uri: string, callback?: RequestCallback): TRequest; - patch(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; - - del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; - del(uri: string, callback?: RequestCallback): TRequest; - del(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; - - forever(agentOptions: any, optionsArg: any): TRequest; - jar(): CookieJar; - cookie(str: string): Cookie; - - initParams: any; - debug: boolean; - } - - interface DefaultUriUrlRequestApi extends RequestAPI { - - defaults(options: TOptions): DefaultUriUrlRequestApi; - (): TRequest; - get(): TRequest; - post(): TRequest; - put(): TRequest; - head(): TRequest; - patch(): TRequest; - del(): TRequest; - } - - interface CoreOptions { - baseUrl?: string; - callback?: (error: any, response: http.IncomingMessage, body: any) => void; - jar?: any; // CookieJar - formData?: any; // Object - form?: any; // Object or string - auth?: AuthOptions; - oauth?: OAuthOptions; - aws?: AWSOptions; - hawk?: HawkOptions; - qs?: any; - json?: any; - multipart?: RequestPart[] | Multipart; - agent?: http.Agent | https.Agent; - agentOptions?: any; - agentClass?: any; - forever?: any; - host?: string; - port?: number; - method?: string; - headers?: Headers; - body?: any; - followRedirect?: boolean | ((response: http.IncomingMessage) => boolean); - followAllRedirects?: boolean; - maxRedirects?: number; - encoding?: string; - pool?: any; - timeout?: number; - proxy?: any; - strictSSL?: boolean; - gzip?: boolean; - preambleCRLF?: boolean; - postambleCRLF?: boolean; - key?: Buffer; - cert?: Buffer; - passphrase?: string; - ca?: string | Buffer | string[] | Buffer[]; - har?: HttpArchiveRequest; - useQuerystring?: boolean; - } - - interface UriOptions { - uri: string; - } - interface UrlOptions { - url: string; - } - export type RequiredUriUrl = UriOptions | UrlOptions; - - interface OptionalUriUrl { - uri?: string; - url?: string; - } - - export type OptionsWithUri = UriOptions & CoreOptions; - export type OptionsWithUrl = UrlOptions & CoreOptions; - export type Options = OptionsWithUri | OptionsWithUrl; - - export interface RequestCallback { - (error: any, response: http.IncomingMessage, body: any): void; - } - - export interface HttpArchiveRequest { - url?: string; - method?: string; - headers?: NameValuePair[]; - postData?: { - mimeType?: string; - params?: NameValuePair[]; - } - } - - export interface NameValuePair { - name: string; - value: string; - } - - export interface Multipart { - chunked?: boolean; - data?: { - 'content-type'?: string, - body: string - }[]; - } - - export interface RequestPart { - headers?: Headers; - body: any; - } - - export interface Request extends stream.Stream { - readable: boolean; - writable: boolean; - - getAgent(): http.Agent; - //start(): void; - //abort(): void; - pipeDest(dest: any): void; - setHeader(name: string, value: string, clobber?: boolean): Request; - setHeaders(headers: Headers): Request; - qs(q: Object, clobber?: boolean): Request; - form(): FormData; - form(form: any): Request; - multipart(multipart: RequestPart[]): Request; - json(val: any): Request; - aws(opts: AWSOptions, now?: boolean): Request; - auth(username: string, password: string, sendInmediately?: boolean, bearer?: string): Request; - oauth(oauth: OAuthOptions): Request; - jar(jar: CookieJar): Request; - - on(event: string, listener: Function): this; - on(event: 'request', listener: (req: http.ClientRequest) => void): this; - on(event: 'response', listener: (resp: http.IncomingMessage) => void): this; - on(event: 'data', listener: (data: Buffer | string) => void): this; - on(event: 'error', listener: (e: Error) => void): this; - on(event: 'complete', listener: (resp: http.IncomingMessage, body?: string | Buffer) => void): this; - - 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; - end(): void; - end(chunk: Buffer, cb?: Function): void; - end(chunk: string, cb?: Function): void; - end(chunk: string, encoding: string, cb?: Function): void; - pause(): void; - resume(): void; - abort(): void; - destroy(): void; - toJSON(): Object; - } - - export interface Headers { - [key: string]: any; - } - - export interface AuthOptions { - user?: string; - username?: string; - pass?: string; - password?: string; - sendImmediately?: boolean; - bearer?: string; - } - - export interface OAuthOptions { - callback?: string; - consumer_key?: string; - consumer_secret?: string; - token?: string; - token_secret?: string; - verifier?: string; - } - - export interface HawkOptions { - credentials: any; - } - - export interface AWSOptions { - secret: string; - bucket?: string; - } - - export interface CookieJar { - setCookie(cookie: Cookie, uri: string | url.Url, options?: any): void - getCookieString(uri: string | url.Url): string - getCookies(uri: string | url.Url): Cookie[] - } - - export interface CookieValue { - name: string; - value: any; - httpOnly: boolean; - } - - export interface Cookie extends Array { - constructor(name: string, req: Request): void; - str: string; - expires: Date; - path: string; - toString(): string; - } - } - var request: request.RequestAPI; - export = request; -} diff --git a/typings/strformat.d.ts b/typings/strformat.d.ts deleted file mode 100644 index 56eb8e3..0000000 --- a/typings/strformat.d.ts +++ /dev/null @@ -1,7 +0,0 @@ - -declare module 'strformat' { - - function strformat(format: string, ...params: any[]): string; - namespace strformat {} - export = strformat; -} \ No newline at end of file diff --git a/typings/tsd.d.ts b/typings/tsd.d.ts deleted file mode 100644 index 8b322da..0000000 --- a/typings/tsd.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// -/// - -/// -/// -/// -/// -/// -/// diff --git a/typings/underscore/underscore.d.ts b/typings/underscore/underscore.d.ts deleted file mode 100644 index d8d08a3..0000000 --- a/typings/underscore/underscore.d.ts +++ /dev/null @@ -1,6085 +0,0 @@ -// Type definitions for Underscore 1.8.3 -// Project: http://underscorejs.org/ -// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare module _ { - /** - * underscore.js _.throttle options. - **/ - 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; - } - - /** - * underscore.js template settings, set templateSettings or pass as an argument - * to 'template()' to override defaults. - **/ - interface TemplateSettings { - /** - * Default value is '/<%([\s\S]+?)%>/g'. - **/ - evaluate?: RegExp; - - /** - * Default value is '/<%=([\s\S]+?)%>/g'. - **/ - interpolate?: RegExp; - - /** - * Default value is '/<%-([\s\S]+?)%>/g'. - **/ - escape?: RegExp; - - /** - * By default, 'template()' places the values from your data in the local scope via the 'with' statement. - * However, you can specify a single variable name with this setting. - **/ - variable?: string; - } - - interface Collection { } - - // Common interface between Arrays and jQuery objects - interface List extends Collection { - [index: number]: T; - length: number; - } - - interface Dictionary extends Collection { - [index: string]: T; - } - - interface ListIterator { - (value: T, index: number, list: List): TResult; - } - - interface ObjectIterator { - (element: T, key: string, list: Dictionary): TResult; - } - - interface MemoIterator { - (prev: TResult, curr: T, index: number, list: List): TResult; - } - - interface MemoObjectIterator { - (prev: TResult, curr: T, key: string, list: Dictionary): TResult; - } - - interface Cancelable { - cancel() : void; - } -} - -interface UnderscoreStatic { - /** - * Underscore OOP Wrapper, all Underscore functions that take an object - * as the first parameter can be invoked through this function. - * @param key First argument to Underscore object functions. - **/ - (value: _.Dictionary): Underscore; - (value: Array): Underscore; - (value: T): Underscore; - - /* ************* - * Collections * - ************* */ - - /** - * Iterates over a list of elements, yielding each in turn to an iterator function. The iterator is - * bound to the context object, if one is passed. Each invocation of iterator is called with three - * arguments: (element, index, list). If list is a JavaScript object, iterator's arguments will be - * (value, key, object). Delegates to the native forEach function if it exists. - * @param list Iterates over this list of elements. - * @param iterator Iterator function for each element `list`. - * @param context 'this' object in `iterator`, optional. - **/ - each( - list: _.List, - iterator: _.ListIterator, - context?: any): _.List; - - /** - * @see _.each - * @param object Iterates over properties of this object. - * @param iterator Iterator function for each property on `object`. - * @param context 'this' object in `iterator`, optional. - **/ - each( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): _.Dictionary; - - /** - * @see _.each - **/ - forEach( - list: _.List, - iterator: _.ListIterator, - context?: any): _.List; - - /** - * @see _.each - **/ - forEach( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): _.Dictionary; - - /** - * Produces a new array of values by mapping each value in list through a transformation function - * (iterator). If the native map method exists, it will be used instead. If list is a JavaScript - * object, iterator's arguments will be (value, key, object). - * @param list Maps the elements of this array. - * @param iterator Map iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return The mapped array result. - **/ - map( - list: _.List, - iterator: _.ListIterator, - context?: any): TResult[]; - - /** - * @see _.map - * @param object Maps the properties of this object. - * @param iterator Map iterator function for each property on `object`. - * @param context `this` object in `iterator`, optional. - * @return The mapped object result. - **/ - map( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): TResult[]; - - /** - * @see _.map - **/ - collect( - list: _.List, - iterator: _.ListIterator, - context?: any): TResult[]; - - /** - * @see _.map - **/ - collect( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): TResult[]; - - /** - * Also known as inject and foldl, reduce boils down a list of values into a single value. - * Memo is the initial state of the reduction, and each successive step of it should be - * returned by iterator. The iterator is passed four arguments: the memo, then the value - * and index (or key) of the iteration, and finally a reference to the entire list. - * @param list Reduces the elements of this array. - * @param iterator Reduce iterator function for each element in `list`. - * @param memo Initial reduce state. - * @param context `this` object in `iterator`, optional. - * @return Reduced object result. - **/ - reduce( - list: _.Collection, - iterator: _.MemoIterator, - memo?: TResult, - context?: any): TResult; - - reduce( - list: _.Dictionary, - iterator: _.MemoObjectIterator, - memo?: TResult, - context?: any): TResult; - - /** - * @see _.reduce - **/ - inject( - list: _.Collection, - iterator: _.MemoIterator, - memo?: TResult, - context?: any): TResult; - - /** - * @see _.reduce - **/ - foldl( - list: _.Collection, - iterator: _.MemoIterator, - memo?: TResult, - context?: any): TResult; - - /** - * The right-associative version of reduce. Delegates to the JavaScript 1.8 version of - * reduceRight, if it exists. `foldr` is not as useful in JavaScript as it would be in a - * language with lazy evaluation. - * @param list Reduces the elements of this array. - * @param iterator Reduce iterator function for each element in `list`. - * @param memo Initial reduce state. - * @param context `this` object in `iterator`, optional. - * @return Reduced object result. - **/ - reduceRight( - list: _.Collection, - iterator: _.MemoIterator, - memo?: TResult, - context?: any): TResult; - - /** - * @see _.reduceRight - **/ - foldr( - list: _.Collection, - iterator: _.MemoIterator, - memo?: TResult, - context?: any): TResult; - - /** - * Looks through each value in the list, returning the first one that passes a truth - * test (iterator). The function returns as soon as it finds an acceptable element, - * and doesn't traverse the entire list. - * @param list Searches for a value in this list. - * @param iterator Search iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return The first acceptable found element in `list`, if nothing is found undefined/null is returned. - **/ - find( - list: _.List, - iterator: _.ListIterator, - context?: any): T; - - /** - * @see _.find - **/ - find( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): T; - - /** - * @see _.find - **/ - find( - object: _.List|_.Dictionary, - iterator: U): T; - - /** - * @see _.find - **/ - find( - object: _.List|_.Dictionary, - iterator: string): T; - - /** - * @see _.find - **/ - detect( - list: _.List, - iterator: _.ListIterator, - context?: any): T; - - /** - * @see _.find - **/ - detect( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): T; - - /** - * @see _.find - **/ - detect( - object: _.List|_.Dictionary, - iterator: U): T; - - /** - * @see _.find - **/ - detect( - object: _.List|_.Dictionary, - iterator: string): T; - - /** - * Looks through each value in the list, returning an array of all the values that pass a truth - * test (iterator). Delegates to the native filter method, if it exists. - * @param list Filter elements out of this list. - * @param iterator Filter iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return The filtered list of elements. - **/ - filter( - list: _.List, - iterator: _.ListIterator, - context?: any): T[]; - - /** - * @see _.filter - **/ - filter( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): T[]; - - /** - * @see _.filter - **/ - select( - list: _.List, - iterator: _.ListIterator, - context?: any): T[]; - - /** - * @see _.filter - **/ - select( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): T[]; - - /** - * Looks through each value in the list, returning an array of all the values that contain all - * of the key-value pairs listed in properties. - * @param list List to match elements again `properties`. - * @param properties The properties to check for on each element within `list`. - * @return The elements within `list` that contain the required `properties`. - **/ - where( - list: _.List, - properties: U): T[]; - - /** - * Looks through the list and returns the first value that matches all of the key-value pairs listed in properties. - * @param list Search through this list's elements for the first object with all `properties`. - * @param properties Properties to look for on the elements within `list`. - * @return The first element in `list` that has all `properties`. - **/ - findWhere( - list: _.List, - properties: U): T; - - /** - * Returns the values in list without the elements that the truth test (iterator) passes. - * The opposite of filter. - * Return all the elements for which a truth test fails. - * @param list Reject elements within this list. - * @param iterator Reject iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return The rejected list of elements. - **/ - reject( - list: _.List, - iterator: _.ListIterator, - context?: any): T[]; - - /** - * @see _.reject - **/ - reject( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): T[]; - - /** - * Returns true if all of the values in the list pass the iterator truth test. Delegates to the - * native method every, if present. - * @param list Truth test against all elements within this list. - * @param iterator Trust test iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return True if all elements passed the truth test, otherwise false. - **/ - every( - list: _.List, - iterator?: _.ListIterator, - context?: any): boolean; - - /** - * @see _.every - **/ - every( - list: _.Dictionary, - iterator?: _.ObjectIterator, - context?: any): boolean; - - /** - * @see _.every - **/ - all( - list: _.List, - iterator?: _.ListIterator, - context?: any): boolean; - - /** - * @see _.every - **/ - all( - list: _.Dictionary, - iterator?: _.ObjectIterator, - context?: any): boolean; - - /** - * Returns true if any of the values in the list pass the iterator truth test. Short-circuits and - * stops traversing the list if a true element is found. Delegates to the native method some, if present. - * @param list Truth test against all elements within this list. - * @param iterator Trust test iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return True if any elements passed the truth test, otherwise false. - **/ - some( - list: _.List, - iterator?: _.ListIterator, - context?: any): boolean; - - /** - * @see _.some - **/ - some( - object: _.Dictionary, - iterator?: _.ObjectIterator, - context?: any): boolean; - - /** - * @see _.some - **/ - any( - list: _.List, - iterator?: _.ListIterator, - context?: any): boolean; - - /** - * @see _.some - **/ - any( - object: _.Dictionary, - iterator?: _.ObjectIterator, - context?: any): boolean; - - any( - list: _.List, - value: T): boolean; - - /** - * Returns true if the value is present in the list. Uses indexOf internally, - * if list is an Array. - * @param list Checks each element to see if `value` is present. - * @param value The value to check for within `list`. - * @return True if `value` is present in `list`, otherwise false. - **/ - contains( - list: _.List, - value: T, - fromIndex?: number): boolean; - - /** - * @see _.contains - **/ - contains( - object: _.Dictionary, - value: T): boolean; - - /** - * @see _.contains - **/ - include( - list: _.Collection, - value: T, - fromIndex?: number): boolean; - - /** - * @see _.contains - **/ - include( - object: _.Dictionary, - value: T): boolean; - - /** - * @see _.contains - **/ - includes( - list: _.Collection, - value: T, - fromIndex?: number): boolean; - - /** - * @see _.contains - **/ - includes( - object: _.Dictionary, - value: T): boolean; - - /** - * Calls the method named by methodName on each value in the list. Any extra arguments passed to - * invoke will be forwarded on to the method invocation. - * @param list The element's in this list will each have the method `methodName` invoked. - * @param methodName The method's name to call on each element within `list`. - * @param arguments Additional arguments to pass to the method `methodName`. - **/ - invoke( - list: _.List, - methodName: string, - ...arguments: any[]): any; - - /** - * A convenient version of what is perhaps the most common use-case for map: extracting a list of - * property values. - * @param list The list to pluck elements out of that have the property `propertyName`. - * @param propertyName The property to look for on each element within `list`. - * @return The list of elements within `list` that have the property `propertyName`. - **/ - pluck( - list: _.List, - propertyName: string): any[]; - - /** - * Returns the maximum value in list. - * @param list Finds the maximum value in this list. - * @return Maximum value in `list`. - **/ - max(list: _.List): number; - - /** - * @see _.max - */ - max(object: _.Dictionary): number; - - /** - * Returns the maximum value in list. If iterator is passed, it will be used on each value to generate - * the criterion by which the value is ranked. - * @param list Finds the maximum value in this list. - * @param iterator Compares each element in `list` to find the maximum value. - * @param context `this` object in `iterator`, optional. - * @return The maximum element within `list`. - **/ - max( - list: _.List, - iterator?: _.ListIterator, - context?: any): T; - - /** - * @see _.max - */ - max( - list: _.Dictionary, - iterator?: _.ObjectIterator, - context?: any): T; - - /** - * Returns the minimum value in list. - * @param list Finds the minimum value in this list. - * @return Minimum value in `list`. - **/ - min(list: _.List): number; - - /** - * @see _.min - */ - min(o: _.Dictionary): number; - - /** - * Returns the minimum value in list. If iterator is passed, it will be used on each value to generate - * the criterion by which the value is ranked. - * @param list Finds the minimum value in this list. - * @param iterator Compares each element in `list` to find the minimum value. - * @param context `this` object in `iterator`, optional. - * @return The minimum element within `list`. - **/ - min( - list: _.List, - iterator?: _.ListIterator, - context?: any): T; - - /** - * @see _.min - */ - min( - list: _.Dictionary, - iterator?: _.ObjectIterator, - context?: any): T; - - /** - * Returns a sorted copy of list, ranked in ascending order by the results of running each value - * through iterator. Iterator may also be the string name of the property to sort by (eg. length). - * @param list Sorts this list. - * @param iterator Sort iterator for each element within `list`. - * @param context `this` object in `iterator`, optional. - * @return A sorted copy of `list`. - **/ - sortBy( - list: _.List, - iterator?: _.ListIterator, - context?: any): T[]; - - /** - * @see _.sortBy - * @param iterator Sort iterator for each element within `list`. - **/ - sortBy( - list: _.List, - iterator: string, - context?: any): T[]; - - /** - * Splits a collection into sets, grouped by the result of running each value through iterator. - * If iterator is a string instead of a function, groups by the property named by iterator on - * each of the values. - * @param list Groups this list. - * @param iterator Group iterator for each element within `list`, return the key to group the element by. - * @param context `this` object in `iterator`, optional. - * @return An object with the group names as properties where each property contains the grouped elements from `list`. - **/ - groupBy( - list: _.List, - iterator?: _.ListIterator, - context?: any): _.Dictionary; - - /** - * @see _.groupBy - * @param iterator Property on each object to group them by. - **/ - groupBy( - list: _.List, - iterator: string, - context?: any): _.Dictionary; - - /** - * Given a `list`, and an `iterator` function that returns a key for each element in the list (or a property name), - * returns an object with an index of each item. Just like _.groupBy, but for when you know your keys are unique. - **/ - indexBy( - list: _.List, - iterator: _.ListIterator, - context?: any): _.Dictionary; - - /** - * @see _.indexBy - * @param iterator Property on each object to index them by. - **/ - indexBy( - list: _.List, - iterator: string, - context?: any): _.Dictionary; - - /** - * Sorts a list into groups and returns a count for the number of objects in each group. Similar - * to groupBy, but instead of returning a list of values, returns a count for the number of values - * in that group. - * @param list Group elements in this list and then count the number of elements in each group. - * @param iterator Group iterator for each element within `list`, return the key to group the element by. - * @param context `this` object in `iterator`, optional. - * @return An object with the group names as properties where each property contains the number of elements in that group. - **/ - countBy( - list: _.List, - iterator?: _.ListIterator, - context?: any): _.Dictionary; - - /** - * @see _.countBy - * @param iterator Function name - **/ - countBy( - list: _.List, - iterator: string, - context?: any): _.Dictionary; - - /** - * Returns a shuffled copy of the list, using a version of the Fisher-Yates shuffle. - * @param list List to shuffle. - * @return Shuffled copy of `list`. - **/ - shuffle(list: _.Collection): T[]; - - /** - * Produce a random sample from the `list`. Pass a number to return `n` random elements from the list. Otherwise a single random item will be returned. - * @param list List to sample. - * @return Random sample of `n` elements in `list`. - **/ - sample(list: _.Collection, n: number): T[]; - - /** - * @see _.sample - **/ - sample(list: _.Collection): T; - - /** - * Converts the list (anything that can be iterated over), into a real Array. Useful for transmuting - * the arguments object. - * @param list object to transform into an array. - * @return `list` as an array. - **/ - toArray(list: _.Collection): T[]; - - /** - * Return the number of values in the list. - * @param list Count the number of values/elements in this list. - * @return Number of values in `list`. - **/ - size(list: _.Collection): number; - - /** - * Split array into two arrays: - * one whose elements all satisfy predicate and one whose elements all do not satisfy predicate. - * @param array Array to split in two. - * @param iterator Filter iterator function for each element in `array`. - * @param context `this` object in `iterator`, optional. - * @return Array where Array[0] are the elements in `array` that satisfies the predicate, and Array[1] the elements that did not. - **/ - partition( - array: Array, - iterator: _.ListIterator, - context?: any): T[][]; - - /********* - * Arrays * - **********/ - - /** - * Returns the first element of an array. Passing n will return the first n elements of the array. - * @param array Retrieves the first element of this array. - * @return Returns the first element of `array`. - **/ - first(array: _.List): T; - - /** - * @see _.first - * @param n Return more than one element from `array`. - **/ - first( - array: _.List, - n: number): T[]; - - /** - * @see _.first - **/ - head(array: _.List): T; - - /** - * @see _.first - **/ - head( - array: _.List, - n: number): T[]; - - /** - * @see _.first - **/ - take(array: _.List): T; - - /** - * @see _.first - **/ - take( - array: _.List, - n: number): T[]; - - /** - * Returns everything but the last entry of the array. Especially useful on the arguments object. - * Pass n to exclude the last n elements from the result. - * @param array Retrieve all elements except the last `n`. - * @param n Leaves this many elements behind, optional. - * @return Returns everything but the last `n` elements of `array`. - **/ - initial( - array: _.List, - n?: number): T[]; - - /** - * Returns the last element of an array. Passing n will return the last n elements of the array. - * @param array Retrieves the last element of this array. - * @return Returns the last element of `array`. - **/ - last(array: _.List): T; - - /** - * @see _.last - * @param n Return more than one element from `array`. - **/ - last( - array: _.List, - n: number): T[]; - - /** - * Returns the rest of the elements in an array. Pass an index to return the values of the array - * from that index onward. - * @param array The array to retrieve all but the first `index` elements. - * @param n The index to start retrieving elements forward from, optional, default = 1. - * @return Returns the elements of `array` from `index` to the end of `array`. - **/ - rest( - array: _.List, - n?: number): T[]; - - /** - * @see _.rest - **/ - tail( - array: _.List, - n?: number): T[]; - - /** - * @see _.rest - **/ - drop( - array: _.List, - n?: number): T[]; - - /** - * Returns a copy of the array with all falsy values removed. In JavaScript, false, null, 0, "", - * undefined and NaN are all falsy. - * @param array Array to compact. - * @return Copy of `array` without false values. - **/ - compact(array: _.List): T[]; - - /** - * Flattens a nested array (the nesting can be to any depth). If you pass shallow, the array will - * only be flattened a single level. - * @param array The array to flatten. - * @param shallow If true then only flatten one level, optional, default = false. - * @return `array` flattened. - **/ - flatten( - array: _.List, - shallow?: boolean): any[]; - - /** - * Returns a copy of the array with all instances of the values removed. - * @param array The array to remove `values` from. - * @param values The values to remove from `array`. - * @return Copy of `array` without `values`. - **/ - without( - array: _.List, - ...values: T[]): T[]; - - /** - * Computes the union of the passed-in arrays: the list of unique items, in order, that are - * present in one or more of the arrays. - * @param arrays Array of arrays to compute the union of. - * @return The union of elements within `arrays`. - **/ - union(...arrays: _.List[]): T[]; - - /** - * Computes the list of values that are the intersection of all the arrays. Each value in the result - * is present in each of the arrays. - * @param arrays Array of arrays to compute the intersection of. - * @return The intersection of elements within `arrays`. - **/ - intersection(...arrays: _.List[]): T[]; - - /** - * Similar to without, but returns the values from array that are not present in the other arrays. - * @param array Keeps values that are within `others`. - * @param others The values to keep within `array`. - * @return Copy of `array` with only `others` values. - **/ - difference( - array: _.List, - ...others: _.List[]): T[]; - - /** - * Produces a duplicate-free version of the array, using === to test object equality. If you know in - * advance that the array is sorted, passing true for isSorted will run a much faster algorithm. If - * you want to compute unique items based on a transformation, pass an iterator function. - * @param array Array to remove duplicates from. - * @param isSorted True if `array` is already sorted, optional, default = false. - * @param iterator Transform the elements of `array` before comparisons for uniqueness. - * @param context 'this' object in `iterator`, optional. - * @return Copy of `array` where all elements are unique. - **/ - uniq( - array: _.List, - isSorted?: boolean, - iterator?: _.ListIterator, - context?: any): T[]; - - /** - * @see _.uniq - **/ - uniq( - array: _.List, - iterator?: _.ListIterator, - context?: any): T[]; - - /** - * @see _.uniq - **/ - unique( - array: _.List, - iterator?: _.ListIterator, - context?: any): T[]; - - /** - * @see _.uniq - **/ - unique( - array: _.List, - isSorted?: boolean, - iterator?: _.ListIterator, - context?: any): T[]; - - - /** - * Merges together the values of each of the arrays with the values at the corresponding position. - * Useful when you have separate data sources that are coordinated through matching array indexes. - * If you're working with a matrix of nested arrays, zip.apply can transpose the matrix in a similar fashion. - * @param arrays The arrays to merge/zip. - * @return Zipped version of `arrays`. - **/ - zip(...arrays: any[][]): any[][]; - - /** - * @see _.zip - **/ - zip(...arrays: any[]): any[]; - - /** - * The opposite of zip. Given a number of arrays, returns a series of new arrays, the first - * of which contains all of the first elements in the input arrays, the second of which - * contains all of the second elements, and so on. Use with apply to pass in an array - * of arrays - * @param arrays The arrays to unzip. - * @return Unzipped version of `arrays`. - **/ - unzip(...arrays: any[][]): any[][]; - - /** - * Converts arrays into objects. Pass either a single list of [key, value] pairs, or a - * list of keys, and a list of values. - * @param keys Key array. - * @param values Value array. - * @return An object containing the `keys` as properties and `values` as the property values. - **/ - object( - keys: _.List, - values: _.List): TResult; - - /** - * Converts arrays into objects. Pass either a single list of [key, value] pairs, or a - * list of keys, and a list of values. - * @param keyValuePairs Array of [key, value] pairs. - * @return An object containing the `keys` as properties and `values` as the property values. - **/ - object(...keyValuePairs: any[][]): TResult; - - /** - * @see _.object - **/ - object( - list: _.List, - values?: any): TResult; - - /** - * Returns the index at which value can be found in the array, or -1 if value is not present in the array. - * Uses the native indexOf function unless it's missing. If you're working with a large array, and you know - * that the array is already sorted, pass true for isSorted to use a faster binary search ... or, pass a number - * as the third argument in order to look for the first matching value in the array after the given index. - * @param array The array to search for the index of `value`. - * @param value The value to search for within `array`. - * @param isSorted True if the array is already sorted, optional, default = false. - * @return The index of `value` within `array`. - **/ - indexOf( - array: _.List, - value: T, - isSorted?: boolean): number; - - /** - * @see _indexof - **/ - indexOf( - array: _.List, - value: T, - startFrom: number): number; - - /** - * Returns the index of the last occurrence of value in the array, or -1 if value is not present. Uses the - * native lastIndexOf function if possible. Pass fromIndex to start your search at a given index. - * @param array The array to search for the last index of `value`. - * @param value The value to search for within `array`. - * @param from The starting index for the search, optional. - * @return The index of the last occurrence of `value` within `array`. - **/ - lastIndexOf( - array: _.List, - value: T, - from?: number): number; - - /** - * Returns the first index of an element in `array` where the predicate truth test passes - * @param array The array to search for the index of the first element where the predicate truth test passes. - * @param predicate Predicate function. - * @param context `this` object in `predicate`, optional. - * @return Returns the index of an element in `array` where the predicate truth test passes or -1.` - **/ - findIndex( - array: _.List, - predicate: _.ListIterator | {}, - context?: any): number; - - /** - * Returns the last index of an element in `array` where the predicate truth test passes - * @param array The array to search for the index of the last element where the predicate truth test passes. - * @param predicate Predicate function. - * @param context `this` object in `predicate`, optional. - * @return Returns the index of an element in `array` where the predicate truth test passes or -1.` - **/ - findLastIndex( - array: _.List, - predicate: _.ListIterator | {}, - context?: any): number; - - /** - * Uses a binary search to determine the index at which the value should be inserted into the list in order - * to maintain the list's sorted order. If an iterator is passed, it will be used to compute the sort ranking - * of each value, including the value you pass. - * @param list The sorted list. - * @param value The value to determine its index within `list`. - * @param iterator Iterator to compute the sort ranking of each value, optional. - * @return The index where `value` should be inserted into `list`. - **/ - sortedIndex( - list: _.List, - value: T, - iterator?: (x: T) => TSort, context?: any): number; - - /** - * A function to create flexibly-numbered lists of integers, handy for each and map loops. start, if omitted, - * defaults to 0; step defaults to 1. Returns a list of integers from start to stop, incremented (or decremented) - * by step, exclusive. - * @param start Start here. - * @param stop Stop here. - * @param step The number to count up by each iteration, optional, default = 1. - * @return Array of numbers from `start` to `stop` with increments of `step`. - **/ - - range( - start: number, - stop: number, - step?: number): number[]; - - /** - * @see _.range - * @param stop Stop here. - * @return Array of numbers from 0 to `stop` with increments of 1. - * @note If start is not specified the implementation will never pull the step (step = arguments[2] || 0) - **/ - range(stop: number): number[]; - - /** - * Split an **array** into several arrays containing **count** or less elements - * of initial array. - * @param array The array to split - * @param count The maximum size of the inner arrays. - */ - chunk(array: _.Collection, count: number): (_.Collection)[] - - /************* - * Functions * - *************/ - - /** - * Bind a function to an object, meaning that whenever the function is called, the value of this will - * be the object. Optionally, bind arguments to the function to pre-fill them, also known as partial application. - * @param func The function to bind `this` to `object`. - * @param context The `this` pointer whenever `fn` is called. - * @param arguments Additional arguments to pass to `fn` when called. - * @return `fn` with `this` bound to `object`. - **/ - bind( - func: Function, - context: any, - ...arguments: any[]): () => any; - - /** - * Binds a number of methods on the object, specified by methodNames, to be run in the context of that object - * whenever they are invoked. Very handy for binding functions that are going to be used as event handlers, - * which would otherwise be invoked with a fairly useless this. If no methodNames are provided, all of the - * object's function properties will be bound to it. - * @param object The object to bind the methods `methodName` to. - * @param methodNames The methods to bind to `object`, optional and if not provided all of `object`'s - * methods are bound. - **/ - bindAll( - object: any, - ...methodNames: string[]): any; - - /** - * Partially apply a function by filling in any number of its arguments, without changing its dynamic this value. - * A close cousin of bind. You may pass _ in your list of arguments to specify an argument that should not be - * pre-filled, but left open to supply at call-time. - * @param fn Function to partially fill in arguments. - * @param arguments The partial arguments. - * @return `fn` with partially filled in arguments. - **/ - - partial( - fn: { (p1: T1):T2 }, - p1: T1 - ): { (): T2 }; - - partial( - fn: { (p1: T1, p2: T2):T3 }, - p1: T1 - ): { (p2: T2): T3 }; - - partial( - fn: { (p1: T1, p2: T2):T3 }, - p1: T1, - p2: T2 - ): { (): T3 }; - - partial( - fn: { (p1: T1, p2: T2):T3 }, - stub1: UnderscoreStatic, - p2: T2 - ): { (p1: T1): T3 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3):T4 }, - p1: T1 - ): { (p2: T2, p3: T3): T4 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3):T4 }, - p1: T1, - p2: T2 - ): { (p3: T3): T4 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3):T4 }, - stub1: UnderscoreStatic, - p2: T2 - ): { (p1: T1, p3: T3): T4 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3):T4 }, - p1: T1, - p2: T2, - p3: T3 - ): { (): T4 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3):T4 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3 - ): { (p1: T1): T4 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3):T4 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3 - ): { (p2: T2): T4 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3):T4 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3 - ): { (p1: T1, p2: T2): T4 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - p1: T1 - ): { (p2: T2, p3: T3, p4: T4): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - p1: T1, - p2: T2 - ): { (p3: T3, p4: T4): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - stub1: UnderscoreStatic, - p2: T2 - ): { (p1: T1, p3: T3, p4: T4): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - p1: T1, - p2: T2, - p3: T3 - ): { (p4: T4): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3 - ): { (p1: T1, p4: T4): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3 - ): { (p2: T2, p4: T4): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3 - ): { (p1: T1, p2: T2, p4: T4): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4 - ): { (): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4 - ): { (p1: T1): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4 - ): { (p2: T2): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4 - ): { (p1: T1, p2: T2): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4 - ): { (p3: T3): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4 - ): { (p1: T1, p3: T3): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4 - ): { (p2: T2, p3: T3): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4 - ): { (p1: T1, p2: T2, p3: T3): T5 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1 - ): { (p2: T2, p3: T3, p4: T4, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - p2: T2 - ): { (p3: T3, p4: T4, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - p2: T2 - ): { (p1: T1, p3: T3, p4: T4, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - p2: T2, - p3: T3 - ): { (p4: T4, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3 - ): { (p1: T1, p4: T4, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3 - ): { (p2: T2, p4: T4, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3 - ): { (p1: T1, p2: T2, p4: T4, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4 - ): { (p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4 - ): { (p1: T1, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4 - ): { (p2: T2, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4 - ): { (p1: T1, p2: T2, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4 - ): { (p3: T3, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4 - ): { (p1: T1, p3: T3, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4 - ): { (p2: T2, p3: T3, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4 - ): { (p1: T1, p2: T2, p3: T3, p5: T5): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4, - p5: T5 - ): { (): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4, - p5: T5 - ): { (p1: T1): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5 - ): { (p2: T2): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5 - ): { (p1: T1, p2: T2): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5 - ): { (p3: T3): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5 - ): { (p1: T1, p3: T3): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5 - ): { (p2: T2, p3: T3): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5 - ): { (p1: T1, p2: T2, p3: T3): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5 - ): { (p4: T4): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5 - ): { (p1: T1, p4: T4): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5 - ): { (p2: T2, p4: T4): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5 - ): { (p1: T1, p2: T2, p4: T4): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5 - ): { (p3: T3, p4: T4): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5 - ): { (p1: T1, p3: T3, p4: T4): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5 - ): { (p2: T2, p3: T3, p4: T4): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5 - ): { (p1: T1, p2: T2, p3: T3, p4: T4): T6 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1 - ): { (p2: T2, p3: T3, p4: T4, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2 - ): { (p3: T3, p4: T4, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2 - ): { (p1: T1, p3: T3, p4: T4, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - p3: T3 - ): { (p4: T4, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3 - ): { (p1: T1, p4: T4, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3 - ): { (p2: T2, p4: T4, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3 - ): { (p1: T1, p2: T2, p4: T4, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4 - ): { (p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4 - ): { (p1: T1, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4 - ): { (p2: T2, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4 - ): { (p1: T1, p2: T2, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4 - ): { (p3: T3, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4 - ): { (p1: T1, p3: T3, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4 - ): { (p2: T2, p3: T3, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4 - ): { (p1: T1, p2: T2, p3: T3, p5: T5, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4, - p5: T5 - ): { (p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4, - p5: T5 - ): { (p1: T1, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5 - ): { (p2: T2, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5 - ): { (p1: T1, p2: T2, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5 - ): { (p3: T3, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5 - ): { (p1: T1, p3: T3, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5 - ): { (p2: T2, p3: T3, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5 - ): { (p1: T1, p2: T2, p3: T3, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5 - ): { (p4: T4, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5 - ): { (p1: T1, p4: T4, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5 - ): { (p2: T2, p4: T4, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5 - ): { (p1: T1, p2: T2, p4: T4, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5 - ): { (p3: T3, p4: T4, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5 - ): { (p1: T1, p3: T3, p4: T4, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5 - ): { (p2: T2, p3: T3, p4: T4, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5 - ): { (p1: T1, p2: T2, p3: T3, p4: T4, p6: T6): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4, - p5: T5, - p6: T6 - ): { (): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4, - p5: T5, - p6: T6 - ): { (p1: T1): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5, - p6: T6 - ): { (p2: T2): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5, - p6: T6 - ): { (p1: T1, p2: T2): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - p6: T6 - ): { (p3: T3): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - p6: T6 - ): { (p1: T1, p3: T3): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - p6: T6 - ): { (p2: T2, p3: T3): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - p6: T6 - ): { (p1: T1, p2: T2, p3: T3): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p4: T4): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p1: T1, p4: T4): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p2: T2, p4: T4): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p1: T1, p2: T2, p4: T4): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p3: T3, p4: T4): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p1: T1, p3: T3, p4: T4): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p2: T2, p3: T3, p4: T4): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p1: T1, p2: T2, p3: T3, p4: T4): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p2: T2, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p2: T2, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p3: T3, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p3: T3, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p2: T2, p3: T3, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p2: T2, p3: T3, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p4: T4, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p4: T4, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p2: T2, p4: T4, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p2: T2, p4: T4, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p3: T3, p4: T4, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p3: T3, p4: T4, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p2: T2, p3: T3, p4: T4, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5): T7 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1 - ): { (p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2 - ): { (p3: T3, p4: T4, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2 - ): { (p1: T1, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3 - ): { (p4: T4, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3 - ): { (p1: T1, p4: T4, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3 - ): { (p2: T2, p4: T4, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3 - ): { (p1: T1, p2: T2, p4: T4, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4 - ): { (p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4 - ): { (p1: T1, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4 - ): { (p2: T2, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4 - ): { (p1: T1, p2: T2, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4 - ): { (p3: T3, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4 - ): { (p1: T1, p3: T3, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4 - ): { (p2: T2, p3: T3, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4 - ): { (p1: T1, p2: T2, p3: T3, p5: T5, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4, - p5: T5 - ): { (p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4, - p5: T5 - ): { (p1: T1, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5 - ): { (p2: T2, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5 - ): { (p1: T1, p2: T2, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5 - ): { (p3: T3, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5 - ): { (p1: T1, p3: T3, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5 - ): { (p2: T2, p3: T3, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5 - ): { (p1: T1, p2: T2, p3: T3, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5 - ): { (p4: T4, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5 - ): { (p1: T1, p4: T4, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5 - ): { (p2: T2, p4: T4, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5 - ): { (p1: T1, p2: T2, p4: T4, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5 - ): { (p3: T3, p4: T4, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5 - ): { (p1: T1, p3: T3, p4: T4, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5 - ): { (p2: T2, p3: T3, p4: T4, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5 - ): { (p1: T1, p2: T2, p3: T3, p4: T4, p6: T6, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4, - p5: T5, - p6: T6 - ): { (p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4, - p5: T5, - p6: T6 - ): { (p1: T1, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5, - p6: T6 - ): { (p2: T2, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5, - p6: T6 - ): { (p1: T1, p2: T2, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - p6: T6 - ): { (p3: T3, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - p6: T6 - ): { (p1: T1, p3: T3, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - p6: T6 - ): { (p2: T2, p3: T3, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - p6: T6 - ): { (p1: T1, p2: T2, p3: T3, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p4: T4, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p1: T1, p4: T4, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p2: T2, p4: T4, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p1: T1, p2: T2, p4: T4, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p3: T3, p4: T4, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p1: T1, p3: T3, p4: T4, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p2: T2, p3: T3, p4: T4, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - p6: T6 - ): { (p1: T1, p2: T2, p3: T3, p4: T4, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p2: T2, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p2: T2, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p3: T3, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p3: T3, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p2: T2, p3: T3, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p2: T2, p3: T3, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p4: T4, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p4: T4, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p2: T2, p4: T4, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p2: T2, p4: T4, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p3: T3, p4: T4, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p3: T3, p4: T4, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p2: T2, p3: T3, p4: T4, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6 - ): { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p7: T7): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4, - p5: T5, - p6: T6, - p7: T7 - ): { (): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4, - p5: T5, - p6: T6, - p7: T7 - ): { (p1: T1): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5, - p6: T6, - p7: T7 - ): { (p2: T2): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5, - p6: T6, - p7: T7 - ): { (p1: T1, p2: T2): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - p6: T6, - p7: T7 - ): { (p3: T3): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - p6: T6, - p7: T7 - ): { (p1: T1, p3: T3): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - p6: T6, - p7: T7 - ): { (p2: T2, p3: T3): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - p6: T6, - p7: T7 - ): { (p1: T1, p2: T2, p3: T3): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - p6: T6, - p7: T7 - ): { (p4: T4): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - p6: T6, - p7: T7 - ): { (p1: T1, p4: T4): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - p6: T6, - p7: T7 - ): { (p2: T2, p4: T4): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - p6: T6, - p7: T7 - ): { (p1: T1, p2: T2, p4: T4): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - p6: T6, - p7: T7 - ): { (p3: T3, p4: T4): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - p6: T6, - p7: T7 - ): { (p1: T1, p3: T3, p4: T4): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - p6: T6, - p7: T7 - ): { (p2: T2, p3: T3, p4: T4): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - p6: T6, - p7: T7 - ): { (p1: T1, p2: T2, p3: T3, p4: T4): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p1: T1, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p2: T2, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p1: T1, p2: T2, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p3: T3, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p1: T1, p3: T3, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p2: T2, p3: T3, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p1: T1, p2: T2, p3: T3, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p4: T4, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p1: T1, p4: T4, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p2: T2, p4: T4, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p1: T1, p2: T2, p4: T4, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p3: T3, p4: T4, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p1: T1, p3: T3, p4: T4, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p2: T2, p3: T3, p4: T4, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - p6: T6, - p7: T7 - ): { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p2: T2, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p2: T2, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p3: T3, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p3: T3, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p2: T2, p3: T3, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p2: T2, p3: T3, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p4: T4, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p4: T4, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p2: T2, p4: T4, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p2: T2, p4: T4, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p3: T3, p4: T4, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p3: T3, p4: T4, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p2: T2, p3: T3, p4: T4, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - p5: T5, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p2: T2, p3: T3, p4: T4, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p2: T2, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - p4: T4, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p2: T2, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p3: T3, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p3: T3, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p2: T2, p3: T3, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - p4: T4, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p2: T2, p3: T3, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p4: T4, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p4: T4, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p2: T2, p4: T4, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - p3: T3, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p2: T2, p4: T4, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p3: T3, p4: T4, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - p2: T2, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p3: T3, p4: T4, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - p1: T1, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p2: T2, p3: T3, p4: T4, p5: T5, p6: T6): T8 }; - - partial( - fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, - stub1: UnderscoreStatic, - stub2: UnderscoreStatic, - stub3: UnderscoreStatic, - stub4: UnderscoreStatic, - stub5: UnderscoreStatic, - stub6: UnderscoreStatic, - p7: T7 - ): { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6): T8 }; - - /** - * Memoizes a given function by caching the computed result. Useful for speeding up slow-running computations. - * If passed an optional hashFunction, it will be used to compute the hash key for storing the result, based - * on the arguments to the original function. The default hashFunction just uses the first argument to the - * memoized function as the key. - * @param fn Computationally expensive function that will now memoized results. - * @param hashFn Hash function for storing the result of `fn`. - * @return Memoized version of `fn`. - **/ - memoize( - fn: Function, - hashFn?: (...args: any[]) => string): Function; - - /** - * Much like setTimeout, invokes function after wait milliseconds. If you pass the optional arguments, - * they will be forwarded on to the function when it is invoked. - * @param func Function to delay `waitMS` amount of ms. - * @param wait The amount of milliseconds to delay `fn`. - * @arguments Additional arguments to pass to `fn`. - **/ - delay( - func: Function, - wait: number, - ...arguments: any[]): any; - - /** - * @see _delay - **/ - delay( - func: Function, - ...arguments: any[]): any; - - /** - * Defers invoking the function until the current call stack has cleared, similar to using setTimeout - * with a delay of 0. Useful for performing expensive computations or HTML rendering in chunks without - * blocking the UI thread from updating. If you pass the optional arguments, they will be forwarded on - * to the function when it is invoked. - * @param fn The function to defer. - * @param arguments Additional arguments to pass to `fn`. - **/ - defer( - fn: Function, - ...arguments: any[]): void; - - /** - * Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly, - * will only actually call the original function at most once per every wait milliseconds. Useful for - * rate-limiting events that occur faster than you can keep up with. - * By default, throttle will execute the function as soon as you call it for the first time, and, - * if you call it again any number of times during the wait period, as soon as that period is over. - * If you'd like to disable the leading-edge call, pass {leading: false}, and if you'd like to disable - * the execution on the trailing-edge, pass {trailing: false}. - * @param func Function to throttle `waitMS` ms. - * @param wait The number of milliseconds to wait before `fn` can be invoked again. - * @param options Allows for disabling execution of the throttled function on either the leading or trailing edge. - * @return `fn` with a throttle of `wait`. - **/ - throttle( - func: T, - wait: number, - options?: _.ThrottleSettings): T & _.Cancelable; - - /** - * Creates and returns a new debounced version of the passed function that will postpone its execution - * until after wait milliseconds have elapsed since the last time it was invoked. Useful for implementing - * behavior that should only happen after the input has stopped arriving. For example: rendering a preview - * of a Markdown comment, recalculating a layout after the window has stopped being resized, and so on. - * - * Pass true for the immediate parameter to cause debounce to trigger the function on the leading instead - * of the trailing edge of the wait interval. Useful in circumstances like preventing accidental double - *-clicks on a "submit" button from firing a second time. - * @param fn Function to debounce `waitMS` ms. - * @param wait The number of milliseconds to wait before `fn` can be invoked again. - * @param immediate True if `fn` should be invoked on the leading edge of `waitMS` instead of the trailing edge. - * @return Debounced version of `fn` that waits `wait` ms when invoked. - **/ - debounce( - fn: T, - wait: number, - immediate?: boolean): T & _.Cancelable; - - /** - * Creates a version of the function that can only be called one time. Repeated calls to the modified - * function will have no effect, returning the value from the original call. Useful for initialization - * functions, instead of having to set a boolean flag and then check it later. - * @param fn Function to only execute once. - * @return Copy of `fn` that can only be invoked once. - **/ - once(fn: T): T; - - /** - * Similar to ES6's rest param (http://ariya.ofilabs.com/2013/03/es6-and-rest-parameter.html) - * This accumulates the arguments passed into an array, after a given index. - **/ - restArgs(func: Function, starIndex?: number) : Function; - - /** - * Creates a version of the function that will only be run after first being called count times. Useful - * for grouping asynchronous responses, where you want to be sure that all the async calls have finished, - * before proceeding. - * @param number count Number of times to be called before actually executing. - * @param Function fn The function to defer execution `count` times. - * @return Copy of `fn` that will not execute until it is invoked `count` times. - **/ - after( - count: number, - fn: Function): Function; - - /** - * Creates a version of the function that can be called no more than count times. The result of - * the last function call is memoized and returned when count has been reached. - * @param number count The maxmimum number of times the function can be called. - * @param Function fn The function to limit the number of times it can be called. - * @return Copy of `fn` that can only be called `count` times. - **/ - before( - count: number, - fn: Function): Function; - - /** - * Wraps the first function inside of the wrapper function, passing it as the first argument. This allows - * the wrapper to execute code before and after the function runs, adjust the arguments, and execute it - * conditionally. - * @param fn Function to wrap. - * @param wrapper The function that will wrap `fn`. - * @return Wrapped version of `fn. - **/ - wrap( - fn: Function, - wrapper: (fn: Function, ...args: any[]) => any): Function; - - /** - * Returns a negated version of the pass-in predicate. - * @param (...args: any[]) => boolean predicate - * @return (...args: any[]) => boolean - **/ - negate(predicate: (...args: any[]) => boolean): (...args: any[]) => boolean; - - /** - * Returns the composition of a list of functions, where each function consumes the return value of the - * function that follows. In math terms, composing the functions f(), g(), and h() produces f(g(h())). - * @param functions List of functions to compose. - * @return Composition of `functions`. - **/ - compose(...functions: Function[]): Function; - - /********** - * Objects * - ***********/ - - /** - * Retrieve all the names of the object's properties. - * @param object Retrieve the key or property names from this object. - * @return List of all the property names on `object`. - **/ - keys(object: any): string[]; - - /** - * Retrieve all the names of object's own and inherited properties. - * @param object Retrieve the key or property names from this object. - * @return List of all the property names on `object`. - **/ - allKeys(object: any): string[]; - - /** - * Return all of the values of the object's properties. - * @param object Retrieve the values of all the properties on this object. - * @return List of all the values on `object`. - **/ - values(object: _.Dictionary): T[]; - - /** - * Return all of the values of the object's properties. - * @param object Retrieve the values of all the properties on this object. - * @return List of all the values on `object`. - **/ - values(object: any): any[]; - - /** - * Like map, but for objects. Transform the value of each property in turn. - * @param object The object to transform - * @param iteratee The function that transforms property values - * @param context The optional context (value of `this`) to bind to - * @return a new _.Dictionary of property values - */ - mapObject(object: _.Dictionary, iteratee: (val: T, key: string, object: _.Dictionary) => U, context?: any): _.Dictionary; - - /** - * Like map, but for objects. Transform the value of each property in turn. - * @param object The object to transform - * @param iteratee The function that tranforms property values - * @param context The optional context (value of `this`) to bind to - */ - mapObject(object: any, iteratee: (val: any, key: string, object: any) => T, context?: any): _.Dictionary; - - /** - * Like map, but for objects. Retrieves a property from each entry in the object, as if by _.property - * @param object The object to transform - * @param iteratee The property name to retrieve - * @param context The optional context (value of `this`) to bind to - */ - mapObject(object: any, iteratee: string, context?: any): _.Dictionary; - - /** - * Convert an object into a list of [key, value] pairs. - * @param object Convert this object to a list of [key, value] pairs. - * @return List of [key, value] pairs on `object`. - **/ - pairs(object: any): any[][]; - - /** - * Returns a copy of the object where the keys have become the values and the values the keys. - * For this to work, all of your object's values should be unique and string serializable. - * @param object Object to invert key/value pairs. - * @return An inverted key/value paired version of `object`. - **/ - invert(object: any): any; - - /** - * Returns a sorted list of the names of every method in an object - that is to say, - * the name of every function property of the object. - * @param object Object to pluck all function property names from. - * @return List of all the function names on `object`. - **/ - functions(object: any): string[]; - - /** - * @see _functions - **/ - methods(object: any): string[]; - - /** - * Copy all of the properties in the source objects over to the destination object, and return - * the destination object. It's in-order, so the last source will override properties of the - * same name in previous arguments. - * @param destination Object to extend all the properties from `sources`. - * @param sources Extends `destination` with all properties from these source objects. - * @return `destination` extended with all the properties from the `sources` objects. - **/ - extend( - destination: any, - ...sources: any[]): any; - - /** - * Like extend, but only copies own properties over to the destination object. (alias: assign) - */ - extendOwn( - destination: any, - ...source: any[]): any; - - /** - * Like extend, but only copies own properties over to the destination object. (alias: extendOwn) - */ - assign( - destination: any, - ...source: any[]): any; - - /** - * Returns the first key on an object that passes a predicate test. - * @param obj the object to search in - * @param predicate Predicate function. - * @param context `this` object in `iterator`, optional. - */ - findKey(obj: _.Dictionary, predicate: _.ObjectIterator, context? : any): T - - /** - * Return a copy of the object, filtered to only have values for the whitelisted keys - * (or array of valid keys). - * @param object Object to strip unwanted key/value pairs. - * @keys The key/value pairs to keep on `object`. - * @return Copy of `object` with only the `keys` properties. - **/ - pick( - object: any, - ...keys: any[]): any; - - /** - * @see _.pick - **/ - pick( - object: any, - fn: (value: any, key: any, object: any) => any): any; - - /** - * Return a copy of the object, filtered to omit the blacklisted keys (or array of keys). - * @param object Object to strip unwanted key/value pairs. - * @param keys The key/value pairs to remove on `object`. - * @return Copy of `object` without the `keys` properties. - **/ - omit( - object: any, - ...keys: string[]): any; - - /** - * @see _.omit - **/ - omit( - object: any, - keys: string[]): any; - - /** - * @see _.omit - **/ - omit( - object: any, - iteratee: Function): any; - - /** - * Fill in null and undefined properties in object with values from the defaults objects, - * and return the object. As soon as the property is filled, further defaults will have no effect. - * @param object Fill this object with default values. - * @param defaults The default values to add to `object`. - * @return `object` with added `defaults` values. - **/ - defaults( - object: any, - ...defaults: any[]): any; - - - /** - * Creates an object that inherits from the given prototype object. - * If additional properties are provided then they will be added to the - * created object. - * @param prototype The prototype that the returned object will inherit from. - * @param props Additional props added to the returned object. - **/ - create(prototype: any, props?: Object): any; - - /** - * Create a shallow-copied clone of the object. - * Any nested objects or arrays will be copied by reference, not duplicated. - * @param object Object to clone. - * @return Copy of `object`. - **/ - clone(object: T): T; - - /** - * Invokes interceptor with the object, and then returns object. The primary purpose of this method - * is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. - * @param object Argument to `interceptor`. - * @param intercepter The function to modify `object` before continuing the method chain. - * @return Modified `object`. - **/ - tap(object: T, intercepter: Function): T; - - /** - * Does the object contain the given key? Identical to object.hasOwnProperty(key), but uses a safe - * reference to the hasOwnProperty function, in case it's been overridden accidentally. - * @param object Object to check for `key`. - * @param key The key to check for on `object`. - * @return True if `key` is a property on `object`, otherwise false. - **/ - has(object: any, key: string): boolean; - - /** - * Returns a predicate function that will tell you if a passed in object contains all of the key/value properties present in attrs. - * @param attrs Object with key values pair - * @return Predicate function - **/ - matches(attrs: T): _.ListIterator; - - /** - * Returns a predicate function that will tell you if a passed in object contains all of the key/value properties present in attrs. - * @see _.matches - * @param attrs Object with key values pair - * @return Predicate function - **/ - matcher(attrs: T): _.ListIterator; - - /** - * Returns a function that will itself return the key property of any passed-in object. - * @param key Property of the object. - * @return Function which accept an object an returns the value of key in that object. - **/ - property(key: string): (object: Object) => any; - - /** - * Returns a function that will itself return the value of a object key property. - * @param key The object to get the property value from. - * @return Function which accept a key property in `object` and returns its value. - **/ - propertyOf(object: Object): (key: string) => any; - - /** - * Performs an optimized deep comparison between the two objects, - * to determine if they should be considered equal. - * @param object Compare to `other`. - * @param other Compare to `object`. - * @return True if `object` is equal to `other`. - **/ - isEqual(object: any, other: any): boolean; - - /** - * Returns true if object contains no values. - * @param object Check if this object has no properties or values. - * @return True if `object` is empty. - **/ - isEmpty(object: any): boolean; - - /** - * Returns true if the keys and values in `properties` matches with the `object` properties. - * @param object Object to be compared with `properties`. - * @param properties Properties be compared with `object` - * @return True if `object` has matching keys and values, otherwise false. - **/ - isMatch(object:any, properties:any): boolean; - - /** - * Returns true if object is a DOM element. - * @param object Check if this object is a DOM element. - * @return True if `object` is a DOM element, otherwise false. - **/ - isElement(object: any): object is Element; - - /** - * Returns true if object is an Array. - * @param object Check if this object is an Array. - * @return True if `object` is an Array, otherwise false. - **/ - isArray(object: any): object is any[]; - - /** - * Returns true if object is an Array. - * @param object Check if this object is an Array. - * @return True if `object` is an Array, otherwise false. - **/ - isArray(object: any): object is T[]; - - /** - * Returns true if object is a Symbol. - * @param object Check if this object is a Symbol. - * @return True if `object` is a Symbol, otherwise false. - **/ - isSymbol(object: any): object is symbol; - - /** - * Returns true if value is an Object. Note that JavaScript arrays and functions are objects, - * while (normal) strings and numbers are not. - * @param object Check if this object is an Object. - * @return True of `object` is an Object, otherwise false. - **/ - isObject(object: any): boolean; - - /** - * Returns true if object is an Arguments object. - * @param object Check if this object is an Arguments object. - * @return True if `object` is an Arguments object, otherwise false. - **/ - isArguments(object: any): object is IArguments; - - /** - * Returns true if object is a Function. - * @param object Check if this object is a Function. - * @return True if `object` is a Function, otherwise false. - **/ - isFunction(object: any): object is Function; - - /** - * Returns true if object inherits from an Error. - * @param object Check if this object is an Error. - * @return True if `object` is a Error, otherwise false. - **/ - isError(object:any): object is Error; - - /** - * Returns true if object is a String. - * @param object Check if this object is a String. - * @return True if `object` is a String, otherwise false. - **/ - isString(object: any): object is string; - - /** - * Returns true if object is a Number (including NaN). - * @param object Check if this object is a Number. - * @return True if `object` is a Number, otherwise false. - **/ - isNumber(object: any): object is number; - - /** - * Returns true if object is a finite Number. - * @param object Check if this object is a finite Number. - * @return True if `object` is a finite Number. - **/ - isFinite(object: any): boolean; - - /** - * Returns true if object is either true or false. - * @param object Check if this object is a bool. - * @return True if `object` is a bool, otherwise false. - **/ - isBoolean(object: any): object is boolean; - - /** - * Returns true if object is a Date. - * @param object Check if this object is a Date. - * @return True if `object` is a Date, otherwise false. - **/ - isDate(object: any): object is Date; - - /** - * Returns true if object is a RegExp. - * @param object Check if this object is a RegExp. - * @return True if `object` is a RegExp, otherwise false. - **/ - isRegExp(object: any): object is RegExp; - - /** - * Returns true if object is NaN. - * Note: this is not the same as the native isNaN function, - * which will also return true if the variable is undefined. - * @param object Check if this object is NaN. - * @return True if `object` is NaN, otherwise false. - **/ - isNaN(object: any): boolean; - - /** - * Returns true if the value of object is null. - * @param object Check if this object is null. - * @return True if `object` is null, otherwise false. - **/ - isNull(object: any): boolean; - - /** - * Returns true if value is undefined. - * @param object Check if this object is undefined. - * @return True if `object` is undefined, otherwise false. - **/ - isUndefined(value: any): boolean; - - /* ********* - * Utility * - ********** */ - - /** - * Give control of the "_" variable back to its previous owner. - * Returns a reference to the Underscore object. - * @return Underscore object reference. - **/ - noConflict(): any; - - /** - * Returns the same value that is used as the argument. In math: f(x) = x - * This function looks useless, but is used throughout Underscore as a default iterator. - * @param value Identity of this object. - * @return `value`. - **/ - identity(value: T): T; - - /** - * Creates a function that returns the same value that is used as the argument of _.constant - * @param value Identity of this object. - * @return Function that return value. - **/ - constant(value: T): () => T; - - /** - * Returns undefined irrespective of the arguments passed to it. Useful as the default - * for optional callback arguments. - * Note there is no way to indicate a 'undefined' return, so it is currently typed as void. - * @return undefined - **/ - noop(): void; - - /** - * Invokes the given iterator function n times. - * Each invocation of iterator is called with an index argument - * @param n Number of times to invoke `iterator`. - * @param iterator Function iterator to invoke `n` times. - * @param context `this` object in `iterator`, optional. - **/ - times(n: number, iterator: (n: number) => TResult, context?: any): TResult[]; - - /** - * Returns a random integer between min and max, inclusive. If you only pass one argument, - * it will return a number between 0 and that number. - * @param max The maximum random number. - * @return A random number between 0 and `max`. - **/ - random(max: number): number; - - /** - * @see _.random - * @param min The minimum random number. - * @return A random number between `min` and `max`. - **/ - random(min: number, max: number): number; - - /** - * Allows you to extend Underscore with your own utility functions. Pass a hash of - * {name: function} definitions to have your functions added to the Underscore object, - * as well as the OOP wrapper. - * @param object Mixin object containing key/function pairs to add to the Underscore object. - **/ - mixin(object: any): void; - - /** - * A mostly-internal function to generate callbacks that can be applied to each element - * in a collection, returning the desired result -- either identity, an arbitrary callback, - * a property matcher, or a propetery accessor. - * @param string|Function|Object value The value to iterate over, usually the key. - * @param any context - * @return Callback that can be applied to each element in a collection. - **/ - iteratee(value: string): Function; - iteratee(value: Function, context?: any): Function; - iteratee(value: Object): Function; - - /** - * Generate a globally-unique id for client-side models or DOM elements that need one. - * If prefix is passed, the id will be appended to it. Without prefix, returns an integer. - * @param prefix A prefix string to start the unique ID with. - * @return Unique string ID beginning with `prefix`. - **/ - uniqueId(prefix?: string): string; - - /** - * Escapes a string for insertion into HTML, replacing &, <, >, ", ', and / characters. - * @param str Raw string to escape. - * @return `str` HTML escaped. - **/ - escape(str: string): string; - - /** - * The opposite of escape, replaces &, <, >, ", and ' with their unescaped counterparts. - * @param str HTML escaped string. - * @return `str` Raw string. - **/ - unescape(str: string): string; - - /** - * If the value of the named property is a function then invoke it; otherwise, return it. - * @param object Object to maybe invoke function `property` on. - * @param property The function by name to invoke on `object`. - * @param defaultValue The value to be returned in case `property` doesn't exist or is undefined. - * @return The result of invoking the function `property` on `object. - **/ - result(object: any, property: string, defaultValue?:any): any; - - /** - * Compiles JavaScript templates into functions that can be evaluated for rendering. Useful - * for rendering complicated bits of HTML from JSON data sources. Template functions can both - * interpolate variables, using <%= ... %>, as well as execute arbitrary JavaScript code, with - * <% ... %>. If you wish to interpolate a value, and have it be HTML-escaped, use <%- ... %> When - * you evaluate a template function, pass in a data object that has properties corresponding to - * the template's free variables. If you're writing a one-off, you can pass the data object as - * the second parameter to template in order to render immediately instead of returning a template - * function. The settings argument should be a hash containing any _.templateSettings that should - * be overridden. - * @param templateString Underscore HTML template. - * @param data Data to use when compiling `templateString`. - * @param settings Settings to use while compiling. - * @return Returns the compiled Underscore HTML template. - **/ - template(templateString: string, settings?: _.TemplateSettings): (...data: any[]) => string; - - /** - * By default, Underscore uses ERB-style template delimiters, change the - * following template settings to use alternative delimiters. - **/ - templateSettings: _.TemplateSettings; - - /** - * Returns an integer timestamp for the current time, using the fastest method available in the runtime. Useful for implementing timing/animation functions. - **/ - now(): number; - - /* ********** - * Chaining * - *********** */ - - /** - * Returns a wrapped object. Calling methods on this object will continue to return wrapped objects - * until value() is used. - * @param obj Object to chain. - * @return Wrapped `obj`. - **/ - chain(obj: T[]): _Chain; - chain(obj: _.Dictionary): _Chain; - chain(obj: T): _Chain; -} - -interface Underscore { - - /* ************* - * Collections * - ************* */ - - /** - * Wrapped type `any[]`. - * @see _.each - **/ - each(iterator: _.ListIterator, context?: any): T[]; - - /** - * @see _.each - **/ - each(iterator: _.ObjectIterator, context?: any): T[]; - - /** - * @see _.each - **/ - forEach(iterator: _.ListIterator, context?: any): T[]; - - /** - * @see _.each - **/ - forEach(iterator: _.ObjectIterator, context?: any): T[]; - - /** - * Wrapped type `any[]`. - * @see _.map - **/ - map(iterator: _.ListIterator, context?: any): TResult[]; - - /** - * Wrapped type `any[]`. - * @see _.map - **/ - map(iterator: _.ObjectIterator, context?: any): TResult[]; - - /** - * @see _.map - **/ - collect(iterator: _.ListIterator, context?: any): TResult[]; - - /** - * @see _.map - **/ - collect(iterator: _.ObjectIterator, context?: any): TResult[]; - - /** - * Wrapped type `any[]`. - * @see _.reduce - **/ - reduce(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; - - /** - * @see _.reduce - **/ - inject(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; - - /** - * @see _.reduce - **/ - foldl(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; - - /** - * Wrapped type `any[]`. - * @see _.reduceRight - **/ - reduceRight(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; - - /** - * @see _.reduceRight - **/ - foldr(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; - - /** - * Wrapped type `any[]`. - * @see _.find - **/ - find(iterator: _.ListIterator|_.ObjectIterator, context?: any): T; - - /** - * @see _.find - **/ - find(interator: U): T; - - /** - * @see _.find - **/ - find(interator: string): T; - - /** - * @see _.find - **/ - detect(iterator: _.ListIterator|_.ObjectIterator, context?: any): T; - - /** - * @see _.find - **/ - detect(interator?: U): T; - - /** - * @see _.find - **/ - detect(interator?: string): T; - - /** - * Wrapped type `any[]`. - * @see _.filter - **/ - filter(iterator: _.ListIterator, context?: any): T[]; - - /** - * @see _.filter - **/ - select(iterator: _.ListIterator, context?: any): T[]; - - /** - * Wrapped type `any[]`. - * @see _.where - **/ - where(properties: U): T[]; - - /** - * Wrapped type `any[]`. - * @see _.findWhere - **/ - findWhere(properties: U): T; - - /** - * Wrapped type `any[]`. - * @see _.reject - **/ - reject(iterator: _.ListIterator, context?: any): T[]; - - /** - * Wrapped type `any[]`. - * @see _.all - **/ - all(iterator?: _.ListIterator, context?: any): boolean; - - /** - * @see _.all - **/ - every(iterator?: _.ListIterator, context?: any): boolean; - - /** - * Wrapped type `any[]`. - * @see _.any - **/ - any(iterator?: _.ListIterator, context?: any): boolean; - - /** - * @see _.any - **/ - some(iterator?: _.ListIterator, context?: any): boolean; - - /** - * Wrapped type `any[]`. - * @see _.contains - **/ - contains(value: T, fromIndex? : number): boolean; - - /** - * Alias for 'contains'. - * @see contains - **/ - include(value: T, fromIndex? : number): boolean; - - /** - * Alias for 'contains'. - * @see contains - **/ - includes(value: T, fromIndex? : number): boolean; - - /** - * Wrapped type `any[]`. - * @see _.invoke - **/ - invoke(methodName: string, ...arguments: any[]): any; - - /** - * Wrapped type `any[]`. - * @see _.pluck - **/ - pluck(propertyName: string): any[]; - - /** - * Wrapped type `number[]`. - * @see _.max - **/ - max(): number; - - /** - * Wrapped type `any[]`. - * @see _.max - **/ - max(iterator: _.ListIterator, context?: any): T; - - /** - * Wrapped type `any[]`. - * @see _.max - **/ - max(iterator?: _.ListIterator, context?: any): T; - - /** - * Wrapped type `number[]`. - * @see _.min - **/ - min(): number; - - /** - * Wrapped type `any[]`. - * @see _.min - **/ - min(iterator: _.ListIterator, context?: any): T; - - /** - * Wrapped type `any[]`. - * @see _.min - **/ - min(iterator?: _.ListIterator, context?: any): T; - - /** - * Wrapped type `any[]`. - * @see _.sortBy - **/ - sortBy(iterator?: _.ListIterator, context?: any): T[]; - - /** - * Wrapped type `any[]`. - * @see _.sortBy - **/ - sortBy(iterator: string, context?: any): T[]; - - /** - * Wrapped type `any[]`. - * @see _.groupBy - **/ - groupBy(iterator?: _.ListIterator, context?: any): _.Dictionary<_.List>; - - /** - * Wrapped type `any[]`. - * @see _.groupBy - **/ - groupBy(iterator: string, context?: any): _.Dictionary; - - /** - * Wrapped type `any[]`. - * @see _.indexBy - **/ - indexBy(iterator: _.ListIterator, context?: any): _.Dictionary; - - /** - * Wrapped type `any[]`. - * @see _.indexBy - **/ - indexBy(iterator: string, context?: any): _.Dictionary; - - /** - * Wrapped type `any[]`. - * @see _.countBy - **/ - countBy(iterator?: _.ListIterator, context?: any): _.Dictionary; - - /** - * Wrapped type `any[]`. - * @see _.countBy - **/ - countBy(iterator: string, context?: any): _.Dictionary; - - /** - * Wrapped type `any[]`. - * @see _.shuffle - **/ - shuffle(): T[]; - - /** - * Wrapped type `any[]`. - * @see _.sample - **/ - sample(n: number): T[]; - - /** - * @see _.sample - **/ - sample(): T; - - /** - * Wrapped type `any`. - * @see _.toArray - **/ - toArray(): T[]; - - /** - * Wrapped type `any`. - * @see _.size - **/ - size(): number; - - /********* - * Arrays * - **********/ - - /** - * Wrapped type `any[]`. - * @see _.first - **/ - first(): T; - - /** - * Wrapped type `any[]`. - * @see _.first - **/ - first(n: number): T[]; - - /** - * @see _.first - **/ - head(): T; - - /** - * @see _.first - **/ - head(n: number): T[]; - - /** - * @see _.first - **/ - take(): T; - - /** - * @see _.first - **/ - take(n: number): T[]; - - /** - * Wrapped type `any[]`. - * @see _.initial - **/ - initial(n?: number): T[]; - - /** - * Wrapped type `any[]`. - * @see _.last - **/ - last(): T; - - /** - * Wrapped type `any[]`. - * @see _.last - **/ - last(n: number): T[]; - - /** - * Wrapped type `any[]`. - * @see _.rest - **/ - rest(n?: number): T[]; - - /** - * @see _.rest - **/ - tail(n?: number): T[]; - - /** - * @see _.rest - **/ - drop(n?: number): T[]; - - /** - * Wrapped type `any[]`. - * @see _.compact - **/ - compact(): T[]; - - /** - * Wrapped type `any`. - * @see _.flatten - **/ - flatten(shallow?: boolean): any[]; - - /** - * Wrapped type `any[]`. - * @see _.without - **/ - without(...values: T[]): T[]; - - /** - * Wrapped type `any[]`. - * @see _.partition - **/ - partition(iterator: _.ListIterator, context?: any): T[][]; - - /** - * Wrapped type `any[][]`. - * @see _.union - **/ - union(...arrays: _.List[]): T[]; - - /** - * Wrapped type `any[][]`. - * @see _.intersection - **/ - intersection(...arrays: _.List[]): T[]; - - /** - * Wrapped type `any[]`. - * @see _.difference - **/ - difference(...others: _.List[]): T[]; - - /** - * Wrapped type `any[]`. - * @see _.uniq - **/ - uniq(isSorted?: boolean, iterator?: _.ListIterator): T[]; - - /** - * Wrapped type `any[]`. - * @see _.uniq - **/ - uniq(iterator?: _.ListIterator, context?: any): T[]; - - /** - * @see _.uniq - **/ - unique(isSorted?: boolean, iterator?: _.ListIterator): T[]; - - /** - * @see _.uniq - **/ - unique(iterator?: _.ListIterator, context?: any): T[]; - - /** - * Wrapped type `any[][]`. - * @see _.zip - **/ - zip(...arrays: any[][]): any[][]; - - /** - * Wrapped type `any[][]`. - * @see _.unzip - **/ - unzip(...arrays: any[][]): any[][]; - - /** - * Wrapped type `any[][]`. - * @see _.object - **/ - object(...keyValuePairs: any[][]): any; - - /** - * @see _.object - **/ - object(values?: any): any; - - /** - * Wrapped type `any[]`. - * @see _.indexOf - **/ - indexOf(value: T, isSorted?: boolean): number; - - /** - * @see _.indexOf - **/ - indexOf(value: T, startFrom: number): number; - - /** - * Wrapped type `any[]`. - * @see _.lastIndexOf - **/ - lastIndexOf(value: T, from?: number): number; - - /** - * @see _.findIndex - **/ - findIndex(array: _.List, predicate: _.ListIterator | {}, context?: any): number; - - /** - * @see _.findLastIndex - **/ - findLastIndex(array: _.List, predicate: _.ListIterator | {}, context?: any): number; - - /** - * Wrapped type `any[]`. - * @see _.sortedIndex - **/ - sortedIndex(value: T, iterator?: (x: T) => any, context?: any): number; - - /** - * Wrapped type `number`. - * @see _.range - **/ - range(stop: number, step?: number): number[]; - - /** - * Wrapped type `number`. - * @see _.range - **/ - range(): number[]; - - /** - * Wrapped type any[][]. - * @see _.chunk - **/ - chunk(): any[][]; - - /* *********** - * Functions * - ************ */ - - /** - * Wrapped type `Function`. - * @see _.bind - **/ - bind(object: any, ...arguments: any[]): Function; - - /** - * Wrapped type `object`. - * @see _.bindAll - **/ - bindAll(...methodNames: string[]): any; - - /** - * Wrapped type `Function`. - * @see _.partial - **/ - partial(...arguments: any[]): Function; - - /** - * Wrapped type `Function`. - * @see _.memoize - **/ - memoize(hashFn?: (n: any) => string): Function; - - /** - * Wrapped type `Function`. - * @see _.defer - **/ - defer(...arguments: any[]): void; - - /** - * Wrapped type `Function`. - * @see _.delay - **/ - delay(wait: number, ...arguments: any[]): any; - - /** - * @see _.delay - **/ - delay(...arguments: any[]): any; - - /** - * Wrapped type `Function`. - * @see _.throttle - **/ - throttle(wait: number, options?: _.ThrottleSettings): Function & _.Cancelable; - - /** - * Wrapped type `Function`. - * @see _.debounce - **/ - debounce(wait: number, immediate?: boolean): Function & _.Cancelable; - - /** - * Wrapped type `Function`. - * @see _.once - **/ - once(): Function; - - /** - * Wrapped type `Function`. - * @see _.once - **/ - restArgs(starIndex?: number) : Function; - - /** - * Wrapped type `number`. - * @see _.after - **/ - after(fn: Function): Function; - - /** - * Wrapped type `number`. - * @see _.before - **/ - before(fn: Function): Function; - - /** - * Wrapped type `Function`. - * @see _.wrap - **/ - wrap(wrapper: Function): () => Function; - - /** - * Wrapped type `Function`. - * @see _.negate - **/ - negate(): boolean; - - /** - * Wrapped type `Function[]`. - * @see _.compose - **/ - compose(...functions: Function[]): Function; - - /********* * - * Objects * - ********** */ - - /** - * Wrapped type `object`. - * @see _.keys - **/ - keys(): string[]; - - /** - * Wrapped type `object`. - * @see _.allKeys - **/ - allKeys(): string[]; - - /** - * Wrapped type `object`. - * @see _.values - **/ - values(): T[]; - - /** - * Wrapped type `object`. - * @see _.pairs - **/ - pairs(): any[][]; - - /** - * Wrapped type `object`. - * @see _.invert - **/ - invert(): any; - - /** - * Wrapped type `object`. - * @see _.functions - **/ - functions(): string[]; - - /** - * @see _.functions - **/ - methods(): string[]; - - /** - * Wrapped type `object`. - * @see _.extend - **/ - extend(...sources: any[]): any; - - /** - * Wrapped type `object`. - * @see _.extend - **/ - findKey(predicate: _.ObjectIterator, context? : any): any - - /** - * Wrapped type `object`. - * @see _.pick - **/ - pick(...keys: any[]): any; - pick(keys: any[]): any; - pick(fn: (value: any, key: any, object: any) => any): any; - - /** - * Wrapped type `object`. - * @see _.omit - **/ - omit(...keys: string[]): any; - omit(keys: string[]): any; - omit(fn: Function): any; - - /** - * Wrapped type `object`. - * @see _.defaults - **/ - defaults(...defaults: any[]): any; - - /** - * Wrapped type `any`. - * @see _.create - **/ - create(props?: Object): any; - - /** - * Wrapped type `any[]`. - * @see _.clone - **/ - clone(): T; - - /** - * Wrapped type `object`. - * @see _.tap - **/ - tap(interceptor: (...as: any[]) => any): any; - - /** - * Wrapped type `object`. - * @see _.has - **/ - has(key: string): boolean; - - /** - * Wrapped type `any[]`. - * @see _.matches - **/ - matches(): _.ListIterator; - - /** - * Wrapped type `any[]`. - * @see _.matcher - **/ - matcher(): _.ListIterator; - - /** - * Wrapped type `string`. - * @see _.property - **/ - property(): (object: Object) => any; - - /** - * Wrapped type `object`. - * @see _.propertyOf - **/ - propertyOf(): (key: string) => any; - - /** - * Wrapped type `object`. - * @see _.isEqual - **/ - isEqual(other: any): boolean; - - /** - * Wrapped type `object`. - * @see _.isEmpty - **/ - isEmpty(): boolean; - - /** - * Wrapped type `object`. - * @see _.isMatch - **/ - isMatch(): boolean; - - /** - * Wrapped type `object`. - * @see _.isElement - **/ - isElement(): boolean; - - /** - * Wrapped type `object`. - * @see _.isArray - **/ - isArray(): boolean; - - /** - * Wrapped type `object`. - * @see _.isSymbol - **/ - isSymbol(): boolean; - - /** - * Wrapped type `object`. - * @see _.isObject - **/ - isObject(): boolean; - - /** - * Wrapped type `object`. - * @see _.isArguments - **/ - isArguments(): boolean; - - /** - * Wrapped type `object`. - * @see _.isFunction - **/ - isFunction(): boolean; - - /** - * Wrapped type `object`. - * @see _.isError - **/ - isError(): boolean; - - /** - * Wrapped type `object`. - * @see _.isString - **/ - isString(): boolean; - - /** - * Wrapped type `object`. - * @see _.isNumber - **/ - isNumber(): boolean; - - /** - * Wrapped type `object`. - * @see _.isFinite - **/ - isFinite(): boolean; - - /** - * Wrapped type `object`. - * @see _.isBoolean - **/ - isBoolean(): boolean; - - /** - * Wrapped type `object`. - * @see _.isDate - **/ - isDate(): boolean; - - /** - * Wrapped type `object`. - * @see _.isRegExp - **/ - isRegExp(): boolean; - - /** - * Wrapped type `object`. - * @see _.isNaN - **/ - isNaN(): boolean; - - /** - * Wrapped type `object`. - * @see _.isNull - **/ - isNull(): boolean; - - /** - * Wrapped type `object`. - * @see _.isUndefined - **/ - isUndefined(): boolean; - - /********* * - * Utility * - ********** */ - - /** - * Wrapped type `any`. - * @see _.identity - **/ - identity(): any; - - /** - * Wrapped type `any`. - * @see _.constant - **/ - constant(): () => T; - - /** - * Wrapped type `any`. - * @see _.noop - **/ - noop(): void; - - /** - * Wrapped type `number`. - * @see _.times - **/ - times(iterator: (n: number) => TResult, context?: any): TResult[]; - - /** - * Wrapped type `number`. - * @see _.random - **/ - random(): number; - /** - * Wrapped type `number`. - * @see _.random - **/ - random(max: number): number; - - /** - * Wrapped type `object`. - * @see _.mixin - **/ - mixin(): void; - - /** - * Wrapped type `string|Function|Object`. - * @see _.iteratee - **/ - iteratee(context?: any): Function; - - /** - * Wrapped type `string`. - * @see _.uniqueId - **/ - uniqueId(): string; - - /** - * Wrapped type `string`. - * @see _.escape - **/ - escape(): string; - - /** - * Wrapped type `string`. - * @see _.unescape - **/ - unescape(): string; - - /** - * Wrapped type `object`. - * @see _.result - **/ - result(property: string, defaultValue?:any): any; - - /** - * Wrapped type `string`. - * @see _.template - **/ - template(settings?: _.TemplateSettings): (...data: any[]) => string; - - /********** * - * Chaining * - *********** */ - - /** - * Wrapped type `any`. - * @see _.chain - **/ - chain(): _Chain; - - /** - * Wrapped type `any`. - * Extracts the value of a wrapped object. - * @return Value of the wrapped object. - **/ - value(): TResult; -} - -interface _Chain { - - /* ************* - * Collections * - ************* */ - - /** - * Wrapped type `any[]`. - * @see _.each - **/ - each(iterator: _.ListIterator, context?: any): _Chain; - - /** - * @see _.each - **/ - each(iterator: _.ObjectIterator, context?: any): _Chain; - - /** - * @see _.each - **/ - forEach(iterator: _.ListIterator, context?: any): _Chain; - - /** - * @see _.each - **/ - forEach(iterator: _.ObjectIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.map - **/ - map(iterator: _.ListIterator, context?: any): _ChainOfArrays; - - /** - * Wrapped type `any[]`. - * @see _.map - **/ - map(iterator: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.map - **/ - map(iterator: _.ObjectIterator, context?: any): _ChainOfArrays; - - /** - * Wrapped type `any[]`. - * @see _.map - **/ - map(iterator: _.ObjectIterator, context?: any): _Chain; - - /** - * @see _.map - **/ - collect(iterator: _.ListIterator, context?: any): _Chain; - - /** - * @see _.map - **/ - collect(iterator: _.ObjectIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.reduce - **/ - reduce(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; - - /** - * @see _.reduce - **/ - inject(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; - - /** - * @see _.reduce - **/ - foldl(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.reduceRight - **/ - reduceRight(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; - - /** - * @see _.reduceRight - **/ - foldr(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.find - **/ - find(iterator: _.ListIterator|_.ObjectIterator, context?: any): _ChainSingle; - - /** - * @see _.find - **/ - find(interator: U): _ChainSingle; - - /** - * @see _.find - **/ - find(interator: string): _ChainSingle; - - /** - * @see _.find - **/ - detect(iterator: _.ListIterator|_.ObjectIterator, context?: any): _ChainSingle; - - /** - * @see _.find - **/ - detect(interator: U): _ChainSingle; - - /** - * @see _.find - **/ - detect(interator: string): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.filter - **/ - filter(iterator: _.ListIterator, context?: any): _Chain; - - /** - * @see _.filter - **/ - select(iterator: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.where - **/ - where(properties: U): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.findWhere - **/ - findWhere(properties: U): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.reject - **/ - reject(iterator: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.all - **/ - all(iterator?: _.ListIterator, context?: any): _ChainSingle; - - /** - * @see _.all - **/ - every(iterator?: _.ListIterator, context?: any): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.any - **/ - any(iterator?: _.ListIterator, context?: any): _ChainSingle; - - /** - * @see _.any - **/ - some(iterator?: _.ListIterator, context?: any): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.contains - **/ - contains(value: T, fromIndex?: number): _ChainSingle; - - /** - * Alias for 'contains'. - * @see contains - **/ - include(value: T, fromIndex?: number): _ChainSingle; - - /** - * Alias for 'contains'. - * @see contains - **/ - includes(value: T, fromIndex?: number): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.invoke - **/ - invoke(methodName: string, ...arguments: any[]): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.pluck - **/ - pluck(propertyName: string): _Chain; - - /** - * Wrapped type `number[]`. - * @see _.max - **/ - max(): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.max - **/ - max(iterator: _.ListIterator, context?: any): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.max - **/ - max(iterator?: _.ListIterator, context?: any): _ChainSingle; - - /** - * Wrapped type `number[]`. - * @see _.min - **/ - min(): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.min - **/ - min(iterator: _.ListIterator, context?: any): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.min - **/ - min(iterator?: _.ListIterator, context?: any): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.sortBy - **/ - sortBy(iterator?: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.sortBy - **/ - sortBy(iterator: string, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.groupBy - **/ - groupBy(iterator?: _.ListIterator, context?: any): _ChainOfArrays; - - /** - * Wrapped type `any[]`. - * @see _.groupBy - **/ - groupBy(iterator: string, context?: any): _ChainOfArrays; - - /** - * Wrapped type `any[]`. - * @see _.indexBy - **/ - indexBy(iterator: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.indexBy - **/ - indexBy(iterator: string, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.countBy - **/ - countBy(iterator?: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.countBy - **/ - countBy(iterator: string, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.shuffle - **/ - shuffle(): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.sample - **/ - sample(n: number): _Chain; - - /** - * @see _.sample - **/ - sample(): _Chain; - - /** - * Wrapped type `any`. - * @see _.toArray - **/ - toArray(): _Chain; - - /** - * Wrapped type `any`. - * @see _.size - **/ - size(): _ChainSingle; - - /********* - * Arrays * - **********/ - - /** - * Wrapped type `any[]`. - * @see _.first - **/ - first(): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.first - **/ - first(n: number): _Chain; - - /** - * @see _.first - **/ - head(): _Chain; - - /** - * @see _.first - **/ - head(n: number): _Chain; - - /** - * @see _.first - **/ - take(): _Chain; - - /** - * @see _.first - **/ - take(n: number): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.initial - **/ - initial(n?: number): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.last - **/ - last(): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.last - **/ - last(n: number): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.rest - **/ - rest(n?: number): _Chain; - - /** - * @see _.rest - **/ - tail(n?: number): _Chain; - - /** - * @see _.rest - **/ - drop(n?: number): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.compact - **/ - compact(): _Chain; - - /** - * Wrapped type `any`. - * @see _.flatten - **/ - flatten(shallow?: boolean): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.without - **/ - without(...values: T[]): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.partition - **/ - partition(iterator: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[][]`. - * @see _.union - **/ - union(...arrays: _.List[]): _Chain; - - /** - * Wrapped type `any[][]`. - * @see _.intersection - **/ - intersection(...arrays: _.List[]): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.difference - **/ - difference(...others: _.List[]): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.uniq - **/ - uniq(isSorted?: boolean, iterator?: _.ListIterator): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.uniq - **/ - uniq(iterator?: _.ListIterator, context?: any): _Chain; - - /** - * @see _.uniq - **/ - unique(isSorted?: boolean, iterator?: _.ListIterator): _Chain; - - /** - * @see _.uniq - **/ - unique(iterator?: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[][]`. - * @see _.zip - **/ - zip(...arrays: any[][]): _Chain; - - /** - * Wrapped type `any[][]`. - * @see _.unzip - **/ - unzip(...arrays: any[][]): _Chain; - - /** - * Wrapped type `any[][]`. - * @see _.object - **/ - object(...keyValuePairs: any[][]): _Chain; - - /** - * @see _.object - **/ - object(values?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.indexOf - **/ - indexOf(value: T, isSorted?: boolean): _ChainSingle; - - /** - * @see _.indexOf - **/ - indexOf(value: T, startFrom: number): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.lastIndexOf - **/ - lastIndexOf(value: T, from?: number): _ChainSingle; - - /** - * @see _.findIndex - **/ - findIndex(predicate: _.ListIterator | {}, context?: any): _ChainSingle; - - /** - * @see _.findLastIndex - **/ - findLastIndex(predicate: _.ListIterator | {}, context?: any): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.sortedIndex - **/ - sortedIndex(value: T, iterator?: (x: T) => any, context?: any): _ChainSingle; - - /** - * Wrapped type `number`. - * @see _.range - **/ - range(stop: number, step?: number): _Chain; - - /** - * Wrapped type `number`. - * @see _.range - **/ - range(): _Chain; - - /** - * Wrapped type `any[][]`. - * @see _.chunk - **/ - chunk(): _Chain; - - /* *********** - * Functions * - ************ */ - - /** - * Wrapped type `Function`. - * @see _.bind - **/ - bind(object: any, ...arguments: any[]): _Chain; - - /** - * Wrapped type `object`. - * @see _.bindAll - **/ - bindAll(...methodNames: string[]): _Chain; - - /** - * Wrapped type `Function`. - * @see _.partial - **/ - partial(...arguments: any[]): _Chain; - - /** - * Wrapped type `Function`. - * @see _.memoize - **/ - memoize(hashFn?: (n: any) => string): _Chain; - - /** - * Wrapped type `Function`. - * @see _.defer - **/ - defer(...arguments: any[]): _Chain; - - /** - * Wrapped type `Function`. - * @see _.delay - **/ - delay(wait: number, ...arguments: any[]): _Chain; - - /** - * @see _.delay - **/ - delay(...arguments: any[]): _Chain; - - /** - * Wrapped type `Function`. - * @see _.throttle - **/ - throttle(wait: number, options?: _.ThrottleSettings): _Chain; - - /** - * Wrapped type `Function`. - * @see _.debounce - **/ - debounce(wait: number, immediate?: boolean): _Chain; - - /** - * Wrapped type `Function`. - * @see _.once - **/ - once(): _Chain; - - /** - * Wrapped type `Function`. - * @see _.once - **/ - restArgs(startIndex? : number): _Chain; - - /** - * Wrapped type `number`. - * @see _.after - **/ - after(func: Function): _Chain; - - /** - * Wrapped type `number`. - * @see _.before - **/ - before(fn: Function): _Chain; - - /** - * Wrapped type `Function`. - * @see _.wrap - **/ - wrap(wrapper: Function): () => _Chain; - - /** - * Wrapped type `Function`. - * @see _.negate - **/ - negate(): _Chain; - - /** - * Wrapped type `Function[]`. - * @see _.compose - **/ - compose(...functions: Function[]): _Chain; - - /********* * - * Objects * - ********** */ - - /** - * Wrapped type `object`. - * @see _.keys - **/ - keys(): _Chain; - - /** - * Wrapped type `object`. - * @see _.allKeys - **/ - allKeys(): _Chain; - - /** - * Wrapped type `object`. - * @see _.values - **/ - values(): _Chain; - - /** - * Wrapped type `object`. - * @see _.pairs - **/ - pairs(): _Chain; - - /** - * Wrapped type `object`. - * @see _.invert - **/ - invert(): _Chain; - - /** - * Wrapped type `object`. - * @see _.functions - **/ - functions(): _Chain; - - /** - * @see _.functions - **/ - methods(): _Chain; - - /** - * Wrapped type `object`. - * @see _.extend - **/ - extend(...sources: any[]): _Chain; - - /** - * Wrapped type `object`. - * @see _.extend - **/ - findKey(predicate: _.ObjectIterator, context? : any): _Chain - - /** - * Wrapped type `object`. - * @see _.pick - **/ - pick(...keys: any[]): _Chain; - pick(keys: any[]): _Chain; - pick(fn: (value: any, key: any, object: any) => any): _Chain; - - /** - * Wrapped type `object`. - * @see _.omit - **/ - omit(...keys: string[]): _Chain; - omit(keys: string[]): _Chain; - omit(iteratee: Function): _Chain; - - /** - * Wrapped type `object`. - * @see _.defaults - **/ - defaults(...defaults: any[]): _Chain; - - /** - * Wrapped type `any`. - * @see _.create - **/ - create(props?: Object): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.clone - **/ - clone(): _Chain; - - /** - * Wrapped type `object`. - * @see _.tap - **/ - tap(interceptor: (...as: any[]) => any): _Chain; - - /** - * Wrapped type `object`. - * @see _.has - **/ - has(key: string): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.matches - **/ - matches(): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.matcher - **/ - matcher(): _Chain; - - /** - * Wrapped type `string`. - * @see _.property - **/ - property(): _Chain; - - /** - * Wrapped type `object`. - * @see _.propertyOf - **/ - propertyOf(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isEqual - **/ - isEqual(other: any): _Chain; - - /** - * Wrapped type `object`. - * @see _.isEmpty - **/ - isEmpty(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isMatch - **/ - isMatch(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isElement - **/ - isElement(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isArray - **/ - isArray(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isSymbol - **/ - isSymbol(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isObject - **/ - isObject(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isArguments - **/ - isArguments(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isFunction - **/ - isFunction(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isError - **/ - isError(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isString - **/ - isString(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isNumber - **/ - isNumber(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isFinite - **/ - isFinite(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isBoolean - **/ - isBoolean(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isDate - **/ - isDate(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isRegExp - **/ - isRegExp(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isNaN - **/ - isNaN(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isNull - **/ - isNull(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isUndefined - **/ - isUndefined(): _Chain; - - /********* * - * Utility * - ********** */ - - /** - * Wrapped type `any`. - * @see _.identity - **/ - identity(): _Chain; - - /** - * Wrapped type `any`. - * @see _.constant - **/ - constant(): _Chain; - - /** - * Wrapped type `any`. - * @see _.noop - **/ - noop(): _Chain; - - /** - * Wrapped type `number`. - * @see _.times - **/ - times(iterator: (n: number) => TResult, context?: any): _Chain; - - /** - * Wrapped type `number`. - * @see _.random - **/ - random(): _Chain; - /** - * Wrapped type `number`. - * @see _.random - **/ - random(max: number): _Chain; - - /** - * Wrapped type `object`. - * @see _.mixin - **/ - mixin(): _Chain; - - /** - * Wrapped type `string|Function|Object`. - * @see _.iteratee - **/ - iteratee(context?: any): _Chain; - - /** - * Wrapped type `string`. - * @see _.uniqueId - **/ - uniqueId(): _Chain; - - /** - * Wrapped type `string`. - * @see _.escape - **/ - escape(): _Chain; - - /** - * Wrapped type `string`. - * @see _.unescape - **/ - unescape(): _Chain; - - /** - * Wrapped type `object`. - * @see _.result - **/ - result(property: string, defaultValue?:any): _Chain; - - /** - * Wrapped type `string`. - * @see _.template - **/ - template(settings?: _.TemplateSettings): (...data: any[]) => _Chain; - - /************* * - * Array proxy * - ************** */ - - /** - * Returns a new array comprised of the array on which it is called - * joined with the array(s) and/or value(s) provided as arguments. - * @param arr Arrays and/or values to concatenate into a new array. See the discussion below for details. - * @return A new array comprised of the array on which it is called - **/ - concat(...arr: Array): _Chain; - - /** - * Join all elements of an array into a string. - * @param separator Optional. Specifies a string to separate each element of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma. - * @return The string conversions of all array elements joined into one string. - **/ - join(separator?: any): _ChainSingle; - - /** - * Removes the last element from an array and returns that element. - * @return Returns the popped element. - **/ - pop(): _ChainSingle; - - /** - * Adds one or more elements to the end of an array and returns the new length of the array. - * @param item The elements to add to the end of the array. - * @return The array with the element added to the end. - **/ - push(...item: Array): _Chain; - - /** - * Reverses an array in place. The first array element becomes the last and the last becomes the first. - * @return The reversed array. - **/ - reverse(): _Chain; - - /** - * Removes the first element from an array and returns that element. This method changes the length of the array. - * @return The shifted element. - **/ - shift(): _ChainSingle; - - /** - * Returns a shallow copy of a portion of an array into a new array object. - * @param start Zero-based index at which to begin extraction. - * @param end Optional. Zero-based index at which to end extraction. slice extracts up to but not including end. - * @return A shallow copy of a portion of an array into a new array object. - **/ - slice(start: number, end?: number): _Chain; - - /** - * Sorts the elements of an array in place and returns the array. The sort is not necessarily stable. The default sort order is according to string Unicode code points. - * @param compareFn Optional. Specifies a function that defines the sort order. If omitted, the array is sorted according to each character's Unicode code point value, according to the string conversion of each element. - * @return The sorted array. - **/ - sort(compareFn: (a: T, b: T) => boolean): _Chain; - - /** - * Changes the content of an array by removing existing elements and/or adding new elements. - * @param index Index at which to start changing the array. If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end. - * @param quantity An integer indicating the number of old array elements to remove. If deleteCount is 0, no elements are removed. In this case, you should specify at least one new element. If deleteCount is greater than the number of elements left in the array starting at index, then all of the elements through the end of the array will be deleted. - * @param items The element to add to the array. If you don't specify any elements, splice will only remove elements from the array. - * @return An array containing the deleted elements. If only one element is removed, an array of one element is returned. If no elements are removed, an empty array is returned. - **/ - splice(index: number, quantity: number, ...items: Array): _Chain; - - /** - * A string representing the specified array and its elements. - * @return A string representing the specified array and its elements. - **/ - toString(): _ChainSingle; - - /** - * Adds one or more elements to the beginning of an array and returns the new length of the array. - * @param items The elements to add to the front of the array. - * @return The array with the element added to the beginning. - **/ - unshift(...items: Array): _Chain; - - /********** * - * Chaining * - *********** */ - - /** - * Wrapped type `any`. - * @see _.chain - **/ - chain(): _Chain; - - /** - * Wrapped type `any`. - * @see _.value - **/ - value(): T[]; -} -interface _ChainSingle { - value(): T; -} -interface _ChainOfArrays extends _Chain { - flatten(shallow?: boolean): _Chain; - mapObject(fn: _.ListIterator): _ChainOfArrays; -} - -declare var _: UnderscoreStatic; - -declare module "underscore" { - export = _; -}