├── bin
└── index.js
├── ~resources
├── appended.png
├── open-wx.png
├── output.gif
├── success.png
├── invalid-path-01.png
├── invalid-path-02.png
└── not-exist-path.png
├── readme
├── ~resources
│ ├── output.gif
│ ├── appended.png
│ ├── success.png
│ ├── invalid-path-01.png
│ ├── invalid-path-02.png
│ └── not-exist-path.png
└── 1.0.3-快捷键编译.md
├── gulp
├── autoCompileGulpTask.ts
└── autoCompileGulpTask.js
├── src
├── constants.ts
├── index.ts
├── constants.js
├── wxChmod.ts
├── index.js
├── wxChmod.js
├── triggerCompile.ts
├── execute.ts
├── io-utils.ts
├── triggerCompile.js
├── io-utils.js
├── cmdPrompt.ts
├── cmdPrompt.js
├── findPort.js
├── exposeShortcut.js
├── findPort.ts
├── exposeShortcut.ts
└── execute.js
├── tsconfig.json
├── webpack
├── wxCompileLoader.ts
└── wxCompileLoader.js
├── typings
├── index.d.ts
└── globals
│ ├── node
│ ├── typings.json
│ └── index.d.ts
│ ├── request
│ ├── typings.json
│ └── index.d.ts
│ ├── form-data
│ ├── typings.json
│ └── index.d.ts
│ └── es6-promise
│ ├── typings.json
│ └── index.d.ts
├── .idea
├── inspectionProfiles
│ ├── profiles_settings.xml
│ └── Project_Default.xml
└── codeStyleSettings.xml
├── typings.json
├── tpl
├── index.ts
├── express.tpl
└── index.js
├── package.json
├── README.md
└── .gitignore
/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
"use strict";
require('../src/index').execute();
--------------------------------------------------------------------------------
/~resources/appended.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jf3096/wx-compile-key/HEAD/~resources/appended.png
--------------------------------------------------------------------------------
/~resources/open-wx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jf3096/wx-compile-key/HEAD/~resources/open-wx.png
--------------------------------------------------------------------------------
/~resources/output.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jf3096/wx-compile-key/HEAD/~resources/output.gif
--------------------------------------------------------------------------------
/~resources/success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jf3096/wx-compile-key/HEAD/~resources/success.png
--------------------------------------------------------------------------------
/readme/~resources/output.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jf3096/wx-compile-key/HEAD/readme/~resources/output.gif
--------------------------------------------------------------------------------
/readme/~resources/appended.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jf3096/wx-compile-key/HEAD/readme/~resources/appended.png
--------------------------------------------------------------------------------
/readme/~resources/success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jf3096/wx-compile-key/HEAD/readme/~resources/success.png
--------------------------------------------------------------------------------
/~resources/invalid-path-01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jf3096/wx-compile-key/HEAD/~resources/invalid-path-01.png
--------------------------------------------------------------------------------
/~resources/invalid-path-02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jf3096/wx-compile-key/HEAD/~resources/invalid-path-02.png
--------------------------------------------------------------------------------
/~resources/not-exist-path.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jf3096/wx-compile-key/HEAD/~resources/not-exist-path.png
--------------------------------------------------------------------------------
/readme/~resources/invalid-path-01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jf3096/wx-compile-key/HEAD/readme/~resources/invalid-path-01.png
--------------------------------------------------------------------------------
/readme/~resources/invalid-path-02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jf3096/wx-compile-key/HEAD/readme/~resources/invalid-path-02.png
--------------------------------------------------------------------------------
/readme/~resources/not-exist-path.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jf3096/wx-compile-key/HEAD/readme/~resources/not-exist-path.png
--------------------------------------------------------------------------------
/gulp/autoCompileGulpTask.ts:
--------------------------------------------------------------------------------
1 | import triggerCompile from '../src/triggerCompile';
2 | export const autoCompileGulpTask = (cb) => {
3 | triggerCompile();
4 | cb();
5 | };
--------------------------------------------------------------------------------
/src/constants.ts:
--------------------------------------------------------------------------------
1 | export const WX_ROOT_PATH = require(`../package.json`).wxtools.path;
2 | export const RELATIVE_SHORTCUT_PATH = require(`../package.json`).wxtools.relativeShortcutPath;
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | export {autoCompileWebpackLoader} from "../webpack/wxCompileLoader";
2 | export {autoCompileGulpTask} from "../gulp/autoCompileGulpTask";
3 | export {execute} from "./execute";
--------------------------------------------------------------------------------
/src/constants.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | exports.WX_ROOT_PATH = require("../package.json").wxtools.path;
3 | exports.RELATIVE_SHORTCUT_PATH = require("../package.json").wxtools.relativeShortcutPath;
4 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es5",
5 | "sourceMap": false
6 | },
7 | "exclude": [
8 | "node_modules"
9 | ]
10 | }
--------------------------------------------------------------------------------
/gulp/autoCompileGulpTask.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var triggerCompile_1 = require('../src/triggerCompile');
3 | exports.autoCompileGulpTask = function (cb) {
4 | triggerCompile_1.default();
5 | cb();
6 | };
7 |
--------------------------------------------------------------------------------
/webpack/wxCompileLoader.ts:
--------------------------------------------------------------------------------
1 | import triggerCompile from '../src/triggerCompile';
2 |
3 | export const autoCompileWebpackLoader = (content: string)=> {
4 | this.cacheable && this.cacheable();
5 | triggerCompile();
6 | return content;
7 | };
--------------------------------------------------------------------------------
/typings/index.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 | ///
5 |
--------------------------------------------------------------------------------
/webpack/wxCompileLoader.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var _this = this;
3 | var triggerCompile_1 = require('../src/triggerCompile');
4 | exports.autoCompileWebpackLoader = function (content) {
5 | _this.cacheable && _this.cacheable();
6 | triggerCompile_1.default();
7 | return content;
8 | };
9 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "globalDependencies": {
3 | "es6-promise": "registry:dt/es6-promise#0.0.0+20160614011821",
4 | "form-data": "registry:dt/form-data#0.0.0+20160724024111",
5 | "node": "registry:dt/node#6.0.0+20160928143418",
6 | "request": "registry:dt/request#0.0.0+20160726020908"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/codeStyleSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/wxChmod.ts:
--------------------------------------------------------------------------------
1 | const chmod = require('chmod');
2 | const permissionMode = 777;
3 | export default function wxChmod(path:string) {
4 | return new Promise((resolve, reject)=> {
5 | try {
6 | chmod(path, permissionMode);
7 | resolve(true);
8 | } catch (err) {
9 | reject(err)
10 | }
11 | });
12 | }
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var wxCompileLoader_1 = require("../webpack/wxCompileLoader");
3 | exports.autoCompileWebpackLoader = wxCompileLoader_1.autoCompileWebpackLoader;
4 | var autoCompileGulpTask_1 = require("../gulp/autoCompileGulpTask");
5 | exports.autoCompileGulpTask = autoCompileGulpTask_1.autoCompileGulpTask;
6 | var execute_1 = require("./execute");
7 | exports.execute = execute_1.execute;
8 |
--------------------------------------------------------------------------------
/typings/globals/node/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "resolution": "main",
3 | "tree": {
4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7be68adbdff4bea14f33f54f27d3bdb5822e3b10/node/node.d.ts",
5 | "raw": "registry:dt/node#6.0.0+20160928143418",
6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7be68adbdff4bea14f33f54f27d3bdb5822e3b10/node/node.d.ts"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/typings/globals/request/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "resolution": "main",
3 | "tree": {
4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/658d360c6a8611e76f7cc75c07fcd0f02055ffc4/request/request.d.ts",
5 | "raw": "registry:dt/request#0.0.0+20160726020908",
6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/658d360c6a8611e76f7cc75c07fcd0f02055ffc4/request/request.d.ts"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/tpl/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by allen on 2016/10/12 0012.
3 | */
4 | import * as fs from 'fs';
5 | import * as path from 'path';
6 | const replaceIndicator = "{{port}}";
7 |
8 | export default function getExpressTpl(port: number): string {
9 | const templatePath = path.join(__dirname, './express.tpl');
10 | const content = fs.readFileSync(templatePath).toString();
11 | return content.replace(replaceIndicator, port.toString());
12 | }
--------------------------------------------------------------------------------
/typings/globals/form-data/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "resolution": "main",
3 | "tree": {
4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/8de2997128443fbde32d9b04f7af78cd0c8c9593/form-data/form-data.d.ts",
5 | "raw": "registry:dt/form-data#0.0.0+20160724024111",
6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/8de2997128443fbde32d9b04f7af78cd0c8c9593/form-data/form-data.d.ts"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/typings/globals/es6-promise/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "resolution": "main",
3 | "tree": {
4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/71c9d2336c0c802f89d530e07563e00b9ac07792/es6-promise/es6-promise.d.ts",
5 | "raw": "registry:dt/es6-promise#0.0.0+20160614011821",
6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/71c9d2336c0c802f89d530e07563e00b9ac07792/es6-promise/es6-promise.d.ts"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/wxChmod.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var chmod = require('chmod');
3 | var permissionMode = 777;
4 | function wxChmod(path) {
5 | return new Promise(function (resolve, reject) {
6 | try {
7 | chmod(path, permissionMode);
8 | resolve(true);
9 | }
10 | catch (err) {
11 | reject(err);
12 | }
13 | });
14 | }
15 | Object.defineProperty(exports, "__esModule", { value: true });
16 | exports.default = wxChmod;
17 |
--------------------------------------------------------------------------------
/tpl/express.tpl:
--------------------------------------------------------------------------------
1 | /*wx-compile-key:start*/
2 | ;(function () {
3 | var http = require('http');
4 | var express = require('express');
5 | var app = express();
6 | var actions = require("../dist/common/actions/actions.js");
7 | app.get('', function (req, res) {
8 | actions.reBuild();
9 | res.end();
10 | });
11 | var server = http.createServer(app);
12 | server.listen({{port}}, function () {
13 | alert('wx-compile-key实时监听已启动')
14 | });
15 | }());
16 | /*wx-compile-key:end*/
--------------------------------------------------------------------------------
/tpl/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Created by allen on 2016/10/12 0012.
4 | */
5 | var fs = require('fs');
6 | var path = require('path');
7 | var replaceIndicator = "{{port}}";
8 | function getExpressTpl(port) {
9 | var templatePath = path.join(__dirname, './express.tpl');
10 | var content = fs.readFileSync(templatePath).toString();
11 | return content.replace(replaceIndicator, port.toString());
12 | }
13 | Object.defineProperty(exports, "__esModule", { value: true });
14 | exports.default = getExpressTpl;
15 |
--------------------------------------------------------------------------------
/src/triggerCompile.ts:
--------------------------------------------------------------------------------
1 | import * as request from 'request';
2 | import {getPort} from './findPort';
3 |
4 | export default function triggerCompile() {
5 | const port = getPort();
6 | if (port) {
7 | try {
8 | request.get(`http://localhost:${port}`).on('error', (err: Error)=> {
9 | console.error(err);
10 | });
11 | } catch (err) {
12 | throw new Error("请打开微信web开发平台\r\n" + err.toString());
13 | }
14 | } else {
15 | throw new Error(`triggerCompile.ts: please append script before trigger compile`);
16 | }
17 | }
--------------------------------------------------------------------------------
/src/execute.ts:
--------------------------------------------------------------------------------
1 | import {cmdPrompt} from './cmdPrompt';
import wxChmod from './wxChmod';
import {exposeCompileShortcut} from './exposeShortcut';
import findPort from './findPort';
import getExpressTpl from '../tpl/index';
export const execute = async function () {
const path = await cmdPrompt();
try {
await wxChmod(path);
const port = await findPort();
const appendScriptStr = getExpressTpl(port);
const isSuccess = await exposeCompileShortcut(path, appendScriptStr);
if (isSuccess) {
console.info(`添加自动编译成功`);
}
} catch (err) {
console.info(err);
}
};
--------------------------------------------------------------------------------
/src/io-utils.ts:
--------------------------------------------------------------------------------
1 | import * as fs from 'fs';
2 | import {WX_ROOT_PATH} from './constants';
3 | import * as path from 'path';
4 | export function isFileExistsSync(path: string) {
5 | return fs.existsSync(path)
6 | }
7 |
8 | function replaceFromFile(filePath: string, searchValue: string, replaceValue: string) {
9 | const content = fs.readFileSync(filePath).toString();
10 | const newContent = content.replace(searchValue, replaceValue);
11 | fs.writeFileSync(filePath, newContent);
12 | }
13 |
14 | export function updateWxRootPath(value: string) {
15 | const packageConfigPath = path.resolve(__dirname, '../package.json');
16 | replaceFromFile(packageConfigPath, WX_ROOT_PATH, value)
17 | }
--------------------------------------------------------------------------------
/src/triggerCompile.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var request = require('request');
3 | var findPort_1 = require('./findPort');
4 | function triggerCompile() {
5 | var port = findPort_1.getPort();
6 | if (port) {
7 | try {
8 | request.get("http://localhost:" + port).on('error', function (err) {
9 | console.error(err);
10 | });
11 | }
12 | catch (err) {
13 | throw new Error("请打开微信web开发平台\r\n" + err.toString());
14 | }
15 | }
16 | else {
17 | throw new Error("triggerCompile.ts: please append script before trigger compile");
18 | }
19 | }
20 | Object.defineProperty(exports, "__esModule", { value: true });
21 | exports.default = triggerCompile;
22 |
--------------------------------------------------------------------------------
/src/io-utils.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var fs = require('fs');
3 | var constants_1 = require('./constants');
4 | var path = require('path');
5 | function isFileExistsSync(path) {
6 | return fs.existsSync(path);
7 | }
8 | exports.isFileExistsSync = isFileExistsSync;
9 | function replaceFromFile(filePath, searchValue, replaceValue) {
10 | var content = fs.readFileSync(filePath).toString();
11 | var newContent = content.replace(searchValue, replaceValue);
12 | fs.writeFileSync(filePath, newContent);
13 | }
14 | function updateWxRootPath(value) {
15 | var packageConfigPath = path.resolve(__dirname, '../package.json');
16 | replaceFromFile(packageConfigPath, constants_1.WX_ROOT_PATH, value);
17 | }
18 | exports.updateWxRootPath = updateWxRootPath;
19 |
--------------------------------------------------------------------------------
/typings/globals/form-data/index.d.ts:
--------------------------------------------------------------------------------
1 | // Generated by typings
2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/8de2997128443fbde32d9b04f7af78cd0c8c9593/form-data/form-data.d.ts
3 | declare module "form-data" {
4 | class FormData {
5 | append(key: string, value: any, options?: any): void;
6 | getHeaders(): FormData.Dictionary;
7 | // TODO expand pipe
8 | pipe(to: any): any;
9 | submit(params: string | Object, callback: (error: any, response: any) => void): any;
10 | getBoundary(): string;
11 | }
12 |
13 | namespace FormData {
14 | interface Dictionary {
15 | [key: string]: T;
16 | }
17 | }
18 |
19 | export = FormData;
20 | }
21 |
--------------------------------------------------------------------------------
/src/cmdPrompt.ts:
--------------------------------------------------------------------------------
1 | import {WX_ROOT_PATH, RELATIVE_SHORTCUT_PATH} from './constants';
2 | import {isFileExistsSync, updateWxRootPath} from './io-utils';
3 | import * as path from 'path';
4 | const inquirer = require('inquirer');
5 |
6 | const questions = [
7 | {
8 | type: 'input',
9 | name: 'wxPath',
10 | message: '请输入微信web开发工具根目录',
11 | default: function () {
12 | return WX_ROOT_PATH;
13 | },
14 | validate: function (rootPath: string): boolean|string {
15 | const isFileExists = isFileExistsSync(path.resolve(rootPath, RELATIVE_SHORTCUT_PATH));
16 | if (isFileExists) {
17 | updateWxRootPath(rootPath);
18 | return true;
19 | }
20 | return '路径不存在,请输入一个合法的路径: ';
21 | }
22 | },
23 | ];
24 |
25 | export function cmdPrompt(): Promise {
26 | return inquirer.prompt(questions).then((msg: {wxPath: string})=> {
27 | return path.resolve(msg.wxPath, RELATIVE_SHORTCUT_PATH);
28 | });
29 | }
--------------------------------------------------------------------------------
/src/cmdPrompt.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var constants_1 = require('./constants');
3 | var io_utils_1 = require('./io-utils');
4 | var path = require('path');
5 | var inquirer = require('inquirer');
6 | var questions = [
7 | {
8 | type: 'input',
9 | name: 'wxPath',
10 | message: '请输入微信web开发工具根目录',
11 | default: function () {
12 | return constants_1.WX_ROOT_PATH;
13 | },
14 | validate: function (rootPath) {
15 | var isFileExists = io_utils_1.isFileExistsSync(path.resolve(rootPath, constants_1.RELATIVE_SHORTCUT_PATH));
16 | if (isFileExists) {
17 | io_utils_1.updateWxRootPath(rootPath);
18 | return true;
19 | }
20 | return '路径不存在,请输入一个合法的路径: ';
21 | }
22 | },
23 | ];
24 | function cmdPrompt() {
25 | return inquirer.prompt(questions).then(function (msg) {
26 | return path.resolve(msg.wxPath, constants_1.RELATIVE_SHORTCUT_PATH);
27 | });
28 | }
29 | exports.cmdPrompt = cmdPrompt;
30 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "wx-compile-key",
3 | "version": "1.0.4-alpha.10",
4 | "description": "微信小程序全局编译快捷键",
5 | "bin": "./bin/index.js",
6 | "main": "./src/index.js",
7 | "scripts": {
8 | "compile": "./src/index.js"
9 | },
10 | "keywords": [
11 | "wx",
12 | "weixin",
13 | "微信",
14 | "微信小程序gulp",
15 | "微信小程序webpack loader",
16 | "小程序",
17 | "微信小程序",
18 | "wechat"
19 | ],
20 | "author": "Ailun She",
21 | "license": "ISC",
22 | "dependencies": {
23 | "chmod": "^0.2.1",
24 | "es6-promise": "^4.0.4",
25 | "inquirer": "^1.2.1",
26 | "portastic": "^1.0.1"
27 | },
28 | "repository": {
29 | "type": "git",
30 | "url": "git+https://github.com/jf3096/wx-compile-key.git"
31 | },
32 | "bugs": {
33 | "url": "https://github.com/jf3096/wx-compile-key/issues"
34 | },
35 | "homepage": "https://github.com/jf3096/wx-compile-key#readme",
36 | "wxtools": {
37 | "path": "c:/Program Files (x86)/Tencent/微信web开发者工具",
38 | "relativeShortcutPath": "package.nw/app/dist/app.js"
39 | },
40 | "port": {
41 | "min": 8000,
42 | "max": 8080
43 | },
44 | "devDependencies": {
45 | "request": "^2.75.0"
46 | }
47 | }
--------------------------------------------------------------------------------
/src/findPort.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var constants_1 = require('./constants');
3 | var fs = require('fs');
4 | var path = require('path');
5 | var portastic = require('portastic');
6 | var packageConfig = require('../package.json');
7 | var port = packageConfig.port;
8 | var minPort = port.min;
9 | var maxPort = port.max;
10 | function findPort() {
11 | var promise = portastic.find({
12 | min: minPort,
13 | max: maxPort
14 | });
15 | return promise.then(function (ports) {
16 | if (ports.length === 0) {
17 | return Promise.reject("findPort.ts: ports from " + minPort + " to " + maxPort + " are all unavailable");
18 | }
19 | return ports[0];
20 | });
21 | }
22 | Object.defineProperty(exports, "__esModule", { value: true });
23 | exports.default = findPort;
24 | var portRegexIndicator = /server\.listen\((\d+)\)/;
25 | function getPort() {
26 | var targetPath = path.resolve(constants_1.WX_ROOT_PATH, constants_1.RELATIVE_SHORTCUT_PATH);
27 | var fileContent = fs.readFileSync(targetPath).toString();
28 | var result = portRegexIndicator.exec(fileContent);
29 | if (result.length > 1) {
30 | return +result[1];
31 | }
32 | return void 0;
33 | }
34 | exports.getPort = getPort;
35 |
--------------------------------------------------------------------------------
/src/exposeShortcut.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var fs = require('fs');
3 | function isAppendScriptExists(content, appendScriptStr) {
4 | return content.indexOf(appendScriptStr) > -1;
5 | }
6 | function hasAppendedPromise(shortcutPath, appendScriptStr) {
7 | return new Promise(function (resolve, reject) {
8 | fs.readFile(shortcutPath, function (err, data) {
9 | if (err) {
10 | reject(err);
11 | return;
12 | }
13 | var content = data.toString();
14 | resolve(isAppendScriptExists(content, appendScriptStr));
15 | });
16 | });
17 | }
18 | function appendScript(shortcutPath, appendScriptStr) {
19 | return new Promise(function (resolve, reject) {
20 | fs.appendFile(shortcutPath, appendScriptStr, function (err) {
21 | !err ? resolve(true) : reject(err);
22 | });
23 | });
24 | }
25 | function exposeCompileShortcut(shortcutPath, appendScriptStr) {
26 | return hasAppendedPromise(shortcutPath, appendScriptStr)
27 | .then(function (hasAppended) {
28 | if (!hasAppended) {
29 | return appendScript(shortcutPath, appendScriptStr);
30 | }
31 | return Promise.reject(new Error("script has already appended."));
32 | });
33 | }
34 | exports.exposeCompileShortcut = exposeCompileShortcut;
35 |
--------------------------------------------------------------------------------
/src/findPort.ts:
--------------------------------------------------------------------------------
1 | import {WX_ROOT_PATH, RELATIVE_SHORTCUT_PATH} from './constants';
2 | import * as fs from 'fs';
3 | import * as path from 'path';
4 |
5 | /**
6 | * Created by allen on 2016/10/12 0012.
7 | */
8 |
9 |
10 | interface IPort {
11 | min: number;
12 | max: number
13 | }
14 |
15 | const portastic = require('portastic');
16 | const packageConfig = require('../package.json');
17 |
18 | const port: IPort = packageConfig.port;
19 |
20 | const minPort = port.min;
21 | const maxPort = port.max;
22 |
23 | export default function findPort(): Promise {
24 | const promise = portastic.find({
25 | min: minPort,
26 | max: maxPort
27 | });
28 | return promise.then((ports)=> {
29 | if (ports.length === 0) {
30 | return Promise.reject(`findPort.ts: ports from ${minPort} to ${maxPort} are all unavailable`);
31 | }
32 | return ports[0];
33 | });
34 | }
35 |
36 |
37 | const portRegexIndicator = /server\.listen\((\d+)\)/;
38 | export function getPort(): number {
39 | const targetPath = path.resolve(WX_ROOT_PATH, RELATIVE_SHORTCUT_PATH);
40 | const fileContent: string = fs.readFileSync(targetPath).toString();
41 | const result = portRegexIndicator.exec(fileContent);
42 | if (result.length > 1) {
43 | return +result[1];
44 | }
45 | return void 0;
46 | }
--------------------------------------------------------------------------------
/src/exposeShortcut.ts:
--------------------------------------------------------------------------------
1 | import * as fs from 'fs';
2 |
3 | function isAppendScriptExists(content: string, appendScriptStr: string) {
4 | return content.indexOf(appendScriptStr) > -1;
5 | }
6 |
7 | function hasAppendedPromise(shortcutPath: string, appendScriptStr: string): Promise {
8 | return new Promise((resolve, reject)=> {
9 | fs.readFile(shortcutPath, (err: NodeJS.ErrnoException, data: Buffer)=> {
10 | if (err) {
11 | reject(err);
12 | return;
13 | }
14 | const content = data.toString();
15 | resolve(isAppendScriptExists(content, appendScriptStr));
16 | })
17 | });
18 | }
19 |
20 | function appendScript(shortcutPath: string, appendScriptStr: string): Promise {
21 | return new Promise((resolve, reject)=> {
22 | fs.appendFile(shortcutPath, appendScriptStr, (err: NodeJS.ErrnoException)=> {
23 | !err ? resolve(true) : reject(err);
24 | })
25 | });
26 | }
27 |
28 | export function exposeCompileShortcut(shortcutPath: string, appendScriptStr: string): Promise {
29 | return hasAppendedPromise(shortcutPath, appendScriptStr)
30 | .then((hasAppended: boolean): Promise=> {
31 | if (!hasAppended) {
32 | return appendScript(shortcutPath, appendScriptStr)
33 | }
34 | return Promise.reject(new Error(`script has already appended.`)) as Promise
35 | })
36 | }
--------------------------------------------------------------------------------
/src/execute.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 | return new (P || (P = Promise))(function (resolve, reject) {
4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5 | function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7 | step((generator = generator.apply(thisArg, _arguments)).next());
8 | });
9 | };
10 | var cmdPrompt_1 = require('./cmdPrompt');
11 | var wxChmod_1 = require('./wxChmod');
12 | var exposeShortcut_1 = require('./exposeShortcut');
13 | var findPort_1 = require('./findPort');
14 | var index_1 = require('../tpl/index');
15 | exports.execute = function () {
16 | return __awaiter(this, void 0, void 0, function* () {
17 | var path = yield cmdPrompt_1.cmdPrompt();
18 | try {
19 | yield wxChmod_1.default(path);
20 | var port = yield findPort_1.default();
21 | var appendScriptStr = index_1.default(port);
22 | var isSuccess = yield exposeShortcut_1.exposeCompileShortcut(path, appendScriptStr);
23 | if (isSuccess) {
24 | console.info("\u6DFB\u52A0\u81EA\u52A8\u7F16\u8BD1\u6210\u529F");
25 | }
26 | }
27 | catch (err) {
28 | console.info(err);
29 | }
30 | });
31 | };
32 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WX Compile key
[](https://www.npmjs.com/package/wx-compile-key)
## 简介
这是一个微信小程序的辅助工具, 作用于gulp或者webpack, 在你使用第三方开发工具例如VSCode的时候实现边开发边自动编译的效果。
## 目的
其实这一个只是gulp-wx-compile的插件之一, 目的很简单, 让微信小程序变得跟webpack或者gulp一样, 当我们保存自己的代码, 小程序就自动编译,
感觉跟browser sync一样, 提高我们开发效率。
## 迭代版本
[1.0.3-快捷键编译](./readme/1.0.3-快捷键编译.md) (已过期, 弃用快捷键的方式, 当前版本性能更佳)
## 安装
```shell
npm i wx-compile-key -g
wx-compile-key ##这句话必须要在管理员模式下执行, 因为微信小程序的文件都是限定了修改权限的
```
成功后会看到以下提示:

然后打开/重启你的微信web开发者工具:

## Gulp 使用
```javascript
npm i wx-compile-key --save-dev
const autoCompileGulpTask = require('wx-compile-key').autoCompileGulpTask;
gulp.task(`wx:autoCompile`, autoCompileGulpTask);
```
在开发阶段, 顺便按一下gulp/webpack监听就可以自动修改代码自动编译微信小程序啦。

## Webpack Loader
(未测试,暂不公开)
## 环境
测试环境在**微信Web开发者工具0.9.092300, 0.10.101100, 0.10.101400**
> 兼容Windows
> 兼容Mac/Linux
## 测试用例
由于时间关系, 只是做了e2e测试, 后续有时间会补上单元测试。 问题应该不大, 如果遇到任何问题,
请open issue,我尽可能在当天给您解答,一下是所有的e2e测试用例截图:
## FAQ
说明wx-compile-key的命令已经使用过。

### 非法路径
输入不合法路劲时,弹出一下提示, 重新输入一个合法路劲即可。


### 路径不存在
路径输入正确,但并非微信小程序的根目录,重新定位目录即可。

## 思路
以前做过游戏脚本开发,所以尝试通过窗口句柄发送ctrl+b(默认微信小程序编译快捷键)来隐式编译, 但在非激活窗口状态下可以发送单个快捷键但
无法发送组合快捷键, 这样当我们边写代码边保存的时候由于需要激活微信窗口会导致失焦的问题,所以放弃这个最简单也最优无依赖的方式。如果有大大能解决, 欢迎给我留言。
后来偶然又读了一下源码, 发现另外一个简易的注入点, 原理很简单, 内部竟然引入了express的包, 你懂的, 那就充分利用, 改进了这个插件。
## 反馈
由于微信小程序没有稳定,而且由于这只是一个辅助工具,并没有花太多时间去完善,部分功能没有用智能方式去获取。如果有任何bug欢迎留言。如果有什么定制功能需要我完善,也可以留言。
* 邮件: 529360897@qq.com
## Licensing
MIT license
--------------------------------------------------------------------------------
/readme/1.0.3-快捷键编译.md:
--------------------------------------------------------------------------------
1 | # WX Compile key
[](https://www.npmjs.com/package/wx-compile-key)
这是一个微信小程序的辅助工具, 作用很简单, 只是一个简单的hack, 改了一下他的源码, 把微信小程序编译的快捷键变成了全局。
快捷键默认设置为**control+alt+shift+f10**。(**不满足?那给你弄一个gulp和webpack让你自动保存自动编译吧**)
[Gif成功样例](#成功样例)
## 目的
其实这一个只是gulp-wx-compile的插件之一, 目的很简单, 让微信小程序变得跟webpack或者gulp一样, 当我们保存自己的代码, 小程序就自动编译,
感觉跟browser sync一样, 提高我们开发效率。
## 思路
以前做过游戏脚本开发,所以尝试通过窗口句柄发送ctrl+b(默认微信小程序编译快捷键)来隐式编译, 但在非激活窗口状态下可以发送单个快捷键但
无法发送组合快捷键, 这样当我们边写代码边保存的时候由于需要激活微信窗口会导致失焦的问题,所以放弃这个最简单也最优的方式。
如果有大大能解决, 欢迎给我留言。
这里选择第二种方式, 通过研读小程序的源码发现编译只是触发一个dispatch rebuild的方法(微信小程序也用到了redux)而且是基于nw.js开发的, 所以由此观察得出一个结论,
我只需要为他注册一个全局的热键并绑定dispatch rebuild即可。
## 安装
```shell
npm i wx-compile-key@1.0.3 -g
wx-compile-key ##这句话必须要在管理员模式下执行, 因为微信小程序的文件都是限定了修改权限的
```
## Gulp 使用
```javascript
npm i wx-compile-key --save-dev
const autoCompileGulpTask = require('wx-compile-key').autoCompileGulpTask;
gulp.task(`wx:autoCompile`, autoCompileGulpTask);
```
## Webpack Loader
(未完成测试,暂不公开)
## 环境
测试环境在**微信Web开发者工具0.9.092300**
> 兼容Windows
> Mac/Linux代码兼容但没有测试,欢迎小伙伴测试
## 测试用例
由于时间关系, 只是做了e2e测试, 后续有时间会补上单元测试。 问题应该不大, 如果遇到任何问题,
请open issue,我尽可能在当天给您解答,一下是所有的e2e测试用例截图:
### 成功用例
当看到添加全局热键成功后可以使用ctrl+alt+shift+f10编译小程序。
例如你在自己Vscode开发的时候, 写完代码, 顺便按这个快捷键编译一下。

### 已添加
说明wx-compile-key的命令已经使用过。

### 非法路径
输入不合法路劲时,弹出一下提示, 重新输入一个合法路劲即可。


### 路径不存在
路径输入正确,但并非微信小程序的根目录,重新定位目录即可。

## 成功样例
在开发阶段, 顺便按一下gulp/webpack监听就可以自动修改代码自动编译微信小程序啦。

## 反馈
1. 由于微信小程序没有稳定,而且由于这只是一个辅助工具,并没有花太多时间去完善,部分功能没有用智能方式去获取。如果有任何bug欢迎留言。
2. 如果有什么定制功能需要我完善,也可以留言。
## Licensing
MIT license
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### JetBrains template
3 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
4 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5 |
6 | # User-specific stuff:
7 | .idea/workspace.xml
8 | .idea/tasks.xml
9 | .idea/dictionaries
10 | .idea/vcs.xml
11 | .idea/jsLibraryMappings.xml
12 |
13 | # Sensitive or high-churn files:
14 | .idea/dataSources.ids
15 | .idea/dataSources.xml
16 | .idea/dataSources.local.xml
17 | .idea/sqlDataSources.xml
18 | .idea/dynamic.xml
19 | .idea/uiDesigner.xml
20 |
21 | # Gradle:
22 | .idea/gradle.xml
23 | .idea/libraries
24 |
25 | # Mongo Explorer plugin:
26 | .idea/mongoSettings.xml
27 |
28 | ## File-based project format:
29 | *.iws
30 |
31 | ## Plugin-specific files:
32 |
33 | # IntelliJ
34 | /out/
35 |
36 | # mpeltonen/sbt-idea plugin
37 | .idea_modules/
38 |
39 | # JIRA plugin
40 | atlassian-ide-plugin.xml
41 |
42 | # Crashlytics plugin (for Android Studio and IntelliJ)
43 | com_crashlytics_export_strings.xml
44 | crashlytics.properties
45 | crashlytics-build.properties
46 | fabric.properties
47 | ### Node template
48 | # Logs
49 | logs
50 | *.log
51 | npm-debug.log*
52 |
53 | # Runtime data
54 | pids
55 | *.pid
56 | *.seed
57 |
58 | # Directory for instrumented libs generated by jscoverage/JSCover
59 | lib-cov
60 |
61 | # Coverage directory used by tools like istanbul
62 | coverage
63 |
64 | # nyc test coverage
65 | .nyc_output
66 |
67 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
68 | .grunt
69 |
70 | # node-waf configuration
71 | .lock-wscript
72 |
73 | # Compiled binary addons (http://nodejs.org/api/addons.html)
74 | build/Release
75 |
76 | # Dependency directories
77 | node_modules
78 | jspm_packages
79 |
80 | # Optional npm cache directory
81 | .npm
82 |
83 | # Optional REPL history
84 | .node_repl_history
85 |
86 | # Sourcemap
87 | *.map
88 | .idea/encodings.xml
89 | .idea/misc.xml
90 | .idea/modules.xml
91 | .idea/typescript-compiler.xml
92 | .idea/watcherTasks.xml
93 | .idea/wx-compile-key.iml
94 |
--------------------------------------------------------------------------------
/typings/globals/es6-promise/index.d.ts:
--------------------------------------------------------------------------------
1 | // Generated by typings
2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/71c9d2336c0c802f89d530e07563e00b9ac07792/es6-promise/es6-promise.d.ts
3 | interface Thenable {
4 | then(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable;
5 | then(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: any) => void): Thenable;
6 | }
7 |
8 | declare class Promise implements Thenable {
9 | /**
10 | * If you call resolve in the body of the callback passed to the constructor,
11 | * your promise is fulfilled with result object passed to resolve.
12 | * If you call reject your promise is rejected with the object passed to reject.
13 | * For consistency and debugging (eg stack traces), obj should be an instanceof Error.
14 | * Any errors thrown in the constructor callback will be implicitly passed to reject().
15 | */
16 | constructor(callback: (resolve : (value?: T | Thenable) => void, reject: (error?: any) => void) => void);
17 |
18 | /**
19 | * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
20 | * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
21 | * Both callbacks have a single parameter , the fulfillment value or rejection reason.
22 | * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
23 | * If an error is thrown in the callback, the returned promise rejects with that error.
24 | *
25 | * @param onFulfilled called when/if "promise" resolves
26 | * @param onRejected called when/if "promise" rejects
27 | */
28 | then(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise;
29 | then(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: any) => void): Promise;
30 |
31 | /**
32 | * Sugar for promise.then(undefined, onRejected)
33 | *
34 | * @param onRejected called when/if "promise" rejects
35 | */
36 | catch(onRejected?: (error: any) => U | Thenable): Promise;
37 | }
38 |
39 | declare namespace Promise {
40 | /**
41 | * Make a new promise from the thenable.
42 | * A thenable is promise-like in as far as it has a "then" method.
43 | */
44 | function resolve(value?: T | Thenable): Promise;
45 |
46 | /**
47 | * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
48 | */
49 | function reject(error: any): Promise;
50 | function reject(error: T): Promise;
51 |
52 | /**
53 | * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
54 | * the array passed to all can be a mixture of promise-like objects and other objects.
55 | * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
56 | */
57 | function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable, T10 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
58 | function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
59 | function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
60 | function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
61 | function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6]>;
62 | function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable]): Promise<[T1, T2, T3, T4, T5]>;
63 | function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable ]): Promise<[T1, T2, T3, T4]>;
64 | function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable]): Promise<[T1, T2, T3]>;
65 | function all(values: [T1 | Thenable, T2 | Thenable]): Promise<[T1, T2]>;
66 | function all(values: (T | Thenable)[]): Promise;
67 |
68 | /**
69 | * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
70 | */
71 | function race(promises: (T | Thenable)[]): Promise;
72 | }
73 |
74 | declare module 'es6-promise' {
75 | var foo: typeof Promise; // Temp variable to reference Promise in local context
76 | namespace rsvp {
77 | export var Promise: typeof foo;
78 | export function polyfill(): void;
79 | }
80 | export = rsvp;
81 | }
82 |
--------------------------------------------------------------------------------
/typings/globals/request/index.d.ts:
--------------------------------------------------------------------------------
1 | // Generated by typings
2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/658d360c6a8611e76f7cc75c07fcd0f02055ffc4/request/request.d.ts
3 | declare module 'request' {
4 | import stream = require('stream');
5 | import http = require('http');
6 | import https = require('https');
7 | import url = require('url');
8 | import fs = require('fs');
9 | import FormData = require('form-data');
10 |
11 | namespace request {
12 | export interface RequestAPI {
15 |
16 | defaults(options: TOptions): RequestAPI;
17 | defaults(options: RequiredUriUrl & TOptions): DefaultUriUrlRequestApi;
18 |
19 | (uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
20 | (uri: string, callback?: RequestCallback): TRequest;
21 | (options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
22 |
23 | get(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
24 | get(uri: string, callback?: RequestCallback): TRequest;
25 | get(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
26 |
27 | post(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
28 | post(uri: string, callback?: RequestCallback): TRequest;
29 | post(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
30 |
31 | put(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
32 | put(uri: string, callback?: RequestCallback): TRequest;
33 | put(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
34 |
35 | head(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
36 | head(uri: string, callback?: RequestCallback): TRequest;
37 | head(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
38 |
39 | patch(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
40 | patch(uri: string, callback?: RequestCallback): TRequest;
41 | patch(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
42 |
43 | del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
44 | del(uri: string, callback?: RequestCallback): TRequest;
45 | del(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
46 |
47 | forever(agentOptions: any, optionsArg: any): TRequest;
48 | jar(): CookieJar;
49 | cookie(str: string): Cookie;
50 |
51 | initParams: any;
52 | debug: boolean;
53 | }
54 |
55 | interface DefaultUriUrlRequestApi extends RequestAPI {
58 |
59 | defaults(options: TOptions): DefaultUriUrlRequestApi;
60 | (): TRequest;
61 | get(): TRequest;
62 | post(): TRequest;
63 | put(): TRequest;
64 | head(): TRequest;
65 | patch(): TRequest;
66 | del(): TRequest;
67 | }
68 |
69 | interface CoreOptions {
70 | baseUrl?: string;
71 | callback?: (error: any, response: http.IncomingMessage, body: any) => void;
72 | jar?: any; // CookieJar
73 | formData?: any; // Object
74 | form?: any; // Object or string
75 | auth?: AuthOptions;
76 | oauth?: OAuthOptions;
77 | aws?: AWSOptions;
78 | hawk?: HawkOptions;
79 | qs?: any;
80 | json?: any;
81 | multipart?: RequestPart[] | Multipart;
82 | agent?: http.Agent | https.Agent;
83 | agentOptions?: any;
84 | agentClass?: any;
85 | forever?: any;
86 | host?: string;
87 | port?: number;
88 | method?: string;
89 | headers?: Headers;
90 | body?: any;
91 | followRedirect?: boolean | ((response: http.IncomingMessage) => boolean);
92 | followAllRedirects?: boolean;
93 | maxRedirects?: number;
94 | encoding?: string;
95 | pool?: any;
96 | timeout?: number;
97 | proxy?: any;
98 | strictSSL?: boolean;
99 | gzip?: boolean;
100 | preambleCRLF?: boolean;
101 | postambleCRLF?: boolean;
102 | key?: Buffer;
103 | cert?: Buffer;
104 | passphrase?: string;
105 | ca?: string | Buffer | string[] | Buffer[];
106 | har?: HttpArchiveRequest;
107 | useQuerystring?: boolean;
108 | }
109 |
110 | interface UriOptions {
111 | uri: string;
112 | }
113 | interface UrlOptions {
114 | url: string;
115 | }
116 | export type RequiredUriUrl = UriOptions | UrlOptions;
117 |
118 | interface OptionalUriUrl {
119 | uri?: string;
120 | url?: string;
121 | }
122 |
123 | export type OptionsWithUri = UriOptions & CoreOptions;
124 | export type OptionsWithUrl = UrlOptions & CoreOptions;
125 | export type Options = OptionsWithUri | OptionsWithUrl;
126 |
127 | export interface RequestCallback {
128 | (error: any, response: http.IncomingMessage, body: any): void;
129 | }
130 |
131 | export interface HttpArchiveRequest {
132 | url?: string;
133 | method?: string;
134 | headers?: NameValuePair[];
135 | postData?: {
136 | mimeType?: string;
137 | params?: NameValuePair[];
138 | }
139 | }
140 |
141 | export interface NameValuePair {
142 | name: string;
143 | value: string;
144 | }
145 |
146 | export interface Multipart {
147 | chunked?: boolean;
148 | data?: {
149 | 'content-type'?: string,
150 | body: string
151 | }[];
152 | }
153 |
154 | export interface RequestPart {
155 | headers?: Headers;
156 | body: any;
157 | }
158 |
159 | export interface Request extends stream.Stream {
160 | readable: boolean;
161 | writable: boolean;
162 |
163 | getAgent(): http.Agent;
164 | //start(): void;
165 | //abort(): void;
166 | pipeDest(dest: any): void;
167 | setHeader(name: string, value: string, clobber?: boolean): Request;
168 | setHeaders(headers: Headers): Request;
169 | qs(q: Object, clobber?: boolean): Request;
170 | form(): FormData;
171 | form(form: any): Request;
172 | multipart(multipart: RequestPart[]): Request;
173 | json(val: any): Request;
174 | aws(opts: AWSOptions, now?: boolean): Request;
175 | auth(username: string, password: string, sendInmediately?: boolean, bearer?: string): Request;
176 | oauth(oauth: OAuthOptions): Request;
177 | jar(jar: CookieJar): Request;
178 |
179 | on(event: string, listener: Function): this;
180 | on(event: 'request', listener: (req: http.ClientRequest) => void): this;
181 | on(event: 'response', listener: (resp: http.IncomingMessage) => void): this;
182 | on(event: 'data', listener: (data: Buffer | string) => void): this;
183 | on(event: 'error', listener: (e: Error) => void): this;
184 | on(event: 'complete', listener: (resp: http.IncomingMessage, body?: string | Buffer) => void): this;
185 |
186 | write(buffer: Buffer, cb?: Function): boolean;
187 | write(str: string, cb?: Function): boolean;
188 | write(str: string, encoding: string, cb?: Function): boolean;
189 | write(str: string, encoding?: string, fd?: string): boolean;
190 | end(): void;
191 | end(chunk: Buffer, cb?: Function): void;
192 | end(chunk: string, cb?: Function): void;
193 | end(chunk: string, encoding: string, cb?: Function): void;
194 | pause(): void;
195 | resume(): void;
196 | abort(): void;
197 | destroy(): void;
198 | toJSON(): Object;
199 | }
200 |
201 | export interface Headers {
202 | [key: string]: any;
203 | }
204 |
205 | export interface AuthOptions {
206 | user?: string;
207 | username?: string;
208 | pass?: string;
209 | password?: string;
210 | sendImmediately?: boolean;
211 | bearer?: string;
212 | }
213 |
214 | export interface OAuthOptions {
215 | callback?: string;
216 | consumer_key?: string;
217 | consumer_secret?: string;
218 | token?: string;
219 | token_secret?: string;
220 | verifier?: string;
221 | }
222 |
223 | export interface HawkOptions {
224 | credentials: any;
225 | }
226 |
227 | export interface AWSOptions {
228 | secret: string;
229 | bucket?: string;
230 | }
231 |
232 | export interface CookieJar {
233 | setCookie(cookie: Cookie, uri: string | url.Url, options?: any): void
234 | getCookieString(uri: string | url.Url): string
235 | getCookies(uri: string | url.Url): Cookie[]
236 | }
237 |
238 | export interface CookieValue {
239 | name: string;
240 | value: any;
241 | httpOnly: boolean;
242 | }
243 |
244 | export interface Cookie extends Array {
245 | constructor(name: string, req: Request): void;
246 | str: string;
247 | expires: Date;
248 | path: string;
249 | toString(): string;
250 | }
251 | }
252 | var request: request.RequestAPI;
253 | export = request;
254 | }
255 |
--------------------------------------------------------------------------------
/typings/globals/node/index.d.ts:
--------------------------------------------------------------------------------
1 | // Generated by typings
2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7be68adbdff4bea14f33f54f27d3bdb5822e3b10/node/node.d.ts
3 | interface Error {
4 | stack?: string;
5 | }
6 |
7 | interface ErrorConstructor {
8 | captureStackTrace(targetObject: Object, constructorOpt?: Function): void;
9 | stackTraceLimit: number;
10 | }
11 |
12 | // compat for TypeScript 1.8
13 | // if you use with --target es3 or --target es5 and use below definitions,
14 | // use the lib.es6.d.ts that is bundled with TypeScript 1.8.
15 | interface MapConstructor { }
16 | interface WeakMapConstructor { }
17 | interface SetConstructor { }
18 | interface WeakSetConstructor { }
19 |
20 | /************************************************
21 | * *
22 | * GLOBAL *
23 | * *
24 | ************************************************/
25 | declare var process: NodeJS.Process;
26 | declare var global: NodeJS.Global;
27 |
28 | declare var __filename: string;
29 | declare var __dirname: string;
30 |
31 | declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
32 | declare function clearTimeout(timeoutId: NodeJS.Timer): void;
33 | declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
34 | declare function clearInterval(intervalId: NodeJS.Timer): void;
35 | declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
36 | declare function clearImmediate(immediateId: any): void;
37 |
38 | interface NodeRequireFunction {
39 | (id: string): any;
40 | }
41 |
42 | interface NodeRequire extends NodeRequireFunction {
43 | resolve(id: string): string;
44 | cache: any;
45 | extensions: any;
46 | main: any;
47 | }
48 |
49 | declare var require: NodeRequire;
50 |
51 | interface NodeModule {
52 | exports: any;
53 | require: NodeRequireFunction;
54 | id: string;
55 | filename: string;
56 | loaded: boolean;
57 | parent: any;
58 | children: any[];
59 | }
60 |
61 | declare var module: NodeModule;
62 |
63 | // Same as module.exports
64 | declare var exports: any;
65 | declare var SlowBuffer: {
66 | new (str: string, encoding?: string): Buffer;
67 | new (size: number): Buffer;
68 | new (size: Uint8Array): Buffer;
69 | new (array: any[]): Buffer;
70 | prototype: Buffer;
71 | isBuffer(obj: any): boolean;
72 | byteLength(string: string, encoding?: string): number;
73 | concat(list: Buffer[], totalLength?: number): Buffer;
74 | };
75 |
76 |
77 | // Buffer class
78 | type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "binary" | "hex";
79 | interface Buffer extends NodeBuffer { }
80 |
81 | /**
82 | * Raw data is stored in instances of the Buffer class.
83 | * 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.
84 | * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
85 | */
86 | declare var Buffer: {
87 | /**
88 | * Allocates a new buffer containing the given {str}.
89 | *
90 | * @param str String to store in buffer.
91 | * @param encoding encoding to use, optional. Default is 'utf8'
92 | */
93 | new (str: string, encoding?: string): Buffer;
94 | /**
95 | * Allocates a new buffer of {size} octets.
96 | *
97 | * @param size count of octets to allocate.
98 | */
99 | new (size: number): Buffer;
100 | /**
101 | * Allocates a new buffer containing the given {array} of octets.
102 | *
103 | * @param array The octets to store.
104 | */
105 | new (array: Uint8Array): Buffer;
106 | /**
107 | * Produces a Buffer backed by the same allocated memory as
108 | * the given {ArrayBuffer}.
109 | *
110 | *
111 | * @param arrayBuffer The ArrayBuffer with which to share memory.
112 | */
113 | new (arrayBuffer: ArrayBuffer): Buffer;
114 | /**
115 | * Allocates a new buffer containing the given {array} of octets.
116 | *
117 | * @param array The octets to store.
118 | */
119 | new (array: any[]): Buffer;
120 | /**
121 | * Copies the passed {buffer} data onto a new {Buffer} instance.
122 | *
123 | * @param buffer The buffer to copy.
124 | */
125 | new (buffer: Buffer): Buffer;
126 | prototype: Buffer;
127 | /**
128 | * Allocates a new Buffer using an {array} of octets.
129 | *
130 | * @param array
131 | */
132 | from(array: any[]): Buffer;
133 | /**
134 | * When passed a reference to the .buffer property of a TypedArray instance,
135 | * the newly created Buffer will share the same allocated memory as the TypedArray.
136 | * The optional {byteOffset} and {length} arguments specify a memory range
137 | * within the {arrayBuffer} that will be shared by the Buffer.
138 | *
139 | * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
140 | * @param byteOffset
141 | * @param length
142 | */
143 | from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
144 | /**
145 | * Copies the passed {buffer} data onto a new Buffer instance.
146 | *
147 | * @param buffer
148 | */
149 | from(buffer: Buffer): Buffer;
150 | /**
151 | * Creates a new Buffer containing the given JavaScript string {str}.
152 | * If provided, the {encoding} parameter identifies the character encoding.
153 | * If not provided, {encoding} defaults to 'utf8'.
154 | *
155 | * @param str
156 | */
157 | from(str: string, encoding?: string): Buffer;
158 | /**
159 | * Returns true if {obj} is a Buffer
160 | *
161 | * @param obj object to test.
162 | */
163 | isBuffer(obj: any): obj is Buffer;
164 | /**
165 | * Returns true if {encoding} is a valid encoding argument.
166 | * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
167 | *
168 | * @param encoding string to test.
169 | */
170 | isEncoding(encoding: string): boolean;
171 | /**
172 | * Gives the actual byte length of a string. encoding defaults to 'utf8'.
173 | * This is not the same as String.prototype.length since that returns the number of characters in a string.
174 | *
175 | * @param string string to test.
176 | * @param encoding encoding used to evaluate (defaults to 'utf8')
177 | */
178 | byteLength(string: string, encoding?: string): number;
179 | /**
180 | * Returns a buffer which is the result of concatenating all the buffers in the list together.
181 | *
182 | * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
183 | * If the list has exactly one item, then the first item of the list is returned.
184 | * If the list has more than one item, then a new Buffer is created.
185 | *
186 | * @param list An array of Buffer objects to concatenate
187 | * @param totalLength Total length of the buffers when concatenated.
188 | * 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.
189 | */
190 | concat(list: Buffer[], totalLength?: number): Buffer;
191 | /**
192 | * The same as buf1.compare(buf2).
193 | */
194 | compare(buf1: Buffer, buf2: Buffer): number;
195 | /**
196 | * Allocates a new buffer of {size} octets.
197 | *
198 | * @param size count of octets to allocate.
199 | * @param fill if specified, buffer will be initialized by calling buf.fill(fill).
200 | * If parameter is omitted, buffer will be filled with zeros.
201 | * @param encoding encoding used for call to buf.fill while initalizing
202 | */
203 | alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
204 | /**
205 | * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
206 | * of the newly created Buffer are unknown and may contain sensitive data.
207 | *
208 | * @param size count of octets to allocate
209 | */
210 | allocUnsafe(size: number): Buffer;
211 | /**
212 | * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
213 | * of the newly created Buffer are unknown and may contain sensitive data.
214 | *
215 | * @param size count of octets to allocate
216 | */
217 | allocUnsafeSlow(size: number): Buffer;
218 | };
219 |
220 | /************************************************
221 | * *
222 | * GLOBAL INTERFACES *
223 | * *
224 | ************************************************/
225 | declare namespace NodeJS {
226 | export interface ErrnoException extends Error {
227 | errno?: string;
228 | code?: string;
229 | path?: string;
230 | syscall?: string;
231 | stack?: string;
232 | }
233 |
234 | export class EventEmitter {
235 | addListener(event: string | symbol, listener: Function): this;
236 | on(event: string | symbol, listener: Function): this;
237 | once(event: string | symbol, listener: Function): this;
238 | removeListener(event: string | symbol, listener: Function): this;
239 | removeAllListeners(event?: string | symbol): this;
240 | setMaxListeners(n: number): this;
241 | getMaxListeners(): number;
242 | listeners(event: string | symbol): Function[];
243 | emit(event: string | symbol, ...args: any[]): boolean;
244 | listenerCount(type: string | symbol): number;
245 | // Added in Node 6...
246 | prependListener(event: string | symbol, listener: Function): this;
247 | prependOnceListener(event: string | symbol, listener: Function): this;
248 | eventNames(): (string | symbol)[];
249 | }
250 |
251 | export interface ReadableStream extends EventEmitter {
252 | readable: boolean;
253 | read(size?: number): string | Buffer;
254 | setEncoding(encoding: string): void;
255 | pause(): ReadableStream;
256 | resume(): ReadableStream;
257 | pipe(destination: T, options?: { end?: boolean; }): T;
258 | unpipe(destination?: T): void;
259 | unshift(chunk: string): void;
260 | unshift(chunk: Buffer): void;
261 | wrap(oldStream: ReadableStream): ReadableStream;
262 | }
263 |
264 | export interface WritableStream extends EventEmitter {
265 | writable: boolean;
266 | write(buffer: Buffer | string, cb?: Function): boolean;
267 | write(str: string, encoding?: string, cb?: Function): boolean;
268 | end(): void;
269 | end(buffer: Buffer, cb?: Function): void;
270 | end(str: string, cb?: Function): void;
271 | end(str: string, encoding?: string, cb?: Function): void;
272 | }
273 |
274 | export interface ReadWriteStream extends ReadableStream, WritableStream {
275 | pause(): ReadWriteStream;
276 | resume(): ReadWriteStream;
277 | }
278 |
279 | export interface Events extends EventEmitter { }
280 |
281 | export interface Domain extends Events {
282 | run(fn: Function): void;
283 | add(emitter: Events): void;
284 | remove(emitter: Events): void;
285 | bind(cb: (err: Error, data: any) => any): any;
286 | intercept(cb: (data: any) => any): any;
287 | dispose(): void;
288 |
289 | addListener(event: string, listener: Function): this;
290 | on(event: string, listener: Function): this;
291 | once(event: string, listener: Function): this;
292 | removeListener(event: string, listener: Function): this;
293 | removeAllListeners(event?: string): this;
294 | }
295 |
296 | export interface MemoryUsage {
297 | rss: number;
298 | heapTotal: number;
299 | heapUsed: number;
300 | }
301 |
302 | export interface ProcessVersions {
303 | http_parser: string;
304 | node: string;
305 | v8: string;
306 | ares: string;
307 | uv: string;
308 | zlib: string;
309 | modules: string;
310 | openssl: string;
311 | }
312 |
313 | export interface Process extends EventEmitter {
314 | stdout: WritableStream;
315 | stderr: WritableStream;
316 | stdin: ReadableStream;
317 | argv: string[];
318 | execArgv: string[];
319 | execPath: string;
320 | abort(): void;
321 | chdir(directory: string): void;
322 | cwd(): string;
323 | env: any;
324 | exit(code?: number): void;
325 | exitCode: number;
326 | getgid(): number;
327 | setgid(id: number): void;
328 | setgid(id: string): void;
329 | getuid(): number;
330 | setuid(id: number): void;
331 | setuid(id: string): void;
332 | version: string;
333 | versions: ProcessVersions;
334 | config: {
335 | target_defaults: {
336 | cflags: any[];
337 | default_configuration: string;
338 | defines: string[];
339 | include_dirs: string[];
340 | libraries: string[];
341 | };
342 | variables: {
343 | clang: number;
344 | host_arch: string;
345 | node_install_npm: boolean;
346 | node_install_waf: boolean;
347 | node_prefix: string;
348 | node_shared_openssl: boolean;
349 | node_shared_v8: boolean;
350 | node_shared_zlib: boolean;
351 | node_use_dtrace: boolean;
352 | node_use_etw: boolean;
353 | node_use_openssl: boolean;
354 | target_arch: string;
355 | v8_no_strict_aliasing: number;
356 | v8_use_snapshot: boolean;
357 | visibility: string;
358 | };
359 | };
360 | kill(pid: number, signal?: string | number): void;
361 | pid: number;
362 | title: string;
363 | arch: string;
364 | platform: string;
365 | memoryUsage(): MemoryUsage;
366 | nextTick(callback: Function, ...args: any[]): void;
367 | umask(mask?: number): number;
368 | uptime(): number;
369 | hrtime(time?: number[]): number[];
370 | domain: Domain;
371 |
372 | // Worker
373 | send?(message: any, sendHandle?: any): void;
374 | disconnect(): void;
375 | connected: boolean;
376 | }
377 |
378 | export interface Global {
379 | Array: typeof Array;
380 | ArrayBuffer: typeof ArrayBuffer;
381 | Boolean: typeof Boolean;
382 | Buffer: typeof Buffer;
383 | DataView: typeof DataView;
384 | Date: typeof Date;
385 | Error: typeof Error;
386 | EvalError: typeof EvalError;
387 | Float32Array: typeof Float32Array;
388 | Float64Array: typeof Float64Array;
389 | Function: typeof Function;
390 | GLOBAL: Global;
391 | Infinity: typeof Infinity;
392 | Int16Array: typeof Int16Array;
393 | Int32Array: typeof Int32Array;
394 | Int8Array: typeof Int8Array;
395 | Intl: typeof Intl;
396 | JSON: typeof JSON;
397 | Map: MapConstructor;
398 | Math: typeof Math;
399 | NaN: typeof NaN;
400 | Number: typeof Number;
401 | Object: typeof Object;
402 | Promise: Function;
403 | RangeError: typeof RangeError;
404 | ReferenceError: typeof ReferenceError;
405 | RegExp: typeof RegExp;
406 | Set: SetConstructor;
407 | String: typeof String;
408 | Symbol: Function;
409 | SyntaxError: typeof SyntaxError;
410 | TypeError: typeof TypeError;
411 | URIError: typeof URIError;
412 | Uint16Array: typeof Uint16Array;
413 | Uint32Array: typeof Uint32Array;
414 | Uint8Array: typeof Uint8Array;
415 | Uint8ClampedArray: Function;
416 | WeakMap: WeakMapConstructor;
417 | WeakSet: WeakSetConstructor;
418 | clearImmediate: (immediateId: any) => void;
419 | clearInterval: (intervalId: NodeJS.Timer) => void;
420 | clearTimeout: (timeoutId: NodeJS.Timer) => void;
421 | console: typeof console;
422 | decodeURI: typeof decodeURI;
423 | decodeURIComponent: typeof decodeURIComponent;
424 | encodeURI: typeof encodeURI;
425 | encodeURIComponent: typeof encodeURIComponent;
426 | escape: (str: string) => string;
427 | eval: typeof eval;
428 | global: Global;
429 | isFinite: typeof isFinite;
430 | isNaN: typeof isNaN;
431 | parseFloat: typeof parseFloat;
432 | parseInt: typeof parseInt;
433 | process: Process;
434 | root: Global;
435 | setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any;
436 | setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
437 | setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
438 | undefined: typeof undefined;
439 | unescape: (str: string) => string;
440 | gc: () => void;
441 | v8debug?: any;
442 | }
443 |
444 | export interface Timer {
445 | ref(): void;
446 | unref(): void;
447 | }
448 | }
449 |
450 | interface IterableIterator { }
451 |
452 | /**
453 | * @deprecated
454 | */
455 | interface NodeBuffer extends Uint8Array {
456 | write(string: string, offset?: number, length?: number, encoding?: string): number;
457 | toString(encoding?: string, start?: number, end?: number): string;
458 | toJSON(): { type: 'Buffer', data: any[] };
459 | equals(otherBuffer: Buffer): boolean;
460 | compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
461 | copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
462 | slice(start?: number, end?: number): Buffer;
463 | writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
464 | writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
465 | writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
466 | writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
467 | readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
468 | readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
469 | readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
470 | readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
471 | readUInt8(offset: number, noAssert?: boolean): number;
472 | readUInt16LE(offset: number, noAssert?: boolean): number;
473 | readUInt16BE(offset: number, noAssert?: boolean): number;
474 | readUInt32LE(offset: number, noAssert?: boolean): number;
475 | readUInt32BE(offset: number, noAssert?: boolean): number;
476 | readInt8(offset: number, noAssert?: boolean): number;
477 | readInt16LE(offset: number, noAssert?: boolean): number;
478 | readInt16BE(offset: number, noAssert?: boolean): number;
479 | readInt32LE(offset: number, noAssert?: boolean): number;
480 | readInt32BE(offset: number, noAssert?: boolean): number;
481 | readFloatLE(offset: number, noAssert?: boolean): number;
482 | readFloatBE(offset: number, noAssert?: boolean): number;
483 | readDoubleLE(offset: number, noAssert?: boolean): number;
484 | readDoubleBE(offset: number, noAssert?: boolean): number;
485 | swap16(): Buffer;
486 | swap32(): Buffer;
487 | swap64(): Buffer;
488 | writeUInt8(value: number, offset: number, noAssert?: boolean): number;
489 | writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
490 | writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
491 | writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
492 | writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
493 | writeInt8(value: number, offset: number, noAssert?: boolean): number;
494 | writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
495 | writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
496 | writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
497 | writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
498 | writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
499 | writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
500 | writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
501 | writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
502 | fill(value: any, offset?: number, end?: number): this;
503 | indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
504 | lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
505 | entries(): IterableIterator<[number, number]>;
506 | includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;
507 | keys(): IterableIterator;
508 | values(): IterableIterator;
509 | }
510 |
511 | /************************************************
512 | * *
513 | * MODULES *
514 | * *
515 | ************************************************/
516 | declare module "buffer" {
517 | export var INSPECT_MAX_BYTES: number;
518 | var BuffType: typeof Buffer;
519 | var SlowBuffType: typeof SlowBuffer;
520 | export { BuffType as Buffer, SlowBuffType as SlowBuffer };
521 | }
522 |
523 | declare module "querystring" {
524 | export interface StringifyOptions {
525 | encodeURIComponent?: Function;
526 | }
527 |
528 | export interface ParseOptions {
529 | maxKeys?: number;
530 | decodeURIComponent?: Function;
531 | }
532 |
533 | export function stringify(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string;
534 | export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any;
535 | export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): T;
536 | export function escape(str: string): string;
537 | export function unescape(str: string): string;
538 | }
539 |
540 | declare module "events" {
541 | export class EventEmitter extends NodeJS.EventEmitter {
542 | static EventEmitter: EventEmitter;
543 | static listenerCount(emitter: EventEmitter, event: string | symbol): number; // deprecated
544 | static defaultMaxListeners: number;
545 |
546 | addListener(event: string | symbol, listener: Function): this;
547 | on(event: string | symbol, listener: Function): this;
548 | once(event: string | symbol, listener: Function): this;
549 | prependListener(event: string | symbol, listener: Function): this;
550 | prependOnceListener(event: string | symbol, listener: Function): this;
551 | removeListener(event: string | symbol, listener: Function): this;
552 | removeAllListeners(event?: string | symbol): this;
553 | setMaxListeners(n: number): this;
554 | getMaxListeners(): number;
555 | listeners(event: string | symbol): Function[];
556 | emit(event: string | symbol, ...args: any[]): boolean;
557 | eventNames(): (string | symbol)[];
558 | listenerCount(type: string | symbol): number;
559 | }
560 | }
561 |
562 | declare module "http" {
563 | import * as events from "events";
564 | import * as net from "net";
565 | import * as stream from "stream";
566 |
567 | export interface RequestOptions {
568 | protocol?: string;
569 | host?: string;
570 | hostname?: string;
571 | family?: number;
572 | port?: number;
573 | localAddress?: string;
574 | socketPath?: string;
575 | method?: string;
576 | path?: string;
577 | headers?: { [key: string]: any };
578 | auth?: string;
579 | agent?: Agent | boolean;
580 | }
581 |
582 | export interface Server extends net.Server {
583 | setTimeout(msecs: number, callback: Function): void;
584 | maxHeadersCount: number;
585 | timeout: number;
586 | listening: boolean;
587 | }
588 | /**
589 | * @deprecated Use IncomingMessage
590 | */
591 | export interface ServerRequest extends IncomingMessage {
592 | connection: net.Socket;
593 | }
594 | export interface ServerResponse extends stream.Writable {
595 | // Extended base methods
596 | write(buffer: Buffer): boolean;
597 | write(buffer: Buffer, cb?: Function): boolean;
598 | write(str: string, cb?: Function): boolean;
599 | write(str: string, encoding?: string, cb?: Function): boolean;
600 | write(str: string, encoding?: string, fd?: string): boolean;
601 |
602 | writeContinue(): void;
603 | writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void;
604 | writeHead(statusCode: number, headers?: any): void;
605 | statusCode: number;
606 | statusMessage: string;
607 | headersSent: boolean;
608 | setHeader(name: string, value: string | string[]): void;
609 | setTimeout(msecs: number, callback: Function): ServerResponse;
610 | sendDate: boolean;
611 | getHeader(name: string): string;
612 | removeHeader(name: string): void;
613 | write(chunk: any, encoding?: string): any;
614 | addTrailers(headers: any): void;
615 | finished: boolean;
616 |
617 | // Extended base methods
618 | end(): void;
619 | end(buffer: Buffer, cb?: Function): void;
620 | end(str: string, cb?: Function): void;
621 | end(str: string, encoding?: string, cb?: Function): void;
622 | end(data?: any, encoding?: string): void;
623 | }
624 | export interface ClientRequest extends stream.Writable {
625 | // Extended base methods
626 | write(buffer: Buffer): boolean;
627 | write(buffer: Buffer, cb?: Function): boolean;
628 | write(str: string, cb?: Function): boolean;
629 | write(str: string, encoding?: string, cb?: Function): boolean;
630 | write(str: string, encoding?: string, fd?: string): boolean;
631 |
632 | write(chunk: any, encoding?: string): void;
633 | abort(): void;
634 | setTimeout(timeout: number, callback?: Function): void;
635 | setNoDelay(noDelay?: boolean): void;
636 | setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
637 |
638 | setHeader(name: string, value: string | string[]): void;
639 | getHeader(name: string): string;
640 | removeHeader(name: string): void;
641 | addTrailers(headers: any): void;
642 |
643 | // Extended base methods
644 | end(): void;
645 | end(buffer: Buffer, cb?: Function): void;
646 | end(str: string, cb?: Function): void;
647 | end(str: string, encoding?: string, cb?: Function): void;
648 | end(data?: any, encoding?: string): void;
649 | }
650 | export interface IncomingMessage extends stream.Readable {
651 | httpVersion: string;
652 | httpVersionMajor: number;
653 | httpVersionMinor: number;
654 | connection: net.Socket;
655 | headers: any;
656 | rawHeaders: string[];
657 | trailers: any;
658 | rawTrailers: any;
659 | setTimeout(msecs: number, callback: Function): NodeJS.Timer;
660 | /**
661 | * Only valid for request obtained from http.Server.
662 | */
663 | method?: string;
664 | /**
665 | * Only valid for request obtained from http.Server.
666 | */
667 | url?: string;
668 | /**
669 | * Only valid for response obtained from http.ClientRequest.
670 | */
671 | statusCode?: number;
672 | /**
673 | * Only valid for response obtained from http.ClientRequest.
674 | */
675 | statusMessage?: string;
676 | socket: net.Socket;
677 | destroy(error?: Error): void;
678 | }
679 | /**
680 | * @deprecated Use IncomingMessage
681 | */
682 | export interface ClientResponse extends IncomingMessage { }
683 |
684 | export interface AgentOptions {
685 | /**
686 | * Keep sockets around in a pool to be used by other requests in the future. Default = false
687 | */
688 | keepAlive?: boolean;
689 | /**
690 | * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000.
691 | * Only relevant if keepAlive is set to true.
692 | */
693 | keepAliveMsecs?: number;
694 | /**
695 | * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
696 | */
697 | maxSockets?: number;
698 | /**
699 | * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256.
700 | */
701 | maxFreeSockets?: number;
702 | }
703 |
704 | export class Agent {
705 | maxSockets: number;
706 | sockets: any;
707 | requests: any;
708 |
709 | constructor(opts?: AgentOptions);
710 |
711 | /**
712 | * Destroy any sockets that are currently in use by the agent.
713 | * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled,
714 | * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise,
715 | * sockets may hang open for quite a long time before the server terminates them.
716 | */
717 | destroy(): void;
718 | }
719 |
720 | export var METHODS: string[];
721 |
722 | export var STATUS_CODES: {
723 | [errorCode: number]: string;
724 | [errorCode: string]: string;
725 | };
726 | export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server;
727 | export function createClient(port?: number, host?: string): any;
728 | export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
729 | export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest;
730 | export var globalAgent: Agent;
731 | }
732 |
733 | declare module "cluster" {
734 | import * as child from "child_process";
735 | import * as events from "events";
736 | import * as net from "net";
737 |
738 | // interfaces
739 | export interface ClusterSettings {
740 | execArgv?: string[]; // default: process.execArgv
741 | exec?: string;
742 | args?: string[];
743 | silent?: boolean;
744 | stdio?: any[];
745 | uid?: number;
746 | gid?: number;
747 | }
748 |
749 | export interface ClusterSetupMasterSettings {
750 | exec?: string; // default: process.argv[1]
751 | args?: string[]; // default: process.argv.slice(2)
752 | silent?: boolean; // default: false
753 | stdio?: any[];
754 | }
755 |
756 | export interface Address {
757 | address: string;
758 | port: number;
759 | addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6"
760 | }
761 |
762 | export class Worker extends events.EventEmitter {
763 | id: string;
764 | process: child.ChildProcess;
765 | suicide: boolean;
766 | send(message: any, sendHandle?: any): boolean;
767 | kill(signal?: string): void;
768 | destroy(signal?: string): void;
769 | disconnect(): void;
770 | isConnected(): boolean;
771 | isDead(): boolean;
772 | exitedAfterDisconnect: boolean;
773 |
774 | /**
775 | * events.EventEmitter
776 | * 1. disconnect
777 | * 2. error
778 | * 3. exit
779 | * 4. listening
780 | * 5. message
781 | * 6. online
782 | */
783 | addListener(event: string, listener: Function): this;
784 | addListener(event: "disconnect", listener: () => void): this;
785 | addListener(event: "error", listener: (code: number, signal: string) => void): this;
786 | addListener(event: "exit", listener: (code: number, signal: string) => void): this;
787 | addListener(event: "listening", listener: (address: Address) => void): this;
788 | 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.
789 | addListener(event: "online", listener: () => void): this;
790 |
791 | emit(event: string, listener: Function): boolean
792 | emit(event: "disconnect", listener: () => void): boolean
793 | emit(event: "error", listener: (code: number, signal: string) => void): boolean
794 | emit(event: "exit", listener: (code: number, signal: string) => void): boolean
795 | emit(event: "listening", listener: (address: Address) => void): boolean
796 | emit(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): boolean
797 | emit(event: "online", listener: () => void): boolean
798 |
799 | on(event: string, listener: Function): this;
800 | on(event: "disconnect", listener: () => void): this;
801 | on(event: "error", listener: (code: number, signal: string) => void): this;
802 | on(event: "exit", listener: (code: number, signal: string) => void): this;
803 | on(event: "listening", listener: (address: Address) => void): this;
804 | 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.
805 | on(event: "online", listener: () => void): this;
806 |
807 | once(event: string, listener: Function): this;
808 | once(event: "disconnect", listener: () => void): this;
809 | once(event: "error", listener: (code: number, signal: string) => void): this;
810 | once(event: "exit", listener: (code: number, signal: string) => void): this;
811 | once(event: "listening", listener: (address: Address) => void): this;
812 | 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.
813 | once(event: "online", listener: () => void): this;
814 |
815 | prependListener(event: string, listener: Function): this;
816 | prependListener(event: "disconnect", listener: () => void): this;
817 | prependListener(event: "error", listener: (code: number, signal: string) => void): this;
818 | prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
819 | prependListener(event: "listening", listener: (address: Address) => void): this;
820 | 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.
821 | prependListener(event: "online", listener: () => void): this;
822 |
823 | prependOnceListener(event: string, listener: Function): this;
824 | prependOnceListener(event: "disconnect", listener: () => void): this;
825 | prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this;
826 | prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
827 | prependOnceListener(event: "listening", listener: (address: Address) => void): this;
828 | 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.
829 | prependOnceListener(event: "online", listener: () => void): this;
830 | }
831 |
832 | export interface Cluster extends events.EventEmitter {
833 | Worker: Worker;
834 | disconnect(callback?: Function): void;
835 | fork(env?: any): Worker;
836 | isMaster: boolean;
837 | isWorker: boolean;
838 | // TODO: cluster.schedulingPolicy
839 | settings: ClusterSettings;
840 | setupMaster(settings?: ClusterSetupMasterSettings): void;
841 | worker: Worker;
842 | workers: {
843 | [index: string]: Worker
844 | };
845 |
846 | /**
847 | * events.EventEmitter
848 | * 1. disconnect
849 | * 2. exit
850 | * 3. fork
851 | * 4. listening
852 | * 5. message
853 | * 6. online
854 | * 7. setup
855 | */
856 | addListener(event: string, listener: Function): this;
857 | addListener(event: "disconnect", listener: (worker: Worker) => void): this;
858 | addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
859 | addListener(event: "fork", listener: (worker: Worker) => void): this;
860 | addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
861 | 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.
862 | addListener(event: "online", listener: (worker: Worker) => void): this;
863 | addListener(event: "setup", listener: (settings: any) => void): this;
864 |
865 | emit(event: string, listener: Function): boolean;
866 | emit(event: "disconnect", listener: (worker: Worker) => void): boolean;
867 | emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean;
868 | emit(event: "fork", listener: (worker: Worker) => void): boolean;
869 | emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean;
870 | emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean;
871 | emit(event: "online", listener: (worker: Worker) => void): boolean;
872 | emit(event: "setup", listener: (settings: any) => void): boolean;
873 |
874 | on(event: string, listener: Function): this;
875 | on(event: "disconnect", listener: (worker: Worker) => void): this;
876 | on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
877 | on(event: "fork", listener: (worker: Worker) => void): this;
878 | on(event: "listening", listener: (worker: Worker, address: Address) => void): this;
879 | 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.
880 | on(event: "online", listener: (worker: Worker) => void): this;
881 | on(event: "setup", listener: (settings: any) => void): this;
882 |
883 | once(event: string, listener: Function): this;
884 | once(event: "disconnect", listener: (worker: Worker) => void): this;
885 | once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
886 | once(event: "fork", listener: (worker: Worker) => void): this;
887 | once(event: "listening", listener: (worker: Worker, address: Address) => void): this;
888 | 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.
889 | once(event: "online", listener: (worker: Worker) => void): this;
890 | once(event: "setup", listener: (settings: any) => void): this;
891 |
892 | prependListener(event: string, listener: Function): this;
893 | prependListener(event: "disconnect", listener: (worker: Worker) => void): this;
894 | prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
895 | prependListener(event: "fork", listener: (worker: Worker) => void): this;
896 | prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
897 | 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.
898 | prependListener(event: "online", listener: (worker: Worker) => void): this;
899 | prependListener(event: "setup", listener: (settings: any) => void): this;
900 |
901 | prependOnceListener(event: string, listener: Function): this;
902 | prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this;
903 | prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
904 | prependOnceListener(event: "fork", listener: (worker: Worker) => void): this;
905 | prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
906 | 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.
907 | prependOnceListener(event: "online", listener: (worker: Worker) => void): this;
908 | prependOnceListener(event: "setup", listener: (settings: any) => void): this;
909 |
910 | }
911 |
912 | export function disconnect(callback?: Function): void;
913 | export function fork(env?: any): Worker;
914 | export var isMaster: boolean;
915 | export var isWorker: boolean;
916 | // TODO: cluster.schedulingPolicy
917 | export var settings: ClusterSettings;
918 | export function setupMaster(settings?: ClusterSetupMasterSettings): void;
919 | export var worker: Worker;
920 | export var workers: {
921 | [index: string]: Worker
922 | };
923 |
924 | /**
925 | * events.EventEmitter
926 | * 1. disconnect
927 | * 2. exit
928 | * 3. fork
929 | * 4. listening
930 | * 5. message
931 | * 6. online
932 | * 7. setup
933 | */
934 | export function addListener(event: string, listener: Function): Cluster;
935 | export function addListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
936 | export function addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
937 | export function addListener(event: "fork", listener: (worker: Worker) => void): Cluster;
938 | export function addListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
939 | 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.
940 | export function addListener(event: "online", listener: (worker: Worker) => void): Cluster;
941 | export function addListener(event: "setup", listener: (settings: any) => void): Cluster;
942 |
943 | export function emit(event: string, listener: Function): boolean;
944 | export function emit(event: "disconnect", listener: (worker: Worker) => void): boolean;
945 | export function emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean;
946 | export function emit(event: "fork", listener: (worker: Worker) => void): boolean;
947 | export function emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean;
948 | export function emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean;
949 | export function emit(event: "online", listener: (worker: Worker) => void): boolean;
950 | export function emit(event: "setup", listener: (settings: any) => void): boolean;
951 |
952 | export function on(event: string, listener: Function): Cluster;
953 | export function on(event: "disconnect", listener: (worker: Worker) => void): Cluster;
954 | export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
955 | export function on(event: "fork", listener: (worker: Worker) => void): Cluster;
956 | export function on(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
957 | 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.
958 | export function on(event: "online", listener: (worker: Worker) => void): Cluster;
959 | export function on(event: "setup", listener: (settings: any) => void): Cluster;
960 |
961 | export function once(event: string, listener: Function): Cluster;
962 | export function once(event: "disconnect", listener: (worker: Worker) => void): Cluster;
963 | export function once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
964 | export function once(event: "fork", listener: (worker: Worker) => void): Cluster;
965 | export function once(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
966 | 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.
967 | export function once(event: "online", listener: (worker: Worker) => void): Cluster;
968 | export function once(event: "setup", listener: (settings: any) => void): Cluster;
969 |
970 | export function removeListener(event: string, listener: Function): Cluster;
971 | export function removeAllListeners(event?: string): Cluster;
972 | export function setMaxListeners(n: number): Cluster;
973 | export function getMaxListeners(): number;
974 | export function listeners(event: string): Function[];
975 | export function listenerCount(type: string): number;
976 |
977 | export function prependListener(event: string, listener: Function): Cluster;
978 | export function prependListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
979 | export function prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
980 | export function prependListener(event: "fork", listener: (worker: Worker) => void): Cluster;
981 | export function prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
982 | 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.
983 | export function prependListener(event: "online", listener: (worker: Worker) => void): Cluster;
984 | export function prependListener(event: "setup", listener: (settings: any) => void): Cluster;
985 |
986 | export function prependOnceListener(event: string, listener: Function): Cluster;
987 | export function prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
988 | export function prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
989 | export function prependOnceListener(event: "fork", listener: (worker: Worker) => void): Cluster;
990 | export function prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
991 | 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.
992 | export function prependOnceListener(event: "online", listener: (worker: Worker) => void): Cluster;
993 | export function prependOnceListener(event: "setup", listener: (settings: any) => void): Cluster;
994 |
995 | export function eventNames(): string[];
996 | }
997 |
998 | declare module "zlib" {
999 | import * as stream from "stream";
1000 | export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; }
1001 |
1002 | export interface Gzip extends stream.Transform { }
1003 | export interface Gunzip extends stream.Transform { }
1004 | export interface Deflate extends stream.Transform { }
1005 | export interface Inflate extends stream.Transform { }
1006 | export interface DeflateRaw extends stream.Transform { }
1007 | export interface InflateRaw extends stream.Transform { }
1008 | export interface Unzip extends stream.Transform { }
1009 |
1010 | export function createGzip(options?: ZlibOptions): Gzip;
1011 | export function createGunzip(options?: ZlibOptions): Gunzip;
1012 | export function createDeflate(options?: ZlibOptions): Deflate;
1013 | export function createInflate(options?: ZlibOptions): Inflate;
1014 | export function createDeflateRaw(options?: ZlibOptions): DeflateRaw;
1015 | export function createInflateRaw(options?: ZlibOptions): InflateRaw;
1016 | export function createUnzip(options?: ZlibOptions): Unzip;
1017 |
1018 | export function deflate(buf: Buffer, callback: (error: Error, result: any) => void): void;
1019 | export function deflateSync(buf: Buffer, options?: ZlibOptions): any;
1020 | export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) => void): void;
1021 | export function deflateRawSync(buf: Buffer, options?: ZlibOptions): any;
1022 | export function gzip(buf: Buffer, callback: (error: Error, result: any) => void): void;
1023 | export function gzipSync(buf: Buffer, options?: ZlibOptions): any;
1024 | export function gunzip(buf: Buffer, callback: (error: Error, result: any) => void): void;
1025 | export function gunzipSync(buf: Buffer, options?: ZlibOptions): any;
1026 | export function inflate(buf: Buffer, callback: (error: Error, result: any) => void): void;
1027 | export function inflateSync(buf: Buffer, options?: ZlibOptions): any;
1028 | export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) => void): void;
1029 | export function inflateRawSync(buf: Buffer, options?: ZlibOptions): any;
1030 | export function unzip(buf: Buffer, callback: (error: Error, result: any) => void): void;
1031 | export function unzipSync(buf: Buffer, options?: ZlibOptions): any;
1032 |
1033 | // Constants
1034 | export var Z_NO_FLUSH: number;
1035 | export var Z_PARTIAL_FLUSH: number;
1036 | export var Z_SYNC_FLUSH: number;
1037 | export var Z_FULL_FLUSH: number;
1038 | export var Z_FINISH: number;
1039 | export var Z_BLOCK: number;
1040 | export var Z_TREES: number;
1041 | export var Z_OK: number;
1042 | export var Z_STREAM_END: number;
1043 | export var Z_NEED_DICT: number;
1044 | export var Z_ERRNO: number;
1045 | export var Z_STREAM_ERROR: number;
1046 | export var Z_DATA_ERROR: number;
1047 | export var Z_MEM_ERROR: number;
1048 | export var Z_BUF_ERROR: number;
1049 | export var Z_VERSION_ERROR: number;
1050 | export var Z_NO_COMPRESSION: number;
1051 | export var Z_BEST_SPEED: number;
1052 | export var Z_BEST_COMPRESSION: number;
1053 | export var Z_DEFAULT_COMPRESSION: number;
1054 | export var Z_FILTERED: number;
1055 | export var Z_HUFFMAN_ONLY: number;
1056 | export var Z_RLE: number;
1057 | export var Z_FIXED: number;
1058 | export var Z_DEFAULT_STRATEGY: number;
1059 | export var Z_BINARY: number;
1060 | export var Z_TEXT: number;
1061 | export var Z_ASCII: number;
1062 | export var Z_UNKNOWN: number;
1063 | export var Z_DEFLATED: number;
1064 | export var Z_NULL: number;
1065 | }
1066 |
1067 | declare module "os" {
1068 | export interface CpuInfo {
1069 | model: string;
1070 | speed: number;
1071 | times: {
1072 | user: number;
1073 | nice: number;
1074 | sys: number;
1075 | idle: number;
1076 | irq: number;
1077 | };
1078 | }
1079 |
1080 | export interface NetworkInterfaceInfo {
1081 | address: string;
1082 | netmask: string;
1083 | family: string;
1084 | mac: string;
1085 | internal: boolean;
1086 | }
1087 |
1088 | export function hostname(): string;
1089 | export function loadavg(): number[];
1090 | export function uptime(): number;
1091 | export function freemem(): number;
1092 | export function totalmem(): number;
1093 | export function cpus(): CpuInfo[];
1094 | export function type(): string;
1095 | export function release(): string;
1096 | export function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] };
1097 | export function homedir(): string;
1098 | export function userInfo(options?: { encoding: string }): { username: string, uid: number, gid: number, shell: any, homedir: string }
1099 | export var constants: {
1100 | UV_UDP_REUSEADDR: number,
1101 | errno: {
1102 | SIGHUP: number;
1103 | SIGINT: number;
1104 | SIGQUIT: number;
1105 | SIGILL: number;
1106 | SIGTRAP: number;
1107 | SIGABRT: number;
1108 | SIGIOT: number;
1109 | SIGBUS: number;
1110 | SIGFPE: number;
1111 | SIGKILL: number;
1112 | SIGUSR1: number;
1113 | SIGSEGV: number;
1114 | SIGUSR2: number;
1115 | SIGPIPE: number;
1116 | SIGALRM: number;
1117 | SIGTERM: number;
1118 | SIGCHLD: number;
1119 | SIGSTKFLT: number;
1120 | SIGCONT: number;
1121 | SIGSTOP: number;
1122 | SIGTSTP: number;
1123 | SIGTTIN: number;
1124 | SIGTTOU: number;
1125 | SIGURG: number;
1126 | SIGXCPU: number;
1127 | SIGXFSZ: number;
1128 | SIGVTALRM: number;
1129 | SIGPROF: number;
1130 | SIGWINCH: number;
1131 | SIGIO: number;
1132 | SIGPOLL: number;
1133 | SIGPWR: number;
1134 | SIGSYS: number;
1135 | SIGUNUSED: number;
1136 | },
1137 | signals: {
1138 | E2BIG: number;
1139 | EACCES: number;
1140 | EADDRINUSE: number;
1141 | EADDRNOTAVAIL: number;
1142 | EAFNOSUPPORT: number;
1143 | EAGAIN: number;
1144 | EALREADY: number;
1145 | EBADF: number;
1146 | EBADMSG: number;
1147 | EBUSY: number;
1148 | ECANCELED: number;
1149 | ECHILD: number;
1150 | ECONNABORTED: number;
1151 | ECONNREFUSED: number;
1152 | ECONNRESET: number;
1153 | EDEADLK: number;
1154 | EDESTADDRREQ: number;
1155 | EDOM: number;
1156 | EDQUOT: number;
1157 | EEXIST: number;
1158 | EFAULT: number;
1159 | EFBIG: number;
1160 | EHOSTUNREACH: number;
1161 | EIDRM: number;
1162 | EILSEQ: number;
1163 | EINPROGRESS: number;
1164 | EINTR: number;
1165 | EINVAL: number;
1166 | EIO: number;
1167 | EISCONN: number;
1168 | EISDIR: number;
1169 | ELOOP: number;
1170 | EMFILE: number;
1171 | EMLINK: number;
1172 | EMSGSIZE: number;
1173 | EMULTIHOP: number;
1174 | ENAMETOOLONG: number;
1175 | ENETDOWN: number;
1176 | ENETRESET: number;
1177 | ENETUNREACH: number;
1178 | ENFILE: number;
1179 | ENOBUFS: number;
1180 | ENODATA: number;
1181 | ENODEV: number;
1182 | ENOENT: number;
1183 | ENOEXEC: number;
1184 | ENOLCK: number;
1185 | ENOLINK: number;
1186 | ENOMEM: number;
1187 | ENOMSG: number;
1188 | ENOPROTOOPT: number;
1189 | ENOSPC: number;
1190 | ENOSR: number;
1191 | ENOSTR: number;
1192 | ENOSYS: number;
1193 | ENOTCONN: number;
1194 | ENOTDIR: number;
1195 | ENOTEMPTY: number;
1196 | ENOTSOCK: number;
1197 | ENOTSUP: number;
1198 | ENOTTY: number;
1199 | ENXIO: number;
1200 | EOPNOTSUPP: number;
1201 | EOVERFLOW: number;
1202 | EPERM: number;
1203 | EPIPE: number;
1204 | EPROTO: number;
1205 | EPROTONOSUPPORT: number;
1206 | EPROTOTYPE: number;
1207 | ERANGE: number;
1208 | EROFS: number;
1209 | ESPIPE: number;
1210 | ESRCH: number;
1211 | ESTALE: number;
1212 | ETIME: number;
1213 | ETIMEDOUT: number;
1214 | ETXTBSY: number;
1215 | EWOULDBLOCK: number;
1216 | EXDEV: number;
1217 | },
1218 | };
1219 | export function arch(): string;
1220 | export function platform(): string;
1221 | export function tmpdir(): string;
1222 | export var EOL: string;
1223 | export function endianness(): "BE" | "LE";
1224 | }
1225 |
1226 | declare module "https" {
1227 | import * as tls from "tls";
1228 | import * as events from "events";
1229 | import * as http from "http";
1230 |
1231 | export interface ServerOptions {
1232 | pfx?: any;
1233 | key?: any;
1234 | passphrase?: string;
1235 | cert?: any;
1236 | ca?: any;
1237 | crl?: any;
1238 | ciphers?: string;
1239 | honorCipherOrder?: boolean;
1240 | requestCert?: boolean;
1241 | rejectUnauthorized?: boolean;
1242 | NPNProtocols?: any;
1243 | SNICallback?: (servername: string, cb: (err: Error, ctx: tls.SecureContext) => any) => any;
1244 | }
1245 |
1246 | export interface RequestOptions extends http.RequestOptions {
1247 | pfx?: any;
1248 | key?: any;
1249 | passphrase?: string;
1250 | cert?: any;
1251 | ca?: any;
1252 | ciphers?: string;
1253 | rejectUnauthorized?: boolean;
1254 | secureProtocol?: string;
1255 | }
1256 |
1257 | export interface Agent extends http.Agent { }
1258 |
1259 | export interface AgentOptions extends http.AgentOptions {
1260 | pfx?: any;
1261 | key?: any;
1262 | passphrase?: string;
1263 | cert?: any;
1264 | ca?: any;
1265 | ciphers?: string;
1266 | rejectUnauthorized?: boolean;
1267 | secureProtocol?: string;
1268 | maxCachedSessions?: number;
1269 | }
1270 |
1271 | export var Agent: {
1272 | new (options?: AgentOptions): Agent;
1273 | };
1274 | export interface Server extends tls.Server { }
1275 | export function createServer(options: ServerOptions, requestListener?: Function): Server;
1276 | export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
1277 | export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
1278 | export var globalAgent: Agent;
1279 | }
1280 |
1281 | declare module "punycode" {
1282 | export function decode(string: string): string;
1283 | export function encode(string: string): string;
1284 | export function toUnicode(domain: string): string;
1285 | export function toASCII(domain: string): string;
1286 | export var ucs2: ucs2;
1287 | interface ucs2 {
1288 | decode(string: string): number[];
1289 | encode(codePoints: number[]): string;
1290 | }
1291 | export var version: any;
1292 | }
1293 |
1294 | declare module "repl" {
1295 | import * as stream from "stream";
1296 | import * as readline from "readline";
1297 |
1298 | export interface ReplOptions {
1299 | prompt?: string;
1300 | input?: NodeJS.ReadableStream;
1301 | output?: NodeJS.WritableStream;
1302 | terminal?: boolean;
1303 | eval?: Function;
1304 | useColors?: boolean;
1305 | useGlobal?: boolean;
1306 | ignoreUndefined?: boolean;
1307 | writer?: Function;
1308 | completer?: Function;
1309 | replMode?: any;
1310 | breakEvalOnSigint?: any;
1311 | }
1312 |
1313 | export interface REPLServer extends readline.ReadLine {
1314 | defineCommand(keyword: string, cmd: Function | { help: string, action: Function }): void;
1315 | displayPrompt(preserveCursor?: boolean): void
1316 | }
1317 |
1318 | export function start(options: ReplOptions): REPLServer;
1319 | }
1320 |
1321 | declare module "readline" {
1322 | import * as events from "events";
1323 | import * as stream from "stream";
1324 |
1325 | export interface Key {
1326 | sequence?: string;
1327 | name?: string;
1328 | ctrl?: boolean;
1329 | meta?: boolean;
1330 | shift?: boolean;
1331 | }
1332 |
1333 | export interface ReadLine extends events.EventEmitter {
1334 | setPrompt(prompt: string): void;
1335 | prompt(preserveCursor?: boolean): void;
1336 | question(query: string, callback: (answer: string) => void): void;
1337 | pause(): ReadLine;
1338 | resume(): ReadLine;
1339 | close(): void;
1340 | write(data: string | Buffer, key?: Key): void;
1341 | }
1342 |
1343 | export interface Completer {
1344 | (line: string): CompleterResult;
1345 | (line: string, callback: (err: any, result: CompleterResult) => void): any;
1346 | }
1347 |
1348 | export interface CompleterResult {
1349 | completions: string[];
1350 | line: string;
1351 | }
1352 |
1353 | export interface ReadLineOptions {
1354 | input: NodeJS.ReadableStream;
1355 | output?: NodeJS.WritableStream;
1356 | completer?: Completer;
1357 | terminal?: boolean;
1358 | historySize?: number;
1359 | }
1360 |
1361 | export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine;
1362 | export function createInterface(options: ReadLineOptions): ReadLine;
1363 |
1364 | export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void;
1365 | export function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void;
1366 | export function clearLine(stream: NodeJS.WritableStream, dir: number): void;
1367 | export function clearScreenDown(stream: NodeJS.WritableStream): void;
1368 | }
1369 |
1370 | declare module "vm" {
1371 | export interface Context { }
1372 | export interface ScriptOptions {
1373 | filename?: string;
1374 | lineOffset?: number;
1375 | columnOffset?: number;
1376 | displayErrors?: boolean;
1377 | timeout?: number;
1378 | cachedData?: Buffer;
1379 | produceCachedData?: boolean;
1380 | }
1381 | export interface RunningScriptOptions {
1382 | filename?: string;
1383 | lineOffset?: number;
1384 | columnOffset?: number;
1385 | displayErrors?: boolean;
1386 | timeout?: number;
1387 | }
1388 | export class Script {
1389 | constructor(code: string, options?: ScriptOptions);
1390 | runInContext(contextifiedSandbox: Context, options?: RunningScriptOptions): any;
1391 | runInNewContext(sandbox?: Context, options?: RunningScriptOptions): any;
1392 | runInThisContext(options?: RunningScriptOptions): any;
1393 | }
1394 | export function createContext(sandbox?: Context): Context;
1395 | export function isContext(sandbox: Context): boolean;
1396 | export function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions): any;
1397 | export function runInDebugContext(code: string): any;
1398 | export function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions): any;
1399 | export function runInThisContext(code: string, options?: RunningScriptOptions): any;
1400 | }
1401 |
1402 | declare module "child_process" {
1403 | import * as events from "events";
1404 | import * as stream from "stream";
1405 |
1406 | export interface ChildProcess extends events.EventEmitter {
1407 | stdin: stream.Writable;
1408 | stdout: stream.Readable;
1409 | stderr: stream.Readable;
1410 | stdio: [stream.Writable, stream.Readable, stream.Readable];
1411 | pid: number;
1412 | kill(signal?: string): void;
1413 | send(message: any, sendHandle?: any): boolean;
1414 | connected: boolean;
1415 | disconnect(): void;
1416 | unref(): void;
1417 | ref(): void;
1418 | }
1419 |
1420 | export interface SpawnOptions {
1421 | cwd?: string;
1422 | env?: any;
1423 | stdio?: any;
1424 | detached?: boolean;
1425 | uid?: number;
1426 | gid?: number;
1427 | shell?: boolean | string;
1428 | }
1429 | export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess;
1430 |
1431 | export interface ExecOptions {
1432 | cwd?: string;
1433 | env?: any;
1434 | shell?: string;
1435 | timeout?: number;
1436 | maxBuffer?: number;
1437 | killSignal?: string;
1438 | uid?: number;
1439 | gid?: number;
1440 | }
1441 | export interface ExecOptionsWithStringEncoding extends ExecOptions {
1442 | encoding: BufferEncoding;
1443 | }
1444 | export interface ExecOptionsWithBufferEncoding extends ExecOptions {
1445 | encoding: string; // specify `null`.
1446 | }
1447 | export function exec(command: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1448 | export function exec(command: string, options: ExecOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1449 | // usage. child_process.exec("tsc", {encoding: null as string}, (err, stdout, stderr) => {});
1450 | export function exec(command: string, options: ExecOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
1451 | export function exec(command: string, options: ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1452 |
1453 | export interface ExecFileOptions {
1454 | cwd?: string;
1455 | env?: any;
1456 | timeout?: number;
1457 | maxBuffer?: number;
1458 | killSignal?: string;
1459 | uid?: number;
1460 | gid?: number;
1461 | }
1462 | export interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
1463 | encoding: BufferEncoding;
1464 | }
1465 | export interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
1466 | encoding: string; // specify `null`.
1467 | }
1468 | export function execFile(file: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1469 | export function execFile(file: string, options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1470 | // usage. child_process.execFile("file.sh", {encoding: null as string}, (err, stdout, stderr) => {});
1471 | export function execFile(file: string, options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
1472 | export function execFile(file: string, options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1473 | export function execFile(file: string, args?: string[], callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1474 | export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1475 | // usage. child_process.execFile("file.sh", ["foo"], {encoding: null as string}, (err, stdout, stderr) => {});
1476 | export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
1477 | export function execFile(file: string, args?: string[], options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
1478 |
1479 | export interface ForkOptions {
1480 | cwd?: string;
1481 | env?: any;
1482 | execPath?: string;
1483 | execArgv?: string[];
1484 | silent?: boolean;
1485 | uid?: number;
1486 | gid?: number;
1487 | }
1488 | export function fork(modulePath: string, args?: string[], options?: ForkOptions): ChildProcess;
1489 |
1490 | export interface SpawnSyncOptions {
1491 | cwd?: string;
1492 | input?: string | Buffer;
1493 | stdio?: any;
1494 | env?: any;
1495 | uid?: number;
1496 | gid?: number;
1497 | timeout?: number;
1498 | killSignal?: string;
1499 | maxBuffer?: number;
1500 | encoding?: string;
1501 | shell?: boolean | string;
1502 | }
1503 | export interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
1504 | encoding: BufferEncoding;
1505 | }
1506 | export interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
1507 | encoding: string; // specify `null`.
1508 | }
1509 | export interface SpawnSyncReturns {
1510 | pid: number;
1511 | output: string[];
1512 | stdout: T;
1513 | stderr: T;
1514 | status: number;
1515 | signal: string;
1516 | error: Error;
1517 | }
1518 | export function spawnSync(command: string): SpawnSyncReturns;
1519 | export function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns;
1520 | export function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns;
1521 | export function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns;
1522 | export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns;
1523 | export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns;
1524 | export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions): SpawnSyncReturns;
1525 |
1526 | export interface ExecSyncOptions {
1527 | cwd?: string;
1528 | input?: string | Buffer;
1529 | stdio?: any;
1530 | env?: any;
1531 | shell?: string;
1532 | uid?: number;
1533 | gid?: number;
1534 | timeout?: number;
1535 | killSignal?: string;
1536 | maxBuffer?: number;
1537 | encoding?: string;
1538 | }
1539 | export interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
1540 | encoding: BufferEncoding;
1541 | }
1542 | export interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
1543 | encoding: string; // specify `null`.
1544 | }
1545 | export function execSync(command: string): Buffer;
1546 | export function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string;
1547 | export function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer;
1548 | export function execSync(command: string, options?: ExecSyncOptions): Buffer;
1549 |
1550 | export interface ExecFileSyncOptions {
1551 | cwd?: string;
1552 | input?: string | Buffer;
1553 | stdio?: any;
1554 | env?: any;
1555 | uid?: number;
1556 | gid?: number;
1557 | timeout?: number;
1558 | killSignal?: string;
1559 | maxBuffer?: number;
1560 | encoding?: string;
1561 | }
1562 | export interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
1563 | encoding: BufferEncoding;
1564 | }
1565 | export interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
1566 | encoding: string; // specify `null`.
1567 | }
1568 | export function execFileSync(command: string): Buffer;
1569 | export function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string;
1570 | export function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
1571 | export function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer;
1572 | export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithStringEncoding): string;
1573 | export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
1574 | export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions): Buffer;
1575 | }
1576 |
1577 | declare module "url" {
1578 | export interface Url {
1579 | href?: string;
1580 | protocol?: string;
1581 | auth?: string;
1582 | hostname?: string;
1583 | port?: string;
1584 | host?: string;
1585 | pathname?: string;
1586 | search?: string;
1587 | query?: string | any;
1588 | slashes?: boolean;
1589 | hash?: string;
1590 | path?: string;
1591 | }
1592 |
1593 | export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url;
1594 | export function format(url: Url): string;
1595 | export function resolve(from: string, to: string): string;
1596 | }
1597 |
1598 | declare module "dns" {
1599 | export interface MxRecord {
1600 | exchange: string,
1601 | priority: number
1602 | }
1603 |
1604 | export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) => void): string;
1605 | export function lookup(domain: string, callback: (err: Error, address: string, family: number) => void): string;
1606 | export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[];
1607 | export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1608 | export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1609 | export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1610 | export function resolveMx(domain: string, callback: (err: Error, addresses: MxRecord[]) => void): string[];
1611 | export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1612 | export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1613 | export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1614 | export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
1615 | export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[];
1616 | export function setServers(servers: string[]): void;
1617 |
1618 | //Error codes
1619 | export var NODATA: string;
1620 | export var FORMERR: string;
1621 | export var SERVFAIL: string;
1622 | export var NOTFOUND: string;
1623 | export var NOTIMP: string;
1624 | export var REFUSED: string;
1625 | export var BADQUERY: string;
1626 | export var BADNAME: string;
1627 | export var BADFAMILY: string;
1628 | export var BADRESP: string;
1629 | export var CONNREFUSED: string;
1630 | export var TIMEOUT: string;
1631 | export var EOF: string;
1632 | export var FILE: string;
1633 | export var NOMEM: string;
1634 | export var DESTRUCTION: string;
1635 | export var BADSTR: string;
1636 | export var BADFLAGS: string;
1637 | export var NONAME: string;
1638 | export var BADHINTS: string;
1639 | export var NOTINITIALIZED: string;
1640 | export var LOADIPHLPAPI: string;
1641 | export var ADDRGETNETWORKPARAMS: string;
1642 | export var CANCELLED: string;
1643 | }
1644 |
1645 | declare module "net" {
1646 | import * as stream from "stream";
1647 |
1648 | export interface Socket extends stream.Duplex {
1649 | // Extended base methods
1650 | write(buffer: Buffer): boolean;
1651 | write(buffer: Buffer, cb?: Function): boolean;
1652 | write(str: string, cb?: Function): boolean;
1653 | write(str: string, encoding?: string, cb?: Function): boolean;
1654 | write(str: string, encoding?: string, fd?: string): boolean;
1655 |
1656 | connect(port: number, host?: string, connectionListener?: Function): void;
1657 | connect(path: string, connectionListener?: Function): void;
1658 | bufferSize: number;
1659 | setEncoding(encoding?: string): void;
1660 | write(data: any, encoding?: string, callback?: Function): void;
1661 | destroy(): void;
1662 | pause(): Socket;
1663 | resume(): Socket;
1664 | setTimeout(timeout: number, callback?: Function): void;
1665 | setNoDelay(noDelay?: boolean): void;
1666 | setKeepAlive(enable?: boolean, initialDelay?: number): void;
1667 | address(): { port: number; family: string; address: string; };
1668 | unref(): void;
1669 | ref(): void;
1670 |
1671 | remoteAddress: string;
1672 | remoteFamily: string;
1673 | remotePort: number;
1674 | localAddress: string;
1675 | localPort: number;
1676 | bytesRead: number;
1677 | bytesWritten: number;
1678 |
1679 | // Extended base methods
1680 | end(): void;
1681 | end(buffer: Buffer, cb?: Function): void;
1682 | end(str: string, cb?: Function): void;
1683 | end(str: string, encoding?: string, cb?: Function): void;
1684 | end(data?: any, encoding?: string): void;
1685 |
1686 | /**
1687 | * events.EventEmitter
1688 | * 1. close
1689 | * 2. connect
1690 | * 3. data
1691 | * 4. drain
1692 | * 5. end
1693 | * 6. error
1694 | * 7. lookup
1695 | * 8. timeout
1696 | */
1697 | addListener(event: string, listener: Function): this;
1698 | addListener(event: "close", listener: (had_error: boolean) => void): this;
1699 | addListener(event: "connect", listener: () => void): this;
1700 | addListener(event: "data", listener: (data: Buffer) => void): this;
1701 | addListener(event: "drain", listener: () => void): this;
1702 | addListener(event: "end", listener: () => void): this;
1703 | addListener(event: "error", listener: (err: Error) => void): this;
1704 | addListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
1705 | addListener(event: "timeout", listener: () => void): this;
1706 |
1707 | emit(event: string, ...args: any[]): boolean;
1708 | emit(event: "close", had_error: boolean): boolean;
1709 | emit(event: "connect"): boolean;
1710 | emit(event: "data", data: Buffer): boolean;
1711 | emit(event: "drain"): boolean;
1712 | emit(event: "end"): boolean;
1713 | emit(event: "error", err: Error): boolean;
1714 | emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean;
1715 | emit(event: "timeout"): boolean;
1716 |
1717 | on(event: string, listener: Function): this;
1718 | on(event: "close", listener: (had_error: boolean) => void): this;
1719 | on(event: "connect", listener: () => void): this;
1720 | on(event: "data", listener: (data: Buffer) => void): this;
1721 | on(event: "drain", listener: () => void): this;
1722 | on(event: "end", listener: () => void): this;
1723 | on(event: "error", listener: (err: Error) => void): this;
1724 | on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
1725 | on(event: "timeout", listener: () => void): this;
1726 |
1727 | once(event: string, listener: Function): this;
1728 | once(event: "close", listener: (had_error: boolean) => void): this;
1729 | once(event: "connect", listener: () => void): this;
1730 | once(event: "data", listener: (data: Buffer) => void): this;
1731 | once(event: "drain", listener: () => void): this;
1732 | once(event: "end", listener: () => void): this;
1733 | once(event: "error", listener: (err: Error) => void): this;
1734 | once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
1735 | once(event: "timeout", listener: () => void): this;
1736 |
1737 | prependListener(event: string, listener: Function): this;
1738 | prependListener(event: "close", listener: (had_error: boolean) => void): this;
1739 | prependListener(event: "connect", listener: () => void): this;
1740 | prependListener(event: "data", listener: (data: Buffer) => void): this;
1741 | prependListener(event: "drain", listener: () => void): this;
1742 | prependListener(event: "end", listener: () => void): this;
1743 | prependListener(event: "error", listener: (err: Error) => void): this;
1744 | prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
1745 | prependListener(event: "timeout", listener: () => void): this;
1746 |
1747 | prependOnceListener(event: string, listener: Function): this;
1748 | prependOnceListener(event: "close", listener: (had_error: boolean) => void): this;
1749 | prependOnceListener(event: "connect", listener: () => void): this;
1750 | prependOnceListener(event: "data", listener: (data: Buffer) => void): this;
1751 | prependOnceListener(event: "drain", listener: () => void): this;
1752 | prependOnceListener(event: "end", listener: () => void): this;
1753 | prependOnceListener(event: "error", listener: (err: Error) => void): this;
1754 | prependOnceListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
1755 | prependOnceListener(event: "timeout", listener: () => void): this;
1756 | }
1757 |
1758 | export var Socket: {
1759 | new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket;
1760 | };
1761 |
1762 | export interface ListenOptions {
1763 | port?: number;
1764 | host?: string;
1765 | backlog?: number;
1766 | path?: string;
1767 | exclusive?: boolean;
1768 | }
1769 |
1770 | export interface Server extends Socket {
1771 | listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): Server;
1772 | listen(port: number, hostname?: string, listeningListener?: Function): Server;
1773 | listen(port: number, backlog?: number, listeningListener?: Function): Server;
1774 | listen(port: number, listeningListener?: Function): Server;
1775 | listen(path: string, backlog?: number, listeningListener?: Function): Server;
1776 | listen(path: string, listeningListener?: Function): Server;
1777 | listen(handle: any, backlog?: number, listeningListener?: Function): Server;
1778 | listen(handle: any, listeningListener?: Function): Server;
1779 | listen(options: ListenOptions, listeningListener?: Function): Server;
1780 | close(callback?: Function): Server;
1781 | address(): { port: number; family: string; address: string; };
1782 | getConnections(cb: (error: Error, count: number) => void): void;
1783 | ref(): Server;
1784 | unref(): Server;
1785 | maxConnections: number;
1786 | connections: number;
1787 |
1788 | /**
1789 | * events.EventEmitter
1790 | * 1. close
1791 | * 2. connection
1792 | * 3. error
1793 | * 4. listening
1794 | */
1795 | addListener(event: string, listener: Function): this;
1796 | addListener(event: "close", listener: () => void): this;
1797 | addListener(event: "connection", listener: (socket: Socket) => void): this;
1798 | addListener(event: "error", listener: (err: Error) => void): this;
1799 | addListener(event: "listening", listener: () => void): this;
1800 |
1801 | emit(event: string, ...args: any[]): boolean;
1802 | emit(event: "close"): boolean;
1803 | emit(event: "connection", socket: Socket): boolean;
1804 | emit(event: "error", err: Error): boolean;
1805 | emit(event: "listening"): boolean;
1806 |
1807 | on(event: string, listener: Function): this;
1808 | on(event: "close", listener: () => void): this;
1809 | on(event: "connection", listener: (socket: Socket) => void): this;
1810 | on(event: "error", listener: (err: Error) => void): this;
1811 | on(event: "listening", listener: () => void): this;
1812 |
1813 | once(event: string, listener: Function): this;
1814 | once(event: "close", listener: () => void): this;
1815 | once(event: "connection", listener: (socket: Socket) => void): this;
1816 | once(event: "error", listener: (err: Error) => void): this;
1817 | once(event: "listening", listener: () => void): this;
1818 |
1819 | prependListener(event: string, listener: Function): this;
1820 | prependListener(event: "close", listener: () => void): this;
1821 | prependListener(event: "connection", listener: (socket: Socket) => void): this;
1822 | prependListener(event: "error", listener: (err: Error) => void): this;
1823 | prependListener(event: "listening", listener: () => void): this;
1824 |
1825 | prependOnceListener(event: string, listener: Function): this;
1826 | prependOnceListener(event: "close", listener: () => void): this;
1827 | prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
1828 | prependOnceListener(event: "error", listener: (err: Error) => void): this;
1829 | prependOnceListener(event: "listening", listener: () => void): this;
1830 | }
1831 | export function createServer(connectionListener?: (socket: Socket) => void): Server;
1832 | export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) => void): Server;
1833 | export function connect(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
1834 | export function connect(port: number, host?: string, connectionListener?: Function): Socket;
1835 | export function connect(path: string, connectionListener?: Function): Socket;
1836 | export function createConnection(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
1837 | export function createConnection(port: number, host?: string, connectionListener?: Function): Socket;
1838 | export function createConnection(path: string, connectionListener?: Function): Socket;
1839 | export function isIP(input: string): number;
1840 | export function isIPv4(input: string): boolean;
1841 | export function isIPv6(input: string): boolean;
1842 | }
1843 |
1844 | declare module "dgram" {
1845 | import * as events from "events";
1846 |
1847 | interface RemoteInfo {
1848 | address: string;
1849 | family: string;
1850 | port: number;
1851 | }
1852 |
1853 | interface AddressInfo {
1854 | address: string;
1855 | family: string;
1856 | port: number;
1857 | }
1858 |
1859 | interface BindOptions {
1860 | port: number;
1861 | address?: string;
1862 | exclusive?: boolean;
1863 | }
1864 |
1865 | interface SocketOptions {
1866 | type: "udp4" | "udp6";
1867 | reuseAddr?: boolean;
1868 | }
1869 |
1870 | export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
1871 | export function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
1872 |
1873 | export interface Socket extends events.EventEmitter {
1874 | send(msg: Buffer | String | any[], port: number, address: string, callback?: (error: Error, bytes: number) => void): void;
1875 | send(msg: Buffer | String | any[], offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void;
1876 | bind(port?: number, address?: string, callback?: () => void): void;
1877 | bind(options: BindOptions, callback?: Function): void;
1878 | close(callback?: any): void;
1879 | address(): AddressInfo;
1880 | setBroadcast(flag: boolean): void;
1881 | setTTL(ttl: number): void;
1882 | setMulticastTTL(ttl: number): void;
1883 | setMulticastLoopback(flag: boolean): void;
1884 | addMembership(multicastAddress: string, multicastInterface?: string): void;
1885 | dropMembership(multicastAddress: string, multicastInterface?: string): void;
1886 | ref(): void;
1887 | unref(): void;
1888 |
1889 | /**
1890 | * events.EventEmitter
1891 | * 1. close
1892 | * 2. error
1893 | * 3. listening
1894 | * 4. message
1895 | **/
1896 | addListener(event: string, listener: Function): this;
1897 | addListener(event: "close", listener: () => void): this;
1898 | addListener(event: "error", listener: (err: Error) => void): this;
1899 | addListener(event: "listening", listener: () => void): this;
1900 | addListener(event: "message", listener: (msg: string, rinfo: AddressInfo) => void): this;
1901 |
1902 | emit(event: string, ...args: any[]): boolean;
1903 | emit(event: "close"): boolean;
1904 | emit(event: "error", err: Error): boolean;
1905 | emit(event: "listening"): boolean;
1906 | emit(event: "message", msg: string, rinfo: AddressInfo): boolean;
1907 |
1908 | on(event: string, listener: Function): this;
1909 | on(event: "close", listener: () => void): this;
1910 | on(event: "error", listener: (err: Error) => void): this;
1911 | on(event: "listening", listener: () => void): this;
1912 | on(event: "message", listener: (msg: string, rinfo: AddressInfo) => void): this;
1913 |
1914 | once(event: string, listener: Function): this;
1915 | once(event: "close", listener: () => void): this;
1916 | once(event: "error", listener: (err: Error) => void): this;
1917 | once(event: "listening", listener: () => void): this;
1918 | once(event: "message", listener: (msg: string, rinfo: AddressInfo) => void): this;
1919 |
1920 | prependListener(event: string, listener: Function): this;
1921 | prependListener(event: "close", listener: () => void): this;
1922 | prependListener(event: "error", listener: (err: Error) => void): this;
1923 | prependListener(event: "listening", listener: () => void): this;
1924 | prependListener(event: "message", listener: (msg: string, rinfo: AddressInfo) => void): this;
1925 |
1926 | prependOnceListener(event: string, listener: Function): this;
1927 | prependOnceListener(event: "close", listener: () => void): this;
1928 | prependOnceListener(event: "error", listener: (err: Error) => void): this;
1929 | prependOnceListener(event: "listening", listener: () => void): this;
1930 | prependOnceListener(event: "message", listener: (msg: string, rinfo: AddressInfo) => void): this;
1931 | }
1932 | }
1933 |
1934 | declare module "fs" {
1935 | import * as stream from "stream";
1936 | import * as events from "events";
1937 |
1938 | interface Stats {
1939 | isFile(): boolean;
1940 | isDirectory(): boolean;
1941 | isBlockDevice(): boolean;
1942 | isCharacterDevice(): boolean;
1943 | isSymbolicLink(): boolean;
1944 | isFIFO(): boolean;
1945 | isSocket(): boolean;
1946 | dev: number;
1947 | ino: number;
1948 | mode: number;
1949 | nlink: number;
1950 | uid: number;
1951 | gid: number;
1952 | rdev: number;
1953 | size: number;
1954 | blksize: number;
1955 | blocks: number;
1956 | atime: Date;
1957 | mtime: Date;
1958 | ctime: Date;
1959 | birthtime: Date;
1960 | }
1961 |
1962 | interface FSWatcher extends events.EventEmitter {
1963 | close(): void;
1964 |
1965 | /**
1966 | * events.EventEmitter
1967 | * 1. change
1968 | * 2. error
1969 | */
1970 | addListener(event: string, listener: Function): this;
1971 | addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
1972 | addListener(event: "error", listener: (code: number, signal: string) => void): this;
1973 |
1974 | on(event: string, listener: Function): this;
1975 | on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
1976 | on(event: "error", listener: (code: number, signal: string) => void): this;
1977 |
1978 | once(event: string, listener: Function): this;
1979 | once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
1980 | once(event: "error", listener: (code: number, signal: string) => void): this;
1981 |
1982 | prependListener(event: string, listener: Function): this;
1983 | prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
1984 | prependListener(event: "error", listener: (code: number, signal: string) => void): this;
1985 |
1986 | prependOnceListener(event: string, listener: Function): this;
1987 | prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
1988 | prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this;
1989 | }
1990 |
1991 | export interface ReadStream extends stream.Readable {
1992 | close(): void;
1993 | destroy(): void;
1994 |
1995 | /**
1996 | * events.EventEmitter
1997 | * 1. open
1998 | * 2. close
1999 | */
2000 | addListener(event: string, listener: Function): this;
2001 | addListener(event: "open", listener: (fd: number) => void): this;
2002 | addListener(event: "close", listener: () => void): this;
2003 |
2004 | on(event: string, listener: Function): this;
2005 | on(event: "open", listener: (fd: number) => void): this;
2006 | on(event: "close", listener: () => void): this;
2007 |
2008 | once(event: string, listener: Function): this;
2009 | once(event: "open", listener: (fd: number) => void): this;
2010 | once(event: "close", listener: () => void): this;
2011 |
2012 | prependListener(event: string, listener: Function): this;
2013 | prependListener(event: "open", listener: (fd: number) => void): this;
2014 | prependListener(event: "close", listener: () => void): this;
2015 |
2016 | prependOnceListener(event: string, listener: Function): this;
2017 | prependOnceListener(event: "open", listener: (fd: number) => void): this;
2018 | prependOnceListener(event: "close", listener: () => void): this;
2019 | }
2020 |
2021 | export interface WriteStream extends stream.Writable {
2022 | close(): void;
2023 | bytesWritten: number;
2024 | path: string | Buffer;
2025 |
2026 | /**
2027 | * events.EventEmitter
2028 | * 1. open
2029 | * 2. close
2030 | */
2031 | addListener(event: string, listener: Function): this;
2032 | addListener(event: "open", listener: (fd: number) => void): this;
2033 | addListener(event: "close", listener: () => void): this;
2034 |
2035 | on(event: string, listener: Function): this;
2036 | on(event: "open", listener: (fd: number) => void): this;
2037 | on(event: "close", listener: () => void): this;
2038 |
2039 | once(event: string, listener: Function): this;
2040 | once(event: "open", listener: (fd: number) => void): this;
2041 | once(event: "close", listener: () => void): this;
2042 |
2043 | prependListener(event: string, listener: Function): this;
2044 | prependListener(event: "open", listener: (fd: number) => void): this;
2045 | prependListener(event: "close", listener: () => void): this;
2046 |
2047 | prependOnceListener(event: string, listener: Function): this;
2048 | prependOnceListener(event: "open", listener: (fd: number) => void): this;
2049 | prependOnceListener(event: "close", listener: () => void): this;
2050 | }
2051 |
2052 | /**
2053 | * Asynchronous rename.
2054 | * @param oldPath
2055 | * @param newPath
2056 | * @param callback No arguments other than a possible exception are given to the completion callback.
2057 | */
2058 | export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
2059 | /**
2060 | * Synchronous rename
2061 | * @param oldPath
2062 | * @param newPath
2063 | */
2064 | export function renameSync(oldPath: string, newPath: string): void;
2065 | export function truncate(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void;
2066 | export function truncate(path: string | Buffer, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2067 | export function truncateSync(path: string | Buffer, len?: number): void;
2068 | export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2069 | export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2070 | export function ftruncateSync(fd: number, len?: number): void;
2071 | export function chown(path: string | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2072 | export function chownSync(path: string | Buffer, uid: number, gid: number): void;
2073 | export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2074 | export function fchownSync(fd: number, uid: number, gid: number): void;
2075 | export function lchown(path: string | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2076 | export function lchownSync(path: string | Buffer, uid: number, gid: number): void;
2077 | export function chmod(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2078 | export function chmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
2079 | export function chmodSync(path: string | Buffer, mode: number): void;
2080 | export function chmodSync(path: string | Buffer, mode: string): void;
2081 | export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2082 | export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
2083 | export function fchmodSync(fd: number, mode: number): void;
2084 | export function fchmodSync(fd: number, mode: string): void;
2085 | export function lchmod(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2086 | export function lchmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
2087 | export function lchmodSync(path: string | Buffer, mode: number): void;
2088 | export function lchmodSync(path: string | Buffer, mode: string): void;
2089 | export function stat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
2090 | export function lstat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
2091 | export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
2092 | export function statSync(path: string | Buffer): Stats;
2093 | export function lstatSync(path: string | Buffer): Stats;
2094 | export function fstatSync(fd: number): Stats;
2095 | export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void;
2096 | export function linkSync(srcpath: string | Buffer, dstpath: string | Buffer): void;
2097 | export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
2098 | export function symlinkSync(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): void;
2099 | export function readlink(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void;
2100 | export function readlinkSync(path: string | Buffer): string;
2101 | export function realpath(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
2102 | export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
2103 | export function realpathSync(path: string | Buffer, cache?: { [path: string]: string }): string;
2104 | /*
2105 | * Asynchronous unlink - deletes the file specified in {path}
2106 | *
2107 | * @param path
2108 | * @param callback No arguments other than a possible exception are given to the completion callback.
2109 | */
2110 | export function unlink(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void;
2111 | /*
2112 | * Synchronous unlink - deletes the file specified in {path}
2113 | *
2114 | * @param path
2115 | */
2116 | export function unlinkSync(path: string | Buffer): void;
2117 | /*
2118 | * Asynchronous rmdir - removes the directory specified in {path}
2119 | *
2120 | * @param path
2121 | * @param callback No arguments other than a possible exception are given to the completion callback.
2122 | */
2123 | export function rmdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void;
2124 | /*
2125 | * Synchronous rmdir - removes the directory specified in {path}
2126 | *
2127 | * @param path
2128 | */
2129 | export function rmdirSync(path: string | Buffer): void;
2130 | /*
2131 | * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
2132 | *
2133 | * @param path
2134 | * @param callback No arguments other than a possible exception are given to the completion callback.
2135 | */
2136 | export function mkdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void;
2137 | /*
2138 | * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
2139 | *
2140 | * @param path
2141 | * @param mode
2142 | * @param callback No arguments other than a possible exception are given to the completion callback.
2143 | */
2144 | export function mkdir(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2145 | /*
2146 | * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
2147 | *
2148 | * @param path
2149 | * @param mode
2150 | * @param callback No arguments other than a possible exception are given to the completion callback.
2151 | */
2152 | export function mkdir(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
2153 | /*
2154 | * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
2155 | *
2156 | * @param path
2157 | * @param mode
2158 | * @param callback No arguments other than a possible exception are given to the completion callback.
2159 | */
2160 | export function mkdirSync(path: string | Buffer, mode?: number): void;
2161 | /*
2162 | * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
2163 | *
2164 | * @param path
2165 | * @param mode
2166 | * @param callback No arguments other than a possible exception are given to the completion callback.
2167 | */
2168 | export function mkdirSync(path: string | Buffer, mode?: string): void;
2169 | /*
2170 | * Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2171 | *
2172 | * @param prefix
2173 | * @param callback The created folder path is passed as a string to the callback's second parameter.
2174 | */
2175 | export function mkdtemp(prefix: string, callback?: (err: NodeJS.ErrnoException, folder: string) => void): void;
2176 | /*
2177 | * Synchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2178 | *
2179 | * @param prefix
2180 | * @returns Returns the created folder path.
2181 | */
2182 | export function mkdtempSync(prefix: string): string;
2183 | export function readdir(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void;
2184 | export function readdirSync(path: string | Buffer): string[];
2185 | export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2186 | export function closeSync(fd: number): void;
2187 | export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void;
2188 | export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void;
2189 | export function openSync(path: string | Buffer, flags: string | number, mode?: number): number;
2190 | export function utimes(path: string | Buffer, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2191 | export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void;
2192 | export function utimesSync(path: string | Buffer, atime: number, mtime: number): void;
2193 | export function utimesSync(path: string | Buffer, atime: Date, mtime: Date): void;
2194 | export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2195 | export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void;
2196 | export function futimesSync(fd: number, atime: number, mtime: number): void;
2197 | export function futimesSync(fd: number, atime: Date, mtime: Date): void;
2198 | export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
2199 | export function fsyncSync(fd: number): void;
2200 | export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
2201 | export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
2202 | export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
2203 | export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
2204 | export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
2205 | export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position?: number): number;
2206 | export function writeSync(fd: number, data: any, position?: number, enconding?: string): number;
2207 | export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void;
2208 | export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
2209 | /*
2210 | * Asynchronous readFile - Asynchronously reads the entire contents of a file.
2211 | *
2212 | * @param fileName
2213 | * @param encoding
2214 | * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
2215 | */
2216 | export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
2217 | /*
2218 | * Asynchronous readFile - Asynchronously reads the entire contents of a file.
2219 | *
2220 | * @param fileName
2221 | * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer.
2222 | * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
2223 | */
2224 | export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
2225 | /*
2226 | * Asynchronous readFile - Asynchronously reads the entire contents of a file.
2227 | *
2228 | * @param fileName
2229 | * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer.
2230 | * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
2231 | */
2232 | export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
2233 | /*
2234 | * Asynchronous readFile - Asynchronously reads the entire contents of a file.
2235 | *
2236 | * @param fileName
2237 | * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
2238 | */
2239 | export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
2240 | /*
2241 | * Synchronous readFile - Synchronously reads the entire contents of a file.
2242 | *
2243 | * @param fileName
2244 | * @param encoding
2245 | */
2246 | export function readFileSync(filename: string, encoding: string): string;
2247 | /*
2248 | * Synchronous readFile - Synchronously reads the entire contents of a file.
2249 | *
2250 | * @param fileName
2251 | * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer.
2252 | */
2253 | export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string;
2254 | /*
2255 | * Synchronous readFile - Synchronously reads the entire contents of a file.
2256 | *
2257 | * @param fileName
2258 | * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer.
2259 | */
2260 | export function readFileSync(filename: string, options?: { flag?: string; }): Buffer;
2261 | export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
2262 | export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
2263 | export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
2264 | export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
2265 | export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
2266 | export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
2267 | export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
2268 | export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
2269 | export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
2270 | export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
2271 | export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void;
2272 | export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void;
2273 | export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void;
2274 | export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher;
2275 | export function watch(filename: string, encoding: string, listener?: (event: string, filename: string | Buffer) => any): FSWatcher;
2276 | export function watch(filename: string, options: { persistent?: boolean; recursive?: boolean; encoding?: string }, listener?: (event: string, filename: string | Buffer) => any): FSWatcher;
2277 | export function exists(path: string | Buffer, callback?: (exists: boolean) => void): void;
2278 | export function existsSync(path: string | Buffer): boolean;
2279 |
2280 | interface Constants {
2281 | /** Constant for fs.access(). File is visible to the calling process. */
2282 | F_OK: number;
2283 |
2284 | /** Constant for fs.access(). File can be read by the calling process. */
2285 | R_OK: number;
2286 |
2287 | /** Constant for fs.access(). File can be written by the calling process. */
2288 | W_OK: number;
2289 |
2290 | /** Constant for fs.access(). File can be executed by the calling process. */
2291 | X_OK: number;
2292 | }
2293 |
2294 | export const constants: Constants;
2295 |
2296 | /** Tests a user's permissions for the file specified by path. */
2297 | export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void;
2298 | export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException) => void): void;
2299 | /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */
2300 | export function accessSync(path: string | Buffer, mode?: number): void;
2301 | export function createReadStream(path: string | Buffer, options?: {
2302 | flags?: string;
2303 | encoding?: string;
2304 | fd?: number;
2305 | mode?: number;
2306 | autoClose?: boolean;
2307 | start?: number;
2308 | end?: number;
2309 | }): ReadStream;
2310 | export function createWriteStream(path: string | Buffer, options?: {
2311 | flags?: string;
2312 | encoding?: string;
2313 | fd?: number;
2314 | mode?: number;
2315 | autoClose?: boolean;
2316 | start?: number;
2317 | }): WriteStream;
2318 | export function fdatasync(fd: number, callback: Function): void;
2319 | export function fdatasyncSync(fd: number): void;
2320 | }
2321 |
2322 | declare module "path" {
2323 |
2324 | /**
2325 | * A parsed path object generated by path.parse() or consumed by path.format().
2326 | */
2327 | export interface ParsedPath {
2328 | /**
2329 | * The root of the path such as '/' or 'c:\'
2330 | */
2331 | root: string;
2332 | /**
2333 | * The full directory path such as '/home/user/dir' or 'c:\path\dir'
2334 | */
2335 | dir: string;
2336 | /**
2337 | * The file name including extension (if any) such as 'index.html'
2338 | */
2339 | base: string;
2340 | /**
2341 | * The file extension (if any) such as '.html'
2342 | */
2343 | ext: string;
2344 | /**
2345 | * The file name without extension (if any) such as 'index'
2346 | */
2347 | name: string;
2348 | }
2349 |
2350 | /**
2351 | * Normalize a string path, reducing '..' and '.' parts.
2352 | * 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.
2353 | *
2354 | * @param p string path to normalize.
2355 | */
2356 | export function normalize(p: string): string;
2357 | /**
2358 | * Join all arguments together and normalize the resulting path.
2359 | * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
2360 | *
2361 | * @param paths string paths to join.
2362 | */
2363 | export function join(...paths: any[]): string;
2364 | /**
2365 | * Join all arguments together and normalize the resulting path.
2366 | * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
2367 | *
2368 | * @param paths string paths to join.
2369 | */
2370 | export function join(...paths: string[]): string;
2371 | /**
2372 | * The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
2373 | *
2374 | * Starting from leftmost {from} paramter, resolves {to} to an absolute path.
2375 | *
2376 | * 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.
2377 | *
2378 | * @param pathSegments string paths to join. Non-string arguments are ignored.
2379 | */
2380 | export function resolve(...pathSegments: any[]): string;
2381 | /**
2382 | * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
2383 | *
2384 | * @param path path to test.
2385 | */
2386 | export function isAbsolute(path: string): boolean;
2387 | /**
2388 | * Solve the relative path from {from} to {to}.
2389 | * 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.
2390 | *
2391 | * @param from
2392 | * @param to
2393 | */
2394 | export function relative(from: string, to: string): string;
2395 | /**
2396 | * Return the directory name of a path. Similar to the Unix dirname command.
2397 | *
2398 | * @param p the path to evaluate.
2399 | */
2400 | export function dirname(p: string): string;
2401 | /**
2402 | * Return the last portion of a path. Similar to the Unix basename command.
2403 | * Often used to extract the file name from a fully qualified path.
2404 | *
2405 | * @param p the path to evaluate.
2406 | * @param ext optionally, an extension to remove from the result.
2407 | */
2408 | export function basename(p: string, ext?: string): string;
2409 | /**
2410 | * Return the extension of the path, from the last '.' to end of string in the last portion of the path.
2411 | * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
2412 | *
2413 | * @param p the path to evaluate.
2414 | */
2415 | export function extname(p: string): string;
2416 | /**
2417 | * The platform-specific file separator. '\\' or '/'.
2418 | */
2419 | export var sep: string;
2420 | /**
2421 | * The platform-specific file delimiter. ';' or ':'.
2422 | */
2423 | export var delimiter: string;
2424 | /**
2425 | * Returns an object from a path string - the opposite of format().
2426 | *
2427 | * @param pathString path to evaluate.
2428 | */
2429 | export function parse(pathString: string): ParsedPath;
2430 | /**
2431 | * Returns a path string from an object - the opposite of parse().
2432 | *
2433 | * @param pathString path to evaluate.
2434 | */
2435 | export function format(pathObject: ParsedPath): string;
2436 |
2437 | export module posix {
2438 | export function normalize(p: string): string;
2439 | export function join(...paths: any[]): string;
2440 | export function resolve(...pathSegments: any[]): string;
2441 | export function isAbsolute(p: string): boolean;
2442 | export function relative(from: string, to: string): string;
2443 | export function dirname(p: string): string;
2444 | export function basename(p: string, ext?: string): string;
2445 | export function extname(p: string): string;
2446 | export var sep: string;
2447 | export var delimiter: string;
2448 | export function parse(p: string): ParsedPath;
2449 | export function format(pP: ParsedPath): string;
2450 | }
2451 |
2452 | export module win32 {
2453 | export function normalize(p: string): string;
2454 | export function join(...paths: any[]): string;
2455 | export function resolve(...pathSegments: any[]): string;
2456 | export function isAbsolute(p: string): boolean;
2457 | export function relative(from: string, to: string): string;
2458 | export function dirname(p: string): string;
2459 | export function basename(p: string, ext?: string): string;
2460 | export function extname(p: string): string;
2461 | export var sep: string;
2462 | export var delimiter: string;
2463 | export function parse(p: string): ParsedPath;
2464 | export function format(pP: ParsedPath): string;
2465 | }
2466 | }
2467 |
2468 | declare module "string_decoder" {
2469 | export interface NodeStringDecoder {
2470 | write(buffer: Buffer): string;
2471 | end(buffer?: Buffer): string;
2472 | }
2473 | export var StringDecoder: {
2474 | new (encoding?: string): NodeStringDecoder;
2475 | };
2476 | }
2477 |
2478 | declare module "tls" {
2479 | import * as crypto from "crypto";
2480 | import * as net from "net";
2481 | import * as stream from "stream";
2482 |
2483 | var CLIENT_RENEG_LIMIT: number;
2484 | var CLIENT_RENEG_WINDOW: number;
2485 |
2486 | export interface Certificate {
2487 | /**
2488 | * Country code.
2489 | */
2490 | C: string;
2491 | /**
2492 | * Street.
2493 | */
2494 | ST: string;
2495 | /**
2496 | * Locality.
2497 | */
2498 | L: string;
2499 | /**
2500 | * Organization.
2501 | */
2502 | O: string;
2503 | /**
2504 | * Organizational unit.
2505 | */
2506 | OU: string;
2507 | /**
2508 | * Common name.
2509 | */
2510 | CN: string;
2511 | }
2512 |
2513 | export interface CipherNameAndProtocol {
2514 | /**
2515 | * The cipher name.
2516 | */
2517 | name: string;
2518 | /**
2519 | * SSL/TLS protocol version.
2520 | */
2521 | version: string;
2522 | }
2523 |
2524 | export class TLSSocket extends stream.Duplex {
2525 | /**
2526 | * Returns the bound address, the address family name and port of the underlying socket as reported by
2527 | * the operating system.
2528 | * @returns {any} - An object with three properties, e.g. { port: 12346, family: 'IPv4', address: '127.0.0.1' }.
2529 | */
2530 | address(): { port: number; family: string; address: string };
2531 | /**
2532 | * A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false.
2533 | */
2534 | authorized: boolean;
2535 | /**
2536 | * The reason why the peer's certificate has not been verified.
2537 | * This property becomes available only when tlsSocket.authorized === false.
2538 | */
2539 | authorizationError: Error;
2540 | /**
2541 | * Static boolean value, always true.
2542 | * May be used to distinguish TLS sockets from regular ones.
2543 | */
2544 | encrypted: boolean;
2545 | /**
2546 | * Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection.
2547 | * @returns {CipherNameAndProtocol} - Returns an object representing the cipher name
2548 | * and the SSL/TLS protocol version of the current connection.
2549 | */
2550 | getCipher(): CipherNameAndProtocol;
2551 | /**
2552 | * Returns an object representing the peer's certificate.
2553 | * The returned object has some properties corresponding to the field of the certificate.
2554 | * If detailed argument is true the full chain with issuer property will be returned,
2555 | * if false only the top certificate without issuer property.
2556 | * If the peer does not provide a certificate, it returns null or an empty object.
2557 | * @param {boolean} detailed - If true; the full chain with issuer property will be returned.
2558 | * @returns {any} - An object representing the peer's certificate.
2559 | */
2560 | getPeerCertificate(detailed?: boolean): {
2561 | subject: Certificate;
2562 | issuerInfo: Certificate;
2563 | issuer: Certificate;
2564 | raw: any;
2565 | valid_from: string;
2566 | valid_to: string;
2567 | fingerprint: string;
2568 | serialNumber: string;
2569 | };
2570 | /**
2571 | * Could be used to speed up handshake establishment when reconnecting to the server.
2572 | * @returns {any} - ASN.1 encoded TLS session or undefined if none was negotiated.
2573 | */
2574 | getSession(): any;
2575 | /**
2576 | * NOTE: Works only with client TLS sockets.
2577 | * Useful only for debugging, for session reuse provide session option to tls.connect().
2578 | * @returns {any} - TLS session ticket or undefined if none was negotiated.
2579 | */
2580 | getTLSTicket(): any;
2581 | /**
2582 | * The string representation of the local IP address.
2583 | */
2584 | localAddress: string;
2585 | /**
2586 | * The numeric representation of the local port.
2587 | */
2588 | localPort: string;
2589 | /**
2590 | * The string representation of the remote IP address.
2591 | * For example, '74.125.127.100' or '2001:4860:a005::68'.
2592 | */
2593 | remoteAddress: string;
2594 | /**
2595 | * The string representation of the remote IP family. 'IPv4' or 'IPv6'.
2596 | */
2597 | remoteFamily: string;
2598 | /**
2599 | * The numeric representation of the remote port. For example, 443.
2600 | */
2601 | remotePort: number;
2602 | /**
2603 | * Initiate TLS renegotiation process.
2604 | *
2605 | * NOTE: Can be used to request peer's certificate after the secure connection has been established.
2606 | * ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout.
2607 | * @param {TlsOptions} options - The options may contain the following fields: rejectUnauthorized,
2608 | * requestCert (See tls.createServer() for details).
2609 | * @param {Function} callback - callback(err) will be executed with null as err, once the renegotiation
2610 | * is successfully completed.
2611 | */
2612 | renegotiate(options: TlsOptions, callback: (err: Error) => any): any;
2613 | /**
2614 | * Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512).
2615 | * Smaller fragment size decreases buffering latency on the client: large fragments are buffered by
2616 | * the TLS layer until the entire fragment is received and its integrity is verified;
2617 | * large fragments can span multiple roundtrips, and their processing can be delayed due to packet
2618 | * loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead,
2619 | * which may decrease overall server throughput.
2620 | * @param {number} size - TLS fragment size (default and maximum value is: 16384, minimum is: 512).
2621 | * @returns {boolean} - Returns true on success, false otherwise.
2622 | */
2623 | setMaxSendFragment(size: number): boolean;
2624 |
2625 | /**
2626 | * events.EventEmitter
2627 | * 1. OCSPResponse
2628 | * 2. secureConnect
2629 | **/
2630 | addListener(event: string, listener: Function): this;
2631 | addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
2632 | addListener(event: "secureConnect", listener: () => void): this;
2633 |
2634 | emit(event: string, ...args: any[]): boolean;
2635 | emit(event: "OCSPResponse", response: Buffer): boolean;
2636 | emit(event: "secureConnect"): boolean;
2637 |
2638 | on(event: string, listener: Function): this;
2639 | on(event: "OCSPResponse", listener: (response: Buffer) => void): this;
2640 | on(event: "secureConnect", listener: () => void): this;
2641 |
2642 | once(event: string, listener: Function): this;
2643 | once(event: "OCSPResponse", listener: (response: Buffer) => void): this;
2644 | once(event: "secureConnect", listener: () => void): this;
2645 |
2646 | prependListener(event: string, listener: Function): this;
2647 | prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
2648 | prependListener(event: "secureConnect", listener: () => void): this;
2649 |
2650 | prependOnceListener(event: string, listener: Function): this;
2651 | prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
2652 | prependOnceListener(event: "secureConnect", listener: () => void): this;
2653 | }
2654 |
2655 | export interface TlsOptions {
2656 | host?: string;
2657 | port?: number;
2658 | pfx?: string | Buffer[];
2659 | key?: string | string[] | Buffer | any[];
2660 | passphrase?: string;
2661 | cert?: string | string[] | Buffer | Buffer[];
2662 | ca?: string | string[] | Buffer | Buffer[];
2663 | crl?: string | string[];
2664 | ciphers?: string;
2665 | honorCipherOrder?: boolean;
2666 | requestCert?: boolean;
2667 | rejectUnauthorized?: boolean;
2668 | NPNProtocols?: string[] | Buffer;
2669 | SNICallback?: (servername: string, cb: (err: Error, ctx: SecureContext) => any) => any;
2670 | ecdhCurve?: string;
2671 | dhparam?: string | Buffer;
2672 | handshakeTimeout?: number;
2673 | ALPNProtocols?: string[] | Buffer;
2674 | sessionTimeout?: number;
2675 | ticketKeys?: any;
2676 | sessionIdContext?: string;
2677 | secureProtocol?: string;
2678 | }
2679 |
2680 | export interface ConnectionOptions {
2681 | host?: string;
2682 | port?: number;
2683 | socket?: net.Socket;
2684 | pfx?: string | Buffer
2685 | key?: string | string[] | Buffer | Buffer[];
2686 | passphrase?: string;
2687 | cert?: string | string[] | Buffer | Buffer[];
2688 | ca?: string | Buffer | (string | Buffer)[];
2689 | rejectUnauthorized?: boolean;
2690 | NPNProtocols?: (string | Buffer)[];
2691 | servername?: string;
2692 | path?: string;
2693 | ALPNProtocols?: (string | Buffer)[];
2694 | checkServerIdentity?: (servername: string, cert: string | Buffer | (string | Buffer)[]) => any;
2695 | secureProtocol?: string;
2696 | secureContext?: Object;
2697 | session?: Buffer;
2698 | minDHSize?: number;
2699 | }
2700 |
2701 | export interface Server extends net.Server {
2702 | close(): Server;
2703 | address(): { port: number; family: string; address: string; };
2704 | addContext(hostName: string, credentials: {
2705 | key: string;
2706 | cert: string;
2707 | ca: string;
2708 | }): void;
2709 | maxConnections: number;
2710 | connections: number;
2711 |
2712 | /**
2713 | * events.EventEmitter
2714 | * 1. tlsClientError
2715 | * 2. newSession
2716 | * 3. OCSPRequest
2717 | * 4. resumeSession
2718 | * 5. secureConnection
2719 | **/
2720 | addListener(event: string, listener: Function): this;
2721 | addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
2722 | addListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this;
2723 | addListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this;
2724 | addListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
2725 | addListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
2726 |
2727 | emit(event: string, ...args: any[]): boolean;
2728 | emit(event: "tlsClientError", err: Error, tlsSocket: TLSSocket): boolean;
2729 | emit(event: "newSession", sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void): boolean;
2730 | emit(event: "OCSPRequest", certificate: Buffer, issuer: Buffer, callback: Function): boolean;
2731 | emit(event: "resumeSession", sessionId: any, callback: (err: Error, sessionData: any) => void): boolean;
2732 | emit(event: "secureConnection", tlsSocket: TLSSocket): boolean;
2733 |
2734 | on(event: string, listener: Function): this;
2735 | on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
2736 | on(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this;
2737 | on(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this;
2738 | on(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
2739 | on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
2740 |
2741 | once(event: string, listener: Function): this;
2742 | once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
2743 | once(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this;
2744 | once(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this;
2745 | once(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
2746 | once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
2747 |
2748 | prependListener(event: string, listener: Function): this;
2749 | prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
2750 | prependListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this;
2751 | prependListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this;
2752 | prependListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
2753 | prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
2754 |
2755 | prependOnceListener(event: string, listener: Function): this;
2756 | prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
2757 | prependOnceListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this;
2758 | prependOnceListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this;
2759 | prependOnceListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
2760 | prependOnceListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
2761 | }
2762 |
2763 | export interface ClearTextStream extends stream.Duplex {
2764 | authorized: boolean;
2765 | authorizationError: Error;
2766 | getPeerCertificate(): any;
2767 | getCipher: {
2768 | name: string;
2769 | version: string;
2770 | };
2771 | address: {
2772 | port: number;
2773 | family: string;
2774 | address: string;
2775 | };
2776 | remoteAddress: string;
2777 | remotePort: number;
2778 | }
2779 |
2780 | export interface SecurePair {
2781 | encrypted: any;
2782 | cleartext: any;
2783 | }
2784 |
2785 | export interface SecureContextOptions {
2786 | pfx?: string | Buffer;
2787 | key?: string | Buffer;
2788 | passphrase?: string;
2789 | cert?: string | Buffer;
2790 | ca?: string | Buffer;
2791 | crl?: string | string[]
2792 | ciphers?: string;
2793 | honorCipherOrder?: boolean;
2794 | }
2795 |
2796 | export interface SecureContext {
2797 | context: any;
2798 | }
2799 |
2800 | export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) => void): Server;
2801 | export function connect(options: ConnectionOptions, secureConnectionListener?: () => void): ClearTextStream;
2802 | export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): ClearTextStream;
2803 | export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): ClearTextStream;
2804 | export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
2805 | export function createSecureContext(details: SecureContextOptions): SecureContext;
2806 | }
2807 |
2808 | declare module "crypto" {
2809 | export interface Certificate {
2810 | exportChallenge(spkac: string | Buffer): Buffer;
2811 | exportPublicKey(spkac: string | Buffer): Buffer;
2812 | verifySpkac(spkac: Buffer): boolean;
2813 | }
2814 | export var Certificate: {
2815 | new (): Certificate;
2816 | (): Certificate;
2817 | }
2818 |
2819 | export var fips: boolean;
2820 |
2821 | export interface CredentialDetails {
2822 | pfx: string;
2823 | key: string;
2824 | passphrase: string;
2825 | cert: string;
2826 | ca: string | string[];
2827 | crl: string | string[];
2828 | ciphers: string;
2829 | }
2830 | export interface Credentials { context?: any; }
2831 | export function createCredentials(details: CredentialDetails): Credentials;
2832 | export function createHash(algorithm: string): Hash;
2833 | export function createHmac(algorithm: string, key: string | Buffer): Hmac;
2834 |
2835 | type Utf8AsciiLatin1Encoding = "utf8" | "ascii" | "latin1";
2836 | type HexBase64Latin1Encoding = "latin1" | "hex" | "base64";
2837 | type Utf8AsciiBinaryEncoding = "utf8" | "ascii" | "binary";
2838 | type HexBase64BinaryEncoding = "binary" | "base64" | "hex";
2839 | type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
2840 |
2841 | export interface Hash extends NodeJS.ReadWriteStream {
2842 | update(data: string | Buffer): Hash;
2843 | update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hash;
2844 | digest(): Buffer;
2845 | digest(encoding: HexBase64Latin1Encoding): string;
2846 | }
2847 | export interface Hmac extends NodeJS.ReadWriteStream {
2848 | update(data: string | Buffer): Hmac;
2849 | update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hmac;
2850 | digest(): Buffer;
2851 | digest(encoding: HexBase64Latin1Encoding): string;
2852 | }
2853 | export function createCipher(algorithm: string, password: any): Cipher;
2854 | export function createCipheriv(algorithm: string, key: any, iv: any): Cipher;
2855 | export interface Cipher extends NodeJS.ReadWriteStream {
2856 | update(data: Buffer): Buffer;
2857 | update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer;
2858 | update(data: Buffer, input_encoding: any, output_encoding: HexBase64BinaryEncoding): string;
2859 | update(data: string, input_encoding: Utf8AsciiBinaryEncoding, output_encoding: HexBase64BinaryEncoding): string;
2860 | final(): Buffer;
2861 | final(output_encoding: string): string;
2862 | setAutoPadding(auto_padding?: boolean): void;
2863 | getAuthTag(): Buffer;
2864 | setAAD(buffer: Buffer): void;
2865 | }
2866 | export function createDecipher(algorithm: string, password: any): Decipher;
2867 | export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher;
2868 | export interface Decipher extends NodeJS.ReadWriteStream {
2869 | update(data: Buffer): Buffer;
2870 | update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer;
2871 | update(data: Buffer, input_encoding: any, output_encoding: Utf8AsciiBinaryEncoding): string;
2872 | update(data: string, input_encoding: HexBase64BinaryEncoding, output_encoding: Utf8AsciiBinaryEncoding): string;
2873 | final(): Buffer;
2874 | final(output_encoding: string): string;
2875 | setAutoPadding(auto_padding?: boolean): void;
2876 | setAuthTag(tag: Buffer): void;
2877 | setAAD(buffer: Buffer): void;
2878 | }
2879 | export function createSign(algorithm: string): Signer;
2880 | export interface Signer extends NodeJS.WritableStream {
2881 | update(data: string | Buffer): Signer;
2882 | update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Signer;
2883 | sign(private_key: string | { key: string; passphrase: string }): Buffer;
2884 | sign(private_key: string | { key: string; passphrase: string }, output_format: HexBase64Latin1Encoding): string;
2885 | }
2886 | export function createVerify(algorith: string): Verify;
2887 | export interface Verify extends NodeJS.WritableStream {
2888 | update(data: string | Buffer): Verify;
2889 | update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Verify;
2890 | verify(object: string, signature: Buffer): boolean;
2891 | verify(object: string, signature: string, signature_format: HexBase64Latin1Encoding): boolean;
2892 | }
2893 | export function createDiffieHellman(prime_length: number, generator?: number): DiffieHellman;
2894 | export function createDiffieHellman(prime: Buffer): DiffieHellman;
2895 | export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman;
2896 | export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | Buffer): DiffieHellman;
2897 | export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: string, generator_encoding: HexBase64Latin1Encoding): DiffieHellman;
2898 | export interface DiffieHellman {
2899 | generateKeys(): Buffer;
2900 | generateKeys(encoding: HexBase64Latin1Encoding): string;
2901 | computeSecret(other_public_key: Buffer): Buffer;
2902 | computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
2903 | computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
2904 | getPrime(): Buffer;
2905 | getPrime(encoding: HexBase64Latin1Encoding): string;
2906 | getGenerator(): Buffer;
2907 | getGenerator(encoding: HexBase64Latin1Encoding): string;
2908 | getPublicKey(): Buffer;
2909 | getPublicKey(encoding: HexBase64Latin1Encoding): string;
2910 | getPrivateKey(): Buffer;
2911 | getPrivateKey(encoding: HexBase64Latin1Encoding): string;
2912 | setPublicKey(public_key: Buffer): void;
2913 | setPublicKey(public_key: string, encoding: string): void;
2914 | setPrivateKey(private_key: Buffer): void;
2915 | setPrivateKey(private_key: string, encoding: string): void;
2916 | verifyError: number;
2917 | }
2918 | export function getDiffieHellman(group_name: string): DiffieHellman;
2919 | export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void;
2920 | export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string): Buffer;
2921 | export function randomBytes(size: number): Buffer;
2922 | export function randomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void;
2923 | export function pseudoRandomBytes(size: number): Buffer;
2924 | export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void;
2925 | export interface RsaPublicKey {
2926 | key: string;
2927 | padding?: number;
2928 | }
2929 | export interface RsaPrivateKey {
2930 | key: string;
2931 | passphrase?: string,
2932 | padding?: number;
2933 | }
2934 | export function publicEncrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer
2935 | export function privateDecrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer
2936 | export function privateEncrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer
2937 | export function publicDecrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer
2938 | export function getCiphers(): string[];
2939 | export function getCurves(): string[];
2940 | export function getHashes(): string[];
2941 | export interface ECDH {
2942 | generateKeys(): Buffer;
2943 | generateKeys(encoding: HexBase64Latin1Encoding): string;
2944 | generateKeys(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string;
2945 | computeSecret(other_public_key: Buffer): Buffer;
2946 | computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
2947 | computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
2948 | getPrivateKey(): Buffer;
2949 | getPrivateKey(encoding: HexBase64Latin1Encoding): string;
2950 | getPublicKey(): Buffer;
2951 | getPublicKey(encoding: HexBase64Latin1Encoding): string;
2952 | getPublicKey(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string;
2953 | setPrivateKey(private_key: Buffer): void;
2954 | setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void;
2955 | }
2956 | export function createECDH(curve_name: string): ECDH;
2957 | export function timingSafeEqual(a: Buffer, b: Buffer): boolean;
2958 | export var DEFAULT_ENCODING: string;
2959 | }
2960 |
2961 | declare module "stream" {
2962 | import * as events from "events";
2963 |
2964 | class internal extends events.EventEmitter {
2965 | pipe(destination: T, options?: { end?: boolean; }): T;
2966 | }
2967 | namespace internal {
2968 |
2969 | export class Stream extends internal { }
2970 |
2971 | export interface ReadableOptions {
2972 | highWaterMark?: number;
2973 | encoding?: string;
2974 | objectMode?: boolean;
2975 | read?: (size?: number) => any;
2976 | }
2977 |
2978 | export class Readable extends events.EventEmitter implements NodeJS.ReadableStream {
2979 | readable: boolean;
2980 | constructor(opts?: ReadableOptions);
2981 | _read(size: number): void;
2982 | read(size?: number): any;
2983 | setEncoding(encoding: string): void;
2984 | pause(): Readable;
2985 | resume(): Readable;
2986 | pipe(destination: T, options?: { end?: boolean; }): T;
2987 | unpipe(destination?: T): void;
2988 | unshift(chunk: any): void;
2989 | wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
2990 | push(chunk: any, encoding?: string): boolean;
2991 |
2992 | /**
2993 | * Event emitter
2994 | * The defined events on documents including:
2995 | * 1. close
2996 | * 2. data
2997 | * 3. end
2998 | * 4. readable
2999 | * 5. error
3000 | **/
3001 | addListener(event: string, listener: Function): this;
3002 | addListener(event: string, listener: Function): this;
3003 | addListener(event: "close", listener: () => void): this;
3004 | addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
3005 | addListener(event: "end", listener: () => void): this;
3006 | addListener(event: "readable", listener: () => void): this;
3007 | addListener(event: "error", listener: (err: Error) => void): this;
3008 |
3009 | emit(event: string, ...args: any[]): boolean;
3010 | emit(event: "close"): boolean;
3011 | emit(event: "data", chunk: Buffer | string): boolean;
3012 | emit(event: "end"): boolean;
3013 | emit(event: "readable"): boolean;
3014 | emit(event: "error", err: Error): boolean;
3015 |
3016 | on(event: string, listener: Function): this;
3017 | on(event: "close", listener: () => void): this;
3018 | on(event: "data", listener: (chunk: Buffer | string) => void): this;
3019 | on(event: "end", listener: () => void): this;
3020 | on(event: "readable", listener: () => void): this;
3021 | on(event: "error", listener: (err: Error) => void): this;
3022 |
3023 | once(event: string, listener: Function): this;
3024 | once(event: "close", listener: () => void): this;
3025 | once(event: "data", listener: (chunk: Buffer | string) => void): this;
3026 | once(event: "end", listener: () => void): this;
3027 | once(event: "readable", listener: () => void): this;
3028 | once(event: "error", listener: (err: Error) => void): this;
3029 |
3030 | prependListener(event: string, listener: Function): this;
3031 | prependListener(event: "close", listener: () => void): this;
3032 | prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
3033 | prependListener(event: "end", listener: () => void): this;
3034 | prependListener(event: "readable", listener: () => void): this;
3035 | prependListener(event: "error", listener: (err: Error) => void): this;
3036 |
3037 | prependOnceListener(event: string, listener: Function): this;
3038 | prependOnceListener(event: "close", listener: () => void): this;
3039 | prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
3040 | prependOnceListener(event: "end", listener: () => void): this;
3041 | prependOnceListener(event: "readable", listener: () => void): this;
3042 | prependOnceListener(event: "error", listener: (err: Error) => void): this;
3043 |
3044 | removeListener(event: string, listener: Function): this;
3045 | removeListener(event: "close", listener: () => void): this;
3046 | removeListener(event: "data", listener: (chunk: Buffer | string) => void): this;
3047 | removeListener(event: "end", listener: () => void): this;
3048 | removeListener(event: "readable", listener: () => void): this;
3049 | removeListener(event: "error", listener: (err: Error) => void): this;
3050 | }
3051 |
3052 | export interface WritableOptions {
3053 | highWaterMark?: number;
3054 | decodeStrings?: boolean;
3055 | objectMode?: boolean;
3056 | write?: (chunk: string | Buffer, encoding: string, callback: Function) => any;
3057 | writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any;
3058 | }
3059 |
3060 | export class Writable extends events.EventEmitter implements NodeJS.WritableStream {
3061 | writable: boolean;
3062 | constructor(opts?: WritableOptions);
3063 | _write(chunk: any, encoding: string, callback: Function): void;
3064 | write(chunk: any, cb?: Function): boolean;
3065 | write(chunk: any, encoding?: string, cb?: Function): boolean;
3066 | end(): void;
3067 | end(chunk: any, cb?: Function): void;
3068 | end(chunk: any, encoding?: string, cb?: Function): void;
3069 |
3070 | /**
3071 | * Event emitter
3072 | * The defined events on documents including:
3073 | * 1. close
3074 | * 2. drain
3075 | * 3. error
3076 | * 4. finish
3077 | * 5. pipe
3078 | * 6. unpipe
3079 | **/
3080 | addListener(event: string, listener: Function): this;
3081 | addListener(event: "close", listener: () => void): this;
3082 | addListener(event: "drain", listener: () => void): this;
3083 | addListener(event: "error", listener: (err: Error) => void): this;
3084 | addListener(event: "finish", listener: () => void): this;
3085 | addListener(event: "pipe", listener: (src: Readable) => void): this;
3086 | addListener(event: "unpipe", listener: (src: Readable) => void): this;
3087 |
3088 | emit(event: string, ...args: any[]): boolean;
3089 | emit(event: "close"): boolean;
3090 | emit(event: "drain", chunk: Buffer | string): boolean;
3091 | emit(event: "error", err: Error): boolean;
3092 | emit(event: "finish"): boolean;
3093 | emit(event: "pipe", src: Readable): boolean;
3094 | emit(event: "unpipe", src: Readable): boolean;
3095 |
3096 | on(event: string, listener: Function): this;
3097 | on(event: "close", listener: () => void): this;
3098 | on(event: "drain", listener: () => void): this;
3099 | on(event: "error", listener: (err: Error) => void): this;
3100 | on(event: "finish", listener: () => void): this;
3101 | on(event: "pipe", listener: (src: Readable) => void): this;
3102 | on(event: "unpipe", listener: (src: Readable) => void): this;
3103 |
3104 | once(event: string, listener: Function): this;
3105 | once(event: "close", listener: () => void): this;
3106 | once(event: "drain", listener: () => void): this;
3107 | once(event: "error", listener: (err: Error) => void): this;
3108 | once(event: "finish", listener: () => void): this;
3109 | once(event: "pipe", listener: (src: Readable) => void): this;
3110 | once(event: "unpipe", listener: (src: Readable) => void): this;
3111 |
3112 | prependListener(event: string, listener: Function): this;
3113 | prependListener(event: "close", listener: () => void): this;
3114 | prependListener(event: "drain", listener: () => void): this;
3115 | prependListener(event: "error", listener: (err: Error) => void): this;
3116 | prependListener(event: "finish", listener: () => void): this;
3117 | prependListener(event: "pipe", listener: (src: Readable) => void): this;
3118 | prependListener(event: "unpipe", listener: (src: Readable) => void): this;
3119 |
3120 | prependOnceListener(event: string, listener: Function): this;
3121 | prependOnceListener(event: "close", listener: () => void): this;
3122 | prependOnceListener(event: "drain", listener: () => void): this;
3123 | prependOnceListener(event: "error", listener: (err: Error) => void): this;
3124 | prependOnceListener(event: "finish", listener: () => void): this;
3125 | prependOnceListener(event: "pipe", listener: (src: Readable) => void): this;
3126 | prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this;
3127 |
3128 | removeListener(event: string, listener: Function): this;
3129 | removeListener(event: "close", listener: () => void): this;
3130 | removeListener(event: "drain", listener: () => void): this;
3131 | removeListener(event: "error", listener: (err: Error) => void): this;
3132 | removeListener(event: "finish", listener: () => void): this;
3133 | removeListener(event: "pipe", listener: (src: Readable) => void): this;
3134 | removeListener(event: "unpipe", listener: (src: Readable) => void): this;
3135 | }
3136 |
3137 | export interface DuplexOptions extends ReadableOptions, WritableOptions {
3138 | allowHalfOpen?: boolean;
3139 | readableObjectMode?: boolean;
3140 | writableObjectMode?: boolean;
3141 | }
3142 |
3143 | // Note: Duplex extends both Readable and Writable.
3144 | export class Duplex extends Readable implements NodeJS.ReadWriteStream {
3145 | // Readable
3146 | pause(): Duplex;
3147 | resume(): Duplex;
3148 | // Writeable
3149 | writable: boolean;
3150 | constructor(opts?: DuplexOptions);
3151 | _write(chunk: any, encoding: string, callback: Function): void;
3152 | write(chunk: any, cb?: Function): boolean;
3153 | write(chunk: any, encoding?: string, cb?: Function): boolean;
3154 | end(): void;
3155 | end(chunk: any, cb?: Function): void;
3156 | end(chunk: any, encoding?: string, cb?: Function): void;
3157 | }
3158 |
3159 | export interface TransformOptions extends ReadableOptions, WritableOptions {
3160 | transform?: (chunk: string | Buffer, encoding: string, callback: Function) => any;
3161 | flush?: (callback: Function) => any;
3162 | }
3163 |
3164 | // Note: Transform lacks the _read and _write methods of Readable/Writable.
3165 | export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream {
3166 | readable: boolean;
3167 | writable: boolean;
3168 | constructor(opts?: TransformOptions);
3169 | _transform(chunk: any, encoding: string, callback: Function): void;
3170 | _flush(callback: Function): void;
3171 | read(size?: number): any;
3172 | setEncoding(encoding: string): void;
3173 | pause(): Transform;
3174 | resume(): Transform;
3175 | pipe(destination: T, options?: { end?: boolean; }): T;
3176 | unpipe(destination?: T): void;
3177 | unshift(chunk: any): void;
3178 | wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
3179 | push(chunk: any, encoding?: string): boolean;
3180 | write(chunk: any, cb?: Function): boolean;
3181 | write(chunk: any, encoding?: string, cb?: Function): boolean;
3182 | end(): void;
3183 | end(chunk: any, cb?: Function): void;
3184 | end(chunk: any, encoding?: string, cb?: Function): void;
3185 | }
3186 |
3187 | export class PassThrough extends Transform { }
3188 | }
3189 |
3190 | export = internal;
3191 | }
3192 |
3193 | declare module "util" {
3194 | export interface InspectOptions {
3195 | showHidden?: boolean;
3196 | depth?: number;
3197 | colors?: boolean;
3198 | customInspect?: boolean;
3199 | }
3200 |
3201 | export function format(format: any, ...param: any[]): string;
3202 | export function debug(string: string): void;
3203 | export function error(...param: any[]): void;
3204 | export function puts(...param: any[]): void;
3205 | export function print(...param: any[]): void;
3206 | export function log(string: string): void;
3207 | export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string;
3208 | export function inspect(object: any, options: InspectOptions): string;
3209 | export function isArray(object: any): boolean;
3210 | export function isRegExp(object: any): boolean;
3211 | export function isDate(object: any): boolean;
3212 | export function isError(object: any): boolean;
3213 | export function inherits(constructor: any, superConstructor: any): void;
3214 | export function debuglog(key: string): (msg: string, ...param: any[]) => void;
3215 | export function isBoolean(object: any): boolean;
3216 | export function isBuffer(object: any): boolean;
3217 | export function isFunction(object: any): boolean;
3218 | export function isNull(object: any): boolean;
3219 | export function isNullOrUndefined(object: any): boolean;
3220 | export function isNumber(object: any): boolean;
3221 | export function isObject(object: any): boolean;
3222 | export function isPrimitive(object: any): boolean;
3223 | export function isString(object: any): boolean;
3224 | export function isSymbol(object: any): boolean;
3225 | export function isUndefined(object: any): boolean;
3226 | export function deprecate(fn: Function, message: string): Function;
3227 | }
3228 |
3229 | declare module "assert" {
3230 | function internal(value: any, message?: string): void;
3231 | namespace internal {
3232 | export class AssertionError implements Error {
3233 | name: string;
3234 | message: string;
3235 | actual: any;
3236 | expected: any;
3237 | operator: string;
3238 | generatedMessage: boolean;
3239 |
3240 | constructor(options?: {
3241 | message?: string; actual?: any; expected?: any;
3242 | operator?: string; stackStartFunction?: Function
3243 | });
3244 | }
3245 |
3246 | export function fail(actual: any, expected: any, message: string, operator: string): void;
3247 | export function ok(value: any, message?: string): void;
3248 | export function equal(actual: any, expected: any, message?: string): void;
3249 | export function notEqual(actual: any, expected: any, message?: string): void;
3250 | export function deepEqual(actual: any, expected: any, message?: string): void;
3251 | export function notDeepEqual(acutal: any, expected: any, message?: string): void;
3252 | export function strictEqual(actual: any, expected: any, message?: string): void;
3253 | export function notStrictEqual(actual: any, expected: any, message?: string): void;
3254 | export function deepStrictEqual(actual: any, expected: any, message?: string): void;
3255 | export function notDeepStrictEqual(actual: any, expected: any, message?: string): void;
3256 | export var throws: {
3257 | (block: Function, message?: string): void;
3258 | (block: Function, error: Function, message?: string): void;
3259 | (block: Function, error: RegExp, message?: string): void;
3260 | (block: Function, error: (err: any) => boolean, message?: string): void;
3261 | };
3262 |
3263 | export var doesNotThrow: {
3264 | (block: Function, message?: string): void;
3265 | (block: Function, error: Function, message?: string): void;
3266 | (block: Function, error: RegExp, message?: string): void;
3267 | (block: Function, error: (err: any) => boolean, message?: string): void;
3268 | };
3269 |
3270 | export function ifError(value: any): void;
3271 | }
3272 |
3273 | export = internal;
3274 | }
3275 |
3276 | declare module "tty" {
3277 | import * as net from "net";
3278 |
3279 | export function isatty(fd: number): boolean;
3280 | export interface ReadStream extends net.Socket {
3281 | isRaw: boolean;
3282 | setRawMode(mode: boolean): void;
3283 | isTTY: boolean;
3284 | }
3285 | export interface WriteStream extends net.Socket {
3286 | columns: number;
3287 | rows: number;
3288 | isTTY: boolean;
3289 | }
3290 | }
3291 |
3292 | declare module "domain" {
3293 | import * as events from "events";
3294 |
3295 | export class Domain extends events.EventEmitter implements NodeJS.Domain {
3296 | run(fn: Function): void;
3297 | add(emitter: events.EventEmitter): void;
3298 | remove(emitter: events.EventEmitter): void;
3299 | bind(cb: (err: Error, data: any) => any): any;
3300 | intercept(cb: (data: any) => any): any;
3301 | dispose(): void;
3302 | members: any[];
3303 | enter(): void;
3304 | exit(): void;
3305 | }
3306 |
3307 | export function create(): Domain;
3308 | }
3309 |
3310 | declare module "constants" {
3311 | export var E2BIG: number;
3312 | export var EACCES: number;
3313 | export var EADDRINUSE: number;
3314 | export var EADDRNOTAVAIL: number;
3315 | export var EAFNOSUPPORT: number;
3316 | export var EAGAIN: number;
3317 | export var EALREADY: number;
3318 | export var EBADF: number;
3319 | export var EBADMSG: number;
3320 | export var EBUSY: number;
3321 | export var ECANCELED: number;
3322 | export var ECHILD: number;
3323 | export var ECONNABORTED: number;
3324 | export var ECONNREFUSED: number;
3325 | export var ECONNRESET: number;
3326 | export var EDEADLK: number;
3327 | export var EDESTADDRREQ: number;
3328 | export var EDOM: number;
3329 | export var EEXIST: number;
3330 | export var EFAULT: number;
3331 | export var EFBIG: number;
3332 | export var EHOSTUNREACH: number;
3333 | export var EIDRM: number;
3334 | export var EILSEQ: number;
3335 | export var EINPROGRESS: number;
3336 | export var EINTR: number;
3337 | export var EINVAL: number;
3338 | export var EIO: number;
3339 | export var EISCONN: number;
3340 | export var EISDIR: number;
3341 | export var ELOOP: number;
3342 | export var EMFILE: number;
3343 | export var EMLINK: number;
3344 | export var EMSGSIZE: number;
3345 | export var ENAMETOOLONG: number;
3346 | export var ENETDOWN: number;
3347 | export var ENETRESET: number;
3348 | export var ENETUNREACH: number;
3349 | export var ENFILE: number;
3350 | export var ENOBUFS: number;
3351 | export var ENODATA: number;
3352 | export var ENODEV: number;
3353 | export var ENOENT: number;
3354 | export var ENOEXEC: number;
3355 | export var ENOLCK: number;
3356 | export var ENOLINK: number;
3357 | export var ENOMEM: number;
3358 | export var ENOMSG: number;
3359 | export var ENOPROTOOPT: number;
3360 | export var ENOSPC: number;
3361 | export var ENOSR: number;
3362 | export var ENOSTR: number;
3363 | export var ENOSYS: number;
3364 | export var ENOTCONN: number;
3365 | export var ENOTDIR: number;
3366 | export var ENOTEMPTY: number;
3367 | export var ENOTSOCK: number;
3368 | export var ENOTSUP: number;
3369 | export var ENOTTY: number;
3370 | export var ENXIO: number;
3371 | export var EOPNOTSUPP: number;
3372 | export var EOVERFLOW: number;
3373 | export var EPERM: number;
3374 | export var EPIPE: number;
3375 | export var EPROTO: number;
3376 | export var EPROTONOSUPPORT: number;
3377 | export var EPROTOTYPE: number;
3378 | export var ERANGE: number;
3379 | export var EROFS: number;
3380 | export var ESPIPE: number;
3381 | export var ESRCH: number;
3382 | export var ETIME: number;
3383 | export var ETIMEDOUT: number;
3384 | export var ETXTBSY: number;
3385 | export var EWOULDBLOCK: number;
3386 | export var EXDEV: number;
3387 | export var WSAEINTR: number;
3388 | export var WSAEBADF: number;
3389 | export var WSAEACCES: number;
3390 | export var WSAEFAULT: number;
3391 | export var WSAEINVAL: number;
3392 | export var WSAEMFILE: number;
3393 | export var WSAEWOULDBLOCK: number;
3394 | export var WSAEINPROGRESS: number;
3395 | export var WSAEALREADY: number;
3396 | export var WSAENOTSOCK: number;
3397 | export var WSAEDESTADDRREQ: number;
3398 | export var WSAEMSGSIZE: number;
3399 | export var WSAEPROTOTYPE: number;
3400 | export var WSAENOPROTOOPT: number;
3401 | export var WSAEPROTONOSUPPORT: number;
3402 | export var WSAESOCKTNOSUPPORT: number;
3403 | export var WSAEOPNOTSUPP: number;
3404 | export var WSAEPFNOSUPPORT: number;
3405 | export var WSAEAFNOSUPPORT: number;
3406 | export var WSAEADDRINUSE: number;
3407 | export var WSAEADDRNOTAVAIL: number;
3408 | export var WSAENETDOWN: number;
3409 | export var WSAENETUNREACH: number;
3410 | export var WSAENETRESET: number;
3411 | export var WSAECONNABORTED: number;
3412 | export var WSAECONNRESET: number;
3413 | export var WSAENOBUFS: number;
3414 | export var WSAEISCONN: number;
3415 | export var WSAENOTCONN: number;
3416 | export var WSAESHUTDOWN: number;
3417 | export var WSAETOOMANYREFS: number;
3418 | export var WSAETIMEDOUT: number;
3419 | export var WSAECONNREFUSED: number;
3420 | export var WSAELOOP: number;
3421 | export var WSAENAMETOOLONG: number;
3422 | export var WSAEHOSTDOWN: number;
3423 | export var WSAEHOSTUNREACH: number;
3424 | export var WSAENOTEMPTY: number;
3425 | export var WSAEPROCLIM: number;
3426 | export var WSAEUSERS: number;
3427 | export var WSAEDQUOT: number;
3428 | export var WSAESTALE: number;
3429 | export var WSAEREMOTE: number;
3430 | export var WSASYSNOTREADY: number;
3431 | export var WSAVERNOTSUPPORTED: number;
3432 | export var WSANOTINITIALISED: number;
3433 | export var WSAEDISCON: number;
3434 | export var WSAENOMORE: number;
3435 | export var WSAECANCELLED: number;
3436 | export var WSAEINVALIDPROCTABLE: number;
3437 | export var WSAEINVALIDPROVIDER: number;
3438 | export var WSAEPROVIDERFAILEDINIT: number;
3439 | export var WSASYSCALLFAILURE: number;
3440 | export var WSASERVICE_NOT_FOUND: number;
3441 | export var WSATYPE_NOT_FOUND: number;
3442 | export var WSA_E_NO_MORE: number;
3443 | export var WSA_E_CANCELLED: number;
3444 | export var WSAEREFUSED: number;
3445 | export var SIGHUP: number;
3446 | export var SIGINT: number;
3447 | export var SIGILL: number;
3448 | export var SIGABRT: number;
3449 | export var SIGFPE: number;
3450 | export var SIGKILL: number;
3451 | export var SIGSEGV: number;
3452 | export var SIGTERM: number;
3453 | export var SIGBREAK: number;
3454 | export var SIGWINCH: number;
3455 | export var SSL_OP_ALL: number;
3456 | export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
3457 | export var SSL_OP_CIPHER_SERVER_PREFERENCE: number;
3458 | export var SSL_OP_CISCO_ANYCONNECT: number;
3459 | export var SSL_OP_COOKIE_EXCHANGE: number;
3460 | export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
3461 | export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
3462 | export var SSL_OP_EPHEMERAL_RSA: number;
3463 | export var SSL_OP_LEGACY_SERVER_CONNECT: number;
3464 | export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
3465 | export var SSL_OP_MICROSOFT_SESS_ID_BUG: number;
3466 | export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
3467 | export var SSL_OP_NETSCAPE_CA_DN_BUG: number;
3468 | export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
3469 | export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
3470 | export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
3471 | export var SSL_OP_NO_COMPRESSION: number;
3472 | export var SSL_OP_NO_QUERY_MTU: number;
3473 | export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
3474 | export var SSL_OP_NO_SSLv2: number;
3475 | export var SSL_OP_NO_SSLv3: number;
3476 | export var SSL_OP_NO_TICKET: number;
3477 | export var SSL_OP_NO_TLSv1: number;
3478 | export var SSL_OP_NO_TLSv1_1: number;
3479 | export var SSL_OP_NO_TLSv1_2: number;
3480 | export var SSL_OP_PKCS1_CHECK_1: number;
3481 | export var SSL_OP_PKCS1_CHECK_2: number;
3482 | export var SSL_OP_SINGLE_DH_USE: number;
3483 | export var SSL_OP_SINGLE_ECDH_USE: number;
3484 | export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
3485 | export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
3486 | export var SSL_OP_TLS_BLOCK_PADDING_BUG: number;
3487 | export var SSL_OP_TLS_D5_BUG: number;
3488 | export var SSL_OP_TLS_ROLLBACK_BUG: number;
3489 | export var ENGINE_METHOD_DSA: number;
3490 | export var ENGINE_METHOD_DH: number;
3491 | export var ENGINE_METHOD_RAND: number;
3492 | export var ENGINE_METHOD_ECDH: number;
3493 | export var ENGINE_METHOD_ECDSA: number;
3494 | export var ENGINE_METHOD_CIPHERS: number;
3495 | export var ENGINE_METHOD_DIGESTS: number;
3496 | export var ENGINE_METHOD_STORE: number;
3497 | export var ENGINE_METHOD_PKEY_METHS: number;
3498 | export var ENGINE_METHOD_PKEY_ASN1_METHS: number;
3499 | export var ENGINE_METHOD_ALL: number;
3500 | export var ENGINE_METHOD_NONE: number;
3501 | export var DH_CHECK_P_NOT_SAFE_PRIME: number;
3502 | export var DH_CHECK_P_NOT_PRIME: number;
3503 | export var DH_UNABLE_TO_CHECK_GENERATOR: number;
3504 | export var DH_NOT_SUITABLE_GENERATOR: number;
3505 | export var NPN_ENABLED: number;
3506 | export var RSA_PKCS1_PADDING: number;
3507 | export var RSA_SSLV23_PADDING: number;
3508 | export var RSA_NO_PADDING: number;
3509 | export var RSA_PKCS1_OAEP_PADDING: number;
3510 | export var RSA_X931_PADDING: number;
3511 | export var RSA_PKCS1_PSS_PADDING: number;
3512 | export var POINT_CONVERSION_COMPRESSED: number;
3513 | export var POINT_CONVERSION_UNCOMPRESSED: number;
3514 | export var POINT_CONVERSION_HYBRID: number;
3515 | export var O_RDONLY: number;
3516 | export var O_WRONLY: number;
3517 | export var O_RDWR: number;
3518 | export var S_IFMT: number;
3519 | export var S_IFREG: number;
3520 | export var S_IFDIR: number;
3521 | export var S_IFCHR: number;
3522 | export var S_IFBLK: number;
3523 | export var S_IFIFO: number;
3524 | export var S_IFSOCK: number;
3525 | export var S_IRWXU: number;
3526 | export var S_IRUSR: number;
3527 | export var S_IWUSR: number;
3528 | export var S_IXUSR: number;
3529 | export var S_IRWXG: number;
3530 | export var S_IRGRP: number;
3531 | export var S_IWGRP: number;
3532 | export var S_IXGRP: number;
3533 | export var S_IRWXO: number;
3534 | export var S_IROTH: number;
3535 | export var S_IWOTH: number;
3536 | export var S_IXOTH: number;
3537 | export var S_IFLNK: number;
3538 | export var O_CREAT: number;
3539 | export var O_EXCL: number;
3540 | export var O_NOCTTY: number;
3541 | export var O_DIRECTORY: number;
3542 | export var O_NOATIME: number;
3543 | export var O_NOFOLLOW: number;
3544 | export var O_SYNC: number;
3545 | export var O_SYMLINK: number;
3546 | export var O_DIRECT: number;
3547 | export var O_NONBLOCK: number;
3548 | export var O_TRUNC: number;
3549 | export var O_APPEND: number;
3550 | export var F_OK: number;
3551 | export var R_OK: number;
3552 | export var W_OK: number;
3553 | export var X_OK: number;
3554 | export var UV_UDP_REUSEADDR: number;
3555 | export var SIGQUIT: number;
3556 | export var SIGTRAP: number;
3557 | export var SIGIOT: number;
3558 | export var SIGBUS: number;
3559 | export var SIGUSR1: number;
3560 | export var SIGUSR2: number;
3561 | export var SIGPIPE: number;
3562 | export var SIGALRM: number;
3563 | export var SIGCHLD: number;
3564 | export var SIGSTKFLT: number;
3565 | export var SIGCONT: number;
3566 | export var SIGSTOP: number;
3567 | export var SIGTSTP: number;
3568 | export var SIGTTIN: number;
3569 | export var SIGTTOU: number;
3570 | export var SIGURG: number;
3571 | export var SIGXCPU: number;
3572 | export var SIGXFSZ: number;
3573 | export var SIGVTALRM: number;
3574 | export var SIGPROF: number;
3575 | export var SIGIO: number;
3576 | export var SIGPOLL: number;
3577 | export var SIGPWR: number;
3578 | export var SIGSYS: number;
3579 | export var SIGUNUSED: number;
3580 | export var defaultCoreCipherList: string;
3581 | export var defaultCipherList: string;
3582 | export var ENGINE_METHOD_RSA: number;
3583 | export var ALPN_ENABLED: number;
3584 | }
3585 |
3586 | declare module "process" {
3587 | export = process;
3588 | }
3589 |
3590 | declare module "v8" {
3591 | interface HeapSpaceInfo {
3592 | space_name: string;
3593 | space_size: number;
3594 | space_used_size: number;
3595 | space_available_size: number;
3596 | physical_space_size: number;
3597 | }
3598 | 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 };
3599 | export function getHeapSpaceStatistics(): HeapSpaceInfo[];
3600 | export function setFlagsFromString(flags: string): void;
3601 | }
3602 |
3603 | declare module "timers" {
3604 | export function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
3605 | export function clearTimeout(timeoutId: NodeJS.Timer): void;
3606 | export function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
3607 | export function clearInterval(intervalId: NodeJS.Timer): void;
3608 | export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
3609 | export function clearImmediate(immediateId: any): void;
3610 | }
3611 |
3612 | declare module "console" {
3613 | export = console;
3614 | }
3615 |
--------------------------------------------------------------------------------