Merge branch 'main' into dependabot/npm_and_yarn/octokit/types-6.21.1
This commit is contained in:
Коммит
6520447123
|
@ -289,7 +289,7 @@ exports.formatWorkflowCause = formatWorkflowCause;
|
|||
async function getWorkflow() {
|
||||
const relativePath = await getWorkflowPath();
|
||||
const absolutePath = path.join(util_1.getRequiredEnvParam("GITHUB_WORKSPACE"), relativePath);
|
||||
return yaml.safeLoad(fs.readFileSync(absolutePath, "utf-8"));
|
||||
return yaml.load(fs.readFileSync(absolutePath, "utf-8"));
|
||||
}
|
||||
exports.getWorkflow = getWorkflow;
|
||||
/**
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -139,7 +139,7 @@ ava_1.default("getWorkflowErrors() when on.pull_requests is a string and correct
|
|||
t.deepEqual(...errorCodes(errors, []));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() when on.push is correct with empty objects", (t) => {
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
@ -228,7 +228,7 @@ ava_1.default("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
|||
}), []));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() when on.pull_request for every branch but push specifies branches", (t) => {
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on:
|
||||
push:
|
||||
|
@ -311,7 +311,7 @@ ava_1.default("patternIsSuperset()", (t) => {
|
|||
t.false(actionsutil.patternIsSuperset("/robin/moose/release/goose", "/robin/*/release/*"));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() when branches contain dots", (t) => {
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
on:
|
||||
push:
|
||||
branches: [4.1, master]
|
||||
|
@ -322,7 +322,7 @@ ava_1.default("getWorkflowErrors() when branches contain dots", (t) => {
|
|||
t.deepEqual(...errorCodes(errors, []));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() when on.push has a trailing comma", (t) => {
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on:
|
||||
push:
|
||||
|
@ -335,7 +335,7 @@ on:
|
|||
});
|
||||
ava_1.default("getWorkflowErrors() should only report the current job's CheckoutWrongHead", (t) => {
|
||||
process.env.GITHUB_JOB = "test";
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on:
|
||||
push:
|
||||
|
@ -359,7 +359,7 @@ jobs:
|
|||
});
|
||||
ava_1.default("getWorkflowErrors() should not report a different job's CheckoutWrongHead", (t) => {
|
||||
process.env.GITHUB_JOB = "test3";
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on:
|
||||
push:
|
||||
|
@ -382,34 +382,34 @@ jobs:
|
|||
t.deepEqual(...errorCodes(errors, []));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() when on is missing", (t) => {
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
`));
|
||||
t.deepEqual(...errorCodes(errors, []));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() with a different on setup", (t) => {
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on: "workflow_dispatch"
|
||||
`)), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on: [workflow_dispatch]
|
||||
`)), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
`)), []));
|
||||
});
|
||||
ava_1.default("getWorkflowErrors() should not report an error if PRs are totally unconfigured", (t) => {
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
`)), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||
name: "CodeQL"
|
||||
on: ["push"]
|
||||
`)), []));
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -277,7 +277,7 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||
function readContents(name) {
|
||||
const x = fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8");
|
||||
console.log(x);
|
||||
return yaml.safeLoad(fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8"));
|
||||
return yaml.load(fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -723,7 +723,7 @@ function getLocalConfig(configFile, workspacePath) {
|
|||
if (!fs.existsSync(configFile)) {
|
||||
throw new Error(getConfigFileDoesNotExistErrorMessage(configFile));
|
||||
}
|
||||
return yaml.safeLoad(fs.readFileSync(configFile, "utf8"));
|
||||
return yaml.load(fs.readFileSync(configFile, "utf8"));
|
||||
}
|
||||
async function getRemoteConfig(configFile, apiDetails) {
|
||||
// retrieve the various parts of the config location, and ensure they're present
|
||||
|
@ -751,7 +751,7 @@ async function getRemoteConfig(configFile, apiDetails) {
|
|||
else {
|
||||
throw new Error(getConfigFileFormatInvalidMessage(configFile));
|
||||
}
|
||||
return yaml.safeLoad(Buffer.from(fileContents, "base64").toString("binary"));
|
||||
return yaml.load(Buffer.from(fileContents, "base64").toString("binary"));
|
||||
}
|
||||
/**
|
||||
* Get the file path where the parsed config will be stored.
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
0
node_modules/js-yaml/node_modules/.bin/esparse → node_modules/.bin/esparse
сгенерированный
поставляемый
0
node_modules/js-yaml/node_modules/.bin/esparse → node_modules/.bin/esparse
сгенерированный
поставляемый
0
node_modules/js-yaml/node_modules/.bin/esvalidate → node_modules/.bin/esvalidate
сгенерированный
поставляемый
0
node_modules/js-yaml/node_modules/.bin/esvalidate → node_modules/.bin/esvalidate
сгенерированный
поставляемый
|
@ -178,6 +178,15 @@
|
|||
"node": "^10.12.0 || >=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc/node_modules/argparse": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc/node_modules/ignore": {
|
||||
"version": "4.0.6",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
|
||||
|
@ -187,6 +196,19 @@
|
|||
"node": ">= 4"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc/node_modules/js-yaml": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
|
||||
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc/node_modules/strip-json-comments": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
|
||||
|
@ -553,8 +575,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "12.12.14",
|
||||
"license": "MIT"
|
||||
"version": "16.4.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.4.3.tgz",
|
||||
"integrity": "sha512-GKM4FLMkWDc0sfx7tXqPWkM6NBow1kge0fgQh0bOnlqo4iT1kvTvMEKE0c1RtUGnbLlGRXiAA8SumE//90uKAg=="
|
||||
},
|
||||
"node_modules/@types/normalize-package-data": {
|
||||
"version": "2.4.0",
|
||||
|
@ -570,9 +593,22 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@types/sinon": {
|
||||
"version": "7.5.2",
|
||||
"version": "10.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.2.tgz",
|
||||
"integrity": "sha512-BHn8Bpkapj8Wdfxvh2jWIUoaYB/9/XhsL0oOvBfRagJtKlSl9NWPcFOz2lRukI9szwGxFtYZCTejJSqsGDbdmw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
"dependencies": {
|
||||
"@sinonjs/fake-timers": "^7.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/sinon/node_modules/@sinonjs/fake-timers": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz",
|
||||
"integrity": "sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@sinonjs/commons": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/tmp": {
|
||||
"version": "0.1.0",
|
||||
|
@ -873,11 +909,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/argparse": {
|
||||
"version": "1.0.10",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
|
||||
},
|
||||
"node_modules/array-find-index": {
|
||||
"version": "1.0.2",
|
||||
|
@ -2384,6 +2418,15 @@
|
|||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/argparse": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/chalk": {
|
||||
"version": "4.1.0",
|
||||
"dev": true,
|
||||
|
@ -2467,6 +2510,19 @@
|
|||
"node": ">= 4"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/js-yaml": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
|
||||
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/path-key": {
|
||||
"version": "3.1.1",
|
||||
"dev": true,
|
||||
|
@ -2553,6 +2609,19 @@
|
|||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"esparse": "bin/esparse.js",
|
||||
"esvalidate": "bin/esvalidate.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/esquery": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz",
|
||||
|
@ -3422,27 +3491,16 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/js-yaml": {
|
||||
"version": "3.13.1",
|
||||
"license": "MIT",
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
||||
"dependencies": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
"argparse": "^2.0.1"
|
||||
},
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/js-yaml/node_modules/esprima": {
|
||||
"version": "4.0.1",
|
||||
"license": "BSD-2-Clause",
|
||||
"bin": {
|
||||
"esparse": "bin/esparse.js",
|
||||
"esvalidate": "bin/esvalidate.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/json-buffer": {
|
||||
"version": "3.0.0",
|
||||
"dev": true,
|
||||
|
@ -4492,8 +4550,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/query-string": {
|
||||
"version": "6.14.0",
|
||||
"license": "MIT",
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/query-string/-/query-string-7.0.1.tgz",
|
||||
"integrity": "sha512-uIw3iRvHnk9to1blJCG3BTc+Ro56CBowJXKmNNAm3RulvPBzWLRqKSiiDk+IplJhsydwtuNMHi8UGQFcCLVfkA==",
|
||||
"dependencies": {
|
||||
"decode-uri-component": "^0.2.0",
|
||||
"filter-obj": "^1.1.0",
|
||||
|
@ -5049,7 +5108,9 @@
|
|||
},
|
||||
"node_modules/sprintf-js": {
|
||||
"version": "1.0.3",
|
||||
"license": "BSD-3-Clause"
|
||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/strict-uri-encode": {
|
||||
"version": "2.0.0",
|
||||
|
@ -5155,6 +5216,15 @@
|
|||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/supertap/node_modules/argparse": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/supertap/node_modules/arrify": {
|
||||
"version": "1.0.1",
|
||||
"dev": true,
|
||||
|
@ -5171,6 +5241,19 @@
|
|||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/supertap/node_modules/js-yaml": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
|
||||
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/supertap/node_modules/strip-ansi": {
|
||||
"version": "4.0.0",
|
||||
"dev": true,
|
||||
|
|
1
node_modules/@eslint/eslintrc/node_modules/.bin/js-yaml
сгенерированный
поставляемый
Symbolic link
1
node_modules/@eslint/eslintrc/node_modules/.bin/js-yaml
сгенерированный
поставляемый
Symbolic link
|
@ -0,0 +1 @@
|
|||
../js-yaml/bin/js-yaml.js
|
185
node_modules/@eslint/eslintrc/node_modules/argparse/CHANGELOG.md
сгенерированный
поставляемый
Normal file
185
node_modules/@eslint/eslintrc/node_modules/argparse/CHANGELOG.md
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,185 @@
|
|||
1.0.10 / 2018-02-15
|
||||
------------------
|
||||
|
||||
- Use .concat instead of + for arrays, #122.
|
||||
|
||||
|
||||
1.0.9 / 2016-09-29
|
||||
------------------
|
||||
|
||||
- Rerelease after 1.0.8 - deps cleanup.
|
||||
|
||||
|
||||
1.0.8 / 2016-09-29
|
||||
------------------
|
||||
|
||||
- Maintenance (deps bump, fix node 6.5+ tests, coverage report).
|
||||
|
||||
|
||||
1.0.7 / 2016-03-17
|
||||
------------------
|
||||
|
||||
- Teach `addArgument` to accept string arg names. #97, @tomxtobin.
|
||||
|
||||
|
||||
1.0.6 / 2016-02-06
|
||||
------------------
|
||||
|
||||
- Maintenance: moved to eslint & updated CS.
|
||||
|
||||
|
||||
1.0.5 / 2016-02-05
|
||||
------------------
|
||||
|
||||
- Removed lodash dependency to significantly reduce install size.
|
||||
Thanks to @mourner.
|
||||
|
||||
|
||||
1.0.4 / 2016-01-17
|
||||
------------------
|
||||
|
||||
- Maintenance: lodash update to 4.0.0.
|
||||
|
||||
|
||||
1.0.3 / 2015-10-27
|
||||
------------------
|
||||
|
||||
- Fix parse `=` in args: `--examplepath="C:\myfolder\env=x64"`. #84, @CatWithApple.
|
||||
|
||||
|
||||
1.0.2 / 2015-03-22
|
||||
------------------
|
||||
|
||||
- Relaxed lodash version dependency.
|
||||
|
||||
|
||||
1.0.1 / 2015-02-20
|
||||
------------------
|
||||
|
||||
- Changed dependencies to be compatible with ancient nodejs.
|
||||
|
||||
|
||||
1.0.0 / 2015-02-19
|
||||
------------------
|
||||
|
||||
- Maintenance release.
|
||||
- Replaced `underscore` with `lodash`.
|
||||
- Bumped version to 1.0.0 to better reflect semver meaning.
|
||||
- HISTORY.md -> CHANGELOG.md
|
||||
|
||||
|
||||
0.1.16 / 2013-12-01
|
||||
-------------------
|
||||
|
||||
- Maintenance release. Updated dependencies and docs.
|
||||
|
||||
|
||||
0.1.15 / 2013-05-13
|
||||
-------------------
|
||||
|
||||
- Fixed #55, @trebor89
|
||||
|
||||
|
||||
0.1.14 / 2013-05-12
|
||||
-------------------
|
||||
|
||||
- Fixed #62, @maxtaco
|
||||
|
||||
|
||||
0.1.13 / 2013-04-08
|
||||
-------------------
|
||||
|
||||
- Added `.npmignore` to reduce package size
|
||||
|
||||
|
||||
0.1.12 / 2013-02-10
|
||||
-------------------
|
||||
|
||||
- Fixed conflictHandler (#46), @hpaulj
|
||||
|
||||
|
||||
0.1.11 / 2013-02-07
|
||||
-------------------
|
||||
|
||||
- Multiple bugfixes, @hpaulj
|
||||
- Added 70+ tests (ported from python), @hpaulj
|
||||
- Added conflictHandler, @applepicke
|
||||
- Added fromfilePrefixChar, @hpaulj
|
||||
|
||||
|
||||
0.1.10 / 2012-12-30
|
||||
-------------------
|
||||
|
||||
- Added [mutual exclusion](http://docs.python.org/dev/library/argparse.html#mutual-exclusion)
|
||||
support, thanks to @hpaulj
|
||||
- Fixed options check for `storeConst` & `appendConst` actions, thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.9 / 2012-12-27
|
||||
------------------
|
||||
|
||||
- Fixed option dest interferens with other options (issue #23), thanks to @hpaulj
|
||||
- Fixed default value behavior with `*` positionals, thanks to @hpaulj
|
||||
- Improve `getDefault()` behavior, thanks to @hpaulj
|
||||
- Imrove negative argument parsing, thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.8 / 2012-12-01
|
||||
------------------
|
||||
|
||||
- Fixed parser parents (issue #19), thanks to @hpaulj
|
||||
- Fixed negative argument parse (issue #20), thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.7 / 2012-10-14
|
||||
------------------
|
||||
|
||||
- Fixed 'choices' argument parse (issue #16)
|
||||
- Fixed stderr output (issue #15)
|
||||
|
||||
|
||||
0.1.6 / 2012-09-09
|
||||
------------------
|
||||
|
||||
- Fixed check for conflict of options (thanks to @tomxtobin)
|
||||
|
||||
|
||||
0.1.5 / 2012-09-03
|
||||
------------------
|
||||
|
||||
- Fix parser #setDefaults method (thanks to @tomxtobin)
|
||||
|
||||
|
||||
0.1.4 / 2012-07-30
|
||||
------------------
|
||||
|
||||
- Fixed pseudo-argument support (thanks to @CGamesPlay)
|
||||
- Fixed addHelp default (should be true), if not set (thanks to @benblank)
|
||||
|
||||
|
||||
0.1.3 / 2012-06-27
|
||||
------------------
|
||||
|
||||
- Fixed formatter api name: Formatter -> HelpFormatter
|
||||
|
||||
|
||||
0.1.2 / 2012-05-29
|
||||
------------------
|
||||
|
||||
- Added basic tests
|
||||
- Removed excess whitespace in help
|
||||
- Fixed error reporting, when parcer with subcommands
|
||||
called with empty arguments
|
||||
|
||||
|
||||
0.1.1 / 2012-05-23
|
||||
------------------
|
||||
|
||||
- Fixed line wrapping in help formatter
|
||||
- Added better error reporting on invalid arguments
|
||||
|
||||
|
||||
0.1.0 / 2012-05-16
|
||||
------------------
|
||||
|
||||
- First release.
|
21
node_modules/@eslint/eslintrc/node_modules/argparse/LICENSE
сгенерированный
поставляемый
Normal file
21
node_modules/@eslint/eslintrc/node_modules/argparse/LICENSE
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,21 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (C) 2012 by Vitaly Puzrin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
257
node_modules/@eslint/eslintrc/node_modules/argparse/README.md
сгенерированный
поставляемый
Normal file
257
node_modules/@eslint/eslintrc/node_modules/argparse/README.md
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,257 @@
|
|||
argparse
|
||||
========
|
||||
|
||||
[![Build Status](https://secure.travis-ci.org/nodeca/argparse.svg?branch=master)](http://travis-ci.org/nodeca/argparse)
|
||||
[![NPM version](https://img.shields.io/npm/v/argparse.svg)](https://www.npmjs.org/package/argparse)
|
||||
|
||||
CLI arguments parser for node.js. Javascript port of python's
|
||||
[argparse](http://docs.python.org/dev/library/argparse.html) module
|
||||
(original version 3.2). That's a full port, except some very rare options,
|
||||
recorded in issue tracker.
|
||||
|
||||
**NB. Difference with original.**
|
||||
|
||||
- Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/).
|
||||
- Use `defaultValue` instead of `default`.
|
||||
- Use `argparse.Const.REMAINDER` instead of `argparse.REMAINDER`, and
|
||||
similarly for constant values `OPTIONAL`, `ZERO_OR_MORE`, and `ONE_OR_MORE`
|
||||
(aliases for `nargs` values `'?'`, `'*'`, `'+'`, respectively), and
|
||||
`SUPPRESS`.
|
||||
|
||||
|
||||
Example
|
||||
=======
|
||||
|
||||
test.js file:
|
||||
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
description: 'Argparse example'
|
||||
});
|
||||
parser.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
help: 'foo bar'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
help: 'bar foo'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
'--baz',
|
||||
{
|
||||
help: 'baz bar'
|
||||
}
|
||||
);
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
```
|
||||
|
||||
Display help:
|
||||
|
||||
```
|
||||
$ ./test.js -h
|
||||
usage: example.js [-h] [-v] [-f FOO] [-b BAR] [--baz BAZ]
|
||||
|
||||
Argparse example
|
||||
|
||||
Optional arguments:
|
||||
-h, --help Show this help message and exit.
|
||||
-v, --version Show program's version number and exit.
|
||||
-f FOO, --foo FOO foo bar
|
||||
-b BAR, --bar BAR bar foo
|
||||
--baz BAZ baz bar
|
||||
```
|
||||
|
||||
Parse arguments:
|
||||
|
||||
```
|
||||
$ ./test.js -f=3 --bar=4 --baz 5
|
||||
{ foo: '3', bar: '4', baz: '5' }
|
||||
```
|
||||
|
||||
More [examples](https://github.com/nodeca/argparse/tree/master/examples).
|
||||
|
||||
|
||||
ArgumentParser objects
|
||||
======================
|
||||
|
||||
```
|
||||
new ArgumentParser({parameters hash});
|
||||
```
|
||||
|
||||
Creates a new ArgumentParser object.
|
||||
|
||||
**Supported params:**
|
||||
|
||||
- ```description``` - Text to display before the argument help.
|
||||
- ```epilog``` - Text to display after the argument help.
|
||||
- ```addHelp``` - Add a -h/–help option to the parser. (default: true)
|
||||
- ```argumentDefault``` - Set the global default value for arguments. (default: null)
|
||||
- ```parents``` - A list of ArgumentParser objects whose arguments should also be included.
|
||||
- ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘)
|
||||
- ```formatterClass``` - A class for customizing the help output.
|
||||
- ```prog``` - The name of the program (default: `path.basename(process.argv[1])`)
|
||||
- ```usage``` - The string describing the program usage (default: generated)
|
||||
- ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals.
|
||||
|
||||
**Not supported yet**
|
||||
|
||||
- ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read.
|
||||
|
||||
|
||||
Details in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects)
|
||||
|
||||
|
||||
addArgument() method
|
||||
====================
|
||||
|
||||
```
|
||||
ArgumentParser.addArgument(name or flag or [name] or [flags...], {options})
|
||||
```
|
||||
|
||||
Defines how a single command-line argument should be parsed.
|
||||
|
||||
- ```name or flag or [name] or [flags...]``` - Either a positional name
|
||||
(e.g., `'foo'`), a single option (e.g., `'-f'` or `'--foo'`), an array
|
||||
of a single positional name (e.g., `['foo']`), or an array of options
|
||||
(e.g., `['-f', '--foo']`).
|
||||
|
||||
Options:
|
||||
|
||||
- ```action``` - The basic type of action to be taken when this argument is encountered at the command line.
|
||||
- ```nargs```- The number of command-line arguments that should be consumed.
|
||||
- ```constant``` - A constant value required by some action and nargs selections.
|
||||
- ```defaultValue``` - The value produced if the argument is absent from the command line.
|
||||
- ```type``` - The type to which the command-line argument should be converted.
|
||||
- ```choices``` - A container of the allowable values for the argument.
|
||||
- ```required``` - Whether or not the command-line option may be omitted (optionals only).
|
||||
- ```help``` - A brief description of what the argument does.
|
||||
- ```metavar``` - A name for the argument in usage messages.
|
||||
- ```dest``` - The name of the attribute to be added to the object returned by parseArgs().
|
||||
|
||||
Details in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method)
|
||||
|
||||
|
||||
Action (some details)
|
||||
================
|
||||
|
||||
ArgumentParser objects associate command-line arguments with actions.
|
||||
These actions can do just about anything with the command-line arguments associated
|
||||
with them, though most actions simply add an attribute to the object returned by
|
||||
parseArgs(). The action keyword argument specifies how the command-line arguments
|
||||
should be handled. The supported actions are:
|
||||
|
||||
- ```store``` - Just stores the argument’s value. This is the default action.
|
||||
- ```storeConst``` - Stores value, specified by the const keyword argument.
|
||||
(Note that the const keyword argument defaults to the rather unhelpful None.)
|
||||
The 'storeConst' action is most commonly used with optional arguments, that
|
||||
specify some sort of flag.
|
||||
- ```storeTrue``` and ```storeFalse``` - Stores values True and False
|
||||
respectively. These are special cases of 'storeConst'.
|
||||
- ```append``` - Stores a list, and appends each argument value to the list.
|
||||
This is useful to allow an option to be specified multiple times.
|
||||
- ```appendConst``` - Stores a list, and appends value, specified by the
|
||||
const keyword argument to the list. (Note, that the const keyword argument defaults
|
||||
is None.) The 'appendConst' action is typically used when multiple arguments need
|
||||
to store constants to the same list.
|
||||
- ```count``` - Counts the number of times a keyword argument occurs. For example,
|
||||
used for increasing verbosity levels.
|
||||
- ```help``` - Prints a complete help message for all the options in the current
|
||||
parser and then exits. By default a help action is automatically added to the parser.
|
||||
See ArgumentParser for details of how the output is created.
|
||||
- ```version``` - Prints version information and exit. Expects a `version=`
|
||||
keyword argument in the addArgument() call.
|
||||
|
||||
Details in [original action guide](http://docs.python.org/dev/library/argparse.html#action)
|
||||
|
||||
|
||||
Sub-commands
|
||||
============
|
||||
|
||||
ArgumentParser.addSubparsers()
|
||||
|
||||
Many programs split their functionality into a number of sub-commands, for
|
||||
example, the svn program can invoke sub-commands like `svn checkout`, `svn update`,
|
||||
and `svn commit`. Splitting up functionality this way can be a particularly good
|
||||
idea when a program performs several different functions which require different
|
||||
kinds of command-line arguments. `ArgumentParser` supports creation of such
|
||||
sub-commands with `addSubparsers()` method. The `addSubparsers()` method is
|
||||
normally called with no arguments and returns an special action object.
|
||||
This object has a single method `addParser()`, which takes a command name and
|
||||
any `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object
|
||||
that can be modified as usual.
|
||||
|
||||
Example:
|
||||
|
||||
sub_commands.js
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
description: 'Argparse examples: sub-commands',
|
||||
});
|
||||
|
||||
var subparsers = parser.addSubparsers({
|
||||
title:'subcommands',
|
||||
dest:"subcommand_name"
|
||||
});
|
||||
|
||||
var bar = subparsers.addParser('c1', {addHelp:true});
|
||||
bar.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
action: 'store',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
var bar = subparsers.addParser(
|
||||
'c2',
|
||||
{aliases:['co'], addHelp:true}
|
||||
);
|
||||
bar.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
action: 'store',
|
||||
type: 'int',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
|
||||
```
|
||||
|
||||
Details in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands)
|
||||
|
||||
|
||||
Contributors
|
||||
============
|
||||
|
||||
- [Eugene Shkuropat](https://github.com/shkuropat)
|
||||
- [Paul Jacobson](https://github.com/hpaulj)
|
||||
|
||||
[others](https://github.com/nodeca/argparse/graphs/contributors)
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
Copyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin).
|
||||
Released under the MIT license. See
|
||||
[LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details.
|
||||
|
||||
|
0
node_modules/argparse/index.js → node_modules/@eslint/eslintrc/node_modules/argparse/index.js
сгенерированный
поставляемый
0
node_modules/argparse/index.js → node_modules/@eslint/eslintrc/node_modules/argparse/index.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/append.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/append.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/append.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/append.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/count.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/count.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/count.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/count.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/help.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/help.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/help.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/help.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/store.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/store.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/store.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/store.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/version.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/version.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action/version.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action/version.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action_container.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action_container.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/action_container.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/action_container.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argparse.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argparse.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argparse.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argparse.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argument/error.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argument/error.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argument/error.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argument/error.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argument/group.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argument/group.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argument/group.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argument/group.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argument_parser.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argument_parser.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/argument_parser.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/argument_parser.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/const.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/const.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/const.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/const.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/help/formatter.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/help/formatter.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/help/formatter.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/help/formatter.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/namespace.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/namespace.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/namespace.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/namespace.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/utils.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/utils.js
сгенерированный
поставляемый
0
node_modules/argparse/lib/utils.js → node_modules/@eslint/eslintrc/node_modules/argparse/lib/utils.js
сгенерированный
поставляемый
34
node_modules/@eslint/eslintrc/node_modules/argparse/package.json
сгенерированный
поставляемый
Normal file
34
node_modules/@eslint/eslintrc/node_modules/argparse/package.json
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "argparse",
|
||||
"description": "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library",
|
||||
"version": "1.0.10",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"parser",
|
||||
"argparse",
|
||||
"option",
|
||||
"args"
|
||||
],
|
||||
"contributors": [
|
||||
"Eugene Shkuropat",
|
||||
"Paul Jacobson"
|
||||
],
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "nodeca/argparse",
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^2.13.1",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^3.1.0",
|
||||
"ndoc": "^5.0.1"
|
||||
}
|
||||
}
|
557
node_modules/@eslint/eslintrc/node_modules/js-yaml/CHANGELOG.md
сгенерированный
поставляемый
Normal file
557
node_modules/@eslint/eslintrc/node_modules/js-yaml/CHANGELOG.md
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,557 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
|
||||
## [3.14.1] - 2020-12-07
|
||||
### Security
|
||||
- Fix possible code execution in (already unsafe) `.load()` (in &anchor).
|
||||
|
||||
|
||||
## [3.14.0] - 2020-05-22
|
||||
### Changed
|
||||
- Support `safe/loadAll(input, options)` variant of call.
|
||||
- CI: drop outdated nodejs versions.
|
||||
- Dev deps bump.
|
||||
|
||||
### Fixed
|
||||
- Quote `=` in plain scalars #519.
|
||||
- Check the node type for `!<?>` tag in case user manually specifies it.
|
||||
- Verify that there are no null-bytes in input.
|
||||
- Fix wrong quote position when writing condensed flow, #526.
|
||||
|
||||
|
||||
## [3.13.1] - 2019-04-05
|
||||
### Security
|
||||
- Fix possible code execution in (already unsafe) `.load()`, #480.
|
||||
|
||||
|
||||
## [3.13.0] - 2019-03-20
|
||||
### Security
|
||||
- Security fix: `safeLoad()` can hang when arrays with nested refs
|
||||
used as key. Now throws exception for nested arrays. #475.
|
||||
|
||||
|
||||
## [3.12.2] - 2019-02-26
|
||||
### Fixed
|
||||
- Fix `noArrayIndent` option for root level, #468.
|
||||
|
||||
|
||||
## [3.12.1] - 2019-01-05
|
||||
### Added
|
||||
- Added `noArrayIndent` option, #432.
|
||||
|
||||
|
||||
## [3.12.0] - 2018-06-02
|
||||
### Changed
|
||||
- Support arrow functions without a block statement, #421.
|
||||
|
||||
|
||||
## [3.11.0] - 2018-03-05
|
||||
### Added
|
||||
- Add arrow functions suport for `!!js/function`.
|
||||
|
||||
### Fixed
|
||||
- Fix dump in bin/octal/hex formats for negative integers, #399.
|
||||
|
||||
|
||||
## [3.10.0] - 2017-09-10
|
||||
### Fixed
|
||||
- Fix `condenseFlow` output (quote keys for sure, instead of spaces), #371, #370.
|
||||
- Dump astrals as codepoints instead of surrogate pair, #368.
|
||||
|
||||
|
||||
## [3.9.1] - 2017-07-08
|
||||
### Fixed
|
||||
- Ensure stack is present for custom errors in node 7.+, #351.
|
||||
|
||||
|
||||
## [3.9.0] - 2017-07-08
|
||||
### Added
|
||||
- Add `condenseFlow` option (to create pretty URL query params), #346.
|
||||
|
||||
### Fixed
|
||||
- Support array return from safeLoadAll/loadAll, #350.
|
||||
|
||||
|
||||
## [3.8.4] - 2017-05-08
|
||||
### Fixed
|
||||
- Dumper: prevent space after dash for arrays that wrap, #343.
|
||||
|
||||
|
||||
## [3.8.3] - 2017-04-05
|
||||
### Fixed
|
||||
- Should not allow numbers to begin and end with underscore, #335.
|
||||
|
||||
|
||||
## [3.8.2] - 2017-03-02
|
||||
### Fixed
|
||||
- Fix `!!float 123` (integers) parse, #333.
|
||||
- Don't allow leading zeros in floats (except 0, 0.xxx).
|
||||
- Allow positive exponent without sign in floats.
|
||||
|
||||
|
||||
## [3.8.1] - 2017-02-07
|
||||
### Changed
|
||||
- Maintenance: update browserified build.
|
||||
|
||||
|
||||
## [3.8.0] - 2017-02-07
|
||||
### Fixed
|
||||
- Fix reported position for `duplicated mapping key` errors.
|
||||
Now points to block start instead of block end.
|
||||
(#243, thanks to @shockey).
|
||||
|
||||
|
||||
## [3.7.0] - 2016-11-12
|
||||
### Added
|
||||
- Support polymorphism for tags (#300, thanks to @monken).
|
||||
|
||||
### Fixed
|
||||
- Fix parsing of quotes followed by newlines (#304, thanks to @dplepage).
|
||||
|
||||
|
||||
## [3.6.1] - 2016-05-11
|
||||
### Fixed
|
||||
- Fix output cut on a pipe, #286.
|
||||
|
||||
|
||||
## [3.6.0] - 2016-04-16
|
||||
### Fixed
|
||||
- Dumper rewrite, fix multiple bugs with trailing `\n`.
|
||||
Big thanks to @aepsilon!
|
||||
- Loader: fix leading/trailing newlines in block scalars, @aepsilon.
|
||||
|
||||
|
||||
## [3.5.5] - 2016-03-17
|
||||
### Fixed
|
||||
- Date parse fix: don't allow dates with on digit in month and day, #268.
|
||||
|
||||
|
||||
## [3.5.4] - 2016-03-09
|
||||
### Added
|
||||
- `noCompatMode` for dumper, to disable quoting YAML 1.1 values.
|
||||
|
||||
|
||||
## [3.5.3] - 2016-02-11
|
||||
### Changed
|
||||
- Maintenance release.
|
||||
|
||||
|
||||
## [3.5.2] - 2016-01-11
|
||||
### Changed
|
||||
- Maintenance: missed comma in bower config.
|
||||
|
||||
|
||||
## [3.5.1] - 2016-01-11
|
||||
### Changed
|
||||
- Removed `inherit` dependency, #239.
|
||||
- Better browserify workaround for esprima load.
|
||||
- Demo rewrite.
|
||||
|
||||
|
||||
## [3.5.0] - 2016-01-10
|
||||
### Fixed
|
||||
- Dumper. Fold strings only, #217.
|
||||
- Dumper. `norefs` option, to clone linked objects, #229.
|
||||
- Loader. Throw a warning for duplicate keys, #166.
|
||||
- Improved browserify support (mark `esprima` & `Buffer` excluded).
|
||||
|
||||
|
||||
## [3.4.6] - 2015-11-26
|
||||
### Changed
|
||||
- Use standalone `inherit` to keep browserified files clear.
|
||||
|
||||
|
||||
## [3.4.5] - 2015-11-23
|
||||
### Added
|
||||
- Added `lineWidth` option to dumper.
|
||||
|
||||
|
||||
## [3.4.4] - 2015-11-21
|
||||
### Fixed
|
||||
- Fixed floats dump (missed dot for scientific format), #220.
|
||||
- Allow non-printable characters inside quoted scalars, #192.
|
||||
|
||||
|
||||
## [3.4.3] - 2015-10-10
|
||||
### Changed
|
||||
- Maintenance release - deps bump (esprima, argparse).
|
||||
|
||||
|
||||
## [3.4.2] - 2015-09-09
|
||||
### Fixed
|
||||
- Fixed serialization of duplicated entries in sequences, #205.
|
||||
Thanks to @vogelsgesang.
|
||||
|
||||
|
||||
## [3.4.1] - 2015-09-05
|
||||
### Fixed
|
||||
- Fixed stacktrace handling in generated errors, for browsers (FF/IE).
|
||||
|
||||
|
||||
## [3.4.0] - 2015-08-23
|
||||
### Changed
|
||||
- Don't throw on warnings anymore. Use `onWarning` option to catch.
|
||||
- Throw error on unknown tags (was warning before).
|
||||
- Reworked internals of error class.
|
||||
|
||||
### Fixed
|
||||
- Fixed multiline keys dump, #197. Thanks to @tcr.
|
||||
- Fixed heading line breaks in some scalars (regression).
|
||||
|
||||
|
||||
## [3.3.1] - 2015-05-13
|
||||
### Added
|
||||
- Added `.sortKeys` dumper option, thanks to @rjmunro.
|
||||
|
||||
### Fixed
|
||||
- Fixed astral characters support, #191.
|
||||
|
||||
|
||||
## [3.3.0] - 2015-04-26
|
||||
### Changed
|
||||
- Significantly improved long strings formatting in dumper, thanks to @isaacs.
|
||||
- Strip BOM if exists.
|
||||
|
||||
|
||||
## [3.2.7] - 2015-02-19
|
||||
### Changed
|
||||
- Maintenance release.
|
||||
- Updated dependencies.
|
||||
- HISTORY.md -> CHANGELOG.md
|
||||
|
||||
|
||||
## [3.2.6] - 2015-02-07
|
||||
### Fixed
|
||||
- Fixed encoding of UTF-16 surrogate pairs. (e.g. "\U0001F431" CAT FACE).
|
||||
- Fixed demo dates dump (#113, thanks to @Hypercubed).
|
||||
|
||||
|
||||
## [3.2.5] - 2014-12-28
|
||||
### Fixed
|
||||
- Fixed resolving of all built-in types on empty nodes.
|
||||
- Fixed invalid warning on empty lines within quoted scalars and flow collections.
|
||||
- Fixed bug: Tag on an empty node didn't resolve in some cases.
|
||||
|
||||
|
||||
## [3.2.4] - 2014-12-19
|
||||
### Fixed
|
||||
- Fixed resolving of !!null tag on an empty node.
|
||||
|
||||
|
||||
## [3.2.3] - 2014-11-08
|
||||
### Fixed
|
||||
- Implemented dumping of objects with circular and cross references.
|
||||
- Partially fixed aliasing of constructed objects. (see issue #141 for details)
|
||||
|
||||
|
||||
## [3.2.2] - 2014-09-07
|
||||
### Fixed
|
||||
- Fixed infinite loop on unindented block scalars.
|
||||
- Rewritten base64 encode/decode in binary type, to keep code licence clear.
|
||||
|
||||
|
||||
## [3.2.1] - 2014-08-24
|
||||
### Fixed
|
||||
- Nothig new. Just fix npm publish error.
|
||||
|
||||
|
||||
## [3.2.0] - 2014-08-24
|
||||
### Added
|
||||
- Added input piping support to CLI.
|
||||
|
||||
### Fixed
|
||||
- Fixed typo, that could cause hand on initial indent (#139).
|
||||
|
||||
|
||||
## [3.1.0] - 2014-07-07
|
||||
### Changed
|
||||
- 1.5x-2x speed boost.
|
||||
- Removed deprecated `require('xxx.yml')` support.
|
||||
- Significant code cleanup and refactoring.
|
||||
- Internal API changed. If you used custom types - see updated examples.
|
||||
Others are not affected.
|
||||
- Even if the input string has no trailing line break character,
|
||||
it will be parsed as if it has one.
|
||||
- Added benchmark scripts.
|
||||
- Moved bower files to /dist folder
|
||||
- Bugfixes.
|
||||
|
||||
|
||||
## [3.0.2] - 2014-02-27
|
||||
### Fixed
|
||||
- Fixed bug: "constructor" string parsed as `null`.
|
||||
|
||||
|
||||
## [3.0.1] - 2013-12-22
|
||||
### Fixed
|
||||
- Fixed parsing of literal scalars. (issue #108)
|
||||
- Prevented adding unnecessary spaces in object dumps. (issue #68)
|
||||
- Fixed dumping of objects with very long (> 1024 in length) keys.
|
||||
|
||||
|
||||
## [3.0.0] - 2013-12-16
|
||||
### Changed
|
||||
- Refactored code. Changed API for custom types.
|
||||
- Removed output colors in CLI, dump json by default.
|
||||
- Removed big dependencies from browser version (esprima, buffer). Load `esprima` manually, if `!!js/function` needed. `!!bin` now returns Array in browser
|
||||
- AMD support.
|
||||
- Don't quote dumped strings because of `-` & `?` (if not first char).
|
||||
- __Deprecated__ loading yaml files via `require()`, as not recommended
|
||||
behaviour for node.
|
||||
|
||||
|
||||
## [2.1.3] - 2013-10-16
|
||||
### Fixed
|
||||
- Fix wrong loading of empty block scalars.
|
||||
|
||||
|
||||
## [2.1.2] - 2013-10-07
|
||||
### Fixed
|
||||
- Fix unwanted line breaks in folded scalars.
|
||||
|
||||
|
||||
## [2.1.1] - 2013-10-02
|
||||
### Fixed
|
||||
- Dumper now respects deprecated booleans syntax from YAML 1.0/1.1
|
||||
- Fixed reader bug in JSON-like sequences/mappings.
|
||||
|
||||
|
||||
## [2.1.0] - 2013-06-05
|
||||
### Added
|
||||
- Add standard YAML schemas: Failsafe (`FAILSAFE_SCHEMA`),
|
||||
JSON (`JSON_SCHEMA`) and Core (`CORE_SCHEMA`).
|
||||
- Add `skipInvalid` dumper option.
|
||||
|
||||
### Changed
|
||||
- Rename `DEFAULT_SCHEMA` to `DEFAULT_FULL_SCHEMA`
|
||||
and `SAFE_SCHEMA` to `DEFAULT_SAFE_SCHEMA`.
|
||||
- Use `safeLoad` for `require` extension.
|
||||
|
||||
### Fixed
|
||||
- Bug fix: export `NIL` constant from the public interface.
|
||||
|
||||
|
||||
## [2.0.5] - 2013-04-26
|
||||
### Security
|
||||
- Close security issue in !!js/function constructor.
|
||||
Big thanks to @nealpoole for security audit.
|
||||
|
||||
|
||||
## [2.0.4] - 2013-04-08
|
||||
### Changed
|
||||
- Updated .npmignore to reduce package size
|
||||
|
||||
|
||||
## [2.0.3] - 2013-02-26
|
||||
### Fixed
|
||||
- Fixed dumping of empty arrays ans objects. ([] and {} instead of null)
|
||||
|
||||
|
||||
## [2.0.2] - 2013-02-15
|
||||
### Fixed
|
||||
- Fixed input validation: tabs are printable characters.
|
||||
|
||||
|
||||
## [2.0.1] - 2013-02-09
|
||||
### Fixed
|
||||
- Fixed error, when options not passed to function cass
|
||||
|
||||
|
||||
## [2.0.0] - 2013-02-09
|
||||
### Changed
|
||||
- Full rewrite. New architecture. Fast one-stage parsing.
|
||||
- Changed custom types API.
|
||||
- Added YAML dumper.
|
||||
|
||||
|
||||
## [1.0.3] - 2012-11-05
|
||||
### Fixed
|
||||
- Fixed utf-8 files loading.
|
||||
|
||||
|
||||
## [1.0.2] - 2012-08-02
|
||||
### Fixed
|
||||
- Pull out hand-written shims. Use ES5-Shims for old browsers support. See #44.
|
||||
- Fix timstamps incorectly parsed in local time when no time part specified.
|
||||
|
||||
|
||||
## [1.0.1] - 2012-07-07
|
||||
### Fixed
|
||||
- Fixes `TypeError: 'undefined' is not an object` under Safari. Thanks Phuong.
|
||||
- Fix timestamps incorrectly parsed in local time. Thanks @caolan. Closes #46.
|
||||
|
||||
|
||||
## [1.0.0] - 2012-07-01
|
||||
### Changed
|
||||
- `y`, `yes`, `n`, `no`, `on`, `off` are not converted to Booleans anymore.
|
||||
Fixes #42.
|
||||
- `require(filename)` now returns a single document and throws an Error if
|
||||
file contains more than one document.
|
||||
- CLI was merged back from js-yaml.bin
|
||||
|
||||
|
||||
## [0.3.7] - 2012-02-28
|
||||
### Fixed
|
||||
- Fix export of `addConstructor()`. Closes #39.
|
||||
|
||||
|
||||
## [0.3.6] - 2012-02-22
|
||||
### Changed
|
||||
- Removed AMD parts - too buggy to use. Need help to rewrite from scratch
|
||||
|
||||
### Fixed
|
||||
- Removed YUI compressor warning (renamed `double` variable). Closes #40.
|
||||
|
||||
|
||||
## [0.3.5] - 2012-01-10
|
||||
### Fixed
|
||||
- Workagound for .npmignore fuckup under windows. Thanks to airportyh.
|
||||
|
||||
|
||||
## [0.3.4] - 2011-12-24
|
||||
### Fixed
|
||||
- Fixes str[] for oldIEs support.
|
||||
- Adds better has change support for browserified demo.
|
||||
- improves compact output of Error. Closes #33.
|
||||
|
||||
|
||||
## [0.3.3] - 2011-12-20
|
||||
### Added
|
||||
- adds `compact` stringification of Errors.
|
||||
|
||||
### Changed
|
||||
- jsyaml executable moved to separate module.
|
||||
|
||||
|
||||
## [0.3.2] - 2011-12-16
|
||||
### Added
|
||||
- Added jsyaml executable.
|
||||
- Added !!js/function support. Closes #12.
|
||||
|
||||
### Fixed
|
||||
- Fixes ug with block style scalars. Closes #26.
|
||||
- All sources are passing JSLint now.
|
||||
- Fixes bug in Safari. Closes #28.
|
||||
- Fixes bug in Opers. Closes #29.
|
||||
- Improves browser support. Closes #20.
|
||||
|
||||
|
||||
## [0.3.1] - 2011-11-18
|
||||
### Added
|
||||
- Added AMD support for browserified version.
|
||||
- Added permalinks for online demo YAML snippets. Now we have YPaste service, lol.
|
||||
- Added !!js/regexp and !!js/undefined types. Partially solves #12.
|
||||
|
||||
### Changed
|
||||
- Wrapped browserified js-yaml into closure.
|
||||
|
||||
### Fixed
|
||||
- Fixed the resolvement of non-specific tags. Closes #17.
|
||||
- Fixed !!set mapping.
|
||||
- Fixed month parse in dates. Closes #19.
|
||||
|
||||
|
||||
## [0.3.0] - 2011-11-09
|
||||
### Added
|
||||
- Added browserified version. Closes #13.
|
||||
- Added live demo of browserified version.
|
||||
- Ported some of the PyYAML tests. See #14.
|
||||
|
||||
### Fixed
|
||||
- Removed JS.Class dependency. Closes #3.
|
||||
- Fixed timestamp bug when fraction was given.
|
||||
|
||||
|
||||
## [0.2.2] - 2011-11-06
|
||||
### Fixed
|
||||
- Fixed crash on docs without ---. Closes #8.
|
||||
- Fixed multiline string parse
|
||||
- Fixed tests/comments for using array as key
|
||||
|
||||
|
||||
## [0.2.1] - 2011-11-02
|
||||
### Fixed
|
||||
- Fixed short file read (<4k). Closes #9.
|
||||
|
||||
|
||||
## [0.2.0] - 2011-11-02
|
||||
### Changed
|
||||
- First public release
|
||||
|
||||
|
||||
[3.14.1]: https://github.com/nodeca/js-yaml/compare/3.14.0...3.14.1
|
||||
[3.14.0]: https://github.com/nodeca/js-yaml/compare/3.13.1...3.14.0
|
||||
[3.13.1]: https://github.com/nodeca/js-yaml/compare/3.13.0...3.13.1
|
||||
[3.13.0]: https://github.com/nodeca/js-yaml/compare/3.12.2...3.13.0
|
||||
[3.12.2]: https://github.com/nodeca/js-yaml/compare/3.12.1...3.12.2
|
||||
[3.12.1]: https://github.com/nodeca/js-yaml/compare/3.12.0...3.12.1
|
||||
[3.12.0]: https://github.com/nodeca/js-yaml/compare/3.11.0...3.12.0
|
||||
[3.11.0]: https://github.com/nodeca/js-yaml/compare/3.10.0...3.11.0
|
||||
[3.10.0]: https://github.com/nodeca/js-yaml/compare/3.9.1...3.10.0
|
||||
[3.9.1]: https://github.com/nodeca/js-yaml/compare/3.9.0...3.9.1
|
||||
[3.9.0]: https://github.com/nodeca/js-yaml/compare/3.8.4...3.9.0
|
||||
[3.8.4]: https://github.com/nodeca/js-yaml/compare/3.8.3...3.8.4
|
||||
[3.8.3]: https://github.com/nodeca/js-yaml/compare/3.8.2...3.8.3
|
||||
[3.8.2]: https://github.com/nodeca/js-yaml/compare/3.8.1...3.8.2
|
||||
[3.8.1]: https://github.com/nodeca/js-yaml/compare/3.8.0...3.8.1
|
||||
[3.8.0]: https://github.com/nodeca/js-yaml/compare/3.7.0...3.8.0
|
||||
[3.7.0]: https://github.com/nodeca/js-yaml/compare/3.6.1...3.7.0
|
||||
[3.6.1]: https://github.com/nodeca/js-yaml/compare/3.6.0...3.6.1
|
||||
[3.6.0]: https://github.com/nodeca/js-yaml/compare/3.5.5...3.6.0
|
||||
[3.5.5]: https://github.com/nodeca/js-yaml/compare/3.5.4...3.5.5
|
||||
[3.5.4]: https://github.com/nodeca/js-yaml/compare/3.5.3...3.5.4
|
||||
[3.5.3]: https://github.com/nodeca/js-yaml/compare/3.5.2...3.5.3
|
||||
[3.5.2]: https://github.com/nodeca/js-yaml/compare/3.5.1...3.5.2
|
||||
[3.5.1]: https://github.com/nodeca/js-yaml/compare/3.5.0...3.5.1
|
||||
[3.5.0]: https://github.com/nodeca/js-yaml/compare/3.4.6...3.5.0
|
||||
[3.4.6]: https://github.com/nodeca/js-yaml/compare/3.4.5...3.4.6
|
||||
[3.4.5]: https://github.com/nodeca/js-yaml/compare/3.4.4...3.4.5
|
||||
[3.4.4]: https://github.com/nodeca/js-yaml/compare/3.4.3...3.4.4
|
||||
[3.4.3]: https://github.com/nodeca/js-yaml/compare/3.4.2...3.4.3
|
||||
[3.4.2]: https://github.com/nodeca/js-yaml/compare/3.4.1...3.4.2
|
||||
[3.4.1]: https://github.com/nodeca/js-yaml/compare/3.4.0...3.4.1
|
||||
[3.4.0]: https://github.com/nodeca/js-yaml/compare/3.3.1...3.4.0
|
||||
[3.3.1]: https://github.com/nodeca/js-yaml/compare/3.3.0...3.3.1
|
||||
[3.3.0]: https://github.com/nodeca/js-yaml/compare/3.2.7...3.3.0
|
||||
[3.2.7]: https://github.com/nodeca/js-yaml/compare/3.2.6...3.2.7
|
||||
[3.2.6]: https://github.com/nodeca/js-yaml/compare/3.2.5...3.2.6
|
||||
[3.2.5]: https://github.com/nodeca/js-yaml/compare/3.2.4...3.2.5
|
||||
[3.2.4]: https://github.com/nodeca/js-yaml/compare/3.2.3...3.2.4
|
||||
[3.2.3]: https://github.com/nodeca/js-yaml/compare/3.2.2...3.2.3
|
||||
[3.2.2]: https://github.com/nodeca/js-yaml/compare/3.2.1...3.2.2
|
||||
[3.2.1]: https://github.com/nodeca/js-yaml/compare/3.2.0...3.2.1
|
||||
[3.2.0]: https://github.com/nodeca/js-yaml/compare/3.1.0...3.2.0
|
||||
[3.1.0]: https://github.com/nodeca/js-yaml/compare/3.0.2...3.1.0
|
||||
[3.0.2]: https://github.com/nodeca/js-yaml/compare/3.0.1...3.0.2
|
||||
[3.0.1]: https://github.com/nodeca/js-yaml/compare/3.0.0...3.0.1
|
||||
[3.0.0]: https://github.com/nodeca/js-yaml/compare/2.1.3...3.0.0
|
||||
[2.1.3]: https://github.com/nodeca/js-yaml/compare/2.1.2...2.1.3
|
||||
[2.1.2]: https://github.com/nodeca/js-yaml/compare/2.1.1...2.1.2
|
||||
[2.1.1]: https://github.com/nodeca/js-yaml/compare/2.1.0...2.1.1
|
||||
[2.1.0]: https://github.com/nodeca/js-yaml/compare/2.0.5...2.1.0
|
||||
[2.0.5]: https://github.com/nodeca/js-yaml/compare/2.0.4...2.0.5
|
||||
[2.0.4]: https://github.com/nodeca/js-yaml/compare/2.0.3...2.0.4
|
||||
[2.0.3]: https://github.com/nodeca/js-yaml/compare/2.0.2...2.0.3
|
||||
[2.0.2]: https://github.com/nodeca/js-yaml/compare/2.0.1...2.0.2
|
||||
[2.0.1]: https://github.com/nodeca/js-yaml/compare/2.0.0...2.0.1
|
||||
[2.0.0]: https://github.com/nodeca/js-yaml/compare/1.0.3...2.0.0
|
||||
[1.0.3]: https://github.com/nodeca/js-yaml/compare/1.0.2...1.0.3
|
||||
[1.0.2]: https://github.com/nodeca/js-yaml/compare/1.0.1...1.0.2
|
||||
[1.0.1]: https://github.com/nodeca/js-yaml/compare/1.0.0...1.0.1
|
||||
[1.0.0]: https://github.com/nodeca/js-yaml/compare/0.3.7...1.0.0
|
||||
[0.3.7]: https://github.com/nodeca/js-yaml/compare/0.3.6...0.3.7
|
||||
[0.3.6]: https://github.com/nodeca/js-yaml/compare/0.3.5...0.3.6
|
||||
[0.3.5]: https://github.com/nodeca/js-yaml/compare/0.3.4...0.3.5
|
||||
[0.3.4]: https://github.com/nodeca/js-yaml/compare/0.3.3...0.3.4
|
||||
[0.3.3]: https://github.com/nodeca/js-yaml/compare/0.3.2...0.3.3
|
||||
[0.3.2]: https://github.com/nodeca/js-yaml/compare/0.3.1...0.3.2
|
||||
[0.3.1]: https://github.com/nodeca/js-yaml/compare/0.3.0...0.3.1
|
||||
[0.3.0]: https://github.com/nodeca/js-yaml/compare/0.2.2...0.3.0
|
||||
[0.2.2]: https://github.com/nodeca/js-yaml/compare/0.2.1...0.2.2
|
||||
[0.2.1]: https://github.com/nodeca/js-yaml/compare/0.2.0...0.2.1
|
||||
[0.2.0]: https://github.com/nodeca/js-yaml/releases/tag/0.2.0
|
21
node_modules/@eslint/eslintrc/node_modules/js-yaml/LICENSE
сгенерированный
поставляемый
Normal file
21
node_modules/@eslint/eslintrc/node_modules/js-yaml/LICENSE
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,21 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (C) 2011-2015 by Vitaly Puzrin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
299
node_modules/@eslint/eslintrc/node_modules/js-yaml/README.md
сгенерированный
поставляемый
Normal file
299
node_modules/@eslint/eslintrc/node_modules/js-yaml/README.md
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,299 @@
|
|||
JS-YAML - YAML 1.2 parser / writer for JavaScript
|
||||
=================================================
|
||||
|
||||
[![Build Status](https://travis-ci.org/nodeca/js-yaml.svg?branch=master)](https://travis-ci.org/nodeca/js-yaml)
|
||||
[![NPM version](https://img.shields.io/npm/v/js-yaml.svg)](https://www.npmjs.org/package/js-yaml)
|
||||
|
||||
__[Online Demo](http://nodeca.github.com/js-yaml/)__
|
||||
|
||||
|
||||
This is an implementation of [YAML](http://yaml.org/), a human-friendly data
|
||||
serialization language. Started as [PyYAML](http://pyyaml.org/) port, it was
|
||||
completely rewritten from scratch. Now it's very fast, and supports 1.2 spec.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
### YAML module for node.js
|
||||
|
||||
```
|
||||
npm install js-yaml
|
||||
```
|
||||
|
||||
|
||||
### CLI executable
|
||||
|
||||
If you want to inspect your YAML files from CLI, install js-yaml globally:
|
||||
|
||||
```
|
||||
npm install -g js-yaml
|
||||
```
|
||||
|
||||
#### Usage
|
||||
|
||||
```
|
||||
usage: js-yaml [-h] [-v] [-c] [-t] file
|
||||
|
||||
Positional arguments:
|
||||
file File with YAML document(s)
|
||||
|
||||
Optional arguments:
|
||||
-h, --help Show this help message and exit.
|
||||
-v, --version Show program's version number and exit.
|
||||
-c, --compact Display errors in compact mode
|
||||
-t, --trace Show stack trace on error
|
||||
```
|
||||
|
||||
|
||||
### Bundled YAML library for browsers
|
||||
|
||||
``` html
|
||||
<!-- esprima required only for !!js/function -->
|
||||
<script src="esprima.js"></script>
|
||||
<script src="js-yaml.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var doc = jsyaml.load('greeting: hello\nname: world');
|
||||
</script>
|
||||
```
|
||||
|
||||
Browser support was done mostly for the online demo. If you find any errors - feel
|
||||
free to send pull requests with fixes. Also note, that IE and other old browsers
|
||||
needs [es5-shims](https://github.com/kriskowal/es5-shim) to operate.
|
||||
|
||||
Notes:
|
||||
|
||||
1. We have no resources to support browserified version. Don't expect it to be
|
||||
well tested. Don't expect fast fixes if something goes wrong there.
|
||||
2. `!!js/function` in browser bundle will not work by default. If you really need
|
||||
it - load `esprima` parser first (via amd or directly).
|
||||
3. `!!bin` in browser will return `Array`, because browsers do not support
|
||||
node.js `Buffer` and adding Buffer shims is completely useless on practice.
|
||||
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
Here we cover the most 'useful' methods. If you need advanced details (creating
|
||||
your own tags), see [wiki](https://github.com/nodeca/js-yaml/wiki) and
|
||||
[examples](https://github.com/nodeca/js-yaml/tree/master/examples) for more
|
||||
info.
|
||||
|
||||
``` javascript
|
||||
const yaml = require('js-yaml');
|
||||
const fs = require('fs');
|
||||
|
||||
// Get document, or throw exception on error
|
||||
try {
|
||||
const doc = yaml.safeLoad(fs.readFileSync('/home/ixti/example.yml', 'utf8'));
|
||||
console.log(doc);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### safeLoad (string [ , options ])
|
||||
|
||||
**Recommended loading way.** Parses `string` as single YAML document. Returns either a
|
||||
plain object, a string or `undefined`, or throws `YAMLException` on error. By default, does
|
||||
not support regexps, functions and undefined. This method is safe for untrusted data.
|
||||
|
||||
options:
|
||||
|
||||
- `filename` _(default: null)_ - string to be used as a file path in
|
||||
error/warning messages.
|
||||
- `onWarning` _(default: null)_ - function to call on warning messages.
|
||||
Loader will call this function with an instance of `YAMLException` for each warning.
|
||||
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ - specifies a schema to use.
|
||||
- `FAILSAFE_SCHEMA` - only strings, arrays and plain objects:
|
||||
http://www.yaml.org/spec/1.2/spec.html#id2802346
|
||||
- `JSON_SCHEMA` - all JSON-supported types:
|
||||
http://www.yaml.org/spec/1.2/spec.html#id2803231
|
||||
- `CORE_SCHEMA` - same as `JSON_SCHEMA`:
|
||||
http://www.yaml.org/spec/1.2/spec.html#id2804923
|
||||
- `DEFAULT_SAFE_SCHEMA` - all supported YAML types, without unsafe ones
|
||||
(`!!js/undefined`, `!!js/regexp` and `!!js/function`):
|
||||
http://yaml.org/type/
|
||||
- `DEFAULT_FULL_SCHEMA` - all supported YAML types.
|
||||
- `json` _(default: false)_ - compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error.
|
||||
|
||||
NOTE: This function **does not** understand multi-document sources, it throws
|
||||
exception on those.
|
||||
|
||||
NOTE: JS-YAML **does not** support schema-specific tag resolution restrictions.
|
||||
So, the JSON schema is not as strictly defined in the YAML specification.
|
||||
It allows numbers in any notation, use `Null` and `NULL` as `null`, etc.
|
||||
The core schema also has no such restrictions. It allows binary notation for integers.
|
||||
|
||||
|
||||
### load (string [ , options ])
|
||||
|
||||
**Use with care with untrusted sources**. The same as `safeLoad()` but uses
|
||||
`DEFAULT_FULL_SCHEMA` by default - adds some JavaScript-specific types:
|
||||
`!!js/function`, `!!js/regexp` and `!!js/undefined`. For untrusted sources, you
|
||||
must additionally validate object structure to avoid injections:
|
||||
|
||||
``` javascript
|
||||
const untrusted_code = '"toString": !<tag:yaml.org,2002:js/function> "function (){very_evil_thing();}"';
|
||||
|
||||
// I'm just converting that string, what could possibly go wrong?
|
||||
require('js-yaml').load(untrusted_code) + ''
|
||||
```
|
||||
|
||||
|
||||
### safeLoadAll (string [, iterator] [, options ])
|
||||
|
||||
Same as `safeLoad()`, but understands multi-document sources. Applies
|
||||
`iterator` to each document if specified, or returns array of documents.
|
||||
|
||||
``` javascript
|
||||
const yaml = require('js-yaml');
|
||||
|
||||
yaml.safeLoadAll(data, function (doc) {
|
||||
console.log(doc);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### loadAll (string [, iterator] [ , options ])
|
||||
|
||||
Same as `safeLoadAll()` but uses `DEFAULT_FULL_SCHEMA` by default.
|
||||
|
||||
|
||||
### safeDump (object [ , options ])
|
||||
|
||||
Serializes `object` as a YAML document. Uses `DEFAULT_SAFE_SCHEMA`, so it will
|
||||
throw an exception if you try to dump regexps or functions. However, you can
|
||||
disable exceptions by setting the `skipInvalid` option to `true`.
|
||||
|
||||
options:
|
||||
|
||||
- `indent` _(default: 2)_ - indentation width to use (in spaces).
|
||||
- `noArrayIndent` _(default: false)_ - when true, will not add an indentation level to array elements
|
||||
- `skipInvalid` _(default: false)_ - do not throw on invalid types (like function
|
||||
in the safe schema) and skip pairs and single values with such types.
|
||||
- `flowLevel` (default: -1) - specifies level of nesting, when to switch from
|
||||
block to flow style for collections. -1 means block style everwhere
|
||||
- `styles` - "tag" => "style" map. Each tag may have own set of styles.
|
||||
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ specifies a schema to use.
|
||||
- `sortKeys` _(default: `false`)_ - if `true`, sort keys when dumping YAML. If a
|
||||
function, use the function to sort the keys.
|
||||
- `lineWidth` _(default: `80`)_ - set max line width.
|
||||
- `noRefs` _(default: `false`)_ - if `true`, don't convert duplicate objects into references
|
||||
- `noCompatMode` _(default: `false`)_ - if `true` don't try to be compatible with older
|
||||
yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1
|
||||
- `condenseFlow` _(default: `false`)_ - if `true` flow sequences will be condensed, omitting the space between `a, b`. Eg. `'[a,b]'`, and omitting the space between `key: value` and quoting the key. Eg. `'{"a":b}'` Can be useful when using yaml for pretty URL query params as spaces are %-encoded.
|
||||
|
||||
The following table show availlable styles (e.g. "canonical",
|
||||
"binary"...) available for each tag (.e.g. !!null, !!int ...). Yaml
|
||||
output is shown on the right side after `=>` (default setting) or `->`:
|
||||
|
||||
``` none
|
||||
!!null
|
||||
"canonical" -> "~"
|
||||
"lowercase" => "null"
|
||||
"uppercase" -> "NULL"
|
||||
"camelcase" -> "Null"
|
||||
|
||||
!!int
|
||||
"binary" -> "0b1", "0b101010", "0b1110001111010"
|
||||
"octal" -> "01", "052", "016172"
|
||||
"decimal" => "1", "42", "7290"
|
||||
"hexadecimal" -> "0x1", "0x2A", "0x1C7A"
|
||||
|
||||
!!bool
|
||||
"lowercase" => "true", "false"
|
||||
"uppercase" -> "TRUE", "FALSE"
|
||||
"camelcase" -> "True", "False"
|
||||
|
||||
!!float
|
||||
"lowercase" => ".nan", '.inf'
|
||||
"uppercase" -> ".NAN", '.INF'
|
||||
"camelcase" -> ".NaN", '.Inf'
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
``` javascript
|
||||
safeDump (object, {
|
||||
'styles': {
|
||||
'!!null': 'canonical' // dump null as ~
|
||||
},
|
||||
'sortKeys': true // sort object keys
|
||||
});
|
||||
```
|
||||
|
||||
### dump (object [ , options ])
|
||||
|
||||
Same as `safeDump()` but without limits (uses `DEFAULT_FULL_SCHEMA` by default).
|
||||
|
||||
|
||||
Supported YAML types
|
||||
--------------------
|
||||
|
||||
The list of standard YAML tags and corresponding JavaScipt types. See also
|
||||
[YAML tag discussion](http://pyyaml.org/wiki/YAMLTagDiscussion) and
|
||||
[YAML types repository](http://yaml.org/type/).
|
||||
|
||||
```
|
||||
!!null '' # null
|
||||
!!bool 'yes' # bool
|
||||
!!int '3...' # number
|
||||
!!float '3.14...' # number
|
||||
!!binary '...base64...' # buffer
|
||||
!!timestamp 'YYYY-...' # date
|
||||
!!omap [ ... ] # array of key-value pairs
|
||||
!!pairs [ ... ] # array or array pairs
|
||||
!!set { ... } # array of objects with given keys and null values
|
||||
!!str '...' # string
|
||||
!!seq [ ... ] # array
|
||||
!!map { ... } # object
|
||||
```
|
||||
|
||||
**JavaScript-specific tags**
|
||||
|
||||
```
|
||||
!!js/regexp /pattern/gim # RegExp
|
||||
!!js/undefined '' # Undefined
|
||||
!!js/function 'function () {...}' # Function
|
||||
```
|
||||
|
||||
Caveats
|
||||
-------
|
||||
|
||||
Note, that you use arrays or objects as key in JS-YAML. JS does not allow objects
|
||||
or arrays as keys, and stringifies (by calling `toString()` method) them at the
|
||||
moment of adding them.
|
||||
|
||||
``` yaml
|
||||
---
|
||||
? [ foo, bar ]
|
||||
: - baz
|
||||
? { foo: bar }
|
||||
: - baz
|
||||
- baz
|
||||
```
|
||||
|
||||
``` javascript
|
||||
{ "foo,bar": ["baz"], "[object Object]": ["baz", "baz"] }
|
||||
```
|
||||
|
||||
Also, reading of properties on implicit block mapping keys is not supported yet.
|
||||
So, the following YAML document cannot be loaded.
|
||||
|
||||
``` yaml
|
||||
&anchor foo:
|
||||
foo: bar
|
||||
*anchor: duplicate key
|
||||
baz: bat
|
||||
*anchor: duplicate key
|
||||
```
|
||||
|
||||
|
||||
js-yaml for enterprise
|
||||
----------------------
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of js-yaml and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-js-yaml?utm_source=npm-js-yaml&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
132
node_modules/@eslint/eslintrc/node_modules/js-yaml/bin/js-yaml.js
сгенерированный
поставляемый
Executable file
132
node_modules/@eslint/eslintrc/node_modules/js-yaml/bin/js-yaml.js
сгенерированный
поставляемый
Executable file
|
@ -0,0 +1,132 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
|
||||
'use strict';
|
||||
|
||||
/*eslint-disable no-console*/
|
||||
|
||||
|
||||
// stdlib
|
||||
var fs = require('fs');
|
||||
|
||||
|
||||
// 3rd-party
|
||||
var argparse = require('argparse');
|
||||
|
||||
|
||||
// internal
|
||||
var yaml = require('..');
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
var cli = new argparse.ArgumentParser({
|
||||
prog: 'js-yaml',
|
||||
version: require('../package.json').version,
|
||||
addHelp: true
|
||||
});
|
||||
|
||||
|
||||
cli.addArgument([ '-c', '--compact' ], {
|
||||
help: 'Display errors in compact mode',
|
||||
action: 'storeTrue'
|
||||
});
|
||||
|
||||
|
||||
// deprecated (not needed after we removed output colors)
|
||||
// option suppressed, but not completely removed for compatibility
|
||||
cli.addArgument([ '-j', '--to-json' ], {
|
||||
help: argparse.Const.SUPPRESS,
|
||||
dest: 'json',
|
||||
action: 'storeTrue'
|
||||
});
|
||||
|
||||
|
||||
cli.addArgument([ '-t', '--trace' ], {
|
||||
help: 'Show stack trace on error',
|
||||
action: 'storeTrue'
|
||||
});
|
||||
|
||||
cli.addArgument([ 'file' ], {
|
||||
help: 'File to read, utf-8 encoded without BOM',
|
||||
nargs: '?',
|
||||
defaultValue: '-'
|
||||
});
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
var options = cli.parseArgs();
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function readFile(filename, encoding, callback) {
|
||||
if (options.file === '-') {
|
||||
// read from stdin
|
||||
|
||||
var chunks = [];
|
||||
|
||||
process.stdin.on('data', function (chunk) {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
|
||||
process.stdin.on('end', function () {
|
||||
return callback(null, Buffer.concat(chunks).toString(encoding));
|
||||
});
|
||||
} else {
|
||||
fs.readFile(filename, encoding, callback);
|
||||
}
|
||||
}
|
||||
|
||||
readFile(options.file, 'utf8', function (error, input) {
|
||||
var output, isYaml;
|
||||
|
||||
if (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
console.error('File not found: ' + options.file);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
console.error(
|
||||
options.trace && error.stack ||
|
||||
error.message ||
|
||||
String(error));
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
output = JSON.parse(input);
|
||||
isYaml = false;
|
||||
} catch (err) {
|
||||
if (err instanceof SyntaxError) {
|
||||
try {
|
||||
output = [];
|
||||
yaml.loadAll(input, function (doc) { output.push(doc); }, {});
|
||||
isYaml = true;
|
||||
|
||||
if (output.length === 0) output = null;
|
||||
else if (output.length === 1) output = output[0];
|
||||
|
||||
} catch (e) {
|
||||
if (options.trace && err.stack) console.error(e.stack);
|
||||
else console.error(e.toString(options.compact));
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
console.error(
|
||||
options.trace && err.stack ||
|
||||
err.message ||
|
||||
String(err));
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (isYaml) console.log(JSON.stringify(output, null, ' '));
|
||||
else console.log(yaml.dump(output));
|
||||
});
|
3989
node_modules/@eslint/eslintrc/node_modules/js-yaml/dist/js-yaml.js
сгенерированный
поставляемый
Normal file
3989
node_modules/@eslint/eslintrc/node_modules/js-yaml/dist/js-yaml.js
сгенерированный
поставляемый
Normal file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
1
node_modules/@eslint/eslintrc/node_modules/js-yaml/dist/js-yaml.min.js
сгенерированный
поставляемый
Normal file
1
node_modules/@eslint/eslintrc/node_modules/js-yaml/dist/js-yaml.min.js
сгенерированный
поставляемый
Normal file
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
7
node_modules/@eslint/eslintrc/node_modules/js-yaml/index.js
сгенерированный
поставляемый
Normal file
7
node_modules/@eslint/eslintrc/node_modules/js-yaml/index.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
var yaml = require('./lib/js-yaml.js');
|
||||
|
||||
|
||||
module.exports = yaml;
|
0
node_modules/js-yaml/lib/js-yaml.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/common.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/common.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/common.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/common.js
сгенерированный
поставляемый
37
node_modules/js-yaml/lib/js-yaml/dumper.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/dumper.js
сгенерированный
поставляемый
37
node_modules/js-yaml/lib/js-yaml/dumper.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/dumper.js
сгенерированный
поставляемый
|
@ -12,6 +12,7 @@ var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|||
|
||||
var CHAR_TAB = 0x09; /* Tab */
|
||||
var CHAR_LINE_FEED = 0x0A; /* LF */
|
||||
var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
|
||||
var CHAR_SPACE = 0x20; /* Space */
|
||||
var CHAR_EXCLAMATION = 0x21; /* ! */
|
||||
var CHAR_DOUBLE_QUOTE = 0x22; /* " */
|
||||
|
@ -23,6 +24,7 @@ var CHAR_ASTERISK = 0x2A; /* * */
|
|||
var CHAR_COMMA = 0x2C; /* , */
|
||||
var CHAR_MINUS = 0x2D; /* - */
|
||||
var CHAR_COLON = 0x3A; /* : */
|
||||
var CHAR_EQUALS = 0x3D; /* = */
|
||||
var CHAR_GREATER_THAN = 0x3E; /* > */
|
||||
var CHAR_QUESTION = 0x3F; /* ? */
|
||||
var CHAR_COMMERCIAL_AT = 0x40; /* @ */
|
||||
|
@ -188,8 +190,23 @@ function isPrintable(c) {
|
|||
|| (0x10000 <= c && c <= 0x10FFFF);
|
||||
}
|
||||
|
||||
// [34] ns-char ::= nb-char - s-white
|
||||
// [27] nb-char ::= c-printable - b-char - c-byte-order-mark
|
||||
// [26] b-char ::= b-line-feed | b-carriage-return
|
||||
// [24] b-line-feed ::= #xA /* LF */
|
||||
// [25] b-carriage-return ::= #xD /* CR */
|
||||
// [3] c-byte-order-mark ::= #xFEFF
|
||||
function isNsChar(c) {
|
||||
return isPrintable(c) && !isWhitespace(c)
|
||||
// byte-order-mark
|
||||
&& c !== 0xFEFF
|
||||
// b-char
|
||||
&& c !== CHAR_CARRIAGE_RETURN
|
||||
&& c !== CHAR_LINE_FEED;
|
||||
}
|
||||
|
||||
// Simplified test for values allowed after the first character in plain style.
|
||||
function isPlainSafe(c) {
|
||||
function isPlainSafe(c, prev) {
|
||||
// Uses a subset of nb-char - c-flow-indicator - ":" - "#"
|
||||
// where nb-char ::= c-printable - b-char - c-byte-order-mark.
|
||||
return isPrintable(c) && c !== 0xFEFF
|
||||
|
@ -200,8 +217,9 @@ function isPlainSafe(c) {
|
|||
&& c !== CHAR_LEFT_CURLY_BRACKET
|
||||
&& c !== CHAR_RIGHT_CURLY_BRACKET
|
||||
// - ":" - "#"
|
||||
// /* An ns-char preceding */ "#"
|
||||
&& c !== CHAR_COLON
|
||||
&& c !== CHAR_SHARP;
|
||||
&& ((c !== CHAR_SHARP) || (prev && isNsChar(prev)));
|
||||
}
|
||||
|
||||
// Simplified test for values allowed as the first character in plain style.
|
||||
|
@ -220,12 +238,13 @@ function isPlainSafeFirst(c) {
|
|||
&& c !== CHAR_RIGHT_SQUARE_BRACKET
|
||||
&& c !== CHAR_LEFT_CURLY_BRACKET
|
||||
&& c !== CHAR_RIGHT_CURLY_BRACKET
|
||||
// | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"”
|
||||
// | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
|
||||
&& c !== CHAR_SHARP
|
||||
&& c !== CHAR_AMPERSAND
|
||||
&& c !== CHAR_ASTERISK
|
||||
&& c !== CHAR_EXCLAMATION
|
||||
&& c !== CHAR_VERTICAL_LINE
|
||||
&& c !== CHAR_EQUALS
|
||||
&& c !== CHAR_GREATER_THAN
|
||||
&& c !== CHAR_SINGLE_QUOTE
|
||||
&& c !== CHAR_DOUBLE_QUOTE
|
||||
|
@ -256,7 +275,7 @@ var STYLE_PLAIN = 1,
|
|||
// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
|
||||
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
|
||||
var i;
|
||||
var char;
|
||||
var char, prev_char;
|
||||
var hasLineBreak = false;
|
||||
var hasFoldableLine = false; // only checked if shouldTrackWidth
|
||||
var shouldTrackWidth = lineWidth !== -1;
|
||||
|
@ -272,7 +291,8 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
|
|||
if (!isPrintable(char)) {
|
||||
return STYLE_DOUBLE;
|
||||
}
|
||||
plain = plain && isPlainSafe(char);
|
||||
prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
|
||||
plain = plain && isPlainSafe(char, prev_char);
|
||||
}
|
||||
} else {
|
||||
// Case: block styles permitted.
|
||||
|
@ -291,7 +311,8 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
|
|||
} else if (!isPrintable(char)) {
|
||||
return STYLE_DOUBLE;
|
||||
}
|
||||
plain = plain && isPlainSafe(char);
|
||||
prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
|
||||
plain = plain && isPlainSafe(char, prev_char);
|
||||
}
|
||||
// in case the end is missing a \n
|
||||
hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
|
||||
|
@ -548,10 +569,12 @@ function writeFlowMapping(state, level, object) {
|
|||
pairBuffer;
|
||||
|
||||
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||
pairBuffer = state.condenseFlow ? '"' : '';
|
||||
|
||||
pairBuffer = '';
|
||||
if (index !== 0) pairBuffer += ', ';
|
||||
|
||||
if (state.condenseFlow) pairBuffer += '"';
|
||||
|
||||
objectKey = objectKeyList[index];
|
||||
objectValue = object[objectKey];
|
||||
|
0
node_modules/js-yaml/lib/js-yaml/exception.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/exception.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/exception.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/exception.js
сгенерированный
поставляемый
43
node_modules/js-yaml/lib/js-yaml/loader.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/loader.js
сгенерированный
поставляемый
43
node_modules/js-yaml/lib/js-yaml/loader.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/loader.js
сгенерированный
поставляемый
|
@ -1272,7 +1272,7 @@ function readAlias(state) {
|
|||
|
||||
alias = state.input.slice(_position, state.position);
|
||||
|
||||
if (!state.anchorMap.hasOwnProperty(alias)) {
|
||||
if (!_hasOwnProperty.call(state.anchorMap, alias)) {
|
||||
throwError(state, 'unidentified alias "' + alias + '"');
|
||||
}
|
||||
|
||||
|
@ -1393,13 +1393,19 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
|
|||
|
||||
if (state.tag !== null && state.tag !== '!') {
|
||||
if (state.tag === '?') {
|
||||
// Implicit resolving is not allowed for non-scalar types, and '?'
|
||||
// non-specific tag is only automatically assigned to plain scalars.
|
||||
//
|
||||
// We only need to check kind conformity in case user explicitly assigns '?'
|
||||
// tag, for example like this: "!<?> [0]"
|
||||
//
|
||||
if (state.result !== null && state.kind !== 'scalar') {
|
||||
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
||||
}
|
||||
|
||||
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
||||
type = state.implicitTypes[typeIndex];
|
||||
|
||||
// Implicit resolving is not allowed for non-scalar types, and '?'
|
||||
// non-specific tag is only assigned to plain scalars. So, it isn't
|
||||
// needed to check for 'kind' conformity.
|
||||
|
||||
if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
|
||||
state.result = type.construct(state.result);
|
||||
state.tag = type.tag;
|
||||
|
@ -1563,6 +1569,13 @@ function loadDocuments(input, options) {
|
|||
|
||||
var state = new State(input, options);
|
||||
|
||||
var nullpos = input.indexOf('\0');
|
||||
|
||||
if (nullpos !== -1) {
|
||||
state.position = nullpos;
|
||||
throwError(state, 'null byte is not allowed in input');
|
||||
}
|
||||
|
||||
// Use 0 as string terminator. That significantly simplifies bounds check.
|
||||
state.input += '\0';
|
||||
|
||||
|
@ -1580,13 +1593,18 @@ function loadDocuments(input, options) {
|
|||
|
||||
|
||||
function loadAll(input, iterator, options) {
|
||||
var documents = loadDocuments(input, options), index, length;
|
||||
if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') {
|
||||
options = iterator;
|
||||
iterator = null;
|
||||
}
|
||||
|
||||
var documents = loadDocuments(input, options);
|
||||
|
||||
if (typeof iterator !== 'function') {
|
||||
return documents;
|
||||
}
|
||||
|
||||
for (index = 0, length = documents.length; index < length; index += 1) {
|
||||
for (var index = 0, length = documents.length; index < length; index += 1) {
|
||||
iterator(documents[index]);
|
||||
}
|
||||
}
|
||||
|
@ -1605,12 +1623,13 @@ function load(input, options) {
|
|||
}
|
||||
|
||||
|
||||
function safeLoadAll(input, output, options) {
|
||||
if (typeof output === 'function') {
|
||||
loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
||||
} else {
|
||||
return loadAll(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
||||
function safeLoadAll(input, iterator, options) {
|
||||
if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') {
|
||||
options = iterator;
|
||||
iterator = null;
|
||||
}
|
||||
|
||||
return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
||||
}
|
||||
|
||||
|
0
node_modules/js-yaml/lib/js-yaml/mark.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/mark.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/mark.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/mark.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/schema.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/schema.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/schema.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/schema.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/bool.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/bool.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/bool.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/bool.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/int.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/int.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/int.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/int.js
сгенерированный
поставляемый
|
@ -14,7 +14,8 @@ try {
|
|||
var _require = require;
|
||||
esprima = _require('esprima');
|
||||
} catch (_) {
|
||||
/*global window */
|
||||
/* eslint-disable no-redeclare */
|
||||
/* global window */
|
||||
if (typeof window !== 'undefined') esprima = window.esprima;
|
||||
}
|
||||
|
0
node_modules/js-yaml/lib/js-yaml/type/map.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/map.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/map.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/map.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/null.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/null.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/null.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/null.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/omap.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/omap.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/omap.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/omap.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/seq.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/seq.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/seq.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/seq.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/set.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/set.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/set.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/set.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/str.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/str.js
сгенерированный
поставляемый
0
node_modules/js-yaml/lib/js-yaml/type/str.js → node_modules/@eslint/eslintrc/node_modules/js-yaml/lib/js-yaml/type/str.js
сгенерированный
поставляемый
49
node_modules/@eslint/eslintrc/node_modules/js-yaml/package.json
сгенерированный
поставляемый
Normal file
49
node_modules/@eslint/eslintrc/node_modules/js-yaml/package.json
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
"name": "js-yaml",
|
||||
"version": "3.14.1",
|
||||
"description": "YAML 1.2 parser and serializer",
|
||||
"keywords": [
|
||||
"yaml",
|
||||
"parser",
|
||||
"serializer",
|
||||
"pyyaml"
|
||||
],
|
||||
"homepage": "https://github.com/nodeca/js-yaml",
|
||||
"author": "Vladimir Zapparov <dervus.grim@gmail.com>",
|
||||
"contributors": [
|
||||
"Aleksey V Zapparov <ixti@member.fsf.org> (http://www.ixti.net/)",
|
||||
"Vitaly Puzrin <vitaly@rcdesign.ru> (https://github.com/puzrin)",
|
||||
"Martin Grenfell <martin.grenfell@gmail.com> (http://got-ravings.blogspot.com)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "nodeca/js-yaml",
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/",
|
||||
"bin/",
|
||||
"dist/"
|
||||
],
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
},
|
||||
"unpkg": "dist/js-yaml.min.js",
|
||||
"jsdelivr": "dist/js-yaml.min.js",
|
||||
"dependencies": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ansi": "^0.3.1",
|
||||
"benchmark": "^2.1.4",
|
||||
"browserify": "^16.2.2",
|
||||
"codemirror": "^5.13.4",
|
||||
"eslint": "^7.0.0",
|
||||
"fast-check": "^1.24.2",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^7.1.2",
|
||||
"uglify-js": "^3.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
}
|
||||
}
|
|
@ -1,21 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
|
|
|
@ -8,9 +8,9 @@ This package contains type definitions for Node.js (http://nodejs.org/).
|
|||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Mon, 25 Nov 2019 22:58:16 GMT
|
||||
* Last updated: Mon, 26 Jul 2021 00:01:15 GMT
|
||||
* Dependencies: none
|
||||
* Global values: `Buffer`, `NodeJS`, `Symbol`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
|
||||
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`
|
||||
|
||||
# Credits
|
||||
These definitions were written by Microsoft TypeScript (https://github.com/Microsoft), DefinitelyTyped (https://github.com/DefinitelyTyped), Alberto Schiabel (https://github.com/jkomyno), Alexander T. (https://github.com/a-tarasyuk), Alvis HT Tang (https://github.com/alvis), Andrew Makarov (https://github.com/r3nya), Benjamin Toueg (https://github.com/btoueg), Bruno Scheufler (https://github.com/brunoscheufler), Chigozirim C. (https://github.com/smac89), Christian Vaagland Tellnes (https://github.com/tellnes), David Junger (https://github.com/touffy), Deividas Bakanas (https://github.com/DeividasBakanas), Eugene Y. Q. Shen (https://github.com/eyqs), Flarna (https://github.com/Flarna), Hannes Magnusson (https://github.com/Hannes-Magnusson-CK), Hoàng Văn Khải (https://github.com/KSXGitHub), Huw (https://github.com/hoo29), Kelvin Jin (https://github.com/kjin), Klaus Meinhardt (https://github.com/ajafff), Lishude (https://github.com/islishude), Mariusz Wiktorczyk (https://github.com/mwiktorczyk), Mohsen Azimi (https://github.com/mohsen1), Nicolas Even (https://github.com/n-e), Nicolas Voigt (https://github.com/octo-sniffle), Nikita Galkin (https://github.com/galkin), Parambir Singh (https://github.com/parambirs), Sebastian Silbermann (https://github.com/eps1lon), Simon Schick (https://github.com/SimonSchick), Thomas den Hollander (https://github.com/ThomasdenH), Wilco Bakker (https://github.com/WilcoBakker), wwwy3y3 (https://github.com/wwwy3y3), Zane Hannan AU (https://github.com/ZaneHannanAU), Samuel Ainsworth (https://github.com/samuela), Kyle Uehlein (https://github.com/kuehlein), Jordi Oliveras Rovira (https://github.com/j-oliveras), Thanik Bhongbhibhat (https://github.com/bhongy), Marcin Kopacz (https://github.com/chyzwar), Trivikram Kamat (https://github.com/trivikr), Minh Son Nguyen (https://github.com/nguymin4), Junxiao Shi (https://github.com/yoursunny), and Ilia Baryshnikov (https://github.com/qwelias).
|
||||
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Hoàng Văn Khải](https://github.com/KSXGitHub), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Minh Son Nguyen](https://github.com/nguymin4), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Surasak Chaisurin](https://github.com/Ryan-Willpower), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Jason Kwok](https://github.com/JasonHK), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), and [NodeJS Contributors](https://github.com/NodeJS).
|
||||
|
|
1469
node_modules/@types/node/assert.d.ts
сгенерированный
поставляемый
Normal file → Executable file
1469
node_modules/@types/node/assert.d.ts
сгенерированный
поставляемый
Normal file → Executable file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,8 @@
|
|||
declare module 'assert/strict' {
|
||||
import { strict } from 'node:assert';
|
||||
export = strict;
|
||||
}
|
||||
declare module 'node:assert/strict' {
|
||||
import { strict } from 'node:assert';
|
||||
export = strict;
|
||||
}
|
469
node_modules/@types/node/async_hooks.d.ts
сгенерированный
поставляемый
Normal file → Executable file
469
node_modules/@types/node/async_hooks.d.ts
сгенерированный
поставляемый
Normal file → Executable file
|
@ -1,17 +1,118 @@
|
|||
/**
|
||||
* Async Hooks module: https://nodejs.org/api/async_hooks.html
|
||||
* The `async_hooks` module provides an API to track asynchronous resources. It
|
||||
* can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const async_hooks = require('async_hooks');
|
||||
* ```
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/async_hooks.js)
|
||||
*/
|
||||
declare module "async_hooks" {
|
||||
declare module 'async_hooks' {
|
||||
/**
|
||||
* Returns the asyncId of the current execution context.
|
||||
* ```js
|
||||
* const async_hooks = require('async_hooks');
|
||||
*
|
||||
* console.log(async_hooks.executionAsyncId()); // 1 - bootstrap
|
||||
* fs.open(path, 'r', (err, fd) => {
|
||||
* console.log(async_hooks.executionAsyncId()); // 6 - open()
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* The ID returned from `executionAsyncId()` is related to execution timing, not
|
||||
* causality (which is covered by `triggerAsyncId()`):
|
||||
*
|
||||
* ```js
|
||||
* const server = net.createServer((conn) => {
|
||||
* // Returns the ID of the server, not of the new connection, because the
|
||||
* // callback runs in the execution scope of the server's MakeCallback().
|
||||
* async_hooks.executionAsyncId();
|
||||
*
|
||||
* }).listen(port, () => {
|
||||
* // Returns the ID of a TickObject (process.nextTick()) because all
|
||||
* // callbacks passed to .listen() are wrapped in a nextTick().
|
||||
* async_hooks.executionAsyncId();
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Promise contexts may not get precise `executionAsyncIds` by default.
|
||||
* See the section on `promise execution tracking`.
|
||||
* @since v8.1.0
|
||||
* @return The `asyncId` of the current execution context. Useful to track when something calls.
|
||||
*/
|
||||
function executionAsyncId(): number;
|
||||
|
||||
/**
|
||||
* Returns the ID of the resource responsible for calling the callback that is currently being executed.
|
||||
* Resource objects returned by `executionAsyncResource()` are most often internal
|
||||
* Node.js handle objects with undocumented APIs. Using any functions or properties
|
||||
* on the object is likely to crash your application and should be avoided.
|
||||
*
|
||||
* Using `executionAsyncResource()` in the top-level execution context will
|
||||
* return an empty object as there is no handle or request object to use,
|
||||
* but having an object representing the top-level can be helpful.
|
||||
*
|
||||
* ```js
|
||||
* const { open } = require('fs');
|
||||
* const { executionAsyncId, executionAsyncResource } = require('async_hooks');
|
||||
*
|
||||
* console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
|
||||
* open(__filename, 'r', (err, fd) => {
|
||||
* console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* This can be used to implement continuation local storage without the
|
||||
* use of a tracking `Map` to store the metadata:
|
||||
*
|
||||
* ```js
|
||||
* const { createServer } = require('http');
|
||||
* const {
|
||||
* executionAsyncId,
|
||||
* executionAsyncResource,
|
||||
* createHook
|
||||
* } = require('async_hooks');
|
||||
* const sym = Symbol('state'); // Private symbol to avoid pollution
|
||||
*
|
||||
* createHook({
|
||||
* init(asyncId, type, triggerAsyncId, resource) {
|
||||
* const cr = executionAsyncResource();
|
||||
* if (cr) {
|
||||
* resource[sym] = cr[sym];
|
||||
* }
|
||||
* }
|
||||
* }).enable();
|
||||
*
|
||||
* const server = createServer((req, res) => {
|
||||
* executionAsyncResource()[sym] = { state: req.url };
|
||||
* setTimeout(function() {
|
||||
* res.end(JSON.stringify(executionAsyncResource()[sym]));
|
||||
* }, 100);
|
||||
* }).listen(3000);
|
||||
* ```
|
||||
* @since v13.9.0, v12.17.0
|
||||
* @return The resource representing the current execution. Useful to store data within the resource.
|
||||
*/
|
||||
function executionAsyncResource(): object;
|
||||
/**
|
||||
* ```js
|
||||
* const server = net.createServer((conn) => {
|
||||
* // The resource that caused (or triggered) this callback to be called
|
||||
* // was that of the new connection. Thus the return value of triggerAsyncId()
|
||||
* // is the asyncId of "conn".
|
||||
* async_hooks.triggerAsyncId();
|
||||
*
|
||||
* }).listen(port, () => {
|
||||
* // Even though all callbacks passed to .listen() are wrapped in a nextTick()
|
||||
* // the callback itself exists because the call to the server's .listen()
|
||||
* // was made. So the return value would be the ID of the server.
|
||||
* async_hooks.triggerAsyncId();
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Promise contexts may not get valid `triggerAsyncId`s by default. See
|
||||
* the section on `promise execution tracking`.
|
||||
* @return The ID of the resource responsible for calling the callback that is currently being executed.
|
||||
*/
|
||||
function triggerAsyncId(): number;
|
||||
|
||||
interface HookCallbacks {
|
||||
/**
|
||||
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
||||
|
@ -20,74 +121,134 @@ declare module "async_hooks" {
|
|||
* @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
|
||||
* @param resource reference to the resource representing the async operation, needs to be released during destroy
|
||||
*/
|
||||
init?(asyncId: number, type: string, triggerAsyncId: number, resource: Object): void;
|
||||
|
||||
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
|
||||
/**
|
||||
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
|
||||
* The before callback is called just before said callback is executed.
|
||||
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
|
||||
*/
|
||||
before?(asyncId: number): void;
|
||||
|
||||
/**
|
||||
* Called immediately after the callback specified in before is completed.
|
||||
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
||||
*/
|
||||
after?(asyncId: number): void;
|
||||
|
||||
/**
|
||||
* Called when a promise has resolve() called. This may not be in the same execution id
|
||||
* as the promise itself.
|
||||
* @param asyncId the unique id for the promise that was resolve()d.
|
||||
*/
|
||||
promiseResolve?(asyncId: number): void;
|
||||
|
||||
/**
|
||||
* Called after the resource corresponding to asyncId is destroyed
|
||||
* @param asyncId a unique ID for the async resource
|
||||
*/
|
||||
destroy?(asyncId: number): void;
|
||||
}
|
||||
|
||||
interface AsyncHook {
|
||||
/**
|
||||
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
||||
*/
|
||||
enable(): this;
|
||||
|
||||
/**
|
||||
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
|
||||
*/
|
||||
disable(): this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers functions to be called for different lifetime events of each async operation.
|
||||
* @param options the callbacks to register
|
||||
* @return an AsyncHooks instance used for disabling and enabling hooks
|
||||
* Registers functions to be called for different lifetime events of each async
|
||||
* operation.
|
||||
*
|
||||
* The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the
|
||||
* respective asynchronous event during a resource's lifetime.
|
||||
*
|
||||
* All callbacks are optional. For example, if only resource cleanup needs to
|
||||
* be tracked, then only the `destroy` callback needs to be passed. The
|
||||
* specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section.
|
||||
*
|
||||
* ```js
|
||||
* const async_hooks = require('async_hooks');
|
||||
*
|
||||
* const asyncHook = async_hooks.createHook({
|
||||
* init(asyncId, type, triggerAsyncId, resource) { },
|
||||
* destroy(asyncId) { }
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* The callbacks will be inherited via the prototype chain:
|
||||
*
|
||||
* ```js
|
||||
* class MyAsyncCallbacks {
|
||||
* init(asyncId, type, triggerAsyncId, resource) { }
|
||||
* destroy(asyncId) {}
|
||||
* }
|
||||
*
|
||||
* class MyAddedCallbacks extends MyAsyncCallbacks {
|
||||
* before(asyncId) { }
|
||||
* after(asyncId) { }
|
||||
* }
|
||||
*
|
||||
* const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
|
||||
* ```
|
||||
*
|
||||
* Because promises are asynchronous resources whose lifecycle is tracked
|
||||
* via the async hooks mechanism, the `init()`, `before()`, `after()`, and`destroy()` callbacks _must not_ be async functions that return promises.
|
||||
* @since v8.1.0
|
||||
* @param callbacks The `Hook Callbacks` to register
|
||||
* @return Instance used for disabling and enabling hooks
|
||||
*/
|
||||
function createHook(options: HookCallbacks): AsyncHook;
|
||||
|
||||
interface AsyncResourceOptions {
|
||||
/**
|
||||
* The ID of the execution context that created this async event.
|
||||
* Default: `executionAsyncId()`
|
||||
*/
|
||||
triggerAsyncId?: number;
|
||||
|
||||
/**
|
||||
* Disables automatic `emitDestroy` when the object is garbage collected.
|
||||
* This usually does not need to be set (even if `emitDestroy` is called
|
||||
* manually), unless the resource's `asyncId` is retrieved and the
|
||||
* sensitive API's `emitDestroy` is called with it.
|
||||
* Default: `false`
|
||||
*/
|
||||
requireManualDestroy?: boolean;
|
||||
/**
|
||||
* The ID of the execution context that created this async event.
|
||||
* @default executionAsyncId()
|
||||
*/
|
||||
triggerAsyncId?: number | undefined;
|
||||
/**
|
||||
* Disables automatic `emitDestroy` when the object is garbage collected.
|
||||
* This usually does not need to be set (even if `emitDestroy` is called
|
||||
* manually), unless the resource's `asyncId` is retrieved and the
|
||||
* sensitive API's `emitDestroy` is called with it.
|
||||
* @default false
|
||||
*/
|
||||
requireManualDestroy?: boolean | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* The class AsyncResource was designed to be extended by the embedder's async resources.
|
||||
* Using this users can easily trigger the lifetime events of their own resources.
|
||||
* The class `AsyncResource` is designed to be extended by the embedder's async
|
||||
* resources. Using this, users can easily trigger the lifetime events of their
|
||||
* own resources.
|
||||
*
|
||||
* The `init` hook will trigger when an `AsyncResource` is instantiated.
|
||||
*
|
||||
* The following is an overview of the `AsyncResource` API.
|
||||
*
|
||||
* ```js
|
||||
* const { AsyncResource, executionAsyncId } = require('async_hooks');
|
||||
*
|
||||
* // AsyncResource() is meant to be extended. Instantiating a
|
||||
* // new AsyncResource() also triggers init. If triggerAsyncId is omitted then
|
||||
* // async_hook.executionAsyncId() is used.
|
||||
* const asyncResource = new AsyncResource(
|
||||
* type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false }
|
||||
* );
|
||||
*
|
||||
* // Run a function in the execution context of the resource. This will
|
||||
* // * establish the context of the resource
|
||||
* // * trigger the AsyncHooks before callbacks
|
||||
* // * call the provided function `fn` with the supplied arguments
|
||||
* // * trigger the AsyncHooks after callbacks
|
||||
* // * restore the original execution context
|
||||
* asyncResource.runInAsyncScope(fn, thisArg, ...args);
|
||||
*
|
||||
* // Call AsyncHooks destroy callbacks.
|
||||
* asyncResource.emitDestroy();
|
||||
*
|
||||
* // Return the unique ID assigned to the AsyncResource instance.
|
||||
* asyncResource.asyncId();
|
||||
*
|
||||
* // Return the trigger ID for the AsyncResource instance.
|
||||
* asyncResource.triggerAsyncId();
|
||||
* ```
|
||||
*/
|
||||
class AsyncResource {
|
||||
/**
|
||||
|
@ -99,34 +260,238 @@ declare module "async_hooks" {
|
|||
* this async event (default: `executionAsyncId()`), or an
|
||||
* AsyncResourceOptions object (since 9.3)
|
||||
*/
|
||||
constructor(type: string, triggerAsyncId?: number|AsyncResourceOptions);
|
||||
|
||||
constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
|
||||
/**
|
||||
* Call the provided function with the provided arguments in the
|
||||
* execution context of the async resource. This will establish the
|
||||
* context, trigger the AsyncHooks before callbacks, call the function,
|
||||
* trigger the AsyncHooks after callbacks, and then restore the original
|
||||
* execution context.
|
||||
* @param fn The function to call in the execution context of this
|
||||
* async resource.
|
||||
* Binds the given function to the current execution context.
|
||||
*
|
||||
* The returned function will have an `asyncResource` property referencing
|
||||
* the `AsyncResource` to which the function is bound.
|
||||
* @since v14.8.0, v12.19.0
|
||||
* @param fn The function to bind to the current execution context.
|
||||
* @param type An optional name to associate with the underlying `AsyncResource`.
|
||||
*/
|
||||
static bind<Func extends (this: ThisArg, ...args: any[]) => any, ThisArg>(
|
||||
fn: Func,
|
||||
type?: string,
|
||||
thisArg?: ThisArg
|
||||
): Func & {
|
||||
asyncResource: AsyncResource;
|
||||
};
|
||||
/**
|
||||
* Binds the given function to execute to this `AsyncResource`'s scope.
|
||||
*
|
||||
* The returned function will have an `asyncResource` property referencing
|
||||
* the `AsyncResource` to which the function is bound.
|
||||
* @since v14.8.0, v12.19.0
|
||||
* @param fn The function to bind to the current `AsyncResource`.
|
||||
*/
|
||||
bind<Func extends (...args: any[]) => any>(
|
||||
fn: Func
|
||||
): Func & {
|
||||
asyncResource: AsyncResource;
|
||||
};
|
||||
/**
|
||||
* Call the provided function with the provided arguments in the execution context
|
||||
* of the async resource. This will establish the context, trigger the AsyncHooks
|
||||
* before callbacks, call the function, trigger the AsyncHooks after callbacks, and
|
||||
* then restore the original execution context.
|
||||
* @since v9.6.0
|
||||
* @param fn The function to call in the execution context of this async resource.
|
||||
* @param thisArg The receiver to be used for the function call.
|
||||
* @param args Optional arguments to pass to the function.
|
||||
* @param ...args Optional arguments to pass to the function.
|
||||
*/
|
||||
runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
|
||||
|
||||
/**
|
||||
* Call AsyncHooks destroy callbacks.
|
||||
* Call all `destroy` hooks. This should only ever be called once. An error will
|
||||
* be thrown if it is called more than once. This **must** be manually called. If
|
||||
* the resource is left to be collected by the GC then the `destroy` hooks will
|
||||
* never be called.
|
||||
* @return A reference to `asyncResource`.
|
||||
*/
|
||||
emitDestroy(): void;
|
||||
|
||||
emitDestroy(): this;
|
||||
/**
|
||||
* @return the unique ID assigned to this AsyncResource instance.
|
||||
* @return The unique `asyncId` assigned to the resource.
|
||||
*/
|
||||
asyncId(): number;
|
||||
|
||||
/**
|
||||
* @return the trigger ID for this AsyncResource instance.
|
||||
*
|
||||
* @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor.
|
||||
*/
|
||||
triggerAsyncId(): number;
|
||||
}
|
||||
/**
|
||||
* This class creates stores that stay coherent through asynchronous operations.
|
||||
*
|
||||
* While you can create your own implementation on top of the `async_hooks` module,`AsyncLocalStorage` should be preferred as it is a performant and memory safe
|
||||
* implementation that involves significant optimizations that are non-obvious to
|
||||
* implement.
|
||||
*
|
||||
* The following example uses `AsyncLocalStorage` to build a simple logger
|
||||
* that assigns IDs to incoming HTTP requests and includes them in messages
|
||||
* logged within each request.
|
||||
*
|
||||
* ```js
|
||||
* const http = require('http');
|
||||
* const { AsyncLocalStorage } = require('async_hooks');
|
||||
*
|
||||
* const asyncLocalStorage = new AsyncLocalStorage();
|
||||
*
|
||||
* function logWithId(msg) {
|
||||
* const id = asyncLocalStorage.getStore();
|
||||
* console.log(`${id !== undefined ? id : '-'}:`, msg);
|
||||
* }
|
||||
*
|
||||
* let idSeq = 0;
|
||||
* http.createServer((req, res) => {
|
||||
* asyncLocalStorage.run(idSeq++, () => {
|
||||
* logWithId('start');
|
||||
* // Imagine any chain of async operations here
|
||||
* setImmediate(() => {
|
||||
* logWithId('finish');
|
||||
* res.end();
|
||||
* });
|
||||
* });
|
||||
* }).listen(8080);
|
||||
*
|
||||
* http.get('http://localhost:8080');
|
||||
* http.get('http://localhost:8080');
|
||||
* // Prints:
|
||||
* // 0: start
|
||||
* // 1: start
|
||||
* // 0: finish
|
||||
* // 1: finish
|
||||
* ```
|
||||
*
|
||||
* Each instance of `AsyncLocalStorage` maintains an independent storage context.
|
||||
* Multiple instances can safely exist simultaneously without risk of interfering
|
||||
* with each other data.
|
||||
* @since v13.10.0, v12.17.0
|
||||
*/
|
||||
class AsyncLocalStorage<T> {
|
||||
/**
|
||||
* Disables the instance of `AsyncLocalStorage`. All subsequent calls
|
||||
* to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
|
||||
*
|
||||
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
||||
* instance will be exited.
|
||||
*
|
||||
* Calling `asyncLocalStorage.disable()` is required before the`asyncLocalStorage` can be garbage collected. This does not apply to stores
|
||||
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
||||
* along with the corresponding async resources.
|
||||
*
|
||||
* Use this method when the `asyncLocalStorage` is not in use anymore
|
||||
* in the current process.
|
||||
* @since v13.10.0, v12.17.0
|
||||
* @experimental
|
||||
*/
|
||||
disable(): void;
|
||||
/**
|
||||
* Returns the current store.
|
||||
* If called outside of an asynchronous context initialized by
|
||||
* calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
|
||||
* returns `undefined`.
|
||||
* @since v13.10.0, v12.17.0
|
||||
*/
|
||||
getStore(): T | undefined;
|
||||
/**
|
||||
* Runs a function synchronously within a context and returns its
|
||||
* return value. The store is not accessible outside of the callback function or
|
||||
* the asynchronous operations created within the callback.
|
||||
*
|
||||
* The optional `args` are passed to the callback function.
|
||||
*
|
||||
* If the callback function throws an error, the error is thrown by `run()` too.
|
||||
* The stacktrace is not impacted by this call and the context is exited.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* const store = { id: 2 };
|
||||
* try {
|
||||
* asyncLocalStorage.run(store, () => {
|
||||
* asyncLocalStorage.getStore(); // Returns the store object
|
||||
* throw new Error();
|
||||
* });
|
||||
* } catch (e) {
|
||||
* asyncLocalStorage.getStore(); // Returns undefined
|
||||
* // The error will be caught here
|
||||
* }
|
||||
* ```
|
||||
* @since v13.10.0, v12.17.0
|
||||
*/
|
||||
run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
|
||||
/**
|
||||
* Runs a function synchronously outside of a context and returns its
|
||||
* return value. The store is not accessible within the callback function or
|
||||
* the asynchronous operations created within the callback. Any `getStore()`call done within the callback function will always return `undefined`.
|
||||
*
|
||||
* The optional `args` are passed to the callback function.
|
||||
*
|
||||
* If the callback function throws an error, the error is thrown by `exit()` too.
|
||||
* The stacktrace is not impacted by this call and the context is re-entered.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* // Within a call to run
|
||||
* try {
|
||||
* asyncLocalStorage.getStore(); // Returns the store object or value
|
||||
* asyncLocalStorage.exit(() => {
|
||||
* asyncLocalStorage.getStore(); // Returns undefined
|
||||
* throw new Error();
|
||||
* });
|
||||
* } catch (e) {
|
||||
* asyncLocalStorage.getStore(); // Returns the same object or value
|
||||
* // The error will be caught here
|
||||
* }
|
||||
* ```
|
||||
* @since v13.10.0, v12.17.0
|
||||
* @experimental
|
||||
*/
|
||||
exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
|
||||
/**
|
||||
* Transitions into the context for the remainder of the current
|
||||
* synchronous execution and then persists the store through any following
|
||||
* asynchronous calls.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* const store = { id: 1 };
|
||||
* // Replaces previous store with the given store object
|
||||
* asyncLocalStorage.enterWith(store);
|
||||
* asyncLocalStorage.getStore(); // Returns the store object
|
||||
* someAsyncOperation(() => {
|
||||
* asyncLocalStorage.getStore(); // Returns the same object
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* This transition will continue for the _entire_ synchronous execution.
|
||||
* This means that if, for example, the context is entered within an event
|
||||
* handler subsequent event handlers will also run within that context unless
|
||||
* specifically bound to another context with an `AsyncResource`. That is why`run()` should be preferred over `enterWith()` unless there are strong reasons
|
||||
* to use the latter method.
|
||||
*
|
||||
* ```js
|
||||
* const store = { id: 1 };
|
||||
*
|
||||
* emitter.on('my-event', () => {
|
||||
* asyncLocalStorage.enterWith(store);
|
||||
* });
|
||||
* emitter.on('my-event', () => {
|
||||
* asyncLocalStorage.getStore(); // Returns the same object
|
||||
* });
|
||||
*
|
||||
* asyncLocalStorage.getStore(); // Returns undefined
|
||||
* emitter.emit('my-event');
|
||||
* asyncLocalStorage.getStore(); // Returns the same object
|
||||
* ```
|
||||
* @since v13.11.0, v12.17.0
|
||||
* @experimental
|
||||
*/
|
||||
enterWith(store: T): void;
|
||||
}
|
||||
}
|
||||
declare module 'node:async_hooks' {
|
||||
export * from 'async_hooks';
|
||||
}
|
||||
|
|
|
@ -1,41 +1,19 @@
|
|||
// base definnitions for all NodeJS modules that are not specific to any version of TypeScript
|
||||
/// <reference path="globals.d.ts" />
|
||||
// NOTE: These definitions support NodeJS and TypeScript 3.7.
|
||||
|
||||
// NOTE: TypeScript version-specific augmentations can be found in the following paths:
|
||||
// - ~/base.d.ts - Shared definitions common to all TypeScript versions
|
||||
// - ~/index.d.ts - Definitions specific to TypeScript 2.1
|
||||
// - ~/ts3.7/base.d.ts - Definitions specific to TypeScript 3.7
|
||||
// - ~/ts3.7/index.d.ts - Definitions specific to TypeScript 3.7 with assert pulled in
|
||||
|
||||
// Reference required types from the default lib:
|
||||
/// <reference lib="es2018" />
|
||||
/// <reference lib="esnext.asynciterable" />
|
||||
/// <reference lib="esnext.intl" />
|
||||
/// <reference lib="esnext.bigint" />
|
||||
|
||||
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
|
||||
/// <reference path="ts3.6/base.d.ts" />
|
||||
|
||||
// TypeScript 3.7-specific augmentations:
|
||||
/// <reference path="assert.d.ts" />
|
||||
/// <reference path="async_hooks.d.ts" />
|
||||
/// <reference path="buffer.d.ts" />
|
||||
/// <reference path="child_process.d.ts" />
|
||||
/// <reference path="cluster.d.ts" />
|
||||
/// <reference path="console.d.ts" />
|
||||
/// <reference path="constants.d.ts" />
|
||||
/// <reference path="crypto.d.ts" />
|
||||
/// <reference path="dgram.d.ts" />
|
||||
/// <reference path="dns.d.ts" />
|
||||
/// <reference path="domain.d.ts" />
|
||||
/// <reference path="events.d.ts" />
|
||||
/// <reference path="fs.d.ts" />
|
||||
/// <reference path="http.d.ts" />
|
||||
/// <reference path="http2.d.ts" />
|
||||
/// <reference path="https.d.ts" />
|
||||
/// <reference path="inspector.d.ts" />
|
||||
/// <reference path="module.d.ts" />
|
||||
/// <reference path="net.d.ts" />
|
||||
/// <reference path="os.d.ts" />
|
||||
/// <reference path="path.d.ts" />
|
||||
/// <reference path="perf_hooks.d.ts" />
|
||||
/// <reference path="process.d.ts" />
|
||||
/// <reference path="punycode.d.ts" />
|
||||
/// <reference path="querystring.d.ts" />
|
||||
/// <reference path="readline.d.ts" />
|
||||
/// <reference path="repl.d.ts" />
|
||||
/// <reference path="stream.d.ts" />
|
||||
/// <reference path="string_decoder.d.ts" />
|
||||
/// <reference path="timers.d.ts" />
|
||||
/// <reference path="tls.d.ts" />
|
||||
/// <reference path="trace_events.d.ts" />
|
||||
/// <reference path="tty.d.ts" />
|
||||
/// <reference path="url.d.ts" />
|
||||
/// <reference path="util.d.ts" />
|
||||
/// <reference path="v8.d.ts" />
|
||||
/// <reference path="vm.d.ts" />
|
||||
/// <reference path="worker_threads.d.ts" />
|
||||
/// <reference path="zlib.d.ts" />
|
||||
|
|
1783
node_modules/@types/node/buffer.d.ts
сгенерированный
поставляемый
Normal file → Executable file
1783
node_modules/@types/node/buffer.d.ts
сгенерированный
поставляемый
Normal file → Executable file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
1463
node_modules/@types/node/child_process.d.ts
сгенерированный
поставляемый
Normal file → Executable file
1463
node_modules/@types/node/child_process.d.ts
сгенерированный
поставляемый
Normal file → Executable file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
568
node_modules/@types/node/cluster.d.ts
сгенерированный
поставляемый
Normal file → Executable file
568
node_modules/@types/node/cluster.d.ts
сгенерированный
поставляемый
Normal file → Executable file
|
@ -1,37 +1,270 @@
|
|||
declare module "cluster" {
|
||||
import * as child from "child_process";
|
||||
import * as events from "events";
|
||||
import * as net from "net";
|
||||
|
||||
// interfaces
|
||||
interface ClusterSettings {
|
||||
execArgv?: string[]; // default: process.execArgv
|
||||
exec?: string;
|
||||
args?: string[];
|
||||
silent?: boolean;
|
||||
stdio?: any[];
|
||||
uid?: number;
|
||||
gid?: number;
|
||||
inspectPort?: number | (() => number);
|
||||
/**
|
||||
* A single instance of Node.js runs in a single thread. To take advantage of
|
||||
* multi-core systems, the user will sometimes want to launch a cluster of Node.js
|
||||
* processes to handle the load.
|
||||
*
|
||||
* The cluster module allows easy creation of child processes that all share
|
||||
* server ports.
|
||||
*
|
||||
* ```js
|
||||
* const cluster = require('cluster');
|
||||
* const http = require('http');
|
||||
* const numCPUs = require('os').cpus().length;
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* console.log(`Primary ${process.pid} is running`);
|
||||
*
|
||||
* // Fork workers.
|
||||
* for (let i = 0; i < numCPUs; i++) {
|
||||
* cluster.fork();
|
||||
* }
|
||||
*
|
||||
* cluster.on('exit', (worker, code, signal) => {
|
||||
* console.log(`worker ${worker.process.pid} died`);
|
||||
* });
|
||||
* } else {
|
||||
* // Workers can share any TCP connection
|
||||
* // In this case it is an HTTP server
|
||||
* http.createServer((req, res) => {
|
||||
* res.writeHead(200);
|
||||
* res.end('hello world\n');
|
||||
* }).listen(8000);
|
||||
*
|
||||
* console.log(`Worker ${process.pid} started`);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Running Node.js will now share port 8000 between the workers:
|
||||
*
|
||||
* ```console
|
||||
* $ node server.js
|
||||
* Primary 3596 is running
|
||||
* Worker 4324 started
|
||||
* Worker 4520 started
|
||||
* Worker 6056 started
|
||||
* Worker 5644 started
|
||||
* ```
|
||||
*
|
||||
* On Windows, it is not yet possible to set up a named pipe server in a worker.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/cluster.js)
|
||||
*/
|
||||
declare module 'cluster' {
|
||||
import * as child from 'node:child_process';
|
||||
import EventEmitter = require('node:events');
|
||||
import * as net from 'node:net';
|
||||
export interface ClusterSettings {
|
||||
execArgv?: string[] | undefined; // default: process.execArgv
|
||||
exec?: string | undefined;
|
||||
args?: string[] | undefined;
|
||||
silent?: boolean | undefined;
|
||||
stdio?: any[] | undefined;
|
||||
uid?: number | undefined;
|
||||
gid?: number | undefined;
|
||||
inspectPort?: number | (() => number) | undefined;
|
||||
}
|
||||
|
||||
interface Address {
|
||||
export interface Address {
|
||||
address: string;
|
||||
port: number;
|
||||
addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6"
|
||||
addressType: number | 'udp4' | 'udp6'; // 4, 6, -1, "udp4", "udp6"
|
||||
}
|
||||
|
||||
class Worker extends events.EventEmitter {
|
||||
/**
|
||||
* A `Worker` object contains all public information and method about a worker.
|
||||
* In the primary it can be obtained using `cluster.workers`. In a worker
|
||||
* it can be obtained using `cluster.worker`.
|
||||
* @since v0.7.0
|
||||
*/
|
||||
export class Worker extends EventEmitter {
|
||||
/**
|
||||
* Each new worker is given its own unique id, this id is stored in the`id`.
|
||||
*
|
||||
* While a worker is alive, this is the key that indexes it in`cluster.workers`.
|
||||
* @since v0.8.0
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* All workers are created using `child_process.fork()`, the returned object
|
||||
* from this function is stored as `.process`. In a worker, the global `process`is stored.
|
||||
*
|
||||
* See: `Child Process module`.
|
||||
*
|
||||
* Workers will call `process.exit(0)` if the `'disconnect'` event occurs
|
||||
* on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
|
||||
* accidental disconnection.
|
||||
* @since v0.7.0
|
||||
*/
|
||||
process: child.ChildProcess;
|
||||
send(message: any, sendHandle?: any, callback?: (error: Error | null) => void): boolean;
|
||||
/**
|
||||
* Send a message to a worker or primary, optionally with a handle.
|
||||
*
|
||||
* In the primary this sends a message to a specific worker. It is identical to `ChildProcess.send()`.
|
||||
*
|
||||
* In a worker this sends a message to the primary. It is identical to`process.send()`.
|
||||
*
|
||||
* This example will echo back all messages from the primary:
|
||||
*
|
||||
* ```js
|
||||
* if (cluster.isPrimary) {
|
||||
* const worker = cluster.fork();
|
||||
* worker.send('hi there');
|
||||
*
|
||||
* } else if (cluster.isWorker) {
|
||||
* process.on('message', (msg) => {
|
||||
* process.send(msg);
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
* @since v0.7.0
|
||||
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties:
|
||||
*/
|
||||
send(message: child.Serializable, sendHandle?: child.SendHandle, callback?: (error: Error | null) => void): boolean;
|
||||
/**
|
||||
* This function will kill the worker. In the primary, it does this
|
||||
* by disconnecting the `worker.process`, and once disconnected, killing
|
||||
* with `signal`. In the worker, it does it by disconnecting the channel,
|
||||
* and then exiting with code `0`.
|
||||
*
|
||||
* Because `kill()` attempts to gracefully disconnect the worker process, it is
|
||||
* susceptible to waiting indefinitely for the disconnect to complete. For example,
|
||||
* if the worker enters an infinite loop, a graceful disconnect will never occur.
|
||||
* If the graceful disconnect behavior is not needed, use `worker.process.kill()`.
|
||||
*
|
||||
* Causes `.exitedAfterDisconnect` to be set.
|
||||
*
|
||||
* This method is aliased as `worker.destroy()` for backward compatibility.
|
||||
*
|
||||
* In a worker, `process.kill()` exists, but it is not this function;
|
||||
* it is `kill()`.
|
||||
* @since v0.9.12
|
||||
* @param signal Name of the kill signal to send to the worker process.
|
||||
*/
|
||||
kill(signal?: string): void;
|
||||
destroy(signal?: string): void;
|
||||
/**
|
||||
* In a worker, this function will close all servers, wait for the `'close'` event
|
||||
* on those servers, and then disconnect the IPC channel.
|
||||
*
|
||||
* In the primary, an internal message is sent to the worker causing it to call`.disconnect()` on itself.
|
||||
*
|
||||
* Causes `.exitedAfterDisconnect` to be set.
|
||||
*
|
||||
* After a server is closed, it will no longer accept new connections,
|
||||
* but connections may be accepted by any other listening worker. Existing
|
||||
* connections will be allowed to close as usual. When no more connections exist,
|
||||
* see `server.close()`, the IPC channel to the worker will close allowing it
|
||||
* to die gracefully.
|
||||
*
|
||||
* The above applies _only_ to server connections, client connections are not
|
||||
* automatically closed by workers, and disconnect does not wait for them to close
|
||||
* before exiting.
|
||||
*
|
||||
* In a worker, `process.disconnect` exists, but it is not this function;
|
||||
* it is `disconnect()`.
|
||||
*
|
||||
* Because long living server connections may block workers from disconnecting, it
|
||||
* may be useful to send a message, so application specific actions may be taken to
|
||||
* close them. It also may be useful to implement a timeout, killing a worker if
|
||||
* the `'disconnect'` event has not been emitted after some time.
|
||||
*
|
||||
* ```js
|
||||
* if (cluster.isPrimary) {
|
||||
* const worker = cluster.fork();
|
||||
* let timeout;
|
||||
*
|
||||
* worker.on('listening', (address) => {
|
||||
* worker.send('shutdown');
|
||||
* worker.disconnect();
|
||||
* timeout = setTimeout(() => {
|
||||
* worker.kill();
|
||||
* }, 2000);
|
||||
* });
|
||||
*
|
||||
* worker.on('disconnect', () => {
|
||||
* clearTimeout(timeout);
|
||||
* });
|
||||
*
|
||||
* } else if (cluster.isWorker) {
|
||||
* const net = require('net');
|
||||
* const server = net.createServer((socket) => {
|
||||
* // Connections never end
|
||||
* });
|
||||
*
|
||||
* server.listen(8000);
|
||||
*
|
||||
* process.on('message', (msg) => {
|
||||
* if (msg === 'shutdown') {
|
||||
* // Initiate graceful close of any connections to server
|
||||
* }
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
* @since v0.7.7
|
||||
* @return A reference to `worker`.
|
||||
*/
|
||||
disconnect(): void;
|
||||
/**
|
||||
* This function returns `true` if the worker is connected to its primary via its
|
||||
* IPC channel, `false` otherwise. A worker is connected to its primary after it
|
||||
* has been created. It is disconnected after the `'disconnect'` event is emitted.
|
||||
* @since v0.11.14
|
||||
*/
|
||||
isConnected(): boolean;
|
||||
/**
|
||||
* This function returns `true` if the worker's process has terminated (either
|
||||
* because of exiting or being signaled). Otherwise, it returns `false`.
|
||||
*
|
||||
* ```js
|
||||
* const cluster = require('cluster');
|
||||
* const http = require('http');
|
||||
* const numCPUs = require('os').cpus().length;
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* console.log(`Primary ${process.pid} is running`);
|
||||
*
|
||||
* // Fork workers.
|
||||
* for (let i = 0; i < numCPUs; i++) {
|
||||
* cluster.fork();
|
||||
* }
|
||||
*
|
||||
* cluster.on('fork', (worker) => {
|
||||
* console.log('worker is dead:', worker.isDead());
|
||||
* });
|
||||
*
|
||||
* cluster.on('exit', (worker, code, signal) => {
|
||||
* console.log('worker is dead:', worker.isDead());
|
||||
* });
|
||||
* } else {
|
||||
* // Workers can share any TCP connection. In this case, it is an HTTP server.
|
||||
* http.createServer((req, res) => {
|
||||
* res.writeHead(200);
|
||||
* res.end(`Current process\n ${process.pid}`);
|
||||
* process.kill(process.pid);
|
||||
* }).listen(8000);
|
||||
* }
|
||||
* ```
|
||||
* @since v0.11.14
|
||||
*/
|
||||
isDead(): boolean;
|
||||
/**
|
||||
* This property is `true` if the worker exited due to `.kill()` or`.disconnect()`. If the worker exited any other way, it is `false`. If the
|
||||
* worker has not exited, it is `undefined`.
|
||||
*
|
||||
* The boolean `worker.exitedAfterDisconnect` allows distinguishing between
|
||||
* voluntary and accidental exit, the primary may choose not to respawn a worker
|
||||
* based on this value.
|
||||
*
|
||||
* ```js
|
||||
* cluster.on('exit', (worker, code, signal) => {
|
||||
* if (worker.exitedAfterDisconnect === true) {
|
||||
* console.log('Oh, it was just voluntary – no need to worry');
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // kill worker
|
||||
* worker.kill();
|
||||
* ```
|
||||
* @since v6.0.0
|
||||
*/
|
||||
exitedAfterDisconnect: boolean;
|
||||
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. disconnect
|
||||
|
@ -42,68 +275,67 @@ declare module "cluster" {
|
|||
* 6. online
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: "disconnect", listener: () => void): this;
|
||||
addListener(event: "error", listener: (error: Error) => void): this;
|
||||
addListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||
addListener(event: "listening", listener: (address: Address) => void): this;
|
||||
addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
addListener(event: "online", listener: () => void): this;
|
||||
|
||||
addListener(event: 'disconnect', listener: () => void): this;
|
||||
addListener(event: 'error', listener: (error: Error) => void): this;
|
||||
addListener(event: 'exit', listener: (code: number, signal: string) => void): this;
|
||||
addListener(event: 'listening', listener: (address: Address) => void): this;
|
||||
addListener(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
addListener(event: 'online', listener: () => void): this;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: "disconnect"): boolean;
|
||||
emit(event: "error", error: Error): boolean;
|
||||
emit(event: "exit", code: number, signal: string): boolean;
|
||||
emit(event: "listening", address: Address): boolean;
|
||||
emit(event: "message", message: any, handle: net.Socket | net.Server): boolean;
|
||||
emit(event: "online"): boolean;
|
||||
|
||||
emit(event: 'disconnect'): boolean;
|
||||
emit(event: 'error', error: Error): boolean;
|
||||
emit(event: 'exit', code: number, signal: string): boolean;
|
||||
emit(event: 'listening', address: Address): boolean;
|
||||
emit(event: 'message', message: any, handle: net.Socket | net.Server): boolean;
|
||||
emit(event: 'online'): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: "disconnect", listener: () => void): this;
|
||||
on(event: "error", listener: (error: Error) => void): this;
|
||||
on(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||
on(event: "listening", listener: (address: Address) => void): this;
|
||||
on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
on(event: "online", listener: () => void): this;
|
||||
|
||||
on(event: 'disconnect', listener: () => void): this;
|
||||
on(event: 'error', listener: (error: Error) => void): this;
|
||||
on(event: 'exit', listener: (code: number, signal: string) => void): this;
|
||||
on(event: 'listening', listener: (address: Address) => void): this;
|
||||
on(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
on(event: 'online', listener: () => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: "disconnect", listener: () => void): this;
|
||||
once(event: "error", listener: (error: Error) => void): this;
|
||||
once(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||
once(event: "listening", listener: (address: Address) => void): this;
|
||||
once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
once(event: "online", listener: () => void): this;
|
||||
|
||||
once(event: 'disconnect', listener: () => void): this;
|
||||
once(event: 'error', listener: (error: Error) => void): this;
|
||||
once(event: 'exit', listener: (code: number, signal: string) => void): this;
|
||||
once(event: 'listening', listener: (address: Address) => void): this;
|
||||
once(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
once(event: 'online', listener: () => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "disconnect", listener: () => void): this;
|
||||
prependListener(event: "error", listener: (error: Error) => void): this;
|
||||
prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||
prependListener(event: "listening", listener: (address: Address) => void): this;
|
||||
prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
prependListener(event: "online", listener: () => void): this;
|
||||
|
||||
prependListener(event: 'disconnect', listener: () => void): this;
|
||||
prependListener(event: 'error', listener: (error: Error) => void): this;
|
||||
prependListener(event: 'exit', listener: (code: number, signal: string) => void): this;
|
||||
prependListener(event: 'listening', listener: (address: Address) => void): this;
|
||||
prependListener(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
prependListener(event: 'online', listener: () => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "disconnect", listener: () => void): this;
|
||||
prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
||||
prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||
prependOnceListener(event: "listening", listener: (address: Address) => void): this;
|
||||
prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
prependOnceListener(event: "online", listener: () => void): this;
|
||||
prependOnceListener(event: 'disconnect', listener: () => void): this;
|
||||
prependOnceListener(event: 'error', listener: (error: Error) => void): this;
|
||||
prependOnceListener(event: 'exit', listener: (code: number, signal: string) => void): this;
|
||||
prependOnceListener(event: 'listening', listener: (address: Address) => void): this;
|
||||
prependOnceListener(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
prependOnceListener(event: 'online', listener: () => void): this;
|
||||
}
|
||||
|
||||
interface Cluster extends events.EventEmitter {
|
||||
Worker: Worker;
|
||||
export interface Cluster extends EventEmitter {
|
||||
disconnect(callback?: () => void): void;
|
||||
fork(env?: any): Worker;
|
||||
isMaster: boolean;
|
||||
isWorker: boolean;
|
||||
// TODO: cluster.schedulingPolicy
|
||||
settings: ClusterSettings;
|
||||
/** @deprecated since v16.0.0 - use setupPrimary. */
|
||||
readonly isMaster: boolean;
|
||||
readonly isPrimary: boolean;
|
||||
readonly isWorker: boolean;
|
||||
schedulingPolicy: number;
|
||||
readonly settings: ClusterSettings;
|
||||
/** @deprecated since v16.0.0 - use setupPrimary. */
|
||||
setupMaster(settings?: ClusterSettings): void;
|
||||
worker?: Worker;
|
||||
workers?: {
|
||||
[index: string]: Worker | undefined
|
||||
};
|
||||
|
||||
/**
|
||||
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings.
|
||||
*/
|
||||
setupPrimary(settings?: ClusterSettings): void;
|
||||
readonly worker?: Worker | undefined;
|
||||
readonly workers?: NodeJS.Dict<Worker> | undefined;
|
||||
readonly SCHED_NONE: number;
|
||||
readonly SCHED_RR: number;
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. disconnect
|
||||
|
@ -115,146 +347,60 @@ declare module "cluster" {
|
|||
* 7. setup
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||
addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
addListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||
addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||
addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
addListener(event: "online", listener: (worker: Worker) => void): this;
|
||||
addListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||
|
||||
addListener(event: 'disconnect', listener: (worker: Worker) => void): this;
|
||||
addListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
addListener(event: 'fork', listener: (worker: Worker) => void): this;
|
||||
addListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
||||
addListener(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
addListener(event: 'online', listener: (worker: Worker) => void): this;
|
||||
addListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: "disconnect", worker: Worker): boolean;
|
||||
emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
|
||||
emit(event: "fork", worker: Worker): boolean;
|
||||
emit(event: "listening", worker: Worker, address: Address): boolean;
|
||||
emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
|
||||
emit(event: "online", worker: Worker): boolean;
|
||||
emit(event: "setup", settings: ClusterSettings): boolean;
|
||||
|
||||
emit(event: 'disconnect', worker: Worker): boolean;
|
||||
emit(event: 'exit', worker: Worker, code: number, signal: string): boolean;
|
||||
emit(event: 'fork', worker: Worker): boolean;
|
||||
emit(event: 'listening', worker: Worker, address: Address): boolean;
|
||||
emit(event: 'message', worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
|
||||
emit(event: 'online', worker: Worker): boolean;
|
||||
emit(event: 'setup', settings: ClusterSettings): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||
on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
on(event: "fork", listener: (worker: Worker) => void): this;
|
||||
on(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||
on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
on(event: "online", listener: (worker: Worker) => void): this;
|
||||
on(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||
|
||||
on(event: 'disconnect', listener: (worker: Worker) => void): this;
|
||||
on(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
on(event: 'fork', listener: (worker: Worker) => void): this;
|
||||
on(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
||||
on(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
on(event: 'online', listener: (worker: Worker) => void): this;
|
||||
on(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||
once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
once(event: "fork", listener: (worker: Worker) => void): this;
|
||||
once(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||
once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
once(event: "online", listener: (worker: Worker) => void): this;
|
||||
once(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||
|
||||
once(event: 'disconnect', listener: (worker: Worker) => void): this;
|
||||
once(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
once(event: 'fork', listener: (worker: Worker) => void): this;
|
||||
once(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
||||
once(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
once(event: 'online', listener: (worker: Worker) => void): this;
|
||||
once(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||
prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
prependListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||
prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||
prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
prependListener(event: "online", listener: (worker: Worker) => void): this;
|
||||
prependListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||
prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
prependOnceListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||
prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||
prependListener(event: 'disconnect', listener: (worker: Worker) => void): this;
|
||||
prependListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
prependListener(event: 'fork', listener: (worker: Worker) => void): this;
|
||||
prependListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
||||
// the handle is a net.Socket or net.Server object, or undefined.
|
||||
prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this;
|
||||
prependOnceListener(event: "online", listener: (worker: Worker) => void): this;
|
||||
prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||
prependListener(event: 'message', listener: (worker: Worker, message: any, handle?: net.Socket | net.Server) => void): this;
|
||||
prependListener(event: 'online', listener: (worker: Worker) => void): this;
|
||||
prependListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: 'disconnect', listener: (worker: Worker) => void): this;
|
||||
prependOnceListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
prependOnceListener(event: 'fork', listener: (worker: Worker) => void): this;
|
||||
prependOnceListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
||||
// the handle is a net.Socket or net.Server object, or undefined.
|
||||
prependOnceListener(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this;
|
||||
prependOnceListener(event: 'online', listener: (worker: Worker) => void): this;
|
||||
prependOnceListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
||||
}
|
||||
|
||||
function disconnect(callback?: () => void): void;
|
||||
function fork(env?: any): Worker;
|
||||
const isMaster: boolean;
|
||||
const isWorker: boolean;
|
||||
// TODO: cluster.schedulingPolicy
|
||||
const settings: ClusterSettings;
|
||||
function setupMaster(settings?: ClusterSettings): void;
|
||||
const worker: Worker;
|
||||
const workers: {
|
||||
[index: string]: Worker | undefined
|
||||
};
|
||||
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. disconnect
|
||||
* 2. exit
|
||||
* 3. fork
|
||||
* 4. listening
|
||||
* 5. message
|
||||
* 6. online
|
||||
* 7. setup
|
||||
*/
|
||||
function addListener(event: string, listener: (...args: any[]) => void): Cluster;
|
||||
function addListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
|
||||
function addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
|
||||
function addListener(event: "fork", listener: (worker: Worker) => void): Cluster;
|
||||
function addListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
|
||||
// the handle is a net.Socket or net.Server object, or undefined.
|
||||
function addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster;
|
||||
function addListener(event: "online", listener: (worker: Worker) => void): Cluster;
|
||||
function addListener(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
|
||||
|
||||
function emit(event: string | symbol, ...args: any[]): boolean;
|
||||
function emit(event: "disconnect", worker: Worker): boolean;
|
||||
function emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
|
||||
function emit(event: "fork", worker: Worker): boolean;
|
||||
function emit(event: "listening", worker: Worker, address: Address): boolean;
|
||||
function emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
|
||||
function emit(event: "online", worker: Worker): boolean;
|
||||
function emit(event: "setup", settings: ClusterSettings): boolean;
|
||||
|
||||
function on(event: string, listener: (...args: any[]) => void): Cluster;
|
||||
function on(event: "disconnect", listener: (worker: Worker) => void): Cluster;
|
||||
function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
|
||||
function on(event: "fork", listener: (worker: Worker) => void): Cluster;
|
||||
function on(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
|
||||
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.
|
||||
function on(event: "online", listener: (worker: Worker) => void): Cluster;
|
||||
function on(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
|
||||
|
||||
function once(event: string, listener: (...args: any[]) => void): Cluster;
|
||||
function once(event: "disconnect", listener: (worker: Worker) => void): Cluster;
|
||||
function once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
|
||||
function once(event: "fork", listener: (worker: Worker) => void): Cluster;
|
||||
function once(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
|
||||
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.
|
||||
function once(event: "online", listener: (worker: Worker) => void): Cluster;
|
||||
function once(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
|
||||
|
||||
function removeListener(event: string, listener: (...args: any[]) => void): Cluster;
|
||||
function removeAllListeners(event?: string): Cluster;
|
||||
function setMaxListeners(n: number): Cluster;
|
||||
function getMaxListeners(): number;
|
||||
function listeners(event: string): Function[];
|
||||
function listenerCount(type: string): number;
|
||||
|
||||
function prependListener(event: string, listener: (...args: any[]) => void): Cluster;
|
||||
function prependListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
|
||||
function prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
|
||||
function prependListener(event: "fork", listener: (worker: Worker) => void): Cluster;
|
||||
function prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
|
||||
// the handle is a net.Socket or net.Server object, or undefined.
|
||||
function prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster;
|
||||
function prependListener(event: "online", listener: (worker: Worker) => void): Cluster;
|
||||
function prependListener(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
|
||||
|
||||
function prependOnceListener(event: string, listener: (...args: any[]) => void): Cluster;
|
||||
function prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
|
||||
function prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
|
||||
function prependOnceListener(event: "fork", listener: (worker: Worker) => void): Cluster;
|
||||
function prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
|
||||
// the handle is a net.Socket or net.Server object, or undefined.
|
||||
function prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster;
|
||||
function prependOnceListener(event: "online", listener: (worker: Worker) => void): Cluster;
|
||||
function prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
|
||||
|
||||
function eventNames(): string[];
|
||||
const cluster: Cluster;
|
||||
export default cluster;
|
||||
}
|
||||
declare module 'node:cluster' {
|
||||
export * from 'cluster';
|
||||
export { default as default } from 'cluster';
|
||||
}
|
||||
|
|
406
node_modules/@types/node/console.d.ts
сгенерированный
поставляемый
Normal file → Executable file
406
node_modules/@types/node/console.d.ts
сгенерированный
поставляемый
Normal file → Executable file
|
@ -1,3 +1,407 @@
|
|||
declare module "console" {
|
||||
/**
|
||||
* The `console` module provides a simple debugging console that is similar to the
|
||||
* JavaScript console mechanism provided by web browsers.
|
||||
*
|
||||
* The module exports two specific components:
|
||||
*
|
||||
* * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
|
||||
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
|
||||
*
|
||||
* _**Warning**_: The global console object's methods are neither consistently
|
||||
* synchronous like the browser APIs they resemble, nor are they consistently
|
||||
* asynchronous like all other Node.js streams. See the `note on process I/O` for
|
||||
* more information.
|
||||
*
|
||||
* Example using the global `console`:
|
||||
*
|
||||
* ```js
|
||||
* console.log('hello world');
|
||||
* // Prints: hello world, to stdout
|
||||
* console.log('hello %s', 'world');
|
||||
* // Prints: hello world, to stdout
|
||||
* console.error(new Error('Whoops, something bad happened'));
|
||||
* // Prints error message and stack trace to stderr:
|
||||
* // Error: Whoops, something bad happened
|
||||
* // at [eval]:5:15
|
||||
* // at Script.runInThisContext (node:vm:132:18)
|
||||
* // at Object.runInThisContext (node:vm:309:38)
|
||||
* // at node:internal/process/execution:77:19
|
||||
* // at [eval]-wrapper:6:22
|
||||
* // at evalScript (node:internal/process/execution:76:60)
|
||||
* // at node:internal/main/eval_string:23:3
|
||||
*
|
||||
* const name = 'Will Robinson';
|
||||
* console.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to stderr
|
||||
* ```
|
||||
*
|
||||
* Example using the `Console` class:
|
||||
*
|
||||
* ```js
|
||||
* const out = getStreamSomehow();
|
||||
* const err = getStreamSomehow();
|
||||
* const myConsole = new console.Console(out, err);
|
||||
*
|
||||
* myConsole.log('hello world');
|
||||
* // Prints: hello world, to out
|
||||
* myConsole.log('hello %s', 'world');
|
||||
* // Prints: hello world, to out
|
||||
* myConsole.error(new Error('Whoops, something bad happened'));
|
||||
* // Prints: [Error: Whoops, something bad happened], to err
|
||||
*
|
||||
* const name = 'Will Robinson';
|
||||
* myConsole.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to err
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/console.js)
|
||||
*/
|
||||
declare module 'console' {
|
||||
import console = require('node:console');
|
||||
export = console;
|
||||
}
|
||||
declare module 'node:console' {
|
||||
import { InspectOptions } from 'node:util';
|
||||
global {
|
||||
// This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
|
||||
interface Console {
|
||||
Console: console.ConsoleConstructor;
|
||||
/**
|
||||
* `console.assert()` writes a message if `value` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) or omitted. It only
|
||||
* writes a message and does not otherwise affect execution. The output always
|
||||
* starts with `"Assertion failed"`. If provided, `message` is formatted using `util.format()`.
|
||||
*
|
||||
* If `value` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), nothing happens.
|
||||
*
|
||||
* ```js
|
||||
* console.assert(true, 'does nothing');
|
||||
*
|
||||
* console.assert(false, 'Whoops %s work', 'didn\'t');
|
||||
* // Assertion failed: Whoops didn't work
|
||||
*
|
||||
* console.assert();
|
||||
* // Assertion failed
|
||||
* ```
|
||||
* @since v0.1.101
|
||||
* @param value The value tested for being truthy.
|
||||
* @param ...message All arguments besides `value` are used as error message.
|
||||
*/
|
||||
assert(value: any, message?: string, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* When `stdout` is a TTY, calling `console.clear()` will attempt to clear the
|
||||
* TTY. When `stdout` is not a TTY, this method does nothing.
|
||||
*
|
||||
* The specific operation of `console.clear()` can vary across operating systems
|
||||
* and terminal types. For most Linux operating systems, `console.clear()`operates similarly to the `clear` shell command. On Windows, `console.clear()`will clear only the output in the
|
||||
* current terminal viewport for the Node.js
|
||||
* binary.
|
||||
* @since v8.3.0
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* Maintains an internal counter specific to `label` and outputs to `stdout` the
|
||||
* number of times `console.count()` has been called with the given `label`.
|
||||
*
|
||||
* ```js
|
||||
* > console.count()
|
||||
* default: 1
|
||||
* undefined
|
||||
* > console.count('default')
|
||||
* default: 2
|
||||
* undefined
|
||||
* > console.count('abc')
|
||||
* abc: 1
|
||||
* undefined
|
||||
* > console.count('xyz')
|
||||
* xyz: 1
|
||||
* undefined
|
||||
* > console.count('abc')
|
||||
* abc: 2
|
||||
* undefined
|
||||
* > console.count()
|
||||
* default: 3
|
||||
* undefined
|
||||
* >
|
||||
* ```
|
||||
* @since v8.3.0
|
||||
* @param label The display label for the counter.
|
||||
*/
|
||||
count(label?: string): void;
|
||||
/**
|
||||
* Resets the internal counter specific to `label`.
|
||||
*
|
||||
* ```js
|
||||
* > console.count('abc');
|
||||
* abc: 1
|
||||
* undefined
|
||||
* > console.countReset('abc');
|
||||
* undefined
|
||||
* > console.count('abc');
|
||||
* abc: 1
|
||||
* undefined
|
||||
* >
|
||||
* ```
|
||||
* @since v8.3.0
|
||||
* @param label The display label for the counter.
|
||||
*/
|
||||
countReset(label?: string): void;
|
||||
/**
|
||||
* The `console.debug()` function is an alias for {@link log}.
|
||||
* @since v8.0.0
|
||||
*/
|
||||
debug(message?: any, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* Uses `util.inspect()` on `obj` and prints the resulting string to `stdout`.
|
||||
* This function bypasses any custom `inspect()` function defined on `obj`.
|
||||
* @since v0.1.101
|
||||
*/
|
||||
dir(obj: any, options?: InspectOptions): void;
|
||||
/**
|
||||
* This method calls `console.log()` passing it the arguments received.
|
||||
* This method does not produce any XML formatting.
|
||||
* @since v8.0.0
|
||||
*/
|
||||
dirxml(...data: any[]): void;
|
||||
/**
|
||||
* Prints to `stderr` with newline. Multiple arguments can be passed, with the
|
||||
* first used as the primary message and all additional used as substitution
|
||||
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`).
|
||||
*
|
||||
* ```js
|
||||
* const code = 5;
|
||||
* console.error('error #%d', code);
|
||||
* // Prints: error #5, to stderr
|
||||
* console.error('error', code);
|
||||
* // Prints: error 5, to stderr
|
||||
* ```
|
||||
*
|
||||
* If formatting elements (e.g. `%d`) are not found in the first string then `util.inspect()` is called on each argument and the resulting string
|
||||
* values are concatenated. See `util.format()` for more information.
|
||||
* @since v0.1.100
|
||||
*/
|
||||
error(message?: any, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* Increases indentation of subsequent lines by spaces for `groupIndentation`length.
|
||||
*
|
||||
* If one or more `label`s are provided, those are printed first without the
|
||||
* additional indentation.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
group(...label: any[]): void;
|
||||
/**
|
||||
* An alias for {@link group}.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
groupCollapsed(...label: any[]): void;
|
||||
/**
|
||||
* Decreases indentation of subsequent lines by spaces for `groupIndentation`length.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
groupEnd(): void;
|
||||
/**
|
||||
* The `console.info()` function is an alias for {@link log}.
|
||||
* @since v0.1.100
|
||||
*/
|
||||
info(message?: any, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* Prints to `stdout` with newline. Multiple arguments can be passed, with the
|
||||
* first used as the primary message and all additional used as substitution
|
||||
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`).
|
||||
*
|
||||
* ```js
|
||||
* const count = 5;
|
||||
* console.log('count: %d', count);
|
||||
* // Prints: count: 5, to stdout
|
||||
* console.log('count:', count);
|
||||
* // Prints: count: 5, to stdout
|
||||
* ```
|
||||
*
|
||||
* See `util.format()` for more information.
|
||||
* @since v0.1.100
|
||||
*/
|
||||
log(message?: any, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* Try to construct a table with the columns of the properties of `tabularData`(or use `properties`) and rows of `tabularData` and log it. Falls back to just
|
||||
* logging the argument if it can’t be parsed as tabular.
|
||||
*
|
||||
* ```js
|
||||
* // These can't be parsed as tabular data
|
||||
* console.table(Symbol());
|
||||
* // Symbol()
|
||||
*
|
||||
* console.table(undefined);
|
||||
* // undefined
|
||||
*
|
||||
* console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);
|
||||
* // ┌─────────┬─────┬─────┐
|
||||
* // │ (index) │ a │ b │
|
||||
* // ├─────────┼─────┼─────┤
|
||||
* // │ 0 │ 1 │ 'Y' │
|
||||
* // │ 1 │ 'Z' │ 2 │
|
||||
* // └─────────┴─────┴─────┘
|
||||
*
|
||||
* console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);
|
||||
* // ┌─────────┬─────┐
|
||||
* // │ (index) │ a │
|
||||
* // ├─────────┼─────┤
|
||||
* // │ 0 │ 1 │
|
||||
* // │ 1 │ 'Z' │
|
||||
* // └─────────┴─────┘
|
||||
* ```
|
||||
* @since v10.0.0
|
||||
* @param properties Alternate properties for constructing the table.
|
||||
*/
|
||||
table(tabularData: any, properties?: ReadonlyArray<string>): void;
|
||||
/**
|
||||
* Starts a timer that can be used to compute the duration of an operation. Timers
|
||||
* are identified by a unique `label`. Use the same `label` when calling {@link timeEnd} to stop the timer and output the elapsed time in
|
||||
* suitable time units to `stdout`. For example, if the elapsed
|
||||
* time is 3869ms, `console.timeEnd()` displays "3.869s".
|
||||
* @since v0.1.104
|
||||
*/
|
||||
time(label?: string): void;
|
||||
/**
|
||||
* Stops a timer that was previously started by calling {@link time} and
|
||||
* prints the result to `stdout`:
|
||||
*
|
||||
* ```js
|
||||
* console.time('100-elements');
|
||||
* for (let i = 0; i < 100; i++) {}
|
||||
* console.timeEnd('100-elements');
|
||||
* // prints 100-elements: 225.438ms
|
||||
* ```
|
||||
* @since v0.1.104
|
||||
*/
|
||||
timeEnd(label?: string): void;
|
||||
/**
|
||||
* For a timer that was previously started by calling {@link time}, prints
|
||||
* the elapsed time and other `data` arguments to `stdout`:
|
||||
*
|
||||
* ```js
|
||||
* console.time('process');
|
||||
* const value = expensiveProcess1(); // Returns 42
|
||||
* console.timeLog('process', value);
|
||||
* // Prints "process: 365.227ms 42".
|
||||
* doExpensiveProcess2(value);
|
||||
* console.timeEnd('process');
|
||||
* ```
|
||||
* @since v10.7.0
|
||||
*/
|
||||
timeLog(label?: string, ...data: any[]): void;
|
||||
/**
|
||||
* Prints to `stderr` the string `'Trace: '`, followed by the `util.format()` formatted message and stack trace to the current position in the code.
|
||||
*
|
||||
* ```js
|
||||
* console.trace('Show me');
|
||||
* // Prints: (stack trace will vary based on where trace is called)
|
||||
* // Trace: Show me
|
||||
* // at repl:2:9
|
||||
* // at REPLServer.defaultEval (repl.js:248:27)
|
||||
* // at bound (domain.js:287:14)
|
||||
* // at REPLServer.runBound [as eval] (domain.js:300:12)
|
||||
* // at REPLServer.<anonymous> (repl.js:412:12)
|
||||
* // at emitOne (events.js:82:20)
|
||||
* // at REPLServer.emit (events.js:169:7)
|
||||
* // at REPLServer.Interface._onLine (readline.js:210:10)
|
||||
* // at REPLServer.Interface._line (readline.js:549:8)
|
||||
* // at REPLServer.Interface._ttyWrite (readline.js:826:14)
|
||||
* ```
|
||||
* @since v0.1.104
|
||||
*/
|
||||
trace(message?: any, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* The `console.warn()` function is an alias for {@link error}.
|
||||
* @since v0.1.100
|
||||
*/
|
||||
warn(message?: any, ...optionalParams: any[]): void;
|
||||
// --- Inspector mode only ---
|
||||
/**
|
||||
* This method does not display anything unless used in the inspector.
|
||||
* Starts a JavaScript CPU profile with an optional label.
|
||||
*/
|
||||
profile(label?: string): void;
|
||||
/**
|
||||
* This method does not display anything unless used in the inspector.
|
||||
* Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector.
|
||||
*/
|
||||
profileEnd(label?: string): void;
|
||||
/**
|
||||
* This method does not display anything unless used in the inspector.
|
||||
* Adds an event with the label `label` to the Timeline panel of the inspector.
|
||||
*/
|
||||
timeStamp(label?: string): void;
|
||||
}
|
||||
/**
|
||||
* The `console` module provides a simple debugging console that is similar to the
|
||||
* JavaScript console mechanism provided by web browsers.
|
||||
*
|
||||
* The module exports two specific components:
|
||||
*
|
||||
* * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
|
||||
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
|
||||
*
|
||||
* _**Warning**_: The global console object's methods are neither consistently
|
||||
* synchronous like the browser APIs they resemble, nor are they consistently
|
||||
* asynchronous like all other Node.js streams. See the `note on process I/O` for
|
||||
* more information.
|
||||
*
|
||||
* Example using the global `console`:
|
||||
*
|
||||
* ```js
|
||||
* console.log('hello world');
|
||||
* // Prints: hello world, to stdout
|
||||
* console.log('hello %s', 'world');
|
||||
* // Prints: hello world, to stdout
|
||||
* console.error(new Error('Whoops, something bad happened'));
|
||||
* // Prints error message and stack trace to stderr:
|
||||
* // Error: Whoops, something bad happened
|
||||
* // at [eval]:5:15
|
||||
* // at Script.runInThisContext (node:vm:132:18)
|
||||
* // at Object.runInThisContext (node:vm:309:38)
|
||||
* // at node:internal/process/execution:77:19
|
||||
* // at [eval]-wrapper:6:22
|
||||
* // at evalScript (node:internal/process/execution:76:60)
|
||||
* // at node:internal/main/eval_string:23:3
|
||||
*
|
||||
* const name = 'Will Robinson';
|
||||
* console.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to stderr
|
||||
* ```
|
||||
*
|
||||
* Example using the `Console` class:
|
||||
*
|
||||
* ```js
|
||||
* const out = getStreamSomehow();
|
||||
* const err = getStreamSomehow();
|
||||
* const myConsole = new console.Console(out, err);
|
||||
*
|
||||
* myConsole.log('hello world');
|
||||
* // Prints: hello world, to out
|
||||
* myConsole.log('hello %s', 'world');
|
||||
* // Prints: hello world, to out
|
||||
* myConsole.error(new Error('Whoops, something bad happened'));
|
||||
* // Prints: [Error: Whoops, something bad happened], to err
|
||||
*
|
||||
* const name = 'Will Robinson';
|
||||
* myConsole.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to err
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/console.js)
|
||||
*/
|
||||
namespace console {
|
||||
interface ConsoleConstructorOptions {
|
||||
stdout: NodeJS.WritableStream;
|
||||
stderr?: NodeJS.WritableStream | undefined;
|
||||
ignoreErrors?: boolean | undefined;
|
||||
colorMode?: boolean | 'auto' | undefined;
|
||||
inspectOptions?: InspectOptions | undefined;
|
||||
}
|
||||
interface ConsoleConstructor {
|
||||
prototype: Console;
|
||||
new (stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): Console;
|
||||
new (options: ConsoleConstructorOptions): Console;
|
||||
}
|
||||
}
|
||||
var console: Console;
|
||||
}
|
||||
export = globalThis.console;
|
||||
}
|
||||
|
|
462
node_modules/@types/node/constants.d.ts
сгенерированный
поставляемый
Normal file → Executable file
462
node_modules/@types/node/constants.d.ts
сгенерированный
поставляемый
Normal file → Executable file
|
@ -1,448 +1,18 @@
|
|||
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
|
||||
declare module "constants" {
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.E2BIG` instead. */
|
||||
const E2BIG: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EACCES` instead. */
|
||||
const EACCES: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EADDRINUSE` instead. */
|
||||
const EADDRINUSE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EADDRNOTAVAIL` instead. */
|
||||
const EADDRNOTAVAIL: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EAFNOSUPPORT` instead. */
|
||||
const EAFNOSUPPORT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EAGAIN` instead. */
|
||||
const EAGAIN: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EALREADY` instead. */
|
||||
const EALREADY: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EBADF` instead. */
|
||||
const EBADF: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EBADMSG` instead. */
|
||||
const EBADMSG: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EBUSY` instead. */
|
||||
const EBUSY: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ECANCELED` instead. */
|
||||
const ECANCELED: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ECHILD` instead. */
|
||||
const ECHILD: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ECONNABORTED` instead. */
|
||||
const ECONNABORTED: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ECONNREFUSED` instead. */
|
||||
const ECONNREFUSED: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ECONNRESET` instead. */
|
||||
const ECONNRESET: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EDEADLK` instead. */
|
||||
const EDEADLK: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EDESTADDRREQ` instead. */
|
||||
const EDESTADDRREQ: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EDOM` instead. */
|
||||
const EDOM: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EEXIST` instead. */
|
||||
const EEXIST: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EFAULT` instead. */
|
||||
const EFAULT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EFBIG` instead. */
|
||||
const EFBIG: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EHOSTUNREACH` instead. */
|
||||
const EHOSTUNREACH: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EIDRM` instead. */
|
||||
const EIDRM: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EILSEQ` instead. */
|
||||
const EILSEQ: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EINPROGRESS` instead. */
|
||||
const EINPROGRESS: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EINTR` instead. */
|
||||
const EINTR: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EINVAL` instead. */
|
||||
const EINVAL: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EIO` instead. */
|
||||
const EIO: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EISCONN` instead. */
|
||||
const EISCONN: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EISDIR` instead. */
|
||||
const EISDIR: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ELOOP` instead. */
|
||||
const ELOOP: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EMFILE` instead. */
|
||||
const EMFILE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EMLINK` instead. */
|
||||
const EMLINK: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EMSGSIZE` instead. */
|
||||
const EMSGSIZE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENAMETOOLONG` instead. */
|
||||
const ENAMETOOLONG: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENETDOWN` instead. */
|
||||
const ENETDOWN: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENETRESET` instead. */
|
||||
const ENETRESET: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENETUNREACH` instead. */
|
||||
const ENETUNREACH: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENFILE` instead. */
|
||||
const ENFILE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOBUFS` instead. */
|
||||
const ENOBUFS: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENODATA` instead. */
|
||||
const ENODATA: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENODEV` instead. */
|
||||
const ENODEV: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOENT` instead. */
|
||||
const ENOENT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOEXEC` instead. */
|
||||
const ENOEXEC: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOLCK` instead. */
|
||||
const ENOLCK: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOLINK` instead. */
|
||||
const ENOLINK: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOMEM` instead. */
|
||||
const ENOMEM: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOMSG` instead. */
|
||||
const ENOMSG: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOPROTOOPT` instead. */
|
||||
const ENOPROTOOPT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOSPC` instead. */
|
||||
const ENOSPC: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOSR` instead. */
|
||||
const ENOSR: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOSTR` instead. */
|
||||
const ENOSTR: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOSYS` instead. */
|
||||
const ENOSYS: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTCONN` instead. */
|
||||
const ENOTCONN: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTDIR` instead. */
|
||||
const ENOTDIR: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTEMPTY` instead. */
|
||||
const ENOTEMPTY: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTSOCK` instead. */
|
||||
const ENOTSOCK: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTSUP` instead. */
|
||||
const ENOTSUP: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTTY` instead. */
|
||||
const ENOTTY: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ENXIO` instead. */
|
||||
const ENXIO: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EOPNOTSUPP` instead. */
|
||||
const EOPNOTSUPP: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EOVERFLOW` instead. */
|
||||
const EOVERFLOW: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EPERM` instead. */
|
||||
const EPERM: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EPIPE` instead. */
|
||||
const EPIPE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EPROTO` instead. */
|
||||
const EPROTO: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EPROTONOSUPPORT` instead. */
|
||||
const EPROTONOSUPPORT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EPROTOTYPE` instead. */
|
||||
const EPROTOTYPE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ERANGE` instead. */
|
||||
const ERANGE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EROFS` instead. */
|
||||
const EROFS: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ESPIPE` instead. */
|
||||
const ESPIPE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ESRCH` instead. */
|
||||
const ESRCH: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ETIME` instead. */
|
||||
const ETIME: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ETIMEDOUT` instead. */
|
||||
const ETIMEDOUT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.ETXTBSY` instead. */
|
||||
const ETXTBSY: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EWOULDBLOCK` instead. */
|
||||
const EWOULDBLOCK: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.EXDEV` instead. */
|
||||
const EXDEV: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINTR` instead. */
|
||||
const WSAEINTR: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEBADF` instead. */
|
||||
const WSAEBADF: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEACCES` instead. */
|
||||
const WSAEACCES: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEFAULT` instead. */
|
||||
const WSAEFAULT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINVAL` instead. */
|
||||
const WSAEINVAL: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEMFILE` instead. */
|
||||
const WSAEMFILE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEWOULDBLOCK` instead. */
|
||||
const WSAEWOULDBLOCK: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINPROGRESS` instead. */
|
||||
const WSAEINPROGRESS: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEALREADY` instead. */
|
||||
const WSAEALREADY: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOTSOCK` instead. */
|
||||
const WSAENOTSOCK: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEDESTADDRREQ` instead. */
|
||||
const WSAEDESTADDRREQ: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEMSGSIZE` instead. */
|
||||
const WSAEMSGSIZE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPROTOTYPE` instead. */
|
||||
const WSAEPROTOTYPE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOPROTOOPT` instead. */
|
||||
const WSAENOPROTOOPT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPROTONOSUPPORT` instead. */
|
||||
const WSAEPROTONOSUPPORT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAESOCKTNOSUPPORT` instead. */
|
||||
const WSAESOCKTNOSUPPORT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEOPNOTSUPP` instead. */
|
||||
const WSAEOPNOTSUPP: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPFNOSUPPORT` instead. */
|
||||
const WSAEPFNOSUPPORT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEAFNOSUPPORT` instead. */
|
||||
const WSAEAFNOSUPPORT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEADDRINUSE` instead. */
|
||||
const WSAEADDRINUSE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEADDRNOTAVAIL` instead. */
|
||||
const WSAEADDRNOTAVAIL: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENETDOWN` instead. */
|
||||
const WSAENETDOWN: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENETUNREACH` instead. */
|
||||
const WSAENETUNREACH: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENETRESET` instead. */
|
||||
const WSAENETRESET: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAECONNABORTED` instead. */
|
||||
const WSAECONNABORTED: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAECONNRESET` instead. */
|
||||
const WSAECONNRESET: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOBUFS` instead. */
|
||||
const WSAENOBUFS: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEISCONN` instead. */
|
||||
const WSAEISCONN: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOTCONN` instead. */
|
||||
const WSAENOTCONN: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAESHUTDOWN` instead. */
|
||||
const WSAESHUTDOWN: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAETOOMANYREFS` instead. */
|
||||
const WSAETOOMANYREFS: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAETIMEDOUT` instead. */
|
||||
const WSAETIMEDOUT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAECONNREFUSED` instead. */
|
||||
const WSAECONNREFUSED: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAELOOP` instead. */
|
||||
const WSAELOOP: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENAMETOOLONG` instead. */
|
||||
const WSAENAMETOOLONG: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEHOSTDOWN` instead. */
|
||||
const WSAEHOSTDOWN: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEHOSTUNREACH` instead. */
|
||||
const WSAEHOSTUNREACH: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOTEMPTY` instead. */
|
||||
const WSAENOTEMPTY: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPROCLIM` instead. */
|
||||
const WSAEPROCLIM: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEUSERS` instead. */
|
||||
const WSAEUSERS: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEDQUOT` instead. */
|
||||
const WSAEDQUOT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAESTALE` instead. */
|
||||
const WSAESTALE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEREMOTE` instead. */
|
||||
const WSAEREMOTE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSASYSNOTREADY` instead. */
|
||||
const WSASYSNOTREADY: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAVERNOTSUPPORTED` instead. */
|
||||
const WSAVERNOTSUPPORTED: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSANOTINITIALISED` instead. */
|
||||
const WSANOTINITIALISED: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEDISCON` instead. */
|
||||
const WSAEDISCON: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOMORE` instead. */
|
||||
const WSAENOMORE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAECANCELLED` instead. */
|
||||
const WSAECANCELLED: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINVALIDPROCTABLE` instead. */
|
||||
const WSAEINVALIDPROCTABLE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINVALIDPROVIDER` instead. */
|
||||
const WSAEINVALIDPROVIDER: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPROVIDERFAILEDINIT` instead. */
|
||||
const WSAEPROVIDERFAILEDINIT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSASYSCALLFAILURE` instead. */
|
||||
const WSASYSCALLFAILURE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSASERVICE_NOT_FOUND` instead. */
|
||||
const WSASERVICE_NOT_FOUND: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSATYPE_NOT_FOUND` instead. */
|
||||
const WSATYPE_NOT_FOUND: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSA_E_NO_MORE` instead. */
|
||||
const WSA_E_NO_MORE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSA_E_CANCELLED` instead. */
|
||||
const WSA_E_CANCELLED: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEREFUSED` instead. */
|
||||
const WSAEREFUSED: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGHUP` instead. */
|
||||
const SIGHUP: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGINT` instead. */
|
||||
const SIGINT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGILL` instead. */
|
||||
const SIGILL: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGABRT` instead. */
|
||||
const SIGABRT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGFPE` instead. */
|
||||
const SIGFPE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGKILL` instead. */
|
||||
const SIGKILL: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGSEGV` instead. */
|
||||
const SIGSEGV: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTERM` instead. */
|
||||
const SIGTERM: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGBREAK` instead. */
|
||||
const SIGBREAK: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGWINCH` instead. */
|
||||
const SIGWINCH: number;
|
||||
const SSL_OP_ALL: number;
|
||||
const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
|
||||
const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
|
||||
const SSL_OP_CISCO_ANYCONNECT: number;
|
||||
const SSL_OP_COOKIE_EXCHANGE: number;
|
||||
const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
|
||||
const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
|
||||
const SSL_OP_EPHEMERAL_RSA: number;
|
||||
const SSL_OP_LEGACY_SERVER_CONNECT: number;
|
||||
const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
|
||||
const SSL_OP_MICROSOFT_SESS_ID_BUG: number;
|
||||
const SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
|
||||
const SSL_OP_NETSCAPE_CA_DN_BUG: number;
|
||||
const SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
|
||||
const SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
|
||||
const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
|
||||
const SSL_OP_NO_COMPRESSION: number;
|
||||
const SSL_OP_NO_QUERY_MTU: number;
|
||||
const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
|
||||
const SSL_OP_NO_SSLv2: number;
|
||||
const SSL_OP_NO_SSLv3: number;
|
||||
const SSL_OP_NO_TICKET: number;
|
||||
const SSL_OP_NO_TLSv1: number;
|
||||
const SSL_OP_NO_TLSv1_1: number;
|
||||
const SSL_OP_NO_TLSv1_2: number;
|
||||
const SSL_OP_PKCS1_CHECK_1: number;
|
||||
const SSL_OP_PKCS1_CHECK_2: number;
|
||||
const SSL_OP_SINGLE_DH_USE: number;
|
||||
const SSL_OP_SINGLE_ECDH_USE: number;
|
||||
const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
|
||||
const SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
|
||||
const SSL_OP_TLS_BLOCK_PADDING_BUG: number;
|
||||
const SSL_OP_TLS_D5_BUG: number;
|
||||
const SSL_OP_TLS_ROLLBACK_BUG: number;
|
||||
const ENGINE_METHOD_DSA: number;
|
||||
const ENGINE_METHOD_DH: number;
|
||||
const ENGINE_METHOD_RAND: number;
|
||||
const ENGINE_METHOD_ECDH: number;
|
||||
const ENGINE_METHOD_ECDSA: number;
|
||||
const ENGINE_METHOD_CIPHERS: number;
|
||||
const ENGINE_METHOD_DIGESTS: number;
|
||||
const ENGINE_METHOD_STORE: number;
|
||||
const ENGINE_METHOD_PKEY_METHS: number;
|
||||
const ENGINE_METHOD_PKEY_ASN1_METHS: number;
|
||||
const ENGINE_METHOD_ALL: number;
|
||||
const ENGINE_METHOD_NONE: number;
|
||||
const DH_CHECK_P_NOT_SAFE_PRIME: number;
|
||||
const DH_CHECK_P_NOT_PRIME: number;
|
||||
const DH_UNABLE_TO_CHECK_GENERATOR: number;
|
||||
const DH_NOT_SUITABLE_GENERATOR: number;
|
||||
const RSA_PKCS1_PADDING: number;
|
||||
const RSA_SSLV23_PADDING: number;
|
||||
const RSA_NO_PADDING: number;
|
||||
const RSA_PKCS1_OAEP_PADDING: number;
|
||||
const RSA_X931_PADDING: number;
|
||||
const RSA_PKCS1_PSS_PADDING: number;
|
||||
const POINT_CONVERSION_COMPRESSED: number;
|
||||
const POINT_CONVERSION_UNCOMPRESSED: number;
|
||||
const POINT_CONVERSION_HYBRID: number;
|
||||
const O_RDONLY: number;
|
||||
const O_WRONLY: number;
|
||||
const O_RDWR: number;
|
||||
const S_IFMT: number;
|
||||
const S_IFREG: number;
|
||||
const S_IFDIR: number;
|
||||
const S_IFCHR: number;
|
||||
const S_IFBLK: number;
|
||||
const S_IFIFO: number;
|
||||
const S_IFSOCK: number;
|
||||
const S_IRWXU: number;
|
||||
const S_IRUSR: number;
|
||||
const S_IWUSR: number;
|
||||
const S_IXUSR: number;
|
||||
const S_IRWXG: number;
|
||||
const S_IRGRP: number;
|
||||
const S_IWGRP: number;
|
||||
const S_IXGRP: number;
|
||||
const S_IRWXO: number;
|
||||
const S_IROTH: number;
|
||||
const S_IWOTH: number;
|
||||
const S_IXOTH: number;
|
||||
const S_IFLNK: number;
|
||||
const O_CREAT: number;
|
||||
const O_EXCL: number;
|
||||
const O_NOCTTY: number;
|
||||
const O_DIRECTORY: number;
|
||||
const O_NOATIME: number;
|
||||
const O_NOFOLLOW: number;
|
||||
const O_SYNC: number;
|
||||
const O_DSYNC: number;
|
||||
const O_SYMLINK: number;
|
||||
const O_DIRECT: number;
|
||||
const O_NONBLOCK: number;
|
||||
const O_TRUNC: number;
|
||||
const O_APPEND: number;
|
||||
const F_OK: number;
|
||||
const R_OK: number;
|
||||
const W_OK: number;
|
||||
const X_OK: number;
|
||||
const COPYFILE_EXCL: number;
|
||||
const COPYFILE_FICLONE: number;
|
||||
const COPYFILE_FICLONE_FORCE: number;
|
||||
const UV_UDP_REUSEADDR: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGQUIT` instead. */
|
||||
const SIGQUIT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTRAP` instead. */
|
||||
const SIGTRAP: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGIOT` instead. */
|
||||
const SIGIOT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGBUS` instead. */
|
||||
const SIGBUS: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGUSR1` instead. */
|
||||
const SIGUSR1: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGUSR2` instead. */
|
||||
const SIGUSR2: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGPIPE` instead. */
|
||||
const SIGPIPE: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGALRM` instead. */
|
||||
const SIGALRM: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGCHLD` instead. */
|
||||
const SIGCHLD: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGSTKFLT` instead. */
|
||||
const SIGSTKFLT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGCONT` instead. */
|
||||
const SIGCONT: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGSTOP` instead. */
|
||||
const SIGSTOP: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTSTP` instead. */
|
||||
const SIGTSTP: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTTIN` instead. */
|
||||
const SIGTTIN: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTTOU` instead. */
|
||||
const SIGTTOU: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGURG` instead. */
|
||||
const SIGURG: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGXCPU` instead. */
|
||||
const SIGXCPU: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGXFSZ` instead. */
|
||||
const SIGXFSZ: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGVTALRM` instead. */
|
||||
const SIGVTALRM: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGPROF` instead. */
|
||||
const SIGPROF: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGIO` instead. */
|
||||
const SIGIO: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGPOLL` instead. */
|
||||
const SIGPOLL: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGPWR` instead. */
|
||||
const SIGPWR: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGSYS` instead. */
|
||||
const SIGSYS: number;
|
||||
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGUNUSED` instead. */
|
||||
const SIGUNUSED: number;
|
||||
const defaultCoreCipherList: string;
|
||||
const defaultCipherList: string;
|
||||
const ENGINE_METHOD_RSA: number;
|
||||
const ALPN_ENABLED: number;
|
||||
declare module 'constants' {
|
||||
import { constants as osConstants, SignalConstants } from 'node:os';
|
||||
import { constants as cryptoConstants } from 'node:crypto';
|
||||
import { constants as fsConstants } from 'node:fs';
|
||||
|
||||
const exp: typeof osConstants.errno &
|
||||
typeof osConstants.priority &
|
||||
SignalConstants &
|
||||
typeof cryptoConstants &
|
||||
typeof fsConstants;
|
||||
export = exp;
|
||||
}
|
||||
|
||||
declare module 'node:constants' {
|
||||
import constants = require('constants');
|
||||
export = constants;
|
||||
}
|
||||
|
|
3854
node_modules/@types/node/crypto.d.ts
сгенерированный
поставляемый
Normal file → Executable file
3854
node_modules/@types/node/crypto.d.ts
сгенерированный
поставляемый
Normal file → Executable file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,70 +1,490 @@
|
|||
declare module "dgram" {
|
||||
import { AddressInfo } from "net";
|
||||
import * as dns from "dns";
|
||||
import * as events from "events";
|
||||
|
||||
/**
|
||||
* The `dgram` module provides an implementation of UDP datagram sockets.
|
||||
*
|
||||
* ```js
|
||||
* const dgram = require('dgram');
|
||||
* const server = dgram.createSocket('udp4');
|
||||
*
|
||||
* server.on('error', (err) => {
|
||||
* console.log(`server error:\n${err.stack}`);
|
||||
* server.close();
|
||||
* });
|
||||
*
|
||||
* server.on('message', (msg, rinfo) => {
|
||||
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
||||
* });
|
||||
*
|
||||
* server.on('listening', () => {
|
||||
* const address = server.address();
|
||||
* console.log(`server listening ${address.address}:${address.port}`);
|
||||
* });
|
||||
*
|
||||
* server.bind(41234);
|
||||
* // Prints: server listening 0.0.0.0:41234
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/dgram.js)
|
||||
*/
|
||||
declare module 'dgram' {
|
||||
import { AddressInfo } from 'node:net';
|
||||
import * as dns from 'node:dns';
|
||||
import { EventEmitter, Abortable } from 'node:events';
|
||||
interface RemoteInfo {
|
||||
address: string;
|
||||
family: 'IPv4' | 'IPv6';
|
||||
port: number;
|
||||
size: number;
|
||||
}
|
||||
|
||||
interface BindOptions {
|
||||
port?: number;
|
||||
address?: string;
|
||||
exclusive?: boolean;
|
||||
fd?: number;
|
||||
port?: number | undefined;
|
||||
address?: string | undefined;
|
||||
exclusive?: boolean | undefined;
|
||||
fd?: number | undefined;
|
||||
}
|
||||
|
||||
type SocketType = "udp4" | "udp6";
|
||||
|
||||
interface SocketOptions {
|
||||
type SocketType = 'udp4' | 'udp6';
|
||||
interface SocketOptions extends Abortable {
|
||||
type: SocketType;
|
||||
reuseAddr?: boolean;
|
||||
reuseAddr?: boolean | undefined;
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
ipv6Only?: boolean;
|
||||
recvBufferSize?: number;
|
||||
sendBufferSize?: number;
|
||||
lookup?: (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
|
||||
ipv6Only?: boolean | undefined;
|
||||
recvBufferSize?: number | undefined;
|
||||
sendBufferSize?: number | undefined;
|
||||
lookup?: ((hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void) | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a `dgram.Socket` object. Once the socket is created, calling `socket.bind()` will instruct the socket to begin listening for datagram
|
||||
* messages. When `address` and `port` are not passed to `socket.bind()` the
|
||||
* method will bind the socket to the "all interfaces" address on a random port
|
||||
* (it does the right thing for both `udp4` and `udp6` sockets). The bound address
|
||||
* and port can be retrieved using `socket.address().address` and `socket.address().port`.
|
||||
*
|
||||
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.close()` on the socket:
|
||||
*
|
||||
* ```js
|
||||
* const controller = new AbortController();
|
||||
* const { signal } = controller;
|
||||
* const server = dgram.createSocket({ type: 'udp4', signal });
|
||||
* server.on('message', (msg, rinfo) => {
|
||||
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
||||
* });
|
||||
* // Later, when you want to close the server.
|
||||
* controller.abort();
|
||||
* ```
|
||||
* @since v0.11.13
|
||||
* @param options Available options are:
|
||||
* @param callback Attached as a listener for `'message'` events. Optional.
|
||||
*/
|
||||
function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
||||
function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
||||
|
||||
class Socket extends events.EventEmitter {
|
||||
/**
|
||||
* Encapsulates the datagram functionality.
|
||||
*
|
||||
* New instances of `dgram.Socket` are created using {@link createSocket}.
|
||||
* The `new` keyword is not to be used to create `dgram.Socket` instances.
|
||||
* @since v0.1.99
|
||||
*/
|
||||
class Socket extends EventEmitter {
|
||||
/**
|
||||
* Tells the kernel to join a multicast group at the given `multicastAddress` and`multicastInterface` using the `IP_ADD_MEMBERSHIP` socket option. If the`multicastInterface` argument is not
|
||||
* specified, the operating system will choose
|
||||
* one interface and will add membership to it. To add membership to every
|
||||
* available interface, call `addMembership` multiple times, once per interface.
|
||||
*
|
||||
* When called on an unbound socket, this method will implicitly bind to a random
|
||||
* port, listening on all interfaces.
|
||||
*
|
||||
* When sharing a UDP socket across multiple `cluster` workers, the`socket.addMembership()` function must be called only once or an`EADDRINUSE` error will occur:
|
||||
*
|
||||
* ```js
|
||||
* const cluster = require('cluster');
|
||||
* const dgram = require('dgram');
|
||||
* if (cluster.isPrimary) {
|
||||
* cluster.fork(); // Works ok.
|
||||
* cluster.fork(); // Fails with EADDRINUSE.
|
||||
* } else {
|
||||
* const s = dgram.createSocket('udp4');
|
||||
* s.bind(1234, () => {
|
||||
* s.addMembership('224.0.0.114');
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
* @since v0.6.9
|
||||
*/
|
||||
addMembership(multicastAddress: string, multicastInterface?: string): void;
|
||||
/**
|
||||
* Returns an object containing the address information for a socket.
|
||||
* For UDP sockets, this object will contain `address`, `family` and `port`properties.
|
||||
*
|
||||
* This method throws `EBADF` if called on an unbound socket.
|
||||
* @since v0.1.99
|
||||
*/
|
||||
address(): AddressInfo;
|
||||
/**
|
||||
* For UDP sockets, causes the `dgram.Socket` to listen for datagram
|
||||
* messages on a named `port` and optional `address`. If `port` is not
|
||||
* specified or is `0`, the operating system will attempt to bind to a
|
||||
* random port. If `address` is not specified, the operating system will
|
||||
* attempt to listen on all addresses. Once binding is complete, a`'listening'` event is emitted and the optional `callback` function is
|
||||
* called.
|
||||
*
|
||||
* Specifying both a `'listening'` event listener and passing a`callback` to the `socket.bind()` method is not harmful but not very
|
||||
* useful.
|
||||
*
|
||||
* A bound datagram socket keeps the Node.js process running to receive
|
||||
* datagram messages.
|
||||
*
|
||||
* If binding fails, an `'error'` event is generated. In rare case (e.g.
|
||||
* attempting to bind with a closed socket), an `Error` may be thrown.
|
||||
*
|
||||
* Example of a UDP server listening on port 41234:
|
||||
*
|
||||
* ```js
|
||||
* const dgram = require('dgram');
|
||||
* const server = dgram.createSocket('udp4');
|
||||
*
|
||||
* server.on('error', (err) => {
|
||||
* console.log(`server error:\n${err.stack}`);
|
||||
* server.close();
|
||||
* });
|
||||
*
|
||||
* server.on('message', (msg, rinfo) => {
|
||||
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
||||
* });
|
||||
*
|
||||
* server.on('listening', () => {
|
||||
* const address = server.address();
|
||||
* console.log(`server listening ${address.address}:${address.port}`);
|
||||
* });
|
||||
*
|
||||
* server.bind(41234);
|
||||
* // Prints: server listening 0.0.0.0:41234
|
||||
* ```
|
||||
* @since v0.1.99
|
||||
* @param callback with no parameters. Called when binding is complete.
|
||||
*/
|
||||
bind(port?: number, address?: string, callback?: () => void): void;
|
||||
bind(port?: number, callback?: () => void): void;
|
||||
bind(callback?: () => void): void;
|
||||
bind(options: BindOptions, callback?: () => void): void;
|
||||
/**
|
||||
* Close the underlying socket and stop listening for data on it. If a callback is
|
||||
* provided, it is added as a listener for the `'close'` event.
|
||||
* @since v0.1.99
|
||||
* @param callback Called when the socket has been closed.
|
||||
*/
|
||||
close(callback?: () => void): void;
|
||||
/**
|
||||
* Associates the `dgram.Socket` to a remote address and port. Every
|
||||
* message sent by this handle is automatically sent to that destination. Also,
|
||||
* the socket will only receive messages from that remote peer.
|
||||
* Trying to call `connect()` on an already connected socket will result
|
||||
* in an `ERR_SOCKET_DGRAM_IS_CONNECTED` exception. If `address` is not
|
||||
* provided, `'127.0.0.1'` (for `udp4` sockets) or `'::1'` (for `udp6` sockets)
|
||||
* will be used by default. Once the connection is complete, a `'connect'` event
|
||||
* is emitted and the optional `callback` function is called. In case of failure,
|
||||
* the `callback` is called or, failing this, an `'error'` event is emitted.
|
||||
* @since v12.0.0
|
||||
* @param callback Called when the connection is completed or on error.
|
||||
*/
|
||||
connect(port: number, address?: string, callback?: () => void): void;
|
||||
connect(port: number, callback: () => void): void;
|
||||
/**
|
||||
* A synchronous function that disassociates a connected `dgram.Socket` from
|
||||
* its remote address. Trying to call `disconnect()` on an unbound or already
|
||||
* disconnected socket will result in an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception.
|
||||
* @since v12.0.0
|
||||
*/
|
||||
disconnect(): void;
|
||||
/**
|
||||
* Instructs the kernel to leave a multicast group at `multicastAddress` using the`IP_DROP_MEMBERSHIP` socket option. This method is automatically called by the
|
||||
* kernel when the socket is closed or the process terminates, so most apps will
|
||||
* never have reason to call this.
|
||||
*
|
||||
* If `multicastInterface` is not specified, the operating system will attempt to
|
||||
* drop membership on all valid interfaces.
|
||||
* @since v0.6.9
|
||||
*/
|
||||
dropMembership(multicastAddress: string, multicastInterface?: string): void;
|
||||
/**
|
||||
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
||||
* @since v8.7.0
|
||||
* @return the `SO_RCVBUF` socket receive buffer size in bytes.
|
||||
*/
|
||||
getRecvBufferSize(): number;
|
||||
/**
|
||||
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
||||
* @since v8.7.0
|
||||
* @return the `SO_SNDBUF` socket send buffer size in bytes.
|
||||
*/
|
||||
getSendBufferSize(): number;
|
||||
/**
|
||||
* By default, binding a socket will cause it to block the Node.js process from
|
||||
* exiting as long as the socket is open. The `socket.unref()` method can be used
|
||||
* to exclude the socket from the reference counting that keeps the Node.js
|
||||
* process active. The `socket.ref()` method adds the socket back to the reference
|
||||
* counting and restores the default behavior.
|
||||
*
|
||||
* Calling `socket.ref()` multiples times will have no additional effect.
|
||||
*
|
||||
* The `socket.ref()` method returns a reference to the socket so calls can be
|
||||
* chained.
|
||||
* @since v0.9.1
|
||||
*/
|
||||
ref(): this;
|
||||
/**
|
||||
* Returns an object containing the `address`, `family`, and `port` of the remote
|
||||
* endpoint. This method throws an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception
|
||||
* if the socket is not connected.
|
||||
* @since v12.0.0
|
||||
*/
|
||||
remoteAddress(): AddressInfo;
|
||||
send(msg: string | Uint8Array | any[], port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
send(msg: string | Uint8Array | any[], port?: number, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
send(msg: string | Uint8Array | any[], callback?: (error: Error | null, bytes: number) => void): void;
|
||||
/**
|
||||
* Broadcasts a datagram on the socket.
|
||||
* For connectionless sockets, the destination `port` and `address` must be
|
||||
* specified. Connected sockets, on the other hand, will use their associated
|
||||
* remote endpoint, so the `port` and `address` arguments must not be set.
|
||||
*
|
||||
* The `msg` argument contains the message to be sent.
|
||||
* Depending on its type, different behavior can apply. If `msg` is a `Buffer`,
|
||||
* any `TypedArray` or a `DataView`,
|
||||
* the `offset` and `length` specify the offset within the `Buffer` where the
|
||||
* message begins and the number of bytes in the message, respectively.
|
||||
* If `msg` is a `String`, then it is automatically converted to a `Buffer`with `'utf8'` encoding. With messages that
|
||||
* contain multi-byte characters, `offset` and `length` will be calculated with
|
||||
* respect to `byte length` and not the character position.
|
||||
* If `msg` is an array, `offset` and `length` must not be specified.
|
||||
*
|
||||
* The `address` argument is a string. If the value of `address` is a host name,
|
||||
* DNS will be used to resolve the address of the host. If `address` is not
|
||||
* provided or otherwise falsy, `'127.0.0.1'` (for `udp4` sockets) or `'::1'`(for `udp6` sockets) will be used by default.
|
||||
*
|
||||
* If the socket has not been previously bound with a call to `bind`, the socket
|
||||
* is assigned a random port number and is bound to the "all interfaces" address
|
||||
* (`'0.0.0.0'` for `udp4` sockets, `'::0'` for `udp6` sockets.)
|
||||
*
|
||||
* An optional `callback` function may be specified to as a way of reporting
|
||||
* DNS errors or for determining when it is safe to reuse the `buf` object.
|
||||
* DNS lookups delay the time to send for at least one tick of the
|
||||
* Node.js event loop.
|
||||
*
|
||||
* The only way to know for sure that the datagram has been sent is by using a`callback`. If an error occurs and a `callback` is given, the error will be
|
||||
* passed as the first argument to the `callback`. If a `callback` is not given,
|
||||
* the error is emitted as an `'error'` event on the `socket` object.
|
||||
*
|
||||
* Offset and length are optional but both _must_ be set if either are used.
|
||||
* They are supported only when the first argument is a `Buffer`, a `TypedArray`,
|
||||
* or a `DataView`.
|
||||
*
|
||||
* This method throws `ERR_SOCKET_BAD_PORT` if called on an unbound socket.
|
||||
*
|
||||
* Example of sending a UDP packet to a port on `localhost`;
|
||||
*
|
||||
* ```js
|
||||
* const dgram = require('dgram');
|
||||
* const message = Buffer.from('Some bytes');
|
||||
* const client = dgram.createSocket('udp4');
|
||||
* client.send(message, 41234, 'localhost', (err) => {
|
||||
* client.close();
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Example of sending a UDP packet composed of multiple buffers to a port on`127.0.0.1`;
|
||||
*
|
||||
* ```js
|
||||
* const dgram = require('dgram');
|
||||
* const buf1 = Buffer.from('Some ');
|
||||
* const buf2 = Buffer.from('bytes');
|
||||
* const client = dgram.createSocket('udp4');
|
||||
* client.send([buf1, buf2], 41234, (err) => {
|
||||
* client.close();
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Sending multiple buffers might be faster or slower depending on the
|
||||
* application and operating system. Run benchmarks to
|
||||
* determine the optimal strategy on a case-by-case basis. Generally speaking,
|
||||
* however, sending multiple buffers is faster.
|
||||
*
|
||||
* Example of sending a UDP packet using a socket connected to a port on`localhost`:
|
||||
*
|
||||
* ```js
|
||||
* const dgram = require('dgram');
|
||||
* const message = Buffer.from('Some bytes');
|
||||
* const client = dgram.createSocket('udp4');
|
||||
* client.connect(41234, 'localhost', (err) => {
|
||||
* client.send(message, (err) => {
|
||||
* client.close();
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
* @since v0.1.99
|
||||
* @param msg Message to be sent.
|
||||
* @param offset Offset in the buffer where the message starts.
|
||||
* @param length Number of bytes in the message.
|
||||
* @param port Destination port.
|
||||
* @param address Destination host name or IP address.
|
||||
* @param callback Called when the message has been sent.
|
||||
*/
|
||||
send(msg: string | Uint8Array | ReadonlyArray<any>, port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
send(msg: string | Uint8Array | ReadonlyArray<any>, port?: number, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
send(msg: string | Uint8Array | ReadonlyArray<any>, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
send(msg: string | Uint8Array, offset: number, length: number, port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
send(msg: string | Uint8Array, offset: number, length: number, port?: number, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
send(msg: string | Uint8Array, offset: number, length: number, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
/**
|
||||
* Sets or clears the `SO_BROADCAST` socket option. When set to `true`, UDP
|
||||
* packets may be sent to a local interface's broadcast address.
|
||||
*
|
||||
* This method throws `EBADF` if called on an unbound socket.
|
||||
* @since v0.6.9
|
||||
*/
|
||||
setBroadcast(flag: boolean): void;
|
||||
/**
|
||||
* _All references to scope in this section are referring to[IPv6 Zone Indices](https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses), which are defined by [RFC
|
||||
* 4007](https://tools.ietf.org/html/rfc4007). In string form, an IP_
|
||||
* _with a scope index is written as `'IP%scope'` where scope is an interface name_
|
||||
* _or interface number._
|
||||
*
|
||||
* Sets the default outgoing multicast interface of the socket to a chosen
|
||||
* interface or back to system interface selection. The `multicastInterface` must
|
||||
* be a valid string representation of an IP from the socket's family.
|
||||
*
|
||||
* For IPv4 sockets, this should be the IP configured for the desired physical
|
||||
* interface. All packets sent to multicast on the socket will be sent on the
|
||||
* interface determined by the most recent successful use of this call.
|
||||
*
|
||||
* For IPv6 sockets, `multicastInterface` should include a scope to indicate the
|
||||
* interface as in the examples that follow. In IPv6, individual `send` calls can
|
||||
* also use explicit scope in addresses, so only packets sent to a multicast
|
||||
* address without specifying an explicit scope are affected by the most recent
|
||||
* successful use of this call.
|
||||
*
|
||||
* This method throws `EBADF` if called on an unbound socket.
|
||||
*
|
||||
* #### Example: IPv6 outgoing multicast interface
|
||||
*
|
||||
* On most systems, where scope format uses the interface name:
|
||||
*
|
||||
* ```js
|
||||
* const socket = dgram.createSocket('udp6');
|
||||
*
|
||||
* socket.bind(1234, () => {
|
||||
* socket.setMulticastInterface('::%eth1');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* On Windows, where scope format uses an interface number:
|
||||
*
|
||||
* ```js
|
||||
* const socket = dgram.createSocket('udp6');
|
||||
*
|
||||
* socket.bind(1234, () => {
|
||||
* socket.setMulticastInterface('::%2');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* #### Example: IPv4 outgoing multicast interface
|
||||
*
|
||||
* All systems use an IP of the host on the desired physical interface:
|
||||
*
|
||||
* ```js
|
||||
* const socket = dgram.createSocket('udp4');
|
||||
*
|
||||
* socket.bind(1234, () => {
|
||||
* socket.setMulticastInterface('10.0.0.2');
|
||||
* });
|
||||
* ```
|
||||
* @since v8.6.0
|
||||
*/
|
||||
setMulticastInterface(multicastInterface: string): void;
|
||||
/**
|
||||
* Sets or clears the `IP_MULTICAST_LOOP` socket option. When set to `true`,
|
||||
* multicast packets will also be received on the local interface.
|
||||
*
|
||||
* This method throws `EBADF` if called on an unbound socket.
|
||||
* @since v0.3.8
|
||||
*/
|
||||
setMulticastLoopback(flag: boolean): void;
|
||||
/**
|
||||
* Sets the `IP_MULTICAST_TTL` socket option. While TTL generally stands for
|
||||
* "Time to Live", in this context it specifies the number of IP hops that a
|
||||
* packet is allowed to travel through, specifically for multicast traffic. Each
|
||||
* router or gateway that forwards a packet decrements the TTL. If the TTL is
|
||||
* decremented to 0 by a router, it will not be forwarded.
|
||||
*
|
||||
* The `ttl` argument may be between 0 and 255\. The default on most systems is `1`.
|
||||
*
|
||||
* This method throws `EBADF` if called on an unbound socket.
|
||||
* @since v0.3.8
|
||||
*/
|
||||
setMulticastTTL(ttl: number): void;
|
||||
/**
|
||||
* Sets the `SO_RCVBUF` socket option. Sets the maximum socket receive buffer
|
||||
* in bytes.
|
||||
*
|
||||
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
||||
* @since v8.7.0
|
||||
*/
|
||||
setRecvBufferSize(size: number): void;
|
||||
/**
|
||||
* Sets the `SO_SNDBUF` socket option. Sets the maximum socket send buffer
|
||||
* in bytes.
|
||||
*
|
||||
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
||||
* @since v8.7.0
|
||||
*/
|
||||
setSendBufferSize(size: number): void;
|
||||
/**
|
||||
* Sets the `IP_TTL` socket option. While TTL generally stands for "Time to Live",
|
||||
* in this context it specifies the number of IP hops that a packet is allowed to
|
||||
* travel through. Each router or gateway that forwards a packet decrements the
|
||||
* TTL. If the TTL is decremented to 0 by a router, it will not be forwarded.
|
||||
* Changing TTL values is typically done for network probes or when multicasting.
|
||||
*
|
||||
* The `ttl` argument may be between between 1 and 255\. The default on most systems
|
||||
* is 64.
|
||||
*
|
||||
* This method throws `EBADF` if called on an unbound socket.
|
||||
* @since v0.1.101
|
||||
*/
|
||||
setTTL(ttl: number): void;
|
||||
/**
|
||||
* By default, binding a socket will cause it to block the Node.js process from
|
||||
* exiting as long as the socket is open. The `socket.unref()` method can be used
|
||||
* to exclude the socket from the reference counting that keeps the Node.js
|
||||
* process active, allowing the process to exit even if the socket is still
|
||||
* listening.
|
||||
*
|
||||
* Calling `socket.unref()` multiple times will have no addition effect.
|
||||
*
|
||||
* The `socket.unref()` method returns a reference to the socket so calls can be
|
||||
* chained.
|
||||
* @since v0.9.1
|
||||
*/
|
||||
unref(): this;
|
||||
|
||||
/**
|
||||
* Tells the kernel to join a source-specific multicast channel at the given`sourceAddress` and `groupAddress`, using the `multicastInterface` with the`IP_ADD_SOURCE_MEMBERSHIP` socket
|
||||
* option. If the `multicastInterface` argument
|
||||
* is not specified, the operating system will choose one interface and will add
|
||||
* membership to it. To add membership to every available interface, call`socket.addSourceSpecificMembership()` multiple times, once per interface.
|
||||
*
|
||||
* When called on an unbound socket, this method will implicitly bind to a random
|
||||
* port, listening on all interfaces.
|
||||
* @since v13.1.0, v12.16.0
|
||||
*/
|
||||
addSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
|
||||
/**
|
||||
* Instructs the kernel to leave a source-specific multicast channel at the given`sourceAddress` and `groupAddress` using the `IP_DROP_SOURCE_MEMBERSHIP`socket option. This method is
|
||||
* automatically called by the kernel when the
|
||||
* socket is closed or the process terminates, so most apps will never have
|
||||
* reason to call this.
|
||||
*
|
||||
* If `multicastInterface` is not specified, the operating system will attempt to
|
||||
* drop membership on all valid interfaces.
|
||||
* @since v13.1.0, v12.16.0
|
||||
*/
|
||||
dropSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. close
|
||||
|
@ -74,45 +494,43 @@ declare module "dgram" {
|
|||
* 5. message
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: "close", listener: () => void): this;
|
||||
addListener(event: "connect", listener: () => void): this;
|
||||
addListener(event: "error", listener: (err: Error) => void): this;
|
||||
addListener(event: "listening", listener: () => void): this;
|
||||
addListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
|
||||
addListener(event: 'close', listener: () => void): this;
|
||||
addListener(event: 'connect', listener: () => void): this;
|
||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
||||
addListener(event: 'listening', listener: () => void): this;
|
||||
addListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: "close"): boolean;
|
||||
emit(event: "connect"): boolean;
|
||||
emit(event: "error", err: Error): boolean;
|
||||
emit(event: "listening"): boolean;
|
||||
emit(event: "message", msg: Buffer, rinfo: RemoteInfo): boolean;
|
||||
|
||||
emit(event: 'close'): boolean;
|
||||
emit(event: 'connect'): boolean;
|
||||
emit(event: 'error', err: Error): boolean;
|
||||
emit(event: 'listening'): boolean;
|
||||
emit(event: 'message', msg: Buffer, rinfo: RemoteInfo): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: "close", listener: () => void): this;
|
||||
on(event: "connect", listener: () => void): this;
|
||||
on(event: "error", listener: (err: Error) => void): this;
|
||||
on(event: "listening", listener: () => void): this;
|
||||
on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
|
||||
on(event: 'close', listener: () => void): this;
|
||||
on(event: 'connect', listener: () => void): this;
|
||||
on(event: 'error', listener: (err: Error) => void): this;
|
||||
on(event: 'listening', listener: () => void): this;
|
||||
on(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: "close", listener: () => void): this;
|
||||
once(event: "connect", listener: () => void): this;
|
||||
once(event: "error", listener: (err: Error) => void): this;
|
||||
once(event: "listening", listener: () => void): this;
|
||||
once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
|
||||
once(event: 'close', listener: () => void): this;
|
||||
once(event: 'connect', listener: () => void): this;
|
||||
once(event: 'error', listener: (err: Error) => void): this;
|
||||
once(event: 'listening', listener: () => void): this;
|
||||
once(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
prependListener(event: "connect", listener: () => void): this;
|
||||
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependListener(event: "listening", listener: () => void): this;
|
||||
prependListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
|
||||
prependListener(event: 'close', listener: () => void): this;
|
||||
prependListener(event: 'connect', listener: () => void): this;
|
||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependListener(event: 'listening', listener: () => void): this;
|
||||
prependListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
prependOnceListener(event: "connect", listener: () => void): this;
|
||||
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: "listening", listener: () => void): this;
|
||||
prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
prependOnceListener(event: 'close', listener: () => void): this;
|
||||
prependOnceListener(event: 'connect', listener: () => void): this;
|
||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: 'listening', listener: () => void): this;
|
||||
prependOnceListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
}
|
||||
}
|
||||
declare module 'node:dgram' {
|
||||
export * from 'dgram';
|
||||
}
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
/**
|
||||
* The `diagnostics_channel` module provides an API to create named channels
|
||||
* to report arbitrary message data for diagnostics purposes.
|
||||
*
|
||||
* It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const diagnostics_channel = require('diagnostics_channel');
|
||||
* ```
|
||||
*
|
||||
* It is intended that a module writer wanting to report diagnostics messages
|
||||
* will create one or many top-level channels to report messages through.
|
||||
* Channels may also be acquired at runtime but it is not encouraged
|
||||
* due to the additional overhead of doing so. Channels may be exported for
|
||||
* convenience, but as long as the name is known it can be acquired anywhere.
|
||||
*
|
||||
* If you intend for your module to produce diagnostics data for others to
|
||||
* consume it is recommended that you include documentation of what named
|
||||
* channels are used along with the shape of the message data. Channel names
|
||||
* should generally include the module name to avoid collisions with data from
|
||||
* other modules.
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/diagnostics_channel.js)
|
||||
*/
|
||||
declare module 'diagnostics_channel' {
|
||||
/**
|
||||
* Check if there are active subscribers to the named channel. This is helpful if
|
||||
* the message you want to send might be expensive to prepare.
|
||||
*
|
||||
* This API is optional but helpful when trying to publish messages from very
|
||||
* performance-sensitive code.
|
||||
*
|
||||
* ```js
|
||||
* const diagnostics_channel = require('diagnostics_channel');
|
||||
*
|
||||
* if (diagnostics_channel.hasSubscribers('my-channel')) {
|
||||
* // There are subscribers, prepare and publish message
|
||||
* }
|
||||
* ```
|
||||
* @param name The channel name
|
||||
* @return If there are active subscribers
|
||||
*/
|
||||
function hasSubscribers(name: string): boolean;
|
||||
/**
|
||||
* This is the primary entry-point for anyone wanting to interact with a named
|
||||
* channel. It produces a channel object which is optimized to reduce overhead at
|
||||
* publish time as much as possible.
|
||||
*
|
||||
* ```js
|
||||
* const diagnostics_channel = require('diagnostics_channel');
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
* ```
|
||||
* @param name The channel name
|
||||
* @return The named channel object
|
||||
*/
|
||||
function channel(name: string): Channel;
|
||||
type ChannelListener = (name: string, message: unknown) => void;
|
||||
/**
|
||||
* The class `Channel` represents an individual named channel within the data
|
||||
* pipeline. It is use to track subscribers and to publish messages when there
|
||||
* are subscribers present. It exists as a separate object to avoid channel
|
||||
* lookups at publish time, enabling very fast publish speeds and allowing
|
||||
* for heavy use while incurring very minimal cost. Channels are created with {@link channel}, constructing a channel directly
|
||||
* with `new Channel(name)` is not supported.
|
||||
*/
|
||||
class Channel {
|
||||
readonly name: string;
|
||||
readonly hashSubscribers: boolean;
|
||||
private constructor(name: string);
|
||||
/**
|
||||
* Register a message handler to subscribe to this channel. This message handler
|
||||
* will be run synchronously whenever a message is published to the channel. Any
|
||||
* errors thrown in the message handler will trigger an `'uncaughtException'`.
|
||||
*
|
||||
* ```js
|
||||
* const diagnostics_channel = require('diagnostics_channel');
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
*
|
||||
* channel.subscribe((message, name) => {
|
||||
* // Received data
|
||||
* });
|
||||
* ```
|
||||
* @param onMessage The handler to receive channel messages
|
||||
*/
|
||||
subscribe(listener: ChannelListener): void;
|
||||
/**
|
||||
* Remove a message handler previously registered to this channel with `channel.subscribe(onMessage)`.
|
||||
*
|
||||
* ```js
|
||||
* const diagnostics_channel = require('diagnostics_channel');
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
*
|
||||
* function onMessage(message, name) {
|
||||
* // Received data
|
||||
* }
|
||||
*
|
||||
* channel.subscribe(onMessage);
|
||||
*
|
||||
* channel.unsubscribe(onMessage);
|
||||
* ```
|
||||
* @param onMessage The previous subscribed handler to remove
|
||||
*/
|
||||
unsubscribe(listener: ChannelListener): void;
|
||||
}
|
||||
}
|
||||
declare module 'node:diagnostics_channel' {
|
||||
export * from 'diagnostics_channel';
|
||||
}
|
|
@ -1,81 +1,191 @@
|
|||
declare module "dns" {
|
||||
/**
|
||||
* The `dns` module enables name resolution. For example, use it to look up IP
|
||||
* addresses of host names.
|
||||
*
|
||||
* Although named for the [Domain Name System (DNS)](https://en.wikipedia.org/wiki/Domain_Name_System), it does not always use the
|
||||
* DNS protocol for lookups. {@link lookup} uses the operating system
|
||||
* facilities to perform name resolution. It may not need to perform any network
|
||||
* communication. To perform name resolution the way other applications on the same
|
||||
* system do, use {@link lookup}.
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('dns');
|
||||
*
|
||||
* dns.lookup('example.org', (err, address, family) => {
|
||||
* console.log('address: %j family: IPv%s', address, family);
|
||||
* });
|
||||
* // address: "93.184.216.34" family: IPv4
|
||||
* ```
|
||||
*
|
||||
* All other functions in the `dns` module connect to an actual DNS server to
|
||||
* perform name resolution. They will always use the network to perform DNS
|
||||
* queries. These functions do not use the same set of configuration files used by {@link lookup} (e.g. `/etc/hosts`). Use these functions to always perform
|
||||
* DNS queries, bypassing other name-resolution facilities.
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('dns');
|
||||
*
|
||||
* dns.resolve4('archive.org', (err, addresses) => {
|
||||
* if (err) throw err;
|
||||
*
|
||||
* console.log(`addresses: ${JSON.stringify(addresses)}`);
|
||||
*
|
||||
* addresses.forEach((a) => {
|
||||
* dns.reverse(a, (err, hostnames) => {
|
||||
* if (err) {
|
||||
* throw err;
|
||||
* }
|
||||
* console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`);
|
||||
* });
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* See the `Implementation considerations section` for more information.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/dns.js)
|
||||
*/
|
||||
declare module 'dns' {
|
||||
import * as dnsPromises from 'node:dns/promises';
|
||||
// Supported getaddrinfo flags.
|
||||
const ADDRCONFIG: number;
|
||||
const V4MAPPED: number;
|
||||
|
||||
interface LookupOptions {
|
||||
family?: number;
|
||||
hints?: number;
|
||||
all?: boolean;
|
||||
verbatim?: boolean;
|
||||
export const ADDRCONFIG: number;
|
||||
export const V4MAPPED: number;
|
||||
/**
|
||||
* If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
|
||||
* well as IPv4 mapped IPv6 addresses.
|
||||
*/
|
||||
export const ALL: number;
|
||||
export interface LookupOptions {
|
||||
family?: number | undefined;
|
||||
hints?: number | undefined;
|
||||
all?: boolean | undefined;
|
||||
verbatim?: boolean | undefined;
|
||||
}
|
||||
|
||||
interface LookupOneOptions extends LookupOptions {
|
||||
all?: false;
|
||||
export interface LookupOneOptions extends LookupOptions {
|
||||
all?: false | undefined;
|
||||
}
|
||||
|
||||
interface LookupAllOptions extends LookupOptions {
|
||||
export interface LookupAllOptions extends LookupOptions {
|
||||
all: true;
|
||||
}
|
||||
|
||||
interface LookupAddress {
|
||||
export interface LookupAddress {
|
||||
address: string;
|
||||
family: number;
|
||||
}
|
||||
|
||||
function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
||||
function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
||||
function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void): void;
|
||||
function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void): void;
|
||||
function lookup(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
||||
|
||||
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
||||
namespace lookup {
|
||||
/**
|
||||
* Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
|
||||
* AAAA (IPv6) record. All `option` properties are optional. If `options` is an
|
||||
* integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
|
||||
* and IPv6 addresses are both returned if found.
|
||||
*
|
||||
* With the `all` option set to `true`, the arguments for `callback` change to`(err, addresses)`, with `addresses` being an array of objects with the
|
||||
* properties `address` and `family`.
|
||||
*
|
||||
* On error, `err` is an `Error` object, where `err.code` is the error code.
|
||||
* Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
|
||||
* the host name does not exist but also when the lookup fails in other ways
|
||||
* such as no available file descriptors.
|
||||
*
|
||||
* `dns.lookup()` does not necessarily have anything to do with the DNS protocol.
|
||||
* The implementation uses an operating system facility that can associate names
|
||||
* with addresses, and vice versa. This implementation can have subtle but
|
||||
* important consequences on the behavior of any Node.js program. Please take some
|
||||
* time to consult the `Implementation considerations section` before using`dns.lookup()`.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('dns');
|
||||
* const options = {
|
||||
* family: 6,
|
||||
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
||||
* };
|
||||
* dns.lookup('example.com', options, (err, address, family) =>
|
||||
* console.log('address: %j family: IPv%s', address, family));
|
||||
* // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
|
||||
*
|
||||
* // When options.all is true, the result will be an Array.
|
||||
* options.all = true;
|
||||
* dns.lookup('example.com', options, (err, addresses) =>
|
||||
* console.log('addresses: %j', addresses));
|
||||
* // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
|
||||
* ```
|
||||
*
|
||||
* If this method is invoked as its `util.promisify()` ed version, and `all`is not set to `true`, it returns a `Promise` for an `Object` with `address` and`family` properties.
|
||||
* @since v0.1.90
|
||||
*/
|
||||
export function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
||||
export function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
||||
export function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void): void;
|
||||
export function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void): void;
|
||||
export function lookup(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
||||
export namespace lookup {
|
||||
function __promisify__(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
||||
function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<LookupAddress>;
|
||||
function __promisify__(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
||||
}
|
||||
|
||||
function lookupService(address: string, port: number, callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void): void;
|
||||
|
||||
namespace lookupService {
|
||||
function __promisify__(address: string, port: number): Promise<{ hostname: string, service: string }>;
|
||||
/**
|
||||
* Resolves the given `address` and `port` into a host name and service using
|
||||
* the operating system's underlying `getnameinfo` implementation.
|
||||
*
|
||||
* If `address` is not a valid IP address, a `TypeError` will be thrown.
|
||||
* The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
|
||||
*
|
||||
* On an error, `err` is an `Error` object, where `err.code` is the error code.
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('dns');
|
||||
* dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
|
||||
* console.log(hostname, service);
|
||||
* // Prints: localhost ssh
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* If this method is invoked as its `util.promisify()` ed version, it returns a`Promise` for an `Object` with `hostname` and `service` properties.
|
||||
* @since v0.11.14
|
||||
*/
|
||||
export function lookupService(address: string, port: number, callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void): void;
|
||||
export namespace lookupService {
|
||||
function __promisify__(
|
||||
address: string,
|
||||
port: number
|
||||
): Promise<{
|
||||
hostname: string;
|
||||
service: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface ResolveOptions {
|
||||
export interface ResolveOptions {
|
||||
ttl: boolean;
|
||||
}
|
||||
|
||||
interface ResolveWithTtlOptions extends ResolveOptions {
|
||||
export interface ResolveWithTtlOptions extends ResolveOptions {
|
||||
ttl: true;
|
||||
}
|
||||
|
||||
interface RecordWithTtl {
|
||||
export interface RecordWithTtl {
|
||||
address: string;
|
||||
ttl: number;
|
||||
}
|
||||
|
||||
/** @deprecated Use AnyARecord or AnyAaaaRecord instead. */
|
||||
type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
|
||||
|
||||
interface AnyARecord extends RecordWithTtl {
|
||||
type: "A";
|
||||
/** @deprecated Use `AnyARecord` or `AnyAaaaRecord` instead. */
|
||||
export type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
|
||||
export interface AnyARecord extends RecordWithTtl {
|
||||
type: 'A';
|
||||
}
|
||||
|
||||
interface AnyAaaaRecord extends RecordWithTtl {
|
||||
type: "AAAA";
|
||||
export interface AnyAaaaRecord extends RecordWithTtl {
|
||||
type: 'AAAA';
|
||||
}
|
||||
|
||||
interface MxRecord {
|
||||
export interface CaaRecord {
|
||||
critial: number;
|
||||
issue?: string | undefined;
|
||||
issuewild?: string | undefined;
|
||||
iodef?: string | undefined;
|
||||
contactemail?: string | undefined;
|
||||
contactphone?: string | undefined;
|
||||
}
|
||||
export interface MxRecord {
|
||||
priority: number;
|
||||
exchange: string;
|
||||
}
|
||||
|
||||
interface AnyMxRecord extends MxRecord {
|
||||
type: "MX";
|
||||
export interface AnyMxRecord extends MxRecord {
|
||||
type: 'MX';
|
||||
}
|
||||
|
||||
interface NaptrRecord {
|
||||
export interface NaptrRecord {
|
||||
flags: string;
|
||||
service: string;
|
||||
regexp: string;
|
||||
|
@ -83,12 +193,10 @@ declare module "dns" {
|
|||
order: number;
|
||||
preference: number;
|
||||
}
|
||||
|
||||
interface AnyNaptrRecord extends NaptrRecord {
|
||||
type: "NAPTR";
|
||||
export interface AnyNaptrRecord extends NaptrRecord {
|
||||
type: 'NAPTR';
|
||||
}
|
||||
|
||||
interface SoaRecord {
|
||||
export interface SoaRecord {
|
||||
nsname: string;
|
||||
hostmaster: string;
|
||||
serial: number;
|
||||
|
@ -97,183 +205,402 @@ declare module "dns" {
|
|||
expire: number;
|
||||
minttl: number;
|
||||
}
|
||||
|
||||
interface AnySoaRecord extends SoaRecord {
|
||||
type: "SOA";
|
||||
export interface AnySoaRecord extends SoaRecord {
|
||||
type: 'SOA';
|
||||
}
|
||||
|
||||
interface SrvRecord {
|
||||
export interface SrvRecord {
|
||||
priority: number;
|
||||
weight: number;
|
||||
port: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface AnySrvRecord extends SrvRecord {
|
||||
type: "SRV";
|
||||
export interface AnySrvRecord extends SrvRecord {
|
||||
type: 'SRV';
|
||||
}
|
||||
|
||||
interface AnyTxtRecord {
|
||||
type: "TXT";
|
||||
export interface AnyTxtRecord {
|
||||
type: 'TXT';
|
||||
entries: string[];
|
||||
}
|
||||
|
||||
interface AnyNsRecord {
|
||||
type: "NS";
|
||||
export interface AnyNsRecord {
|
||||
type: 'NS';
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface AnyPtrRecord {
|
||||
type: "PTR";
|
||||
export interface AnyPtrRecord {
|
||||
type: 'PTR';
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface AnyCnameRecord {
|
||||
type: "CNAME";
|
||||
export interface AnyCnameRecord {
|
||||
type: 'CNAME';
|
||||
value: string;
|
||||
}
|
||||
|
||||
type AnyRecord = AnyARecord |
|
||||
AnyAaaaRecord |
|
||||
AnyCnameRecord |
|
||||
AnyMxRecord |
|
||||
AnyNaptrRecord |
|
||||
AnyNsRecord |
|
||||
AnyPtrRecord |
|
||||
AnySoaRecord |
|
||||
AnySrvRecord |
|
||||
AnyTxtRecord;
|
||||
|
||||
function resolve(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
function resolve(hostname: string, rrtype: "A", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
function resolve(hostname: string, rrtype: "AAAA", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
function resolve(hostname: string, rrtype: "ANY", callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
|
||||
function resolve(hostname: string, rrtype: "CNAME", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
function resolve(hostname: string, rrtype: "MX", callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
|
||||
function resolve(hostname: string, rrtype: "NAPTR", callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
|
||||
function resolve(hostname: string, rrtype: "NS", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
function resolve(hostname: string, rrtype: "PTR", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
function resolve(hostname: string, rrtype: "SOA", callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void): void;
|
||||
function resolve(hostname: string, rrtype: "SRV", callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
|
||||
function resolve(hostname: string, rrtype: "TXT", callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
||||
function resolve(
|
||||
export type AnyRecord = AnyARecord | AnyAaaaRecord | AnyCnameRecord | AnyMxRecord | AnyNaptrRecord | AnyNsRecord | AnyPtrRecord | AnySoaRecord | AnySrvRecord | AnyTxtRecord;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
|
||||
* of the resource records. The `callback` function has arguments`(err, records)`. When successful, `records` will be an array of resource
|
||||
* records. The type and structure of individual results varies based on `rrtype`:
|
||||
*
|
||||
* <omitted>
|
||||
*
|
||||
* On error, `err` is an `Error` object, where `err.code` is one of the `DNS error codes`.
|
||||
* @since v0.1.27
|
||||
* @param hostname Host name to resolve.
|
||||
* @param rrtype Resource record type.
|
||||
*/
|
||||
export function resolve(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: 'A', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: 'AAAA', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: 'ANY', callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: 'CNAME', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: 'MX', callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: 'NAPTR', callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: 'NS', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: 'PTR', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: 'SOA', callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void): void;
|
||||
export function resolve(hostname: string, rrtype: 'SRV', callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
|
||||
export function resolve(hostname: string, rrtype: 'TXT', callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]) => void,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]) => void
|
||||
): void;
|
||||
|
||||
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
||||
namespace resolve {
|
||||
function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
|
||||
function __promisify__(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
||||
function __promisify__(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
||||
export namespace resolve {
|
||||
function __promisify__(hostname: string, rrtype?: 'A' | 'AAAA' | 'CNAME' | 'NS' | 'PTR'): Promise<string[]>;
|
||||
function __promisify__(hostname: string, rrtype: 'ANY'): Promise<AnyRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: 'MX'): Promise<MxRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: 'NAPTR'): Promise<NaptrRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: 'SOA'): Promise<SoaRecord>;
|
||||
function __promisify__(hostname: string, rrtype: 'SRV'): Promise<SrvRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: 'TXT'): Promise<string[][]>;
|
||||
function __promisify__(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
||||
}
|
||||
|
||||
function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
||||
function resolve4(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
||||
|
||||
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
||||
namespace resolve4 {
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
||||
* will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
||||
* @since v0.1.16
|
||||
* @param hostname Host name to resolve.
|
||||
*/
|
||||
export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
export function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
||||
export function resolve4(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
||||
export namespace resolve4 {
|
||||
function __promisify__(hostname: string): Promise<string[]>;
|
||||
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||
}
|
||||
|
||||
function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
||||
function resolve6(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
||||
|
||||
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
||||
namespace resolve6 {
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
||||
* will contain an array of IPv6 addresses.
|
||||
* @since v0.1.16
|
||||
* @param hostname Host name to resolve.
|
||||
*/
|
||||
export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
export function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
||||
export function resolve6(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
||||
export namespace resolve6 {
|
||||
function __promisify__(hostname: string): Promise<string[]>;
|
||||
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||
}
|
||||
|
||||
function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
namespace resolveCname {
|
||||
/**
|
||||
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The`addresses` argument passed to the `callback` function
|
||||
* will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`).
|
||||
* @since v0.3.2
|
||||
*/
|
||||
export function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
export namespace resolveCname {
|
||||
function __promisify__(hostname: string): Promise<string[]>;
|
||||
}
|
||||
|
||||
function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
|
||||
namespace resolveMx {
|
||||
/**
|
||||
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. The`addresses` argument passed to the `callback` function
|
||||
* will contain an array of certification authority authorization records
|
||||
* available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`).
|
||||
* @since v15.0.0
|
||||
*/
|
||||
export function resolveCaa(hostname: string, callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void): void;
|
||||
export namespace resolveCaa {
|
||||
function __promisify__(hostname: string): Promise<CaaRecord[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* contain an array of objects containing both a `priority` and `exchange`property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
|
||||
* @since v0.1.27
|
||||
*/
|
||||
export function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
|
||||
export namespace resolveMx {
|
||||
function __promisify__(hostname: string): Promise<MxRecord[]>;
|
||||
}
|
||||
|
||||
function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
|
||||
namespace resolveNaptr {
|
||||
/**
|
||||
* Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of
|
||||
* objects with the following properties:
|
||||
*
|
||||
* * `flags`
|
||||
* * `service`
|
||||
* * `regexp`
|
||||
* * `replacement`
|
||||
* * `order`
|
||||
* * `preference`
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* flags: 's',
|
||||
* service: 'SIP+D2U',
|
||||
* regexp: '',
|
||||
* replacement: '_sip._udp.example.com',
|
||||
* order: 30,
|
||||
* preference: 100
|
||||
* }
|
||||
* ```
|
||||
* @since v0.9.12
|
||||
*/
|
||||
export function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
|
||||
export namespace resolveNaptr {
|
||||
function __promisify__(hostname: string): Promise<NaptrRecord[]>;
|
||||
}
|
||||
|
||||
function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
namespace resolveNs {
|
||||
/**
|
||||
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`).
|
||||
* @since v0.1.90
|
||||
*/
|
||||
export function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
export namespace resolveNs {
|
||||
function __promisify__(hostname: string): Promise<string[]>;
|
||||
}
|
||||
|
||||
function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
namespace resolvePtr {
|
||||
/**
|
||||
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* be an array of strings containing the reply records.
|
||||
* @since v6.0.0
|
||||
*/
|
||||
export function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||
export namespace resolvePtr {
|
||||
function __promisify__(hostname: string): Promise<string[]>;
|
||||
}
|
||||
|
||||
function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
|
||||
namespace resolveSoa {
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
||||
* the `hostname`. The `address` argument passed to the `callback` function will
|
||||
* be an object with the following properties:
|
||||
*
|
||||
* * `nsname`
|
||||
* * `hostmaster`
|
||||
* * `serial`
|
||||
* * `refresh`
|
||||
* * `retry`
|
||||
* * `expire`
|
||||
* * `minttl`
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* nsname: 'ns.example.com',
|
||||
* hostmaster: 'root.example.com',
|
||||
* serial: 2013101809,
|
||||
* refresh: 10000,
|
||||
* retry: 2400,
|
||||
* expire: 604800,
|
||||
* minttl: 3600
|
||||
* }
|
||||
* ```
|
||||
* @since v0.11.10
|
||||
*/
|
||||
export function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
|
||||
export namespace resolveSoa {
|
||||
function __promisify__(hostname: string): Promise<SoaRecord>;
|
||||
}
|
||||
|
||||
function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
|
||||
namespace resolveSrv {
|
||||
/**
|
||||
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* be an array of objects with the following properties:
|
||||
*
|
||||
* * `priority`
|
||||
* * `weight`
|
||||
* * `port`
|
||||
* * `name`
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* priority: 10,
|
||||
* weight: 5,
|
||||
* port: 21223,
|
||||
* name: 'service.example.com'
|
||||
* }
|
||||
* ```
|
||||
* @since v0.1.27
|
||||
*/
|
||||
export function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
|
||||
export namespace resolveSrv {
|
||||
function __promisify__(hostname: string): Promise<SrvRecord[]>;
|
||||
}
|
||||
|
||||
function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
||||
namespace resolveTxt {
|
||||
/**
|
||||
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. The `records` argument passed to the `callback` function is a
|
||||
* two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
||||
* one record. Depending on the use case, these could be either joined together or
|
||||
* treated separately.
|
||||
* @since v0.1.27
|
||||
*/
|
||||
export function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
||||
export namespace resolveTxt {
|
||||
function __promisify__(hostname: string): Promise<string[][]>;
|
||||
}
|
||||
|
||||
function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
|
||||
namespace resolveAny {
|
||||
/**
|
||||
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
|
||||
* The `ret` argument passed to the `callback` function will be an array containing
|
||||
* various types of records. Each object has a property `type` that indicates the
|
||||
* type of the current record. And depending on the `type`, additional properties
|
||||
* will be present on the object:
|
||||
*
|
||||
* <omitted>
|
||||
*
|
||||
* Here is an example of the `ret` object passed to the callback:
|
||||
*
|
||||
* ```js
|
||||
* [ { type: 'A', address: '127.0.0.1', ttl: 299 },
|
||||
* { type: 'CNAME', value: 'example.com' },
|
||||
* { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
|
||||
* { type: 'NS', value: 'ns1.example.com' },
|
||||
* { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
|
||||
* { type: 'SOA',
|
||||
* nsname: 'ns1.example.com',
|
||||
* hostmaster: 'admin.example.com',
|
||||
* serial: 156696742,
|
||||
* refresh: 900,
|
||||
* retry: 900,
|
||||
* expire: 1800,
|
||||
* minttl: 60 } ]
|
||||
* ```
|
||||
*
|
||||
* DNS server operators may choose not to respond to `ANY`queries. It may be better to call individual methods like {@link resolve4},{@link resolveMx}, and so on. For more details, see [RFC
|
||||
* 8482](https://tools.ietf.org/html/rfc8482).
|
||||
*/
|
||||
export function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
|
||||
export namespace resolveAny {
|
||||
function __promisify__(hostname: string): Promise<AnyRecord[]>;
|
||||
}
|
||||
|
||||
function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void): void;
|
||||
function setServers(servers: ReadonlyArray<string>): void;
|
||||
function getServers(): string[];
|
||||
|
||||
/**
|
||||
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
||||
* array of host names.
|
||||
*
|
||||
* On error, `err` is an `Error` object, where `err.code` is
|
||||
* one of the `DNS error codes`.
|
||||
* @since v0.1.16
|
||||
*/
|
||||
export function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void): void;
|
||||
/**
|
||||
* Sets the IP address and port of servers to be used when performing DNS
|
||||
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
|
||||
* addresses. If the port is the IANA default DNS port (53) it can be omitted.
|
||||
*
|
||||
* ```js
|
||||
* dns.setServers([
|
||||
* '4.4.4.4',
|
||||
* '[2001:4860:4860::8888]',
|
||||
* '4.4.4.4:1053',
|
||||
* '[2001:4860:4860::8888]:1053',
|
||||
* ]);
|
||||
* ```
|
||||
*
|
||||
* An error will be thrown if an invalid address is provided.
|
||||
*
|
||||
* The `dns.setServers()` method must not be called while a DNS query is in
|
||||
* progress.
|
||||
*
|
||||
* The {@link setServers} method affects only {@link resolve},`dns.resolve*()` and {@link reverse} (and specifically _not_ {@link lookup}).
|
||||
*
|
||||
* This method works much like[resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
|
||||
* That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
|
||||
* subsequent servers provided. Fallback DNS servers will only be used if the
|
||||
* earlier ones time out or result in some other error.
|
||||
* @since v0.11.3
|
||||
* @param servers array of `RFC 5952` formatted addresses
|
||||
*/
|
||||
export function setServers(servers: ReadonlyArray<string>): void;
|
||||
/**
|
||||
* Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
|
||||
* that are currently configured for DNS resolution. A string will include a port
|
||||
* section if a custom port is used.
|
||||
*
|
||||
* ```js
|
||||
* [
|
||||
* '4.4.4.4',
|
||||
* '2001:4860:4860::8888',
|
||||
* '4.4.4.4:1053',
|
||||
* '[2001:4860:4860::8888]:1053',
|
||||
* ]
|
||||
* ```
|
||||
* @since v0.11.3
|
||||
*/
|
||||
export function getServers(): string[];
|
||||
// Error codes
|
||||
const NODATA: string;
|
||||
const FORMERR: string;
|
||||
const SERVFAIL: string;
|
||||
const NOTFOUND: string;
|
||||
const NOTIMP: string;
|
||||
const REFUSED: string;
|
||||
const BADQUERY: string;
|
||||
const BADNAME: string;
|
||||
const BADFAMILY: string;
|
||||
const BADRESP: string;
|
||||
const CONNREFUSED: string;
|
||||
const TIMEOUT: string;
|
||||
const EOF: string;
|
||||
const FILE: string;
|
||||
const NOMEM: string;
|
||||
const DESTRUCTION: string;
|
||||
const BADSTR: string;
|
||||
const BADFLAGS: string;
|
||||
const NONAME: string;
|
||||
const BADHINTS: string;
|
||||
const NOTINITIALIZED: string;
|
||||
const LOADIPHLPAPI: string;
|
||||
const ADDRGETNETWORKPARAMS: string;
|
||||
const CANCELLED: string;
|
||||
|
||||
class Resolver {
|
||||
export const NODATA: string;
|
||||
export const FORMERR: string;
|
||||
export const SERVFAIL: string;
|
||||
export const NOTFOUND: string;
|
||||
export const NOTIMP: string;
|
||||
export const REFUSED: string;
|
||||
export const BADQUERY: string;
|
||||
export const BADNAME: string;
|
||||
export const BADFAMILY: string;
|
||||
export const BADRESP: string;
|
||||
export const CONNREFUSED: string;
|
||||
export const TIMEOUT: string;
|
||||
export const EOF: string;
|
||||
export const FILE: string;
|
||||
export const NOMEM: string;
|
||||
export const DESTRUCTION: string;
|
||||
export const BADSTR: string;
|
||||
export const BADFLAGS: string;
|
||||
export const NONAME: string;
|
||||
export const BADHINTS: string;
|
||||
export const NOTINITIALIZED: string;
|
||||
export const LOADIPHLPAPI: string;
|
||||
export const ADDRGETNETWORKPARAMS: string;
|
||||
export const CANCELLED: string;
|
||||
export interface ResolverOptions {
|
||||
timeout?: number | undefined;
|
||||
}
|
||||
/**
|
||||
* An independent resolver for DNS requests.
|
||||
*
|
||||
* Creating a new resolver uses the default server settings. Setting
|
||||
* the servers used for a resolver using `resolver.setServers()` does not affect
|
||||
* other resolvers:
|
||||
*
|
||||
* ```js
|
||||
* const { Resolver } = require('dns');
|
||||
* const resolver = new Resolver();
|
||||
* resolver.setServers(['4.4.4.4']);
|
||||
*
|
||||
* // This request will use the server at 4.4.4.4, independent of global settings.
|
||||
* resolver.resolve4('example.org', (err, addresses) => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* The following methods from the `dns` module are available:
|
||||
*
|
||||
* * `resolver.getServers()`
|
||||
* * `resolver.resolve()`
|
||||
* * `resolver.resolve4()`
|
||||
* * `resolver.resolve6()`
|
||||
* * `resolver.resolveAny()`
|
||||
* * `resolver.resolveCaa()`
|
||||
* * `resolver.resolveCname()`
|
||||
* * `resolver.resolveMx()`
|
||||
* * `resolver.resolveNaptr()`
|
||||
* * `resolver.resolveNs()`
|
||||
* * `resolver.resolvePtr()`
|
||||
* * `resolver.resolveSoa()`
|
||||
* * `resolver.resolveSrv()`
|
||||
* * `resolver.resolveTxt()`
|
||||
* * `resolver.reverse()`
|
||||
* * `resolver.setServers()`
|
||||
* @since v8.3.0
|
||||
*/
|
||||
export class Resolver {
|
||||
constructor(options?: ResolverOptions);
|
||||
/**
|
||||
* Cancel all outstanding DNS queries made by this resolver. The corresponding
|
||||
* callbacks will be called with an error with code `ECANCELLED`.
|
||||
* @since v8.3.0
|
||||
*/
|
||||
cancel(): void;
|
||||
getServers: typeof getServers;
|
||||
setServers: typeof setServers;
|
||||
resolve: typeof resolve;
|
||||
resolve4: typeof resolve4;
|
||||
resolve6: typeof resolve6;
|
||||
|
@ -287,80 +614,26 @@ declare module "dns" {
|
|||
resolveSrv: typeof resolveSrv;
|
||||
resolveTxt: typeof resolveTxt;
|
||||
reverse: typeof reverse;
|
||||
cancel(): void;
|
||||
}
|
||||
|
||||
namespace promises {
|
||||
function getServers(): string[];
|
||||
|
||||
function lookup(hostname: string, family: number): Promise<LookupAddress>;
|
||||
function lookup(hostname: string, options: LookupOneOptions): Promise<LookupAddress>;
|
||||
function lookup(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
||||
function lookup(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
||||
function lookup(hostname: string): Promise<LookupAddress>;
|
||||
|
||||
function lookupService(address: string, port: number): Promise<{ hostname: string, service: string }>;
|
||||
|
||||
function resolve(hostname: string): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: "A"): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: "AAAA"): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
||||
function resolve(hostname: string, rrtype: "CNAME"): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
||||
function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
||||
function resolve(hostname: string, rrtype: "NS"): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: "PTR"): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
||||
function resolve(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
|
||||
function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
||||
function resolve(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
||||
|
||||
function resolve4(hostname: string): Promise<string[]>;
|
||||
function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||
function resolve4(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||
|
||||
function resolve6(hostname: string): Promise<string[]>;
|
||||
function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||
function resolve6(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||
|
||||
function resolveAny(hostname: string): Promise<AnyRecord[]>;
|
||||
|
||||
function resolveCname(hostname: string): Promise<string[]>;
|
||||
|
||||
function resolveMx(hostname: string): Promise<MxRecord[]>;
|
||||
|
||||
function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
|
||||
|
||||
function resolveNs(hostname: string): Promise<string[]>;
|
||||
|
||||
function resolvePtr(hostname: string): Promise<string[]>;
|
||||
|
||||
function resolveSoa(hostname: string): Promise<SoaRecord>;
|
||||
|
||||
function resolveSrv(hostname: string): Promise<SrvRecord[]>;
|
||||
|
||||
function resolveTxt(hostname: string): Promise<string[][]>;
|
||||
|
||||
function reverse(ip: string): Promise<string[]>;
|
||||
|
||||
function setServers(servers: ReadonlyArray<string>): void;
|
||||
|
||||
class Resolver {
|
||||
getServers: typeof getServers;
|
||||
resolve: typeof resolve;
|
||||
resolve4: typeof resolve4;
|
||||
resolve6: typeof resolve6;
|
||||
resolveAny: typeof resolveAny;
|
||||
resolveCname: typeof resolveCname;
|
||||
resolveMx: typeof resolveMx;
|
||||
resolveNaptr: typeof resolveNaptr;
|
||||
resolveNs: typeof resolveNs;
|
||||
resolvePtr: typeof resolvePtr;
|
||||
resolveSoa: typeof resolveSoa;
|
||||
resolveSrv: typeof resolveSrv;
|
||||
resolveTxt: typeof resolveTxt;
|
||||
reverse: typeof reverse;
|
||||
setServers: typeof setServers;
|
||||
}
|
||||
/**
|
||||
* The resolver instance will send its requests from the specified IP address.
|
||||
* This allows programs to specify outbound interfaces when used on multi-homed
|
||||
* systems.
|
||||
*
|
||||
* If a v4 or v6 address is not specified, it is set to the default, and the
|
||||
* operating system will choose a local address automatically.
|
||||
*
|
||||
* The resolver will use the v4 local address when making requests to IPv4 DNS
|
||||
* servers, and the v6 local address when making requests to IPv6 DNS servers.
|
||||
* The `rrtype` of resolution requests has no impact on the local address used.
|
||||
* @since v15.1.0
|
||||
* @param ipv4 A string representation of an IPv4 address.
|
||||
* @param ipv6 A string representation of an IPv6 address.
|
||||
*/
|
||||
setLocalAddress(ipv4?: string, ipv6?: string): void;
|
||||
setServers: typeof setServers;
|
||||
}
|
||||
export { dnsPromises as promises };
|
||||
}
|
||||
declare module 'node:dns' {
|
||||
export * from 'dns';
|
||||
}
|
||||
|
|
|
@ -0,0 +1,357 @@
|
|||
/**
|
||||
* The `dns.promises` API provides an alternative set of asynchronous DNS methods
|
||||
* that return `Promise` objects rather than using callbacks. The API is accessible
|
||||
* via `require('dns').promises` or `require('dns/promises')`.
|
||||
* @since v10.6.0
|
||||
*/
|
||||
declare module 'dns/promises' {
|
||||
import {
|
||||
LookupAddress,
|
||||
LookupOneOptions,
|
||||
LookupAllOptions,
|
||||
LookupOptions,
|
||||
AnyRecord,
|
||||
CaaRecord,
|
||||
MxRecord,
|
||||
NaptrRecord,
|
||||
SoaRecord,
|
||||
SrvRecord,
|
||||
ResolveWithTtlOptions,
|
||||
RecordWithTtl,
|
||||
ResolveOptions,
|
||||
ResolverOptions,
|
||||
} from 'node:dns';
|
||||
/**
|
||||
* Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
|
||||
* that are currently configured for DNS resolution. A string will include a port
|
||||
* section if a custom port is used.
|
||||
*
|
||||
* ```js
|
||||
* [
|
||||
* '4.4.4.4',
|
||||
* '2001:4860:4860::8888',
|
||||
* '4.4.4.4:1053',
|
||||
* '[2001:4860:4860::8888]:1053',
|
||||
* ]
|
||||
* ```
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function getServers(): string[];
|
||||
/**
|
||||
* Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
|
||||
* AAAA (IPv6) record. All `option` properties are optional. If `options` is an
|
||||
* integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
|
||||
* and IPv6 addresses are both returned if found.
|
||||
*
|
||||
* With the `all` option set to `true`, the `Promise` is resolved with `addresses`being an array of objects with the properties `address` and `family`.
|
||||
*
|
||||
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
|
||||
* Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
|
||||
* the host name does not exist but also when the lookup fails in other ways
|
||||
* such as no available file descriptors.
|
||||
*
|
||||
* `dnsPromises.lookup()` does not necessarily have anything to do with the DNS
|
||||
* protocol. The implementation uses an operating system facility that can
|
||||
* associate names with addresses, and vice versa. This implementation can have
|
||||
* subtle but important consequences on the behavior of any Node.js program. Please
|
||||
* take some time to consult the `Implementation considerations section` before
|
||||
* using `dnsPromises.lookup()`.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('dns');
|
||||
* const dnsPromises = dns.promises;
|
||||
* const options = {
|
||||
* family: 6,
|
||||
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
||||
* };
|
||||
*
|
||||
* dnsPromises.lookup('example.com', options).then((result) => {
|
||||
* console.log('address: %j family: IPv%s', result.address, result.family);
|
||||
* // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
|
||||
* });
|
||||
*
|
||||
* // When options.all is true, the result will be an Array.
|
||||
* options.all = true;
|
||||
* dnsPromises.lookup('example.com', options).then((result) => {
|
||||
* console.log('addresses: %j', result);
|
||||
* // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
|
||||
* });
|
||||
* ```
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function lookup(hostname: string, family: number): Promise<LookupAddress>;
|
||||
function lookup(hostname: string, options: LookupOneOptions): Promise<LookupAddress>;
|
||||
function lookup(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
||||
function lookup(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
||||
function lookup(hostname: string): Promise<LookupAddress>;
|
||||
/**
|
||||
* Resolves the given `address` and `port` into a host name and service using
|
||||
* the operating system's underlying `getnameinfo` implementation.
|
||||
*
|
||||
* If `address` is not a valid IP address, a `TypeError` will be thrown.
|
||||
* The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
|
||||
*
|
||||
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
|
||||
*
|
||||
* ```js
|
||||
* const dnsPromises = require('dns').promises;
|
||||
* dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
|
||||
* console.log(result.hostname, result.service);
|
||||
* // Prints: localhost ssh
|
||||
* });
|
||||
* ```
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function lookupService(
|
||||
address: string,
|
||||
port: number
|
||||
): Promise<{
|
||||
hostname: string;
|
||||
service: string;
|
||||
}>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
|
||||
* of the resource records. When successful, the `Promise` is resolved with an
|
||||
* array of resource records. The type and structure of individual results vary
|
||||
* based on `rrtype`:
|
||||
*
|
||||
* <omitted>
|
||||
*
|
||||
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`.
|
||||
* @since v10.6.0
|
||||
* @param hostname Host name to resolve.
|
||||
* @param rrtype Resource record type.
|
||||
*/
|
||||
function resolve(hostname: string): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: 'A'): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: 'AAAA'): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: 'ANY'): Promise<AnyRecord[]>;
|
||||
function resolve(hostname: string, rrtype: 'CAA'): Promise<CaaRecord[]>;
|
||||
function resolve(hostname: string, rrtype: 'CNAME'): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: 'MX'): Promise<MxRecord[]>;
|
||||
function resolve(hostname: string, rrtype: 'NAPTR'): Promise<NaptrRecord[]>;
|
||||
function resolve(hostname: string, rrtype: 'NS'): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: 'PTR'): Promise<string[]>;
|
||||
function resolve(hostname: string, rrtype: 'SOA'): Promise<SoaRecord>;
|
||||
function resolve(hostname: string, rrtype: 'SRV'): Promise<SrvRecord[]>;
|
||||
function resolve(hostname: string, rrtype: 'TXT'): Promise<string[][]>;
|
||||
function resolve(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv4
|
||||
* addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
||||
* @since v10.6.0
|
||||
* @param hostname Host name to resolve.
|
||||
*/
|
||||
function resolve4(hostname: string): Promise<string[]>;
|
||||
function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||
function resolve4(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv6
|
||||
* addresses.
|
||||
* @since v10.6.0
|
||||
* @param hostname Host name to resolve.
|
||||
*/
|
||||
function resolve6(hostname: string): Promise<string[]>;
|
||||
function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||
function resolve6(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
|
||||
* On success, the `Promise` is resolved with an array containing various types of
|
||||
* records. Each object has a property `type` that indicates the type of the
|
||||
* current record. And depending on the `type`, additional properties will be
|
||||
* present on the object:
|
||||
*
|
||||
* <omitted>
|
||||
*
|
||||
* Here is an example of the result object:
|
||||
*
|
||||
* ```js
|
||||
* [ { type: 'A', address: '127.0.0.1', ttl: 299 },
|
||||
* { type: 'CNAME', value: 'example.com' },
|
||||
* { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
|
||||
* { type: 'NS', value: 'ns1.example.com' },
|
||||
* { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
|
||||
* { type: 'SOA',
|
||||
* nsname: 'ns1.example.com',
|
||||
* hostmaster: 'admin.example.com',
|
||||
* serial: 156696742,
|
||||
* refresh: 900,
|
||||
* retry: 900,
|
||||
* expire: 1800,
|
||||
* minttl: 60 } ]
|
||||
* ```
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function resolveAny(hostname: string): Promise<AnyRecord[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success,
|
||||
* the `Promise` is resolved with an array of objects containing available
|
||||
* certification authority authorization records available for the `hostname`(e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]`).
|
||||
* @since v15.0.0
|
||||
*/
|
||||
function resolveCaa(hostname: string): Promise<CaaRecord[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. On success,
|
||||
* the `Promise` is resolved with an array of canonical name records available for
|
||||
* the `hostname` (e.g. `['bar.example.com']`).
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function resolveCname(hostname: string): Promise<string[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects
|
||||
* containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`).
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function resolveMx(hostname: string): Promise<MxRecord[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array
|
||||
* of objects with the following properties:
|
||||
*
|
||||
* * `flags`
|
||||
* * `service`
|
||||
* * `regexp`
|
||||
* * `replacement`
|
||||
* * `order`
|
||||
* * `preference`
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* flags: 's',
|
||||
* service: 'SIP+D2U',
|
||||
* regexp: '',
|
||||
* replacement: '_sip._udp.example.com',
|
||||
* order: 30,
|
||||
* preference: 100
|
||||
* }
|
||||
* ```
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. On success, the `Promise` is resolved with an array of name server
|
||||
* records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`).
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function resolveNs(hostname: string): Promise<string[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. On success, the `Promise` is resolved with an array of strings
|
||||
* containing the reply records.
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function resolvePtr(hostname: string): Promise<string[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
||||
* the `hostname`. On success, the `Promise` is resolved with an object with the
|
||||
* following properties:
|
||||
*
|
||||
* * `nsname`
|
||||
* * `hostmaster`
|
||||
* * `serial`
|
||||
* * `refresh`
|
||||
* * `retry`
|
||||
* * `expire`
|
||||
* * `minttl`
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* nsname: 'ns.example.com',
|
||||
* hostmaster: 'root.example.com',
|
||||
* serial: 2013101809,
|
||||
* refresh: 10000,
|
||||
* retry: 2400,
|
||||
* expire: 604800,
|
||||
* minttl: 3600
|
||||
* }
|
||||
* ```
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function resolveSoa(hostname: string): Promise<SoaRecord>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects with
|
||||
* the following properties:
|
||||
*
|
||||
* * `priority`
|
||||
* * `weight`
|
||||
* * `port`
|
||||
* * `name`
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* priority: 10,
|
||||
* weight: 5,
|
||||
* port: 21223,
|
||||
* name: 'service.example.com'
|
||||
* }
|
||||
* ```
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function resolveSrv(hostname: string): Promise<SrvRecord[]>;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. On success, the `Promise` is resolved with a two-dimensional array
|
||||
* of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
||||
* one record. Depending on the use case, these could be either joined together or
|
||||
* treated separately.
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function resolveTxt(hostname: string): Promise<string[][]>;
|
||||
/**
|
||||
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
||||
* array of host names.
|
||||
*
|
||||
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`.
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function reverse(ip: string): Promise<string[]>;
|
||||
/**
|
||||
* Sets the IP address and port of servers to be used when performing DNS
|
||||
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
|
||||
* addresses. If the port is the IANA default DNS port (53) it can be omitted.
|
||||
*
|
||||
* ```js
|
||||
* dnsPromises.setServers([
|
||||
* '4.4.4.4',
|
||||
* '[2001:4860:4860::8888]',
|
||||
* '4.4.4.4:1053',
|
||||
* '[2001:4860:4860::8888]:1053',
|
||||
* ]);
|
||||
* ```
|
||||
*
|
||||
* An error will be thrown if an invalid address is provided.
|
||||
*
|
||||
* The `dnsPromises.setServers()` method must not be called while a DNS query is in
|
||||
* progress.
|
||||
*
|
||||
* This method works much like[resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
|
||||
* That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
|
||||
* subsequent servers provided. Fallback DNS servers will only be used if the
|
||||
* earlier ones time out or result in some other error.
|
||||
* @since v10.6.0
|
||||
* @param servers array of `RFC 5952` formatted addresses
|
||||
*/
|
||||
function setServers(servers: ReadonlyArray<string>): void;
|
||||
class Resolver {
|
||||
constructor(options?: ResolverOptions);
|
||||
cancel(): void;
|
||||
getServers: typeof getServers;
|
||||
resolve: typeof resolve;
|
||||
resolve4: typeof resolve4;
|
||||
resolve6: typeof resolve6;
|
||||
resolveAny: typeof resolveAny;
|
||||
resolveCname: typeof resolveCname;
|
||||
resolveMx: typeof resolveMx;
|
||||
resolveNaptr: typeof resolveNaptr;
|
||||
resolveNs: typeof resolveNs;
|
||||
resolvePtr: typeof resolvePtr;
|
||||
resolveSoa: typeof resolveSoa;
|
||||
resolveSrv: typeof resolveSrv;
|
||||
resolveTxt: typeof resolveTxt;
|
||||
reverse: typeof reverse;
|
||||
setLocalAddress(ipv4?: string, ipv6?: string): void;
|
||||
setServers: typeof setServers;
|
||||
}
|
||||
}
|
||||
declare module 'node:dns/promises' {
|
||||
export * from 'dns/promises';
|
||||
}
|
|
@ -1,16 +1,169 @@
|
|||
declare module "domain" {
|
||||
import * as events from "events";
|
||||
|
||||
class Domain extends events.EventEmitter implements NodeJS.Domain {
|
||||
run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
|
||||
add(emitter: events.EventEmitter | NodeJS.Timer): void;
|
||||
remove(emitter: events.EventEmitter | NodeJS.Timer): void;
|
||||
bind<T extends Function>(cb: T): T;
|
||||
intercept<T extends Function>(cb: T): T;
|
||||
members: Array<events.EventEmitter | NodeJS.Timer>;
|
||||
/**
|
||||
* **This module is pending deprecation**. Once a replacement API has been
|
||||
* finalized, this module will be fully deprecated. Most developers should**not** have cause to use this module. Users who absolutely must have
|
||||
* the functionality that domains provide may rely on it for the time being
|
||||
* but should expect to have to migrate to a different solution
|
||||
* in the future.
|
||||
*
|
||||
* Domains provide a way to handle multiple different IO operations as a
|
||||
* single group. If any of the event emitters or callbacks registered to a
|
||||
* domain emit an `'error'` event, or throw an error, then the domain object
|
||||
* will be notified, rather than losing the context of the error in the`process.on('uncaughtException')` handler, or causing the program to
|
||||
* exit immediately with an error code.
|
||||
* @deprecated Since v1.4.2 - Deprecated
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/domain.js)
|
||||
*/
|
||||
declare module 'domain' {
|
||||
import EventEmitter = require('node:events');
|
||||
/**
|
||||
* The `Domain` class encapsulates the functionality of routing errors and
|
||||
* uncaught exceptions to the active `Domain` object.
|
||||
*
|
||||
* To handle the errors that it catches, listen to its `'error'` event.
|
||||
*/
|
||||
class Domain extends EventEmitter {
|
||||
/**
|
||||
* An array of timers and event emitters that have been explicitly added
|
||||
* to the domain.
|
||||
*/
|
||||
members: Array<EventEmitter | NodeJS.Timer>;
|
||||
/**
|
||||
* The `enter()` method is plumbing used by the `run()`, `bind()`, and`intercept()` methods to set the active domain. It sets `domain.active` and`process.domain` to the domain, and implicitly
|
||||
* pushes the domain onto the domain
|
||||
* stack managed by the domain module (see {@link exit} for details on the
|
||||
* domain stack). The call to `enter()` delimits the beginning of a chain of
|
||||
* asynchronous calls and I/O operations bound to a domain.
|
||||
*
|
||||
* Calling `enter()` changes only the active domain, and does not alter the domain
|
||||
* itself. `enter()` and `exit()` can be called an arbitrary number of times on a
|
||||
* single domain.
|
||||
*/
|
||||
enter(): void;
|
||||
/**
|
||||
* The `exit()` method exits the current domain, popping it off the domain stack.
|
||||
* Any time execution is going to switch to the context of a different chain of
|
||||
* asynchronous calls, it's important to ensure that the current domain is exited.
|
||||
* The call to `exit()` delimits either the end of or an interruption to the chain
|
||||
* of asynchronous calls and I/O operations bound to a domain.
|
||||
*
|
||||
* If there are multiple, nested domains bound to the current execution context,`exit()` will exit any domains nested within this domain.
|
||||
*
|
||||
* Calling `exit()` changes only the active domain, and does not alter the domain
|
||||
* itself. `enter()` and `exit()` can be called an arbitrary number of times on a
|
||||
* single domain.
|
||||
*/
|
||||
exit(): void;
|
||||
/**
|
||||
* Run the supplied function in the context of the domain, implicitly
|
||||
* binding all event emitters, timers, and lowlevel requests that are
|
||||
* created in that context. Optionally, arguments can be passed to
|
||||
* the function.
|
||||
*
|
||||
* This is the most basic way to use a domain.
|
||||
*
|
||||
* ```js
|
||||
* const domain = require('domain');
|
||||
* const fs = require('fs');
|
||||
* const d = domain.create();
|
||||
* d.on('error', (er) => {
|
||||
* console.error('Caught error!', er);
|
||||
* });
|
||||
* d.run(() => {
|
||||
* process.nextTick(() => {
|
||||
* setTimeout(() => { // Simulating some various async stuff
|
||||
* fs.open('non-existent file', 'r', (er, fd) => {
|
||||
* if (er) throw er;
|
||||
* // proceed...
|
||||
* });
|
||||
* }, 100);
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* In this example, the `d.on('error')` handler will be triggered, rather
|
||||
* than crashing the program.
|
||||
*/
|
||||
run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
|
||||
/**
|
||||
* Explicitly adds an emitter to the domain. If any event handlers called by
|
||||
* the emitter throw an error, or if the emitter emits an `'error'` event, it
|
||||
* will be routed to the domain's `'error'` event, just like with implicit
|
||||
* binding.
|
||||
*
|
||||
* This also works with timers that are returned from `setInterval()` and `setTimeout()`. If their callback function throws, it will be caught by
|
||||
* the domain `'error'` handler.
|
||||
*
|
||||
* If the Timer or `EventEmitter` was already bound to a domain, it is removed
|
||||
* from that one, and bound to this one instead.
|
||||
* @param emitter emitter or timer to be added to the domain
|
||||
*/
|
||||
add(emitter: EventEmitter | NodeJS.Timer): void;
|
||||
/**
|
||||
* The opposite of {@link add}. Removes domain handling from the
|
||||
* specified emitter.
|
||||
* @param emitter emitter or timer to be removed from the domain
|
||||
*/
|
||||
remove(emitter: EventEmitter | NodeJS.Timer): void;
|
||||
/**
|
||||
* The returned function will be a wrapper around the supplied callback
|
||||
* function. When the returned function is called, any errors that are
|
||||
* thrown will be routed to the domain's `'error'` event.
|
||||
*
|
||||
* ```js
|
||||
* const d = domain.create();
|
||||
*
|
||||
* function readSomeFile(filename, cb) {
|
||||
* fs.readFile(filename, 'utf8', d.bind((er, data) => {
|
||||
* // If this throws, it will also be passed to the domain.
|
||||
* return cb(er, data ? JSON.parse(data) : null);
|
||||
* }));
|
||||
* }
|
||||
*
|
||||
* d.on('error', (er) => {
|
||||
* // An error occurred somewhere. If we throw it now, it will crash the program
|
||||
* // with the normal line number and stack message.
|
||||
* });
|
||||
* ```
|
||||
* @param callback The callback function
|
||||
* @return The bound function
|
||||
*/
|
||||
bind<T extends Function>(cb: T): T;
|
||||
/**
|
||||
* This method is almost identical to {@link bind}. However, in
|
||||
* addition to catching thrown errors, it will also intercept `Error` objects sent as the first argument to the function.
|
||||
*
|
||||
* In this way, the common `if (err) return callback(err);` pattern can be replaced
|
||||
* with a single error handler in a single place.
|
||||
*
|
||||
* ```js
|
||||
* const d = domain.create();
|
||||
*
|
||||
* function readSomeFile(filename, cb) {
|
||||
* fs.readFile(filename, 'utf8', d.intercept((data) => {
|
||||
* // Note, the first argument is never passed to the
|
||||
* // callback since it is assumed to be the 'Error' argument
|
||||
* // and thus intercepted by the domain.
|
||||
*
|
||||
* // If this throws, it will also be passed to the domain
|
||||
* // so the error-handling logic can be moved to the 'error'
|
||||
* // event on the domain instead of being repeated throughout
|
||||
* // the program.
|
||||
* return cb(null, JSON.parse(data));
|
||||
* }));
|
||||
* }
|
||||
*
|
||||
* d.on('error', (er) => {
|
||||
* // An error occurred somewhere. If we throw it now, it will crash the program
|
||||
* // with the normal line number and stack message.
|
||||
* });
|
||||
* ```
|
||||
* @param callback The callback function
|
||||
* @return The intercepted function
|
||||
*/
|
||||
intercept<T extends Function>(cb: T): T;
|
||||
}
|
||||
|
||||
function create(): Domain;
|
||||
}
|
||||
declare module 'node:domain' {
|
||||
export * from 'domain';
|
||||
}
|
||||
|
|
|
@ -1,39 +1,444 @@
|
|||
declare module "events" {
|
||||
class internal extends NodeJS.EventEmitter { }
|
||||
|
||||
/**
|
||||
* Much of the Node.js core API is built around an idiomatic asynchronous
|
||||
* event-driven architecture in which certain kinds of objects (called "emitters")
|
||||
* emit named events that cause `Function` objects ("listeners") to be called.
|
||||
*
|
||||
* For instance: a `net.Server` object emits an event each time a peer
|
||||
* connects to it; a `fs.ReadStream` emits an event when the file is opened;
|
||||
* a `stream` emits an event whenever data is available to be read.
|
||||
*
|
||||
* All objects that emit events are instances of the `EventEmitter` class. These
|
||||
* objects expose an `eventEmitter.on()` function that allows one or more
|
||||
* functions to be attached to named events emitted by the object. Typically,
|
||||
* event names are camel-cased strings but any valid JavaScript property key
|
||||
* can be used.
|
||||
*
|
||||
* When the `EventEmitter` object emits an event, all of the functions attached
|
||||
* to that specific event are called _synchronously_. Any values returned by the
|
||||
* called listeners are _ignored_ and discarded.
|
||||
*
|
||||
* The following example shows a simple `EventEmitter` instance with a single
|
||||
* listener. The `eventEmitter.on()` method is used to register listeners, while
|
||||
* the `eventEmitter.emit()` method is used to trigger the event.
|
||||
*
|
||||
* ```js
|
||||
* const EventEmitter = require('events');
|
||||
*
|
||||
* class MyEmitter extends EventEmitter {}
|
||||
*
|
||||
* const myEmitter = new MyEmitter();
|
||||
* myEmitter.on('event', () => {
|
||||
* console.log('an event occurred!');
|
||||
* });
|
||||
* myEmitter.emit('event');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/events.js)
|
||||
*/
|
||||
declare module 'events' {
|
||||
interface EventEmitterOptions {
|
||||
/**
|
||||
* Enables automatic capturing of promise rejection.
|
||||
*/
|
||||
captureRejections?: boolean | undefined;
|
||||
}
|
||||
interface NodeEventTarget {
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
interface DOMEventTarget {
|
||||
addEventListener(event: string, listener: (...args: any[]) => void, opts?: { once: boolean }): any;
|
||||
addEventListener(
|
||||
event: string,
|
||||
listener: (...args: any[]) => void,
|
||||
opts?: {
|
||||
once: boolean;
|
||||
}
|
||||
): any;
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
function once(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>;
|
||||
function once(emitter: DOMEventTarget, event: string): Promise<any[]>;
|
||||
class EventEmitter extends internal {
|
||||
/** @deprecated since v4.0.0 */
|
||||
static listenerCount(emitter: EventEmitter, event: string | symbol): number;
|
||||
static defaultMaxListeners: number;
|
||||
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
removeAllListeners(event?: string | symbol): this;
|
||||
setMaxListeners(n: number): this;
|
||||
getMaxListeners(): number;
|
||||
listeners(event: string | symbol): Function[];
|
||||
rawListeners(event: string | symbol): Function[];
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
eventNames(): Array<string | symbol>;
|
||||
listenerCount(type: string | symbol): number;
|
||||
interface StaticEventEmitterOptions {
|
||||
signal?: AbortSignal | undefined;
|
||||
}
|
||||
interface EventEmitter extends NodeJS.EventEmitter {}
|
||||
/**
|
||||
* The `EventEmitter` class is defined and exposed by the `events` module:
|
||||
*
|
||||
* ```js
|
||||
* const EventEmitter = require('events');
|
||||
* ```
|
||||
*
|
||||
* All `EventEmitter`s emit the event `'newListener'` when new listeners are
|
||||
* added and `'removeListener'` when existing listeners are removed.
|
||||
*
|
||||
* It supports the following option:
|
||||
* @since v0.1.26
|
||||
*/
|
||||
class EventEmitter {
|
||||
constructor(options?: EventEmitterOptions);
|
||||
static once(emitter: NodeEventTarget, event: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||
static once(emitter: DOMEventTarget, event: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||
static on(emitter: NodeJS.EventEmitter, event: string, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>;
|
||||
/** @deprecated since v4.0.0 */
|
||||
static listenerCount(emitter: NodeJS.EventEmitter, event: string | symbol): number;
|
||||
/**
|
||||
* Returns a list listener for a specific emitter event name.
|
||||
*/
|
||||
static getEventListener(emitter: DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
||||
/**
|
||||
* This symbol shall be used to install a listener for only monitoring `'error'`
|
||||
* events. Listeners installed using this symbol are called before the regular
|
||||
* `'error'` listeners are called.
|
||||
*
|
||||
* Installing a listener using this symbol does not change the behavior once an
|
||||
* `'error'` event is emitted, therefore the process will still crash if no
|
||||
* regular `'error'` listener is installed.
|
||||
*/
|
||||
static readonly errorMonitor: unique symbol;
|
||||
static readonly captureRejectionSymbol: unique symbol;
|
||||
/**
|
||||
* Sets or gets the default captureRejection value for all emitters.
|
||||
*/
|
||||
// TODO: These should be described using static getter/setter pairs:
|
||||
static captureRejections: boolean;
|
||||
static defaultMaxListeners: number;
|
||||
}
|
||||
import internal = require('node:events');
|
||||
namespace EventEmitter {
|
||||
// Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4
|
||||
export { internal as EventEmitter };
|
||||
export interface Abortable {
|
||||
/**
|
||||
* When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
|
||||
*/
|
||||
signal?: AbortSignal | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export = internal;
|
||||
global {
|
||||
namespace NodeJS {
|
||||
interface EventEmitter {
|
||||
/**
|
||||
* Alias for `emitter.on(eventName, listener)`.
|
||||
* @since v0.1.26
|
||||
*/
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
/**
|
||||
* Adds the `listener` function to the end of the listeners array for the
|
||||
* event named `eventName`. No checks are made to see if the `listener` has
|
||||
* already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
|
||||
* times.
|
||||
*
|
||||
* ```js
|
||||
* server.on('connection', (stream) => {
|
||||
* console.log('someone connected!');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
*
|
||||
* By default, event listeners are invoked in the order they are added. The`emitter.prependListener()` method can be used as an alternative to add the
|
||||
* event listener to the beginning of the listeners array.
|
||||
*
|
||||
* ```js
|
||||
* const myEE = new EventEmitter();
|
||||
* myEE.on('foo', () => console.log('a'));
|
||||
* myEE.prependListener('foo', () => console.log('b'));
|
||||
* myEE.emit('foo');
|
||||
* // Prints:
|
||||
* // b
|
||||
* // a
|
||||
* ```
|
||||
* @since v0.1.101
|
||||
* @param eventName The name of the event.
|
||||
* @param listener The callback function
|
||||
*/
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
/**
|
||||
* Adds a **one-time**`listener` function for the event named `eventName`. The
|
||||
* next time `eventName` is triggered, this listener is removed and then invoked.
|
||||
*
|
||||
* ```js
|
||||
* server.once('connection', (stream) => {
|
||||
* console.log('Ah, we have our first user!');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
*
|
||||
* By default, event listeners are invoked in the order they are added. The`emitter.prependOnceListener()` method can be used as an alternative to add the
|
||||
* event listener to the beginning of the listeners array.
|
||||
*
|
||||
* ```js
|
||||
* const myEE = new EventEmitter();
|
||||
* myEE.once('foo', () => console.log('a'));
|
||||
* myEE.prependOnceListener('foo', () => console.log('b'));
|
||||
* myEE.emit('foo');
|
||||
* // Prints:
|
||||
* // b
|
||||
* // a
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
* @param eventName The name of the event.
|
||||
* @param listener The callback function
|
||||
*/
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
/**
|
||||
* Removes the specified `listener` from the listener array for the event named`eventName`.
|
||||
*
|
||||
* ```js
|
||||
* const callback = (stream) => {
|
||||
* console.log('someone connected!');
|
||||
* };
|
||||
* server.on('connection', callback);
|
||||
* // ...
|
||||
* server.removeListener('connection', callback);
|
||||
* ```
|
||||
*
|
||||
* `removeListener()` will remove, at most, one instance of a listener from the
|
||||
* listener array. If any single listener has been added multiple times to the
|
||||
* listener array for the specified `eventName`, then `removeListener()` must be
|
||||
* called multiple times to remove each instance.
|
||||
*
|
||||
* Once an event is emitted, all listeners attached to it at the
|
||||
* time of emitting are called in order. This implies that any`removeListener()` or `removeAllListeners()` calls _after_ emitting and_before_ the last listener finishes execution will
|
||||
* not remove them from`emit()` in progress. Subsequent events behave as expected.
|
||||
*
|
||||
* ```js
|
||||
* const myEmitter = new MyEmitter();
|
||||
*
|
||||
* const callbackA = () => {
|
||||
* console.log('A');
|
||||
* myEmitter.removeListener('event', callbackB);
|
||||
* };
|
||||
*
|
||||
* const callbackB = () => {
|
||||
* console.log('B');
|
||||
* };
|
||||
*
|
||||
* myEmitter.on('event', callbackA);
|
||||
*
|
||||
* myEmitter.on('event', callbackB);
|
||||
*
|
||||
* // callbackA removes listener callbackB but it will still be called.
|
||||
* // Internal listener array at time of emit [callbackA, callbackB]
|
||||
* myEmitter.emit('event');
|
||||
* // Prints:
|
||||
* // A
|
||||
* // B
|
||||
*
|
||||
* // callbackB is now removed.
|
||||
* // Internal listener array [callbackA]
|
||||
* myEmitter.emit('event');
|
||||
* // Prints:
|
||||
* // A
|
||||
* ```
|
||||
*
|
||||
* Because listeners are managed using an internal array, calling this will
|
||||
* change the position indices of any listener registered _after_ the listener
|
||||
* being removed. This will not impact the order in which listeners are called,
|
||||
* but it means that any copies of the listener array as returned by
|
||||
* the `emitter.listeners()` method will need to be recreated.
|
||||
*
|
||||
* When a single function has been added as a handler multiple times for a single
|
||||
* event (as in the example below), `removeListener()` will remove the most
|
||||
* recently added instance. In the example the `once('ping')`listener is removed:
|
||||
*
|
||||
* ```js
|
||||
* const ee = new EventEmitter();
|
||||
*
|
||||
* function pong() {
|
||||
* console.log('pong');
|
||||
* }
|
||||
*
|
||||
* ee.on('ping', pong);
|
||||
* ee.once('ping', pong);
|
||||
* ee.removeListener('ping', pong);
|
||||
*
|
||||
* ee.emit('ping');
|
||||
* ee.emit('ping');
|
||||
* ```
|
||||
*
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
* @since v0.1.26
|
||||
*/
|
||||
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
/**
|
||||
* Alias for `emitter.removeListener()`.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
/**
|
||||
* Removes all listeners, or those of the specified `eventName`.
|
||||
*
|
||||
* It is bad practice to remove listeners added elsewhere in the code,
|
||||
* particularly when the `EventEmitter` instance was created by some other
|
||||
* component or module (e.g. sockets or file streams).
|
||||
*
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
* @since v0.1.26
|
||||
*/
|
||||
removeAllListeners(event?: string | symbol): this;
|
||||
/**
|
||||
* By default `EventEmitter`s will print a warning if more than `10` listeners are
|
||||
* added for a particular event. This is a useful default that helps finding
|
||||
* memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
|
||||
* modified for this specific `EventEmitter` instance. The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
|
||||
*
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
* @since v0.3.5
|
||||
*/
|
||||
setMaxListeners(n: number): this;
|
||||
/**
|
||||
* Returns the current max listener value for the `EventEmitter` which is either
|
||||
* set by `emitter.setMaxListeners(n)` or defaults to {@link defaultMaxListeners}.
|
||||
* @since v1.0.0
|
||||
*/
|
||||
getMaxListeners(): number;
|
||||
/**
|
||||
* Returns a copy of the array of listeners for the event named `eventName`.
|
||||
*
|
||||
* ```js
|
||||
* server.on('connection', (stream) => {
|
||||
* console.log('someone connected!');
|
||||
* });
|
||||
* console.log(util.inspect(server.listeners('connection')));
|
||||
* // Prints: [ [Function] ]
|
||||
* ```
|
||||
* @since v0.1.26
|
||||
*/
|
||||
listeners(event: string | symbol): Function[];
|
||||
/**
|
||||
* Returns a copy of the array of listeners for the event named `eventName`,
|
||||
* including any wrappers (such as those created by `.once()`).
|
||||
*
|
||||
* ```js
|
||||
* const emitter = new EventEmitter();
|
||||
* emitter.once('log', () => console.log('log once'));
|
||||
*
|
||||
* // Returns a new Array with a function `onceWrapper` which has a property
|
||||
* // `listener` which contains the original listener bound above
|
||||
* const listeners = emitter.rawListeners('log');
|
||||
* const logFnWrapper = listeners[0];
|
||||
*
|
||||
* // Logs "log once" to the console and does not unbind the `once` event
|
||||
* logFnWrapper.listener();
|
||||
*
|
||||
* // Logs "log once" to the console and removes the listener
|
||||
* logFnWrapper();
|
||||
*
|
||||
* emitter.on('log', () => console.log('log persistently'));
|
||||
* // Will return a new Array with a single function bound by `.on()` above
|
||||
* const newListeners = emitter.rawListeners('log');
|
||||
*
|
||||
* // Logs "log persistently" twice
|
||||
* newListeners[0]();
|
||||
* emitter.emit('log');
|
||||
* ```
|
||||
* @since v9.4.0
|
||||
*/
|
||||
rawListeners(event: string | symbol): Function[];
|
||||
/**
|
||||
* Synchronously calls each of the listeners registered for the event named`eventName`, in the order they were registered, passing the supplied arguments
|
||||
* to each.
|
||||
*
|
||||
* Returns `true` if the event had listeners, `false` otherwise.
|
||||
*
|
||||
* ```js
|
||||
* const EventEmitter = require('events');
|
||||
* const myEmitter = new EventEmitter();
|
||||
*
|
||||
* // First listener
|
||||
* myEmitter.on('event', function firstListener() {
|
||||
* console.log('Helloooo! first listener');
|
||||
* });
|
||||
* // Second listener
|
||||
* myEmitter.on('event', function secondListener(arg1, arg2) {
|
||||
* console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
|
||||
* });
|
||||
* // Third listener
|
||||
* myEmitter.on('event', function thirdListener(...args) {
|
||||
* const parameters = args.join(', ');
|
||||
* console.log(`event with parameters ${parameters} in third listener`);
|
||||
* });
|
||||
*
|
||||
* console.log(myEmitter.listeners('event'));
|
||||
*
|
||||
* myEmitter.emit('event', 1, 2, 3, 4, 5);
|
||||
*
|
||||
* // Prints:
|
||||
* // [
|
||||
* // [Function: firstListener],
|
||||
* // [Function: secondListener],
|
||||
* // [Function: thirdListener]
|
||||
* // ]
|
||||
* // Helloooo! first listener
|
||||
* // event with parameters 1, 2 in second listener
|
||||
* // event with parameters 1, 2, 3, 4, 5 in third listener
|
||||
* ```
|
||||
* @since v0.1.26
|
||||
*/
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
/**
|
||||
* Returns the number of listeners listening to the event named `eventName`.
|
||||
* @since v3.2.0
|
||||
* @param eventName The name of the event being listened for
|
||||
*/
|
||||
listenerCount(event: string | symbol): number;
|
||||
/**
|
||||
* Adds the `listener` function to the _beginning_ of the listeners array for the
|
||||
* event named `eventName`. No checks are made to see if the `listener` has
|
||||
* already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
|
||||
* times.
|
||||
*
|
||||
* ```js
|
||||
* server.prependListener('connection', (stream) => {
|
||||
* console.log('someone connected!');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
* @since v6.0.0
|
||||
* @param eventName The name of the event.
|
||||
* @param listener The callback function
|
||||
*/
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
/**
|
||||
* Adds a **one-time**`listener` function for the event named `eventName` to the_beginning_ of the listeners array. The next time `eventName` is triggered, this
|
||||
* listener is removed, and then invoked.
|
||||
*
|
||||
* ```js
|
||||
* server.prependOnceListener('connection', (stream) => {
|
||||
* console.log('Ah, we have our first user!');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
* @since v6.0.0
|
||||
* @param eventName The name of the event.
|
||||
* @param listener The callback function
|
||||
*/
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
/**
|
||||
* Returns an array listing the events for which the emitter has registered
|
||||
* listeners. The values in the array are strings or `Symbol`s.
|
||||
*
|
||||
* ```js
|
||||
* const EventEmitter = require('events');
|
||||
* const myEE = new EventEmitter();
|
||||
* myEE.on('foo', () => {});
|
||||
* myEE.on('bar', () => {});
|
||||
*
|
||||
* const sym = Symbol('symbol');
|
||||
* myEE.on(sym, () => {});
|
||||
*
|
||||
* console.log(myEE.eventNames());
|
||||
* // Prints: [ 'foo', 'bar', Symbol(symbol) ]
|
||||
* ```
|
||||
* @since v6.0.0
|
||||
*/
|
||||
eventNames(): Array<string | symbol>;
|
||||
}
|
||||
}
|
||||
}
|
||||
export = EventEmitter;
|
||||
}
|
||||
declare module 'node:events' {
|
||||
import events = require('events');
|
||||
export = events;
|
||||
}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,937 @@
|
|||
/**
|
||||
* The `fs/promises` API provides asynchronous file system methods that return
|
||||
* promises.
|
||||
*
|
||||
* The promise APIs use the underlying Node.js threadpool to perform file
|
||||
* system operations off the event loop thread. These operations are not
|
||||
* synchronized or threadsafe. Care must be taken when performing multiple
|
||||
* concurrent modifications on the same file or data corruption may occur.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
declare module 'fs/promises' {
|
||||
import { Abortable } from 'node:events';
|
||||
import { Stream } from 'node:stream';
|
||||
import {
|
||||
Stats,
|
||||
BigIntStats,
|
||||
StatOptions,
|
||||
WriteVResult,
|
||||
ReadVResult,
|
||||
PathLike,
|
||||
RmDirOptions,
|
||||
RmOptions,
|
||||
MakeDirectoryOptions,
|
||||
Dirent,
|
||||
OpenDirOptions,
|
||||
Dir,
|
||||
ObjectEncodingOptions,
|
||||
BufferEncodingOption,
|
||||
OpenMode,
|
||||
Mode,
|
||||
WatchOptions,
|
||||
} from 'node:fs';
|
||||
interface FlagAndOpenMode {
|
||||
mode?: Mode | undefined;
|
||||
flag?: OpenMode | undefined;
|
||||
}
|
||||
interface FileReadResult<T extends ArrayBufferView> {
|
||||
bytesRead: number;
|
||||
buffer: T;
|
||||
}
|
||||
interface FileReadOptions<T extends ArrayBufferView = Buffer> {
|
||||
/**
|
||||
* @default `Buffer.alloc(0xffff)`
|
||||
*/
|
||||
buffer?: T;
|
||||
/**
|
||||
* @default 0
|
||||
*/
|
||||
offset?: number | null;
|
||||
/**
|
||||
* @default `buffer.byteLength`
|
||||
*/
|
||||
length?: number | null;
|
||||
position?: number | null;
|
||||
}
|
||||
// TODO: Add `EventEmitter` close
|
||||
interface FileHandle {
|
||||
/**
|
||||
* The numeric file descriptor managed by the {FileHandle} object.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
readonly fd: number;
|
||||
/**
|
||||
* Alias of `filehandle.writeFile()`.
|
||||
*
|
||||
* When operating on file handles, the mode cannot be changed from what it was set
|
||||
* to with `fsPromises.open()`. Therefore, this is equivalent to `filehandle.writeFile()`.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
appendFile(data: string | Uint8Array, options?: (ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding | null): Promise<void>;
|
||||
/**
|
||||
* Changes the ownership of the file. A wrapper for [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html).
|
||||
* @since v10.0.0
|
||||
* @param uid The file's new owner's user id.
|
||||
* @param gid The file's new group's group id.
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
chown(uid: number, gid: number): Promise<void>;
|
||||
/**
|
||||
* Modifies the permissions on the file. See [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html).
|
||||
* @since v10.0.0
|
||||
* @param mode the file mode bit mask.
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
chmod(mode: Mode): Promise<void>;
|
||||
/**
|
||||
* Forces all currently queued I/O operations associated with the file to the
|
||||
* operating system's synchronized I/O completion state. Refer to the POSIX[`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details.
|
||||
*
|
||||
* Unlike `filehandle.sync` this method does not flush modified metadata.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
datasync(): Promise<void>;
|
||||
/**
|
||||
* Request that all data for the open file descriptor is flushed to the storage
|
||||
* device. The specific implementation is operating system and device specific.
|
||||
* Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail.
|
||||
* @since v10.0.0
|
||||
* @return Fufills with `undefined` upon success.
|
||||
*/
|
||||
sync(): Promise<void>;
|
||||
/**
|
||||
* Reads data from the file and stores that in the given buffer.
|
||||
*
|
||||
* If the file is not modified concurrently, the end-of-file is reached when the
|
||||
* number of bytes read is zero.
|
||||
* @since v10.0.0
|
||||
* @param buffer A buffer that will be filled with the file data read.
|
||||
* @param offset The location in the buffer at which to start filling.
|
||||
* @param length The number of bytes to read.
|
||||
* @param position The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an
|
||||
* integer, the current file position will remain unchanged.
|
||||
* @return Fulfills upon success with an object with two properties:
|
||||
*/
|
||||
read<T extends ArrayBufferView>(buffer: T, offset?: number | null, length?: number | null, position?: number | null): Promise<FileReadResult<T>>;
|
||||
read<T extends ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file.
|
||||
*
|
||||
* If `options` is a string, then it specifies the `encoding`.
|
||||
*
|
||||
* The `<FileHandle>` has to support reading.
|
||||
*
|
||||
* If one or more `filehandle.read()` calls are made on a file handle and then a`filehandle.readFile()` call is made, the data will be read from the current
|
||||
* position till the end of the file. It doesn't always read from the beginning
|
||||
* of the file.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills upon a successful read with the contents of the file. If no encoding is specified (using `options.encoding`), the data is returned as a {Buffer} object. Otherwise, the
|
||||
* data will be a string.
|
||||
*/
|
||||
readFile(
|
||||
options?: {
|
||||
encoding?: null | undefined;
|
||||
flag?: OpenMode | undefined;
|
||||
} | null
|
||||
): Promise<Buffer>;
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
||||
* The `FileHandle` must have been opened for reading.
|
||||
* @param options An object that may contain an optional flag.
|
||||
* If a flag is not provided, it defaults to `'r'`.
|
||||
*/
|
||||
readFile(
|
||||
options:
|
||||
| {
|
||||
encoding: BufferEncoding;
|
||||
flag?: OpenMode | undefined;
|
||||
}
|
||||
| BufferEncoding
|
||||
): Promise<string>;
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
||||
* The `FileHandle` must have been opened for reading.
|
||||
* @param options An object that may contain an optional flag.
|
||||
* If a flag is not provided, it defaults to `'r'`.
|
||||
*/
|
||||
readFile(
|
||||
options?:
|
||||
| (ObjectEncodingOptions & {
|
||||
flag?: OpenMode | undefined;
|
||||
})
|
||||
| BufferEncoding
|
||||
| null
|
||||
): Promise<string | Buffer>;
|
||||
/**
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with an {fs.Stats} for the file.
|
||||
*/
|
||||
stat(
|
||||
opts?: StatOptions & {
|
||||
bigint?: false | undefined;
|
||||
}
|
||||
): Promise<Stats>;
|
||||
stat(
|
||||
opts: StatOptions & {
|
||||
bigint: true;
|
||||
}
|
||||
): Promise<BigIntStats>;
|
||||
stat(opts?: StatOptions): Promise<Stats | BigIntStats>;
|
||||
/**
|
||||
* Truncates the file.
|
||||
*
|
||||
* If the file was larger than `len` bytes, only the first `len` bytes will be
|
||||
* retained in the file.
|
||||
*
|
||||
* The following example retains only the first four bytes of the file:
|
||||
*
|
||||
* ```js
|
||||
* import { open } from 'fs/promises';
|
||||
*
|
||||
* let filehandle = null;
|
||||
* try {
|
||||
* filehandle = await open('temp.txt', 'r+');
|
||||
* await filehandle.truncate(4);
|
||||
* } finally {
|
||||
* await filehandle?.close();
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* If the file previously was shorter than `len` bytes, it is extended, and the
|
||||
* extended part is filled with null bytes (`'\0'`):
|
||||
*
|
||||
* If `len` is negative then `0` will be used.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
truncate(len?: number): Promise<void>;
|
||||
/**
|
||||
* Change the file system timestamps of the object referenced by the `<FileHandle>` then resolves the promise with no arguments upon success.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
utimes(atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
||||
/**
|
||||
* Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, or an object with an own `toString` function
|
||||
* property. The promise is resolved with no arguments upon success.
|
||||
*
|
||||
* If `options` is a string, then it specifies the `encoding`.
|
||||
*
|
||||
* The `<FileHandle>` has to support writing.
|
||||
*
|
||||
* It is unsafe to use `filehandle.writeFile()` multiple times on the same file
|
||||
* without waiting for the promise to be resolved (or rejected).
|
||||
*
|
||||
* If one or more `filehandle.write()` calls are made on a file handle and then a`filehandle.writeFile()` call is made, the data will be written from the
|
||||
* current position till the end of the file. It doesn't always write from the
|
||||
* beginning of the file.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
writeFile(data: string | Uint8Array, options?: (ObjectEncodingOptions & FlagAndOpenMode & Abortable) | BufferEncoding | null): Promise<void>;
|
||||
/**
|
||||
* Write an array of [<ArrayBufferView>](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView)s to the file.
|
||||
*
|
||||
* The promise is resolved with an object containing a two properties:
|
||||
*
|
||||
* It is unsafe to call `writev()` multiple times on the same file without waiting
|
||||
* for the promise to be resolved (or rejected).
|
||||
*
|
||||
* On Linux, positional writes don't work when the file is opened in append mode.
|
||||
* The kernel ignores the position argument and always appends the data to
|
||||
* the end of the file.
|
||||
* @since v12.9.0
|
||||
* @param position The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current
|
||||
* position.
|
||||
*/
|
||||
writev(buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<WriteVResult>;
|
||||
/**
|
||||
* Read from a file and write to an array of [<ArrayBufferView>](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView)s
|
||||
* @since v13.13.0, v12.17.0
|
||||
* @param position The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position.
|
||||
* @return Fulfills upon success an object containing two properties:
|
||||
*/
|
||||
readv(buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<ReadVResult>;
|
||||
/**
|
||||
* Closes the file handle after waiting for any pending operation on the handle to
|
||||
* complete.
|
||||
*
|
||||
* ```js
|
||||
* import { open } from 'fs/promises';
|
||||
*
|
||||
* let filehandle;
|
||||
* try {
|
||||
* filehandle = await open('thefile.txt', 'r');
|
||||
* } finally {
|
||||
* await filehandle?.close();
|
||||
* }
|
||||
* ```
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Tests a user's permissions for the file or directory specified by `path`.
|
||||
* The `mode` argument is an optional integer that specifies the accessibility
|
||||
* checks to be performed. Check `File access constants` for possible values
|
||||
* of `mode`. It is possible to create a mask consisting of the bitwise OR of
|
||||
* two or more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`).
|
||||
*
|
||||
* If the accessibility check is successful, the promise is resolved with no
|
||||
* value. If any of the accessibility checks fail, the promise is rejected
|
||||
* with an [<Error>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object. The following example checks if the file`/etc/passwd` can be read and
|
||||
* written by the current process.
|
||||
*
|
||||
* ```js
|
||||
* import { access } from 'fs/promises';
|
||||
* import { constants } from 'fs';
|
||||
*
|
||||
* try {
|
||||
* await access('/etc/passwd', constants.R_OK | constants.W_OK);
|
||||
* console.log('can access');
|
||||
* } catch {
|
||||
* console.error('cannot access');
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Using `fsPromises.access()` to check for the accessibility of a file before
|
||||
* calling `fsPromises.open()` is not recommended. Doing so introduces a race
|
||||
* condition, since other processes may change the file's state between the two
|
||||
* calls. Instead, user code should open/read/write the file directly and handle
|
||||
* the error raised if the file is not accessible.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function access(path: PathLike, mode?: number): Promise<void>;
|
||||
/**
|
||||
* Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it
|
||||
* already exists.
|
||||
*
|
||||
* No guarantees are made about the atomicity of the copy operation. If an
|
||||
* error occurs after the destination file has been opened for writing, an attempt
|
||||
* will be made to remove the destination.
|
||||
*
|
||||
* ```js
|
||||
* import { constants } from 'fs';
|
||||
* import { copyFile } from 'fs/promises';
|
||||
*
|
||||
* try {
|
||||
* await copyFile('source.txt', 'destination.txt');
|
||||
* console.log('source.txt was copied to destination.txt');
|
||||
* } catch {
|
||||
* console.log('The file could not be copied');
|
||||
* }
|
||||
*
|
||||
* // By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
|
||||
* try {
|
||||
* await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL);
|
||||
* console.log('source.txt was copied to destination.txt');
|
||||
* } catch {
|
||||
* console.log('The file could not be copied');
|
||||
* }
|
||||
* ```
|
||||
* @since v10.0.0
|
||||
* @param src source filename to copy
|
||||
* @param dest destination filename of the copy operation
|
||||
* @param mode Optional modifiers that specify the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g.
|
||||
* `fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`)
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function copyFile(src: PathLike, dest: PathLike, flags?: number): Promise<void>;
|
||||
/**
|
||||
* Opens a `<FileHandle>`.
|
||||
*
|
||||
* Refer to the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more detail.
|
||||
*
|
||||
* Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented
|
||||
* by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains
|
||||
* a colon, Node.js will open a file system stream, as described by[this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).
|
||||
* @since v10.0.0
|
||||
* @param flags See `support of file system `flags``.
|
||||
* @param mode Sets the file mode (permission and sticky bits) if the file is created.
|
||||
* @return Fulfills with a {FileHandle} object.
|
||||
*/
|
||||
function open(path: PathLike, flags: string | number, mode?: Mode): Promise<FileHandle>;
|
||||
/**
|
||||
* Renames `oldPath` to `newPath`.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
|
||||
/**
|
||||
* Truncates (shortens or extends the length) of the content at `path` to `len`bytes.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function truncate(path: PathLike, len?: number): Promise<void>;
|
||||
/**
|
||||
* Removes the directory identified by `path`.
|
||||
*
|
||||
* Using `fsPromises.rmdir()` on a file (not a directory) results in the
|
||||
* promise being rejected with an `ENOENT` error on Windows and an `ENOTDIR`error on POSIX.
|
||||
*
|
||||
* To get a behavior similar to the `rm -rf` Unix command, use `fsPromises.rm()` with options `{ recursive: true, force: true }`.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function rmdir(path: PathLike, options?: RmDirOptions): Promise<void>;
|
||||
/**
|
||||
* Removes files and directories (modeled on the standard POSIX `rm` utility).
|
||||
* @since v14.14.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function rm(path: PathLike, options?: RmOptions): Promise<void>;
|
||||
/**
|
||||
* Asynchronously creates a directory.
|
||||
*
|
||||
* The optional `options` argument can be an integer specifying `mode` (permission
|
||||
* and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fsPromises.mkdir()` when `path` is a directory
|
||||
* that exists results in a
|
||||
* rejection only when `recursive` is false.
|
||||
* @since v10.0.0
|
||||
* @return Upon success, fulfills with `undefined` if `recursive` is `false`, or the first directory path created if `recursive` is `true`.
|
||||
*/
|
||||
function mkdir(
|
||||
path: PathLike,
|
||||
options: MakeDirectoryOptions & {
|
||||
recursive: true;
|
||||
}
|
||||
): Promise<string | undefined>;
|
||||
/**
|
||||
* Asynchronous mkdir(2) - create a directory.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
||||
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
||||
*/
|
||||
function mkdir(
|
||||
path: PathLike,
|
||||
options?:
|
||||
| Mode
|
||||
| (MakeDirectoryOptions & {
|
||||
recursive?: false | undefined;
|
||||
})
|
||||
| null
|
||||
): Promise<void>;
|
||||
/**
|
||||
* Asynchronous mkdir(2) - create a directory.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
||||
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
||||
*/
|
||||
function mkdir(path: PathLike, options?: Mode | MakeDirectoryOptions | null): Promise<string | undefined>;
|
||||
/**
|
||||
* Reads the contents of a directory.
|
||||
*
|
||||
* The optional `options` argument can be a string specifying an encoding, or an
|
||||
* object with an `encoding` property specifying the character encoding to use for
|
||||
* the filenames. If the `encoding` is set to `'buffer'`, the filenames returned
|
||||
* will be passed as `<Buffer>` objects.
|
||||
*
|
||||
* If `options.withFileTypes` is set to `true`, the resolved array will contain `<fs.Dirent>` objects.
|
||||
*
|
||||
* ```js
|
||||
* import { readdir } from 'fs/promises';
|
||||
*
|
||||
* try {
|
||||
* const files = await readdir(path);
|
||||
* for (const file of files)
|
||||
* console.log(file);
|
||||
* } catch (err) {
|
||||
* console.error(err);
|
||||
* }
|
||||
* ```
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with an array of the names of the files in the directory excluding `'.'` and `'..'`.
|
||||
*/
|
||||
function readdir(
|
||||
path: PathLike,
|
||||
options?:
|
||||
| (ObjectEncodingOptions & {
|
||||
withFileTypes?: false | undefined;
|
||||
})
|
||||
| BufferEncoding
|
||||
| null
|
||||
): Promise<string[]>;
|
||||
/**
|
||||
* Asynchronous readdir(3) - read a directory.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
||||
*/
|
||||
function readdir(
|
||||
path: PathLike,
|
||||
options:
|
||||
| {
|
||||
encoding: 'buffer';
|
||||
withFileTypes?: false | undefined;
|
||||
}
|
||||
| 'buffer'
|
||||
): Promise<Buffer[]>;
|
||||
/**
|
||||
* Asynchronous readdir(3) - read a directory.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
||||
*/
|
||||
function readdir(
|
||||
path: PathLike,
|
||||
options?:
|
||||
| (ObjectEncodingOptions & {
|
||||
withFileTypes?: false | undefined;
|
||||
})
|
||||
| BufferEncoding
|
||||
| null
|
||||
): Promise<string[] | Buffer[]>;
|
||||
/**
|
||||
* Asynchronous readdir(3) - read a directory.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
|
||||
*/
|
||||
function readdir(
|
||||
path: PathLike,
|
||||
options: ObjectEncodingOptions & {
|
||||
withFileTypes: true;
|
||||
}
|
||||
): Promise<Dirent[]>;
|
||||
/**
|
||||
* Reads the contents of the symbolic link referred to by `path`. See the POSIX[`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more detail. The promise is
|
||||
* resolved with the`linkString` upon success.
|
||||
*
|
||||
* The optional `options` argument can be a string specifying an encoding, or an
|
||||
* object with an `encoding` property specifying the character encoding to use for
|
||||
* the link path returned. If the `encoding` is set to `'buffer'`, the link path
|
||||
* returned will be passed as a `<Buffer>` object.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with the `linkString` upon success.
|
||||
*/
|
||||
function readlink(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
||||
/**
|
||||
* Asynchronous readlink(2) - read value of a symbolic link.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
||||
*/
|
||||
function readlink(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
|
||||
/**
|
||||
* Asynchronous readlink(2) - read value of a symbolic link.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
||||
*/
|
||||
function readlink(path: PathLike, options?: ObjectEncodingOptions | string | null): Promise<string | Buffer>;
|
||||
/**
|
||||
* Creates a symbolic link.
|
||||
*
|
||||
* The `type` argument is only used on Windows platforms and can be one of `'dir'`,`'file'`, or `'junction'`. Windows junction points require the destination path
|
||||
* to be absolute. When using `'junction'`, the `target` argument will
|
||||
* automatically be normalized to absolute path.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function symlink(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
|
||||
/**
|
||||
* Equivalent to `fsPromises.stat()` unless `path` refers to a symbolic link,
|
||||
* in which case the link itself is stat-ed, not the file that it refers to.
|
||||
* Refer to the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) document for more detail.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with the {fs.Stats} object for the given symbolic link `path`.
|
||||
*/
|
||||
function lstat(
|
||||
path: PathLike,
|
||||
opts?: StatOptions & {
|
||||
bigint?: false | undefined;
|
||||
}
|
||||
): Promise<Stats>;
|
||||
function lstat(
|
||||
path: PathLike,
|
||||
opts: StatOptions & {
|
||||
bigint: true;
|
||||
}
|
||||
): Promise<BigIntStats>;
|
||||
function lstat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
|
||||
/**
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with the {fs.Stats} object for the given `path`.
|
||||
*/
|
||||
function stat(
|
||||
path: PathLike,
|
||||
opts?: StatOptions & {
|
||||
bigint?: false | undefined;
|
||||
}
|
||||
): Promise<Stats>;
|
||||
function stat(
|
||||
path: PathLike,
|
||||
opts: StatOptions & {
|
||||
bigint: true;
|
||||
}
|
||||
): Promise<BigIntStats>;
|
||||
function stat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
|
||||
/**
|
||||
* Creates a new link from the `existingPath` to the `newPath`. See the POSIX[`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function link(existingPath: PathLike, newPath: PathLike): Promise<void>;
|
||||
/**
|
||||
* If `path` refers to a symbolic link, then the link is removed without affecting
|
||||
* the file or directory to which that link refers. If the `path` refers to a file
|
||||
* path that is not a symbolic link, the file is deleted. See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html)documentation for more detail.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function unlink(path: PathLike): Promise<void>;
|
||||
/**
|
||||
* Changes the permissions of a file.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function chmod(path: PathLike, mode: Mode): Promise<void>;
|
||||
/**
|
||||
* Changes the permissions on a symbolic link.
|
||||
*
|
||||
* This method is only implemented on macOS.
|
||||
* @deprecated Since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function lchmod(path: PathLike, mode: Mode): Promise<void>;
|
||||
/**
|
||||
* Changes the ownership on a symbolic link.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function lchown(path: PathLike, uid: number, gid: number): Promise<void>;
|
||||
/**
|
||||
* Changes the access and modification times of a file in the same way as `fsPromises.utimes()`, with the difference that if the path refers to a
|
||||
* symbolic link, then the link is not dereferenced: instead, the timestamps of
|
||||
* the symbolic link itself are changed.
|
||||
* @since v14.5.0, v12.19.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function lutimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
||||
/**
|
||||
* Changes the ownership of a file.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function chown(path: PathLike, uid: number, gid: number): Promise<void>;
|
||||
/**
|
||||
* Change the file system timestamps of the object referenced by `path`.
|
||||
*
|
||||
* The `atime` and `mtime` arguments follow these rules:
|
||||
*
|
||||
* * Values can be either numbers representing Unix epoch time, `Date`s, or a
|
||||
* numeric string like `'123456789.0'`.
|
||||
* * If the value can not be converted to a number, or is `NaN`, `Infinity` or`-Infinity`, an `Error` will be thrown.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
||||
/**
|
||||
* Determines the actual location of `path` using the same semantics as the`fs.realpath.native()` function.
|
||||
*
|
||||
* Only paths that can be converted to UTF8 strings are supported.
|
||||
*
|
||||
* The optional `options` argument can be a string specifying an encoding, or an
|
||||
* object with an `encoding` property specifying the character encoding to use for
|
||||
* the path. If the `encoding` is set to `'buffer'`, the path returned will be
|
||||
* passed as a `<Buffer>` object.
|
||||
*
|
||||
* On Linux, when Node.js is linked against musl libc, the procfs file system must
|
||||
* be mounted on `/proc` in order for this function to work. Glibc does not have
|
||||
* this restriction.
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with the resolved path upon success.
|
||||
*/
|
||||
function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
||||
/**
|
||||
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
||||
*/
|
||||
function realpath(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
|
||||
/**
|
||||
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
||||
*/
|
||||
function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
|
||||
/**
|
||||
* Creates a unique temporary directory. A unique directory name is generated by
|
||||
* appending six random characters to the end of the provided `prefix`. Due to
|
||||
* platform inconsistencies, avoid trailing `X` characters in `prefix`. Some
|
||||
* platforms, notably the BSDs, can return more than six random characters, and
|
||||
* replace trailing `X` characters in `prefix` with random characters.
|
||||
*
|
||||
* The optional `options` argument can be a string specifying an encoding, or an
|
||||
* object with an `encoding` property specifying the character encoding to use.
|
||||
*
|
||||
* ```js
|
||||
* import { mkdtemp } from 'fs/promises';
|
||||
*
|
||||
* try {
|
||||
* await mkdtemp(path.join(os.tmpdir(), 'foo-'));
|
||||
* } catch (err) {
|
||||
* console.error(err);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* The `fsPromises.mkdtemp()` method will append the six randomly selected
|
||||
* characters directly to the `prefix` string. For instance, given a directory`/tmp`, if the intention is to create a temporary directory _within_`/tmp`, the`prefix` must end with a trailing
|
||||
* platform-specific path separator
|
||||
* (`require('path').sep`).
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with a string containing the filesystem path of the newly created temporary directory.
|
||||
*/
|
||||
function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
||||
/**
|
||||
* Asynchronously creates a unique temporary directory.
|
||||
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
||||
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
||||
*/
|
||||
function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<Buffer>;
|
||||
/**
|
||||
* Asynchronously creates a unique temporary directory.
|
||||
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
||||
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
||||
*/
|
||||
function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
|
||||
/**
|
||||
* Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a `<Buffer>`, or an object with an own `toString` function
|
||||
* property.
|
||||
*
|
||||
* The `encoding` option is ignored if `data` is a buffer.
|
||||
*
|
||||
* If `options` is a string, then it specifies the encoding.
|
||||
*
|
||||
* Any specified `<FileHandle>` has to support writing.
|
||||
*
|
||||
* It is unsafe to use `fsPromises.writeFile()` multiple times on the same file
|
||||
* without waiting for the promise to be settled.
|
||||
*
|
||||
* Similarly to `fsPromises.readFile` \- `fsPromises.writeFile` is a convenience
|
||||
* method that performs multiple `write` calls internally to write the buffer
|
||||
* passed to it. For performance sensitive code consider using `fs.createWriteStream()`.
|
||||
*
|
||||
* It is possible to use an `<AbortSignal>` to cancel an `fsPromises.writeFile()`.
|
||||
* Cancelation is "best effort", and some amount of data is likely still
|
||||
* to be written.
|
||||
*
|
||||
* ```js
|
||||
* import { writeFile } from 'fs/promises';
|
||||
*
|
||||
* try {
|
||||
* const controller = new AbortController();
|
||||
* const { signal } = controller;
|
||||
* const data = new Uint8Array(Buffer.from('Hello Node.js'));
|
||||
* const promise = writeFile('message.txt', data, { signal });
|
||||
*
|
||||
* // Abort the request before the promise settles.
|
||||
* controller.abort();
|
||||
*
|
||||
* await promise;
|
||||
* } catch (err) {
|
||||
* // When a request is aborted - err is an AbortError
|
||||
* console.error(err);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Aborting an ongoing request does not abort individual operating
|
||||
* system requests but rather the internal buffering `fs.writeFile` performs.
|
||||
* @since v10.0.0
|
||||
* @param file filename or `FileHandle`
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function writeFile(
|
||||
path: PathLike | FileHandle,
|
||||
data: string | NodeJS.ArrayBufferView | Iterable<string | NodeJS.ArrayBufferView> | AsyncIterable<string | NodeJS.ArrayBufferView> | Stream,
|
||||
options?:
|
||||
| (ObjectEncodingOptions & {
|
||||
mode?: Mode | undefined;
|
||||
flag?: OpenMode | undefined;
|
||||
} & Abortable)
|
||||
| BufferEncoding
|
||||
| null
|
||||
): Promise<void>;
|
||||
/**
|
||||
* Asynchronously append data to a file, creating the file if it does not yet
|
||||
* exist. `data` can be a string or a `<Buffer>`.
|
||||
*
|
||||
* If `options` is a string, then it specifies the `encoding`.
|
||||
*
|
||||
* The `path` may be specified as a `<FileHandle>` that has been opened
|
||||
* for appending (using `fsPromises.open()`).
|
||||
* @since v10.0.0
|
||||
* @param path filename or {FileHandle}
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function appendFile(path: PathLike | FileHandle, data: string | Uint8Array, options?: (ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding | null): Promise<void>;
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file.
|
||||
*
|
||||
* If no encoding is specified (using `options.encoding`), the data is returned
|
||||
* as a `<Buffer>` object. Otherwise, the data will be a string.
|
||||
*
|
||||
* If `options` is a string, then it specifies the encoding.
|
||||
*
|
||||
* When the `path` is a directory, the behavior of `fsPromises.readFile()` is
|
||||
* platform-specific. On macOS, Linux, and Windows, the promise will be rejected
|
||||
* with an error. On FreeBSD, a representation of the directory's contents will be
|
||||
* returned.
|
||||
*
|
||||
* It is possible to abort an ongoing `readFile` using an `<AbortSignal>`. If a
|
||||
* request is aborted the promise returned is rejected with an `AbortError`:
|
||||
*
|
||||
* ```js
|
||||
* import { readFile } from 'fs/promises';
|
||||
*
|
||||
* try {
|
||||
* const controller = new AbortController();
|
||||
* const { signal } = controller;
|
||||
* const promise = readFile(fileName, { signal });
|
||||
*
|
||||
* // Abort the request before the promise settles.
|
||||
* controller.abort();
|
||||
*
|
||||
* await promise;
|
||||
* } catch (err) {
|
||||
* // When a request is aborted - err is an AbortError
|
||||
* console.error(err);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Aborting an ongoing request does not abort individual operating
|
||||
* system requests but rather the internal buffering `fs.readFile` performs.
|
||||
*
|
||||
* Any specified `<FileHandle>` has to support reading.
|
||||
* @since v10.0.0
|
||||
* @param path filename or `FileHandle`
|
||||
* @return Fulfills with the contents of the file.
|
||||
*/
|
||||
function readFile(
|
||||
path: PathLike | FileHandle,
|
||||
options?:
|
||||
| ({
|
||||
encoding?: null | undefined;
|
||||
flag?: OpenMode | undefined;
|
||||
} & Abortable)
|
||||
| null
|
||||
): Promise<Buffer>;
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
|
||||
* @param options An object that may contain an optional flag.
|
||||
* If a flag is not provided, it defaults to `'r'`.
|
||||
*/
|
||||
function readFile(
|
||||
path: PathLike | FileHandle,
|
||||
options:
|
||||
| ({
|
||||
encoding: BufferEncoding;
|
||||
flag?: OpenMode | undefined;
|
||||
} & Abortable)
|
||||
| BufferEncoding
|
||||
): Promise<string>;
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
|
||||
* @param options An object that may contain an optional flag.
|
||||
* If a flag is not provided, it defaults to `'r'`.
|
||||
*/
|
||||
function readFile(
|
||||
path: PathLike | FileHandle,
|
||||
options?:
|
||||
| (ObjectEncodingOptions &
|
||||
Abortable & {
|
||||
flag?: OpenMode | undefined;
|
||||
})
|
||||
| BufferEncoding
|
||||
| null
|
||||
): Promise<string | Buffer>;
|
||||
/**
|
||||
* Asynchronously open a directory for iterative scanning. See the POSIX[`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for more detail.
|
||||
*
|
||||
* Creates an `<fs.Dir>`, which contains all further functions for reading from
|
||||
* and cleaning up the directory.
|
||||
*
|
||||
* The `encoding` option sets the encoding for the `path` while opening the
|
||||
* directory and subsequent read operations.
|
||||
*
|
||||
* Example using async iteration:
|
||||
*
|
||||
* ```js
|
||||
* import { opendir } from 'fs/promises';
|
||||
*
|
||||
* try {
|
||||
* const dir = await opendir('./');
|
||||
* for await (const dirent of dir)
|
||||
* console.log(dirent.name);
|
||||
* } catch (err) {
|
||||
* console.error(err);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* When using the async iterator, the `<fs.Dir>` object will be automatically
|
||||
* closed after the iterator exits.
|
||||
* @since v12.12.0
|
||||
* @return Fulfills with an {fs.Dir}.
|
||||
*/
|
||||
function opendir(path: string, options?: OpenDirOptions): Promise<Dir>;
|
||||
/**
|
||||
* Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
|
||||
*
|
||||
* ```js
|
||||
* const { watch } = require('fs/promises');
|
||||
*
|
||||
* const ac = new AbortController();
|
||||
* const { signal } = ac;
|
||||
* setTimeout(() => ac.abort(), 10000);
|
||||
*
|
||||
* (async () => {
|
||||
* try {
|
||||
* const watcher = watch(__filename, { signal });
|
||||
* for await (const event of watcher)
|
||||
* console.log(event);
|
||||
* } catch (err) {
|
||||
* if (err.name === 'AbortError')
|
||||
* return;
|
||||
* throw err;
|
||||
* }
|
||||
* })();
|
||||
* ```
|
||||
*
|
||||
* On most platforms, `'rename'` is emitted whenever a filename appears or
|
||||
* disappears in the directory.
|
||||
*
|
||||
* All the `caveats` for `fs.watch()` also apply to `fsPromises.watch()`.
|
||||
* @since v15.9.0
|
||||
* @return of objects with the properties:
|
||||
*/
|
||||
function watch(
|
||||
filename: PathLike,
|
||||
options:
|
||||
| (WatchOptions & {
|
||||
encoding: 'buffer';
|
||||
})
|
||||
| 'buffer'
|
||||
): AsyncIterable<Buffer>;
|
||||
/**
|
||||
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
||||
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
|
||||
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
||||
* If `persistent` is not supplied, the default of `true` is used.
|
||||
* If `recursive` is not supplied, the default of `false` is used.
|
||||
*/
|
||||
function watch(filename: PathLike, options?: WatchOptions | BufferEncoding): AsyncIterable<string>;
|
||||
/**
|
||||
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
||||
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
|
||||
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
||||
* If `persistent` is not supplied, the default of `true` is used.
|
||||
* If `recursive` is not supplied, the default of `false` is used.
|
||||
*/
|
||||
function watch(filename: PathLike, options: WatchOptions | string): AsyncIterable<string> | AsyncIterable<Buffer>;
|
||||
}
|
||||
declare module 'node:fs/promises' {
|
||||
export * from 'fs/promises';
|
||||
}
|
1101
node_modules/@types/node/globals.d.ts
сгенерированный
поставляемый
Normal file → Executable file
1101
node_modules/@types/node/globals.d.ts
сгенерированный
поставляемый
Normal file → Executable file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1 @@
|
|||
declare var global: typeof globalThis;
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче