mirror of
https://github.com/github/codeql-action.git
synced 2026-08-05 13:02:04 -05:00
Compare commits
109 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9763bdd6ec | |||
| 00d4d60204 | |||
| e5d84de18b | |||
| ea1acc573a | |||
| 79ea6d6a7c | |||
| 3e50d096f8 | |||
| cca1cfdacf | |||
| cdea582765 | |||
| 3e59dee9e2 | |||
| 249c7ffce1 | |||
| 254816c2d2 | |||
| 6d62c245ec | |||
| 5e87034b3b | |||
| 621e0794ac | |||
| d6499fad61 | |||
| 04671efa1d | |||
| e1f05902cd | |||
| f9e96fa857 | |||
| 14a5537e13 | |||
| d3eb4974a3 | |||
| 39216d10d3 | |||
| 265a7db16a | |||
| f623d4cec3 | |||
| eacec3646a | |||
| e0e2abc1a5 | |||
| 716b5980cd | |||
| 1d83f2a0bc | |||
| ce77f88627 | |||
| a777b51ef7 | |||
| 88fbabe21d | |||
| eeb215b041 | |||
| 5f53256358 | |||
| 25a5103778 | |||
| 0782554948 | |||
| 705f634a1d | |||
| b7b7607959 | |||
| 7bcc6564d4 | |||
| b661ef1697 | |||
| 6ad00fd084 | |||
| fccdee04ba | |||
| e694ca6192 | |||
| 67d11b5928 | |||
| 924a64d2e0 | |||
| 45dc27d3c1 | |||
| cbed0358c6 | |||
| a8cf6f42c2 | |||
| eebe7c46f1 | |||
| dc32d5448f | |||
| fac22de4f9 | |||
| 0a1efd7f45 | |||
| 043e3deaeb | |||
| 0dbcb55617 | |||
| 00c59b98ce | |||
| 7069ada3ed | |||
| dd1f9a96d8 | |||
| 546b30f35a | |||
| d1dde03d7a | |||
| f44219c94b | |||
| bdaac951f7 | |||
| a82f53a364 | |||
| f721f011bf | |||
| c82e09aa41 | |||
| 460d053698 | |||
| 3bf14e85d8 | |||
| 13a9d6c442 | |||
| dd65833ab6 | |||
| c2d9e4b48f | |||
| e095058bfa | |||
| 2c99f99c4a | |||
| bcd7e6896f | |||
| 0b242db78f | |||
| c897659213 | |||
| 8b902e1723 | |||
| 26567f6a49 | |||
| dbf7ac4b37 | |||
| 077f7b2532 | |||
| a392055010 | |||
| 0aea878963 | |||
| bca71988d3 | |||
| 02e1cdcd36 | |||
| 4860ed1ad4 | |||
| 3e36cddb07 | |||
| b9bd459b70 | |||
| 215c4f5ff5 | |||
| 4eef7ef32c | |||
| e0b9b9a248 | |||
| 823bb21bbb | |||
| 49fc4c9b40 | |||
| 21a786fda0 | |||
| 316ad9d919 | |||
| a627e9fa50 | |||
| 160021fe53 | |||
| 3f2269bf58 | |||
| 2ecc17d74f | |||
| 9b506fed7c | |||
| 2803f4a792 | |||
| 720bf9d157 | |||
| bbf0a22e84 | |||
| d7b5c618a4 | |||
| 37a4db94ad | |||
| 6a98a4b500 | |||
| ea8a175a94 | |||
| f360da772a | |||
| ea169430d2 | |||
| 375c14729e | |||
| 0442e71a2a | |||
| 3832953584 | |||
| 3ce10aec2e | |||
| c4b0d49ea3 |
@@ -28,7 +28,6 @@ runs:
|
|||||||
echo "::set-output name=tools-url::https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/codeql-bundle-$VERSION-manual/codeql-bundle.tar.gz"
|
echo "::set-output name=tools-url::https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/codeql-bundle-$VERSION-manual/codeql-bundle.tar.gz"
|
||||||
elif [[ ${{ inputs.version }} == *"stable"* ]]; then
|
elif [[ ${{ inputs.version }} == *"stable"* ]]; then
|
||||||
export VERSION=`echo ${{ inputs.version }} | sed -e 's/^.*\-//'`
|
export VERSION=`echo ${{ inputs.version }} | sed -e 's/^.*\-//'`
|
||||||
echo "Hello $VERSION"
|
|
||||||
echo "::set-output name=tools-url::https://github.com/github/codeql-action/releases/download/codeql-bundle-$VERSION/codeql-bundle.tar.gz"
|
echo "::set-output name=tools-url::https://github.com/github/codeql-action/releases/download/codeql-bundle-$VERSION/codeql-bundle.tar.gz"
|
||||||
elif [[ ${{ inputs.version }} == "latest" ]]; then
|
elif [[ ${{ inputs.version }} == "latest" ]]; then
|
||||||
echo "::set-output name=tools-url::latest"
|
echo "::set-output name=tools-url::latest"
|
||||||
|
|||||||
Generated
+1
-1
@@ -52,7 +52,7 @@ jobs:
|
|||||||
id: analysis
|
id: analysis
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: debug-artifacts
|
name: debug-artifacts-${{ matrix.os }}-${{ matrix.version }}
|
||||||
- shell: bash
|
- shell: bash
|
||||||
run: |
|
run: |
|
||||||
LANGUAGES="cpp csharp go java javascript python"
|
LANGUAGES="cpp csharp go java javascript python"
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
|
|
||||||
- name: Remove PR label
|
- name: Remove PR label
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
name: Update release branch
|
name: Update release branch
|
||||||
on:
|
on:
|
||||||
schedule:
|
|
||||||
- cron: 0 9 * * 1
|
|
||||||
repository_dispatch:
|
repository_dispatch:
|
||||||
# Example of how to trigger this:
|
# Example of how to trigger this:
|
||||||
# curl -H "Authorization: Bearer <token>" -X POST https://api.github.com/repos/github/codeql-action/dispatches -d '{"event_type":"update-release-branch"}'
|
# curl -H "Authorization: Bearer <token>" -X POST https://api.github.com/repos/github/codeql-action/dispatches -d '{"event_type":"update-release-branch"}'
|
||||||
|
|||||||
@@ -1,5 +1,27 @@
|
|||||||
# CodeQL Action and CodeQL Runner Changelog
|
# CodeQL Action and CodeQL Runner Changelog
|
||||||
|
|
||||||
|
## [UNRELEASED]
|
||||||
|
|
||||||
|
- The `analyze` and `upload-sarif` actions will now wait up to 2 minutes for processing to complete after they have uploaded the results so they can report any processing errors that occurred. This behavior can be disabled by setting the `wait-for-processing` action input to `"false"`.
|
||||||
|
|
||||||
|
|
||||||
|
## 1.0.26 - 10 Dec 2021
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.7.3. [#842](https://github.com/github/codeql-action/pull/842)
|
||||||
|
|
||||||
|
## 1.0.25 - 06 Dec 2021
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
|
## 1.0.24 - 23 Nov 2021
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.7.2. [#827](https://github.com/github/codeql-action/pull/827)
|
||||||
|
|
||||||
|
## 1.0.23 - 16 Nov 2021
|
||||||
|
|
||||||
|
- The `upload-sarif` action now allows multiple uploads in a single job, as long as they have different categories. [#801](https://github.com/github/codeql-action/pull/801)
|
||||||
|
- Update default CodeQL bundle version to 2.7.1. [#816](https://github.com/github/codeql-action/pull/816)
|
||||||
|
|
||||||
## 1.0.22 - 04 Nov 2021
|
## 1.0.22 - 04 Nov 2021
|
||||||
|
|
||||||
- The `init` step of the Action now supports `ram` and `threads` inputs to limit resource use of CodeQL extractors. These inputs also serve as defaults to the subsequent `analyze` step, which finalizes the database and executes queries. [#738](https://github.com/github/codeql-action/pull/738)
|
- The `init` step of the Action now supports `ram` and `threads` inputs to limit resource use of CodeQL extractors. These inputs also serve as defaults to the subsequent `analyze` step, which finalizes the database and executes queries. [#738](https://github.com/github/codeql-action/pull/738)
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ inputs:
|
|||||||
description: Whether to upload the resulting CodeQL database
|
description: Whether to upload the resulting CodeQL database
|
||||||
required: false
|
required: false
|
||||||
default: "true"
|
default: "true"
|
||||||
|
wait-for-processing:
|
||||||
|
description: If true, the Action will wait for the uploaded SARIF to be processed before completing.
|
||||||
|
required: true
|
||||||
|
default: "true"
|
||||||
token:
|
token:
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
matrix:
|
matrix:
|
||||||
|
|||||||
Generated
+6
-1
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.isAnalyzingDefaultBranch = exports.getRelativeScriptPath = exports.isRunningLocalAction = exports.sendStatusReport = exports.createStatusReportBase = exports.getRef = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRunID = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = exports.getCommitOid = exports.getToolCacheDirectory = exports.getTemporaryDirectory = exports.getOptionalInput = exports.getRequiredInput = void 0;
|
exports.sanitizeArifactName = exports.isAnalyzingDefaultBranch = exports.getRelativeScriptPath = exports.isRunningLocalAction = exports.sendStatusReport = exports.createStatusReportBase = exports.getRef = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRunID = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = exports.getCommitOid = exports.getToolCacheDirectory = exports.getTemporaryDirectory = exports.getOptionalInput = exports.getRequiredInput = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
@@ -98,6 +98,7 @@ const getCommitOid = async function (ref = "HEAD") {
|
|||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
core.info(`Failed to call git to get current commit. Continuing with data from environment: ${e}`);
|
core.info(`Failed to call git to get current commit. Continuing with data from environment: ${e}`);
|
||||||
|
core.info(e.stack || "NO STACK");
|
||||||
return (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
|
return (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -574,4 +575,8 @@ async function isAnalyzingDefaultBranch() {
|
|||||||
return currentRef === defaultBranch;
|
return currentRef === defaultBranch;
|
||||||
}
|
}
|
||||||
exports.isAnalyzingDefaultBranch = isAnalyzingDefaultBranch;
|
exports.isAnalyzingDefaultBranch = isAnalyzingDefaultBranch;
|
||||||
|
function sanitizeArifactName(name) {
|
||||||
|
return name.replace(/[^a-zA-Z0-9_\\-]+/g, "");
|
||||||
|
}
|
||||||
|
exports.sanitizeArifactName = sanitizeArifactName;
|
||||||
//# sourceMappingURL=actions-util.js.map
|
//# sourceMappingURL=actions-util.js.map
|
||||||
File diff suppressed because one or more lines are too long
Generated
+6
@@ -440,4 +440,10 @@ on: ["push"]
|
|||||||
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), false);
|
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
(0, ava_1.default)("sanitizeArifactName", (t) => {
|
||||||
|
t.deepEqual(actionsutil.sanitizeArifactName("hello-world_"), "hello-world_");
|
||||||
|
t.deepEqual(actionsutil.sanitizeArifactName("hello`world`"), "helloworld");
|
||||||
|
t.deepEqual(actionsutil.sanitizeArifactName("hello===123"), "hello123");
|
||||||
|
t.deepEqual(actionsutil.sanitizeArifactName("*m)a&n^y%i££n+v!a:l[i]d"), "manyinvalid");
|
||||||
|
});
|
||||||
//# sourceMappingURL=actions-util.test.js.map
|
//# sourceMappingURL=actions-util.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
Generated
+2
@@ -45,6 +45,7 @@ const util = __importStar(require("./util"));
|
|||||||
.resolves({});
|
.resolves({});
|
||||||
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
|
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
|
||||||
sinon.stub(configUtils, "getConfig").resolves({
|
sinon.stub(configUtils, "getConfig").resolves({
|
||||||
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
languages: [],
|
languages: [],
|
||||||
});
|
});
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
@@ -53,6 +54,7 @@ const util = __importStar(require("./util"));
|
|||||||
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
||||||
optionalInputStub.withArgs("cleanup-level").returns("none");
|
optionalInputStub.withArgs("cleanup-level").returns("none");
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
||||||
// When there are no action inputs for RAM and threads, the action uses
|
// When there are no action inputs for RAM and threads, the action uses
|
||||||
// environment variables (passed down from the init action) to set RAM and
|
// environment variables (passed down from the init action) to set RAM and
|
||||||
// threads usage.
|
// threads usage.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analyze-action-env.test.js","sourceRoot":"","sources":["../src/analyze-action-env.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,4DAA8C;AAC9C,mDAA+D;AAC/D,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,iCAAiC;AAEjC,IAAA,aAAI,EAAC,8DAA8D,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC/E,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,KAAK;aACF,IAAI,CAAC,WAAW,EAAE,wBAAwB,CAAC;aAC3C,QAAQ,CAAC,EAAkC,CAAC,CAAC;QAChD,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC3D,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC;YAC5C,SAAS,EAAE,EAAE;SACmB,CAAC,CAAC;QACpC,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACtE,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC1D,iBAAiB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC/D,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACtE,iBAAiB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC5D,IAAA,gCAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAEjC,uEAAuE;QACvE,0EAA0E;QAC1E,iBAAiB;QACjB,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;QAEnC,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC3D,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACzD,MAAM,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAElD,uEAAuE;QACvE,oEAAoE;QACpE,4EAA4E;QAC5E,wEAAwE;QACxE,MAAM,aAAa,CAAC,UAAU,CAAC;QAE/B,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC/D,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
{"version":3,"file":"analyze-action-env.test.js","sourceRoot":"","sources":["../src/analyze-action-env.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,4DAA8C;AAC9C,mDAIyB;AACzB,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,iCAAiC;AAEjC,IAAA,aAAI,EAAC,8DAA8D,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC/E,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,KAAK;aACF,IAAI,CAAC,WAAW,EAAE,wBAAwB,CAAC;aAC3C,QAAQ,CAAC,EAAkC,CAAC,CAAC;QAChD,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC3D,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC;YAC5C,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YAClD,SAAS,EAAE,EAAE;SACmB,CAAC,CAAC;QACpC,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACtE,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC1D,iBAAiB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC/D,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACtE,iBAAiB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC5D,IAAA,gCAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,IAAA,0CAA0B,EAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAEpC,uEAAuE;QACvE,0EAA0E;QAC1E,iBAAiB;QACjB,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;QAEnC,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC3D,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACzD,MAAM,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAElD,uEAAuE;QACvE,oEAAoE;QACpE,4EAA4E;QAC5E,wEAAwE;QACxE,MAAM,aAAa,CAAC,UAAU,CAAC;QAE/B,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC/D,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
Generated
+2
@@ -45,6 +45,7 @@ const util = __importStar(require("./util"));
|
|||||||
.resolves({});
|
.resolves({});
|
||||||
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
|
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
|
||||||
sinon.stub(configUtils, "getConfig").resolves({
|
sinon.stub(configUtils, "getConfig").resolves({
|
||||||
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
languages: [],
|
languages: [],
|
||||||
});
|
});
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
@@ -53,6 +54,7 @@ const util = __importStar(require("./util"));
|
|||||||
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
||||||
optionalInputStub.withArgs("cleanup-level").returns("none");
|
optionalInputStub.withArgs("cleanup-level").returns("none");
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
||||||
process.env["CODEQL_THREADS"] = "1";
|
process.env["CODEQL_THREADS"] = "1";
|
||||||
process.env["CODEQL_RAM"] = "4992";
|
process.env["CODEQL_RAM"] = "4992";
|
||||||
// Action inputs have precedence over environment variables.
|
// Action inputs have precedence over environment variables.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analyze-action-input.test.js","sourceRoot":"","sources":["../src/analyze-action-input.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,4DAA8C;AAC9C,mDAA+D;AAC/D,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,iCAAiC;AAEjC,IAAA,aAAI,EAAC,sDAAsD,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACvE,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,KAAK;aACF,IAAI,CAAC,WAAW,EAAE,wBAAwB,CAAC;aAC3C,QAAQ,CAAC,EAAkC,CAAC,CAAC;QAChD,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC3D,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC;YAC5C,SAAS,EAAE,EAAE;SACmB,CAAC,CAAC;QACpC,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACtE,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC1D,iBAAiB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC/D,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACtE,iBAAiB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC5D,IAAA,gCAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAEjC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,GAAG,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;QAEnC,4DAA4D;QAC5D,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACpD,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAElD,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC3D,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACzD,MAAM,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAElD,uEAAuE;QACvE,oEAAoE;QACpE,4EAA4E;QAC5E,wEAAwE;QACxE,MAAM,aAAa,CAAC,UAAU,CAAC;QAE/B,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC/D,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
{"version":3,"file":"analyze-action-input.test.js","sourceRoot":"","sources":["../src/analyze-action-input.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,4DAA8C;AAC9C,mDAIyB;AACzB,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,iCAAiC;AAEjC,IAAA,aAAI,EAAC,sDAAsD,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACvE,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,KAAK;aACF,IAAI,CAAC,WAAW,EAAE,wBAAwB,CAAC;aAC3C,QAAQ,CAAC,EAAkC,CAAC,CAAC;QAChD,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC3D,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC;YAC5C,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YAClD,SAAS,EAAE,EAAE;SACmB,CAAC,CAAC;QACpC,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACtE,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC1D,iBAAiB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC/D,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACtE,iBAAiB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC5D,IAAA,gCAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,IAAA,0CAA0B,EAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAEpC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,GAAG,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;QAEnC,4DAA4D;QAC5D,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACpD,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAElD,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC3D,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACzD,MAAM,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAElD,uEAAuE;QACvE,oEAAoE;QACpE,4EAA4E;QAC5E,wEAAwE;QACxE,MAAM,aAAa,CAAC,UAAU,CAAC;QAE/B,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC/D,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
Generated
+36
-13
@@ -29,6 +29,7 @@ const analyze_1 = require("./analyze");
|
|||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const config_utils_1 = require("./config-utils");
|
const config_utils_1 = require("./config-utils");
|
||||||
const database_upload_1 = require("./database-upload");
|
const database_upload_1 = require("./database-upload");
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const repository_1 = require("./repository");
|
const repository_1 = require("./repository");
|
||||||
const upload_lib = __importStar(require("./upload-lib"));
|
const upload_lib = __importStar(require("./upload-lib"));
|
||||||
@@ -50,7 +51,7 @@ async function sendStatusReport(startedAt, stats, error) {
|
|||||||
exports.sendStatusReport = sendStatusReport;
|
exports.sendStatusReport = sendStatusReport;
|
||||||
async function run() {
|
async function run() {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
let uploadStats = undefined;
|
let uploadResult = undefined;
|
||||||
let runStats = undefined;
|
let runStats = undefined;
|
||||||
let config = undefined;
|
let config = undefined;
|
||||||
util.initializeEnvironment(util.Mode.actions, pkg.version);
|
util.initializeEnvironment(util.Mode.actions, pkg.version);
|
||||||
@@ -71,6 +72,9 @@ async function run() {
|
|||||||
const outputDir = actionsUtil.getRequiredInput("output");
|
const outputDir = actionsUtil.getRequiredInput("output");
|
||||||
const threads = util.getThreadsFlag(actionsUtil.getOptionalInput("threads") || process.env["CODEQL_THREADS"], logger);
|
const threads = util.getThreadsFlag(actionsUtil.getOptionalInput("threads") || process.env["CODEQL_THREADS"], logger);
|
||||||
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]);
|
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]);
|
||||||
|
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
||||||
|
const featureFlags = new feature_flags_1.GitHubFeatureFlags(config.gitHubVersion, apiDetails, repositoryNwo, logger);
|
||||||
|
void featureFlags.preloadFeatureFlags();
|
||||||
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger);
|
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger);
|
||||||
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
||||||
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger);
|
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger);
|
||||||
@@ -105,19 +109,16 @@ async function run() {
|
|||||||
}
|
}
|
||||||
core.setOutput("db-locations", dbLocations);
|
core.setOutput("db-locations", dbLocations);
|
||||||
if (runStats && actionsUtil.getRequiredInput("upload") === "true") {
|
if (runStats && actionsUtil.getRequiredInput("upload") === "true") {
|
||||||
uploadStats = await upload_lib.uploadFromActions(outputDir, config.gitHubVersion, apiDetails, logger);
|
uploadResult = await upload_lib.uploadFromActions(outputDir, config.gitHubVersion, apiDetails, logger);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.info("Not uploading results");
|
logger.info("Not uploading results");
|
||||||
}
|
}
|
||||||
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
// Possibly upload the database bundles for remote queries
|
||||||
await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, apiDetails, logger); // Possibly upload the database bundles for remote queries
|
await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, featureFlags, apiDetails, logger);
|
||||||
if (config.debugMode) {
|
if (uploadResult !== undefined &&
|
||||||
// Upload the database bundles as an Actions artifact for debugging
|
actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
||||||
const toUpload = [];
|
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)());
|
||||||
for (const language of config.languages)
|
|
||||||
toUpload.push(await (0, util_1.bundleDb)(config, language, codeql));
|
|
||||||
await uploadDebugArtifacts(toUpload, config.dbLocation);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (origError) {
|
catch (origError) {
|
||||||
@@ -134,6 +135,19 @@ async function run() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
if (config !== undefined && config.debugMode) {
|
||||||
|
try {
|
||||||
|
// Upload the database bundles as an Actions artifact for debugging
|
||||||
|
const toUpload = [];
|
||||||
|
for (const language of config.languages) {
|
||||||
|
toUpload.push(await (0, util_1.bundleDb)(config, language, await (0, codeql_1.getCodeQL)(config.codeQLCmd)));
|
||||||
|
}
|
||||||
|
await uploadDebugArtifacts(toUpload, config.dbLocation);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.log(`Failed to upload database debug bundles: ${error}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (core.isDebug() && config !== undefined) {
|
if (core.isDebug() && config !== undefined) {
|
||||||
core.info("Debug mode is on. Printing CodeQL debug logs...");
|
core.info("Debug mode is on. Printing CodeQL debug logs...");
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
@@ -156,8 +170,11 @@ async function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (runStats && uploadStats) {
|
if (runStats && uploadResult) {
|
||||||
await sendStatusReport(startedAt, { ...runStats, ...uploadStats });
|
await sendStatusReport(startedAt, {
|
||||||
|
...runStats,
|
||||||
|
...uploadResult.statusReport,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if (runStats) {
|
else if (runStats) {
|
||||||
await sendStatusReport(startedAt, { ...runStats });
|
await sendStatusReport(startedAt, { ...runStats });
|
||||||
@@ -167,7 +184,13 @@ async function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function uploadDebugArtifacts(toUpload, rootDir) {
|
async function uploadDebugArtifacts(toUpload, rootDir) {
|
||||||
await artifact.create().uploadArtifact(util_1.DEBUG_ARTIFACT_NAME, toUpload.map((file) => path.normalize(file)), path.normalize(rootDir));
|
let suffix = "";
|
||||||
|
const matrix = actionsUtil.getRequiredInput("matrix");
|
||||||
|
if (matrix !== undefined && matrix !== "null") {
|
||||||
|
for (const entry of Object.entries(JSON.parse(matrix)).sort())
|
||||||
|
suffix += `-${entry[1]}`;
|
||||||
|
}
|
||||||
|
await artifact.create().uploadArtifact(actionsUtil.sanitizeArifactName(`${util_1.DEBUG_ARTIFACT_NAME}${suffix}`), toUpload.map((file) => path.normalize(file)), path.normalize(rootDir));
|
||||||
}
|
}
|
||||||
function listFolder(dir) {
|
function listFolder(dir) {
|
||||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
|||||||
{ "maximumVersion": "3.3", "minimumVersion": "3.0" }
|
{ "maximumVersion": "3.4", "minimumVersion": "3.0" }
|
||||||
|
|||||||
Generated
+2
-1
@@ -37,6 +37,7 @@ const languages_1 = require("./languages");
|
|||||||
const toolcache = __importStar(require("./toolcache"));
|
const toolcache = __importStar(require("./toolcache"));
|
||||||
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
|
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
|
const util_1 = require("./util");
|
||||||
class CommandInvocationError extends Error {
|
class CommandInvocationError extends Error {
|
||||||
constructor(cmd, args, exitCode, error) {
|
constructor(cmd, args, exitCode, error) {
|
||||||
super(`Failure invoking ${cmd} with arguments ${args}.\n
|
super(`Failure invoking ${cmd} with arguments ${args}.\n
|
||||||
@@ -215,7 +216,7 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant
|
|||||||
// specified explicitly (in which case we always honor it).
|
// specified explicitly (in which case we always honor it).
|
||||||
if (!codeqlFolder && !codeqlURL && !forceLatest) {
|
if (!codeqlFolder && !codeqlURL && !forceLatest) {
|
||||||
const codeqlVersions = toolcache.findAllVersions("CodeQL", toolCacheDir, logger);
|
const codeqlVersions = toolcache.findAllVersions("CodeQL", toolCacheDir, logger);
|
||||||
if (codeqlVersions.length === 1) {
|
if (codeqlVersions.length === 1 && (0, util_1.isGoodVersion)(codeqlVersions[0])) {
|
||||||
const tmpCodeqlFolder = toolcache.find("CodeQL", codeqlVersions[0], toolCacheDir, logger);
|
const tmpCodeqlFolder = toolcache.find("CodeQL", codeqlVersions[0], toolCacheDir, logger);
|
||||||
if (fs.existsSync(path.join(tmpCodeqlFolder, "pinned-version"))) {
|
if (fs.existsSync(path.join(tmpCodeqlFolder, "pinned-version"))) {
|
||||||
logger.debug(`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`);
|
logger.debug(`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`);
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+23
-16
@@ -24,9 +24,10 @@ const fs = __importStar(require("fs"));
|
|||||||
const actionsUtil = __importStar(require("./actions-util"));
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
const api_client_1 = require("./api-client");
|
const api_client_1 = require("./api-client");
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
async function uploadDatabases(repositoryNwo, config, apiDetails, logger) {
|
async function uploadDatabases(repositoryNwo, config, featureFlags, apiDetails, logger) {
|
||||||
if (actionsUtil.getRequiredInput("upload-database") !== "true") {
|
if (actionsUtil.getRequiredInput("upload-database") !== "true") {
|
||||||
logger.debug("Database upload disabled in workflow. Skipping upload.");
|
logger.debug("Database upload disabled in workflow. Skipping upload.");
|
||||||
return;
|
return;
|
||||||
@@ -41,34 +42,40 @@ async function uploadDatabases(repositoryNwo, config, apiDetails, logger) {
|
|||||||
logger.debug("Not analyzing default branch. Skipping upload.");
|
logger.debug("Not analyzing default branch. Skipping upload.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const client = (0, api_client_1.getApiClient)(apiDetails);
|
if (!(await featureFlags.getValue(feature_flags_1.FeatureFlag.DatabaseUploadsEnabled))) {
|
||||||
try {
|
|
||||||
await client.request("GET /repos/:owner/:repo/code-scanning/codeql/databases", {
|
|
||||||
owner: repositoryNwo.owner,
|
|
||||||
repo: repositoryNwo.repo,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
if (util.isHTTPError(e) && e.status === 404) {
|
|
||||||
logger.debug("Repository is not opted in to database uploads. Skipping upload.");
|
logger.debug("Repository is not opted in to database uploads. Skipping upload.");
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(e);
|
|
||||||
logger.info(`Skipping database upload due to unknown error: ${e}`);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const client = (0, api_client_1.getApiClient)(apiDetails);
|
||||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
|
const useUploadDomain = await featureFlags.getValue(feature_flags_1.FeatureFlag.UploadsDomainEnabled);
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
// Upload the database bundle
|
// Upload the database bundle.
|
||||||
|
// Although we are uploading arbitrary file contents to the API, it's worth
|
||||||
|
// noting that it's the API's job to validate that the contents is acceptable.
|
||||||
|
// This API method is available to anyone with write access to the repo.
|
||||||
const payload = fs.readFileSync(await (0, util_1.bundleDb)(config, language, codeql));
|
const payload = fs.readFileSync(await (0, util_1.bundleDb)(config, language, codeql));
|
||||||
try {
|
try {
|
||||||
|
if (useUploadDomain) {
|
||||||
|
await client.request(`POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name`, {
|
||||||
|
owner: repositoryNwo.owner,
|
||||||
|
repo: repositoryNwo.repo,
|
||||||
|
language,
|
||||||
|
name: `${language}-database`,
|
||||||
|
data: payload,
|
||||||
|
headers: {
|
||||||
|
authorization: `token ${apiDetails.auth}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
await client.request(`PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language`, {
|
await client.request(`PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language`, {
|
||||||
owner: repositoryNwo.owner,
|
owner: repositoryNwo.owner,
|
||||||
repo: repositoryNwo.repo,
|
repo: repositoryNwo.repo,
|
||||||
language,
|
language,
|
||||||
data: payload,
|
data: payload,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
logger.debug(`Successfully uploaded database for ${language}`);
|
logger.debug(`Successfully uploaded database for ${language}`);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"database-upload.js","sourceRoot":"","sources":["../src/database-upload.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,4DAA8C;AAC9C,6CAA8D;AAC9D,qCAAqC;AAIrC,6CAA+B;AAC/B,iCAAkC;AAE3B,KAAK,UAAU,eAAe,CACnC,aAA4B,EAC5B,MAAc,EACd,UAA4B,EAC5B,MAAc;IAEd,IAAI,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,KAAK,MAAM,EAAE;QAC9D,MAAM,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACvE,OAAO;KACR;IAED,iDAAiD;IACjD,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;QAC3D,MAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACjE,OAAO;KACR;IAED,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,wBAAwB,EAAE,CAAC,EAAE;QACnD,4EAA4E;QAC5E,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAC/D,OAAO;KACR;IAED,MAAM,MAAM,GAAG,IAAA,yBAAY,EAAC,UAAU,CAAC,CAAC;IACxC,IAAI;QACF,MAAM,MAAM,CAAC,OAAO,CAClB,wDAAwD,EACxD;YACE,KAAK,EAAE,aAAa,CAAC,KAAK;YAC1B,IAAI,EAAE,aAAa,CAAC,IAAI;SACzB,CACF,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,EAAE;YAC3C,MAAM,CAAC,KAAK,CACV,kEAAkE,CACnE,CAAC;SACH;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,kDAAkD,CAAC,EAAE,CAAC,CAAC;SACpE;QACD,OAAO;KACR;IAED,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE;QACvC,6BAA6B;QAC7B,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,IAAA,eAAQ,EAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QAC1E,IAAI;YACF,MAAM,MAAM,CAAC,OAAO,CAClB,kEAAkE,EAClE;gBACE,KAAK,EAAE,aAAa,CAAC,KAAK;gBAC1B,IAAI,EAAE,aAAa,CAAC,IAAI;gBACxB,QAAQ;gBACR,IAAI,EAAE,OAAO;aACd,CACF,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,sCAAsC,QAAQ,EAAE,CAAC,CAAC;SAChE;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACf,4CAA4C;YAC5C,MAAM,CAAC,OAAO,CAAC,iCAAiC,QAAQ,KAAK,CAAC,EAAE,CAAC,CAAC;SACnE;KACF;AACH,CAAC;AAjED,0CAiEC"}
|
{"version":3,"file":"database-upload.js","sourceRoot":"","sources":["../src/database-upload.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,4DAA8C;AAC9C,6CAA8D;AAC9D,qCAAqC;AAErC,mDAA4D;AAG5D,6CAA+B;AAC/B,iCAAkC;AAE3B,KAAK,UAAU,eAAe,CACnC,aAA4B,EAC5B,MAAc,EACd,YAA0B,EAC1B,UAA4B,EAC5B,MAAc;IAEd,IAAI,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,KAAK,MAAM,EAAE;QAC9D,MAAM,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACvE,OAAO;KACR;IAED,iDAAiD;IACjD,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;QAC3D,MAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACjE,OAAO;KACR;IAED,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,wBAAwB,EAAE,CAAC,EAAE;QACnD,4EAA4E;QAC5E,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAC/D,OAAO;KACR;IAED,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,QAAQ,CAAC,2BAAW,CAAC,sBAAsB,CAAC,CAAC,EAAE;QACtE,MAAM,CAAC,KAAK,CACV,kEAAkE,CACnE,CAAC;QACF,OAAO;KACR;IAED,MAAM,MAAM,GAAG,IAAA,yBAAY,EAAC,UAAU,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjD,MAAM,eAAe,GAAG,MAAM,YAAY,CAAC,QAAQ,CACjD,2BAAW,CAAC,oBAAoB,CACjC,CAAC;IAEF,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE;QACvC,8BAA8B;QAC9B,2EAA2E;QAC3E,8EAA8E;QAC9E,wEAAwE;QACxE,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,IAAA,eAAQ,EAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QAC1E,IAAI;YACF,IAAI,eAAe,EAAE;gBACnB,MAAM,MAAM,CAAC,OAAO,CAClB,wGAAwG,EACxG;oBACE,KAAK,EAAE,aAAa,CAAC,KAAK;oBAC1B,IAAI,EAAE,aAAa,CAAC,IAAI;oBACxB,QAAQ;oBACR,IAAI,EAAE,GAAG,QAAQ,WAAW;oBAC5B,IAAI,EAAE,OAAO;oBACb,OAAO,EAAE;wBACP,aAAa,EAAE,SAAS,UAAU,CAAC,IAAI,EAAE;qBAC1C;iBACF,CACF,CAAC;aACH;iBAAM;gBACL,MAAM,MAAM,CAAC,OAAO,CAClB,kEAAkE,EAClE;oBACE,KAAK,EAAE,aAAa,CAAC,KAAK;oBAC1B,IAAI,EAAE,aAAa,CAAC,IAAI;oBACxB,QAAQ;oBACR,IAAI,EAAE,OAAO;iBACd,CACF,CAAC;aACH;YACD,MAAM,CAAC,KAAK,CAAC,sCAAsC,QAAQ,EAAE,CAAC,CAAC;SAChE;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACf,4CAA4C;YAC5C,MAAM,CAAC,OAAO,CAAC,iCAAiC,QAAQ,KAAK,CAAC,EAAE,CAAC,CAAC;SACnE;KACF;AACH,CAAC;AA5ED,0CA4EC"}
|
||||||
Generated
+44
-67
@@ -30,6 +30,7 @@ const actionsUtil = __importStar(require("./actions-util"));
|
|||||||
const apiClient = __importStar(require("./api-client"));
|
const apiClient = __importStar(require("./api-client"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const database_upload_1 = require("./database-upload");
|
const database_upload_1 = require("./database-upload");
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
@@ -37,6 +38,10 @@ const util_1 = require("./util");
|
|||||||
ava_1.default.beforeEach(() => {
|
ava_1.default.beforeEach(() => {
|
||||||
(0, util_1.initializeEnvironment)(util_1.Mode.actions, "1.2.3");
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, "1.2.3");
|
||||||
});
|
});
|
||||||
|
const uploadToUploadsDomainFlags = (0, feature_flags_1.createFeatureFlags)([
|
||||||
|
feature_flags_1.FeatureFlag.DatabaseUploadsEnabled,
|
||||||
|
feature_flags_1.FeatureFlag.UploadsDomainEnabled,
|
||||||
|
]);
|
||||||
const testRepoName = { owner: "github", repo: "example" };
|
const testRepoName = { owner: "github", repo: "example" };
|
||||||
const testApiDetails = {
|
const testApiDetails = {
|
||||||
auth: "1234",
|
auth: "1234",
|
||||||
@@ -58,49 +63,20 @@ function getTestConfig(tmpDir) {
|
|||||||
debugMode: false,
|
debugMode: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function getRecordingLogger(messages) {
|
async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
|
||||||
return {
|
|
||||||
debug: (message) => {
|
|
||||||
messages.push({ type: "debug", message });
|
|
||||||
console.debug(message);
|
|
||||||
},
|
|
||||||
info: (message) => {
|
|
||||||
messages.push({ type: "info", message });
|
|
||||||
console.info(message);
|
|
||||||
},
|
|
||||||
warning: (message) => {
|
|
||||||
messages.push({ type: "warning", message });
|
|
||||||
console.warn(message);
|
|
||||||
},
|
|
||||||
error: (message) => {
|
|
||||||
messages.push({ type: "error", message });
|
|
||||||
console.error(message);
|
|
||||||
},
|
|
||||||
isDebug: () => true,
|
|
||||||
startGroup: () => undefined,
|
|
||||||
endGroup: () => undefined,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
function mockHttpRequests(optInStatusCode, databaseUploadStatusCode) {
|
|
||||||
// Passing an auth token is required, so we just use a dummy value
|
// Passing an auth token is required, so we just use a dummy value
|
||||||
const client = github.getOctokit("123");
|
const client = github.getOctokit("123");
|
||||||
const requestSpy = sinon.stub(client, "request");
|
const requestSpy = sinon.stub(client, "request");
|
||||||
const optInSpy = requestSpy.withArgs("GET /repos/:owner/:repo/code-scanning/codeql/databases");
|
const url = (await featureFlags.getValue(feature_flags_1.FeatureFlag.UploadsDomainEnabled))
|
||||||
if (optInStatusCode < 300) {
|
? "POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name"
|
||||||
optInSpy.resolves(undefined);
|
: "PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language";
|
||||||
}
|
const databaseUploadSpy = requestSpy.withArgs(url);
|
||||||
else {
|
|
||||||
optInSpy.throws(new util_1.HTTPError("some error message", optInStatusCode));
|
|
||||||
}
|
|
||||||
if (databaseUploadStatusCode !== undefined) {
|
|
||||||
const databaseUploadSpy = requestSpy.withArgs("PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language");
|
|
||||||
if (databaseUploadStatusCode < 300) {
|
if (databaseUploadStatusCode < 300) {
|
||||||
databaseUploadSpy.resolves(undefined);
|
databaseUploadSpy.resolves(undefined);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
databaseUploadSpy.throws(new util_1.HTTPError("some error message", databaseUploadStatusCode));
|
databaseUploadSpy.throws(new util_1.HTTPError("some error message", databaseUploadStatusCode));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
sinon.stub(apiClient, "getApiClient").value(() => client);
|
sinon.stub(apiClient, "getApiClient").value(() => client);
|
||||||
}
|
}
|
||||||
(0, ava_1.default)("Abort database upload if 'upload-database' input set to false", async (t) => {
|
(0, ava_1.default)("Abort database upload if 'upload-database' input set to false", async (t) => {
|
||||||
@@ -112,7 +88,7 @@ function mockHttpRequests(optInStatusCode, databaseUploadStatusCode) {
|
|||||||
.returns("false");
|
.returns("false");
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
v.message === "Database upload disabled in workflow. Skipping upload.") !== undefined);
|
v.message === "Database upload disabled in workflow. Skipping upload.") !== undefined);
|
||||||
});
|
});
|
||||||
@@ -128,7 +104,7 @@ function mockHttpRequests(optInStatusCode, databaseUploadStatusCode) {
|
|||||||
const config = getTestConfig(tmpDir);
|
const config = getTestConfig(tmpDir);
|
||||||
config.gitHubVersion = { type: util_1.GitHubVariant.GHES, version: "3.0" };
|
config.gitHubVersion = { type: util_1.GitHubVariant.GHES, version: "3.0" };
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, config, testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, config, (0, feature_flags_1.createFeatureFlags)([]), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
v.message === "Not running against github.com. Skipping upload.") !== undefined);
|
v.message === "Not running against github.com. Skipping upload.") !== undefined);
|
||||||
});
|
});
|
||||||
@@ -144,7 +120,7 @@ function mockHttpRequests(optInStatusCode, databaseUploadStatusCode) {
|
|||||||
const config = getTestConfig(tmpDir);
|
const config = getTestConfig(tmpDir);
|
||||||
config.gitHubVersion = { type: util_1.GitHubVariant.GHAE };
|
config.gitHubVersion = { type: util_1.GitHubVariant.GHAE };
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, config, testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, config, (0, feature_flags_1.createFeatureFlags)([]), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
v.message === "Not running against github.com. Skipping upload.") !== undefined);
|
v.message === "Not running against github.com. Skipping upload.") !== undefined);
|
||||||
});
|
});
|
||||||
@@ -158,12 +134,12 @@ function mockHttpRequests(optInStatusCode, databaseUploadStatusCode) {
|
|||||||
.returns("true");
|
.returns("true");
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
v.message === "Not analyzing default branch. Skipping upload.") !== undefined);
|
v.message === "Not analyzing default branch. Skipping upload.") !== undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Abort database upload if opt-in request returns 404", async (t) => {
|
(0, ava_1.default)("Abort database upload if feature flag is disabled", async (t) => {
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
sinon
|
sinon
|
||||||
@@ -171,40 +147,18 @@ function mockHttpRequests(optInStatusCode, databaseUploadStatusCode) {
|
|||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
mockHttpRequests(404);
|
|
||||||
(0, codeql_1.setCodeQL)({
|
(0, codeql_1.setCodeQL)({
|
||||||
async databaseBundle() {
|
async databaseBundle() {
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.UploadsDomainEnabled]), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
v.message ===
|
v.message ===
|
||||||
"Repository is not opted in to database uploads. Skipping upload.") !== undefined);
|
"Repository is not opted in to database uploads. Skipping upload.") !== undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Abort database upload if opt-in request fails with something other than 404", async (t) => {
|
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
|
||||||
sinon
|
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
|
||||||
.withArgs("upload-database")
|
|
||||||
.returns("true");
|
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
|
||||||
mockHttpRequests(500);
|
|
||||||
(0, codeql_1.setCodeQL)({
|
|
||||||
async databaseBundle() {
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const loggedMessages = [];
|
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
|
||||||
t.assert(loggedMessages.find((v) => v.type === "info" &&
|
|
||||||
v.message ===
|
|
||||||
"Skipping database upload due to unknown error: Error: some error message") !== undefined);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
(0, ava_1.default)("Don't crash if uploading a database fails", async (t) => {
|
(0, ava_1.default)("Don't crash if uploading a database fails", async (t) => {
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
@@ -213,20 +167,23 @@ function mockHttpRequests(optInStatusCode, databaseUploadStatusCode) {
|
|||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
mockHttpRequests(204, 500);
|
const featureFlags = (0, feature_flags_1.createFeatureFlags)([
|
||||||
|
feature_flags_1.FeatureFlag.DatabaseUploadsEnabled,
|
||||||
|
]);
|
||||||
|
await mockHttpRequests(featureFlags, 500);
|
||||||
(0, codeql_1.setCodeQL)({
|
(0, codeql_1.setCodeQL)({
|
||||||
async databaseBundle(_, outputFilePath) {
|
async databaseBundle(_, outputFilePath) {
|
||||||
fs.writeFileSync(outputFilePath, "");
|
fs.writeFileSync(outputFilePath, "");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), featureFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "warning" &&
|
t.assert(loggedMessages.find((v) => v.type === "warning" &&
|
||||||
v.message ===
|
v.message ===
|
||||||
"Failed to upload database for javascript: Error: some error message") !== undefined);
|
"Failed to upload database for javascript: Error: some error message") !== undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Successfully uploading a database", async (t) => {
|
(0, ava_1.default)("Successfully uploading a database to api.github.com", async (t) => {
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
sinon
|
sinon
|
||||||
@@ -234,14 +191,34 @@ function mockHttpRequests(optInStatusCode, databaseUploadStatusCode) {
|
|||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
mockHttpRequests(204, 201);
|
await mockHttpRequests(uploadToUploadsDomainFlags, 201);
|
||||||
(0, codeql_1.setCodeQL)({
|
(0, codeql_1.setCodeQL)({
|
||||||
async databaseBundle(_, outputFilePath) {
|
async databaseBundle(_, outputFilePath) {
|
||||||
fs.writeFileSync(outputFilePath, "");
|
fs.writeFileSync(outputFilePath, "");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
|
v.message === "Successfully uploaded database for javascript") !== undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
(0, ava_1.default)("Successfully uploading a database to uploads.github.com", async (t) => {
|
||||||
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
|
sinon
|
||||||
|
.stub(actionsUtil, "getRequiredInput")
|
||||||
|
.withArgs("upload-database")
|
||||||
|
.returns("true");
|
||||||
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
|
await mockHttpRequests(uploadToUploadsDomainFlags, 201);
|
||||||
|
(0, codeql_1.setCodeQL)({
|
||||||
|
async databaseBundle(_, outputFilePath) {
|
||||||
|
fs.writeFileSync(outputFilePath, "");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const loggedMessages = [];
|
||||||
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
v.message === "Successfully uploaded database for javascript") !== undefined);
|
v.message === "Successfully uploaded database for javascript") !== undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-20211025"
|
"bundleVersion": "codeql-bundle-20211208"
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+91
@@ -0,0 +1,91 @@
|
|||||||
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.createFeatureFlags = exports.GitHubFeatureFlags = exports.FeatureFlag = void 0;
|
||||||
|
const api_client_1 = require("./api-client");
|
||||||
|
const util = __importStar(require("./util"));
|
||||||
|
var FeatureFlag;
|
||||||
|
(function (FeatureFlag) {
|
||||||
|
FeatureFlag["DatabaseUploadsEnabled"] = "database_uploads_enabled";
|
||||||
|
FeatureFlag["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
||||||
|
FeatureFlag["UploadsDomainEnabled"] = "uploads_domain_enabled";
|
||||||
|
})(FeatureFlag = exports.FeatureFlag || (exports.FeatureFlag = {}));
|
||||||
|
class GitHubFeatureFlags {
|
||||||
|
constructor(gitHubVersion, apiDetails, repositoryNwo, logger) {
|
||||||
|
this.gitHubVersion = gitHubVersion;
|
||||||
|
this.apiDetails = apiDetails;
|
||||||
|
this.repositoryNwo = repositoryNwo;
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
async getValue(flag) {
|
||||||
|
const response = (await this.getApiResponse())[flag];
|
||||||
|
if (response === undefined) {
|
||||||
|
this.logger.debug(`Feature flag '${flag}' undefined in API response, considering it disabled.`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
async preloadFeatureFlags() {
|
||||||
|
await this.getApiResponse();
|
||||||
|
}
|
||||||
|
async getApiResponse() {
|
||||||
|
const loadApiResponse = async () => {
|
||||||
|
// Do nothing when not running against github.com
|
||||||
|
if (this.gitHubVersion.type !== util.GitHubVariant.DOTCOM) {
|
||||||
|
this.logger.debug("Not running against github.com. Disabling all feature flags.");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
const client = (0, api_client_1.getApiClient)(this.apiDetails);
|
||||||
|
try {
|
||||||
|
const response = await client.request("GET /repos/:owner/:repo/code-scanning/codeql-action/features", {
|
||||||
|
owner: this.repositoryNwo.owner,
|
||||||
|
repo: this.repositoryNwo.repo,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// Some feature flags, such as `ml_powered_queries_enabled` affect the produced alerts.
|
||||||
|
// Considering these feature flags disabled in the event of a transient error could
|
||||||
|
// therefore lead to alert churn. As a result, we crash if we cannot determine the value of
|
||||||
|
// the feature flags.
|
||||||
|
throw new Error(`Encountered an error while trying to load feature flags: ${e}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const apiResponse = this.cachedApiResponse || (await loadApiResponse());
|
||||||
|
this.cachedApiResponse = apiResponse;
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.GitHubFeatureFlags = GitHubFeatureFlags;
|
||||||
|
/**
|
||||||
|
* Create a feature flags instance with the specified set of enabled flags.
|
||||||
|
*
|
||||||
|
* This should be only used within tests.
|
||||||
|
*/
|
||||||
|
function createFeatureFlags(enabledFlags) {
|
||||||
|
return {
|
||||||
|
getValue: async (flag) => {
|
||||||
|
return enabledFlags.includes(flag);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.createFeatureFlags = createFeatureFlags;
|
||||||
|
//# sourceMappingURL=feature-flags.js.map
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"feature-flags.js","sourceRoot":"","sources":["../src/feature-flags.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8D;AAG9D,6CAA+B;AAM/B,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,kEAAmD,CAAA;IACnD,qEAAsD,CAAA;IACtD,8DAA+C,CAAA;AACjD,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAUD,MAAa,kBAAkB;IAG7B,YACU,aAAiC,EACjC,UAA4B,EAC5B,aAA4B,EAC5B,MAAc;QAHd,kBAAa,GAAb,aAAa,CAAoB;QACjC,eAAU,GAAV,UAAU,CAAkB;QAC5B,kBAAa,GAAb,aAAa,CAAe;QAC5B,WAAM,GAAN,MAAM,CAAQ;IACrB,CAAC;IAEJ,KAAK,CAAC,QAAQ,CAAC,IAAiB;QAC9B,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,iBAAiB,IAAI,uDAAuD,CAC7E,CAAC;YACF,OAAO,KAAK,CAAC;SACd;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,mBAAmB;QACvB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAC9B,CAAC;IAEO,KAAK,CAAC,cAAc;QAC1B,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE;YACjC,iDAAiD;YACjD,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;gBACzD,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,8DAA8D,CAC/D,CAAC;gBACF,OAAO,EAAE,CAAC;aACX;YACD,MAAM,MAAM,GAAG,IAAA,yBAAY,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC7C,IAAI;gBACF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CACnC,8DAA8D,EAC9D;oBACE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK;oBAC/B,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI;iBAC9B,CACF,CAAC;gBACF,OAAO,QAAQ,CAAC,IAAI,CAAC;aACtB;YAAC,OAAO,CAAC,EAAE;gBACV,uFAAuF;gBACvF,mFAAmF;gBACnF,2FAA2F;gBAC3F,qBAAqB;gBACrB,MAAM,IAAI,KAAK,CACb,4DAA4D,CAAC,EAAE,CAChE,CAAC;aACH;QACH,CAAC,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,IAAI,CAAC,MAAM,eAAe,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,iBAAiB,GAAG,WAAW,CAAC;QACrC,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AA3DD,gDA2DC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,YAA2B;IAC5D,OAAO;QACL,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YACvB,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;KACF,CAAC;AACJ,CAAC;AAND,gDAMC"}
|
||||||
Generated
+98
@@ -0,0 +1,98 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const ava_1 = __importDefault(require("ava"));
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
|
const logging_1 = require("./logging");
|
||||||
|
const repository_1 = require("./repository");
|
||||||
|
const testing_utils_1 = require("./testing-utils");
|
||||||
|
const util_1 = require("./util");
|
||||||
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
|
ava_1.default.beforeEach(() => {
|
||||||
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, "1.2.3");
|
||||||
|
});
|
||||||
|
const testApiDetails = {
|
||||||
|
auth: "1234",
|
||||||
|
url: "https://github.com",
|
||||||
|
};
|
||||||
|
const testRepositoryNwo = (0, repository_1.parseRepositoryNwo)("github/example");
|
||||||
|
const ALL_FEATURE_FLAGS_DISABLED_VARIANTS = [
|
||||||
|
{
|
||||||
|
description: "GHES",
|
||||||
|
gitHubVersion: { type: util_1.GitHubVariant.GHES, version: "3.0.0" },
|
||||||
|
},
|
||||||
|
{ description: "GHAE", gitHubVersion: { type: util_1.GitHubVariant.GHAE } },
|
||||||
|
];
|
||||||
|
for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) {
|
||||||
|
(0, ava_1.default)(`All feature flags are disabled if running against ${variant.description}`, async (t) => {
|
||||||
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
|
const loggedMessages = [];
|
||||||
|
const featureFlags = new feature_flags_1.GitHubFeatureFlags(variant.gitHubVersion, testApiDetails, testRepositoryNwo, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
|
for (const flag of Object.values(feature_flags_1.FeatureFlag)) {
|
||||||
|
t.assert((await featureFlags.getValue(flag)) === false);
|
||||||
|
}
|
||||||
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
|
v.message ===
|
||||||
|
"Not running against github.com. Disabling all feature flags.") !== undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
(0, ava_1.default)("Feature flags are disabled if they're not returned in API response", async (t) => {
|
||||||
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
|
const loggedMessages = [];
|
||||||
|
const featureFlags = new feature_flags_1.GitHubFeatureFlags({ type: util_1.GitHubVariant.DOTCOM }, testApiDetails, testRepositoryNwo, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
||||||
|
for (const flag of Object.values(feature_flags_1.FeatureFlag)) {
|
||||||
|
t.assert((await featureFlags.getValue(flag)) === false);
|
||||||
|
}
|
||||||
|
for (const featureFlag of [
|
||||||
|
"database_uploads_enabled",
|
||||||
|
"ml_powered_queries_enabled",
|
||||||
|
"uploads_domain_enabled",
|
||||||
|
]) {
|
||||||
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
|
v.message ===
|
||||||
|
`Feature flag '${featureFlag}' undefined in API response, considering it disabled.`) !== undefined);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
(0, ava_1.default)("Feature flags exception is propagated if the API request errors", async (t) => {
|
||||||
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
|
const featureFlags = new feature_flags_1.GitHubFeatureFlags({ type: util_1.GitHubVariant.DOTCOM }, testApiDetails, testRepositoryNwo, (0, logging_1.getRunnerLogger)(true));
|
||||||
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(500, {});
|
||||||
|
await t.throwsAsync(async () => featureFlags.preloadFeatureFlags(), {
|
||||||
|
message: "Encountered an error while trying to load feature flags: Error: some error message",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const FEATURE_FLAGS = [
|
||||||
|
"database_uploads_enabled",
|
||||||
|
"ml_powered_queries_enabled",
|
||||||
|
"uploads_domain_enabled",
|
||||||
|
];
|
||||||
|
for (const featureFlag of FEATURE_FLAGS) {
|
||||||
|
(0, ava_1.default)(`Feature flag '${featureFlag}' is enabled if enabled in the API response`, async (t) => {
|
||||||
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
|
const featureFlags = new feature_flags_1.GitHubFeatureFlags({ type: util_1.GitHubVariant.DOTCOM }, testApiDetails, testRepositoryNwo, (0, logging_1.getRunnerLogger)(true));
|
||||||
|
const expectedFeatureFlags = {};
|
||||||
|
for (const f of FEATURE_FLAGS) {
|
||||||
|
expectedFeatureFlags[f] = false;
|
||||||
|
}
|
||||||
|
expectedFeatureFlags[featureFlag] = true;
|
||||||
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureFlags);
|
||||||
|
const actualFeatureFlags = {
|
||||||
|
database_uploads_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.DatabaseUploadsEnabled),
|
||||||
|
ml_powered_queries_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled),
|
||||||
|
uploads_domain_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.UploadsDomainEnabled),
|
||||||
|
};
|
||||||
|
t.deepEqual(actualFeatureFlags, expectedFeatureFlags);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=feature-flags.test.js.map
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"feature-flags.test.js","sourceRoot":"","sources":["../src/feature-flags.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AAGvB,mDAAkE;AAClE,uCAA4C;AAC5C,6CAAkD;AAClD,mDAMyB;AAEzB,iCAAgF;AAEhF,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,UAAU,CAAC,GAAG,EAAE;IACnB,IAAA,4BAAqB,EAAC,WAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEH,MAAM,cAAc,GAAqB;IACvC,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,oBAAoB;CAC1B,CAAC;AAEF,MAAM,iBAAiB,GAAG,IAAA,+BAAkB,EAAC,gBAAgB,CAAC,CAAC;AAE/D,MAAM,mCAAmC,GAGpC;IACH;QACE,WAAW,EAAE,MAAM;QACnB,aAAa,EAAE,EAAE,IAAI,EAAE,oBAAa,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;KAC9D;IACD,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,oBAAa,CAAC,IAAI,EAAE,EAAE;CACrE,CAAC;AAEF,KAAK,MAAM,OAAO,IAAI,mCAAmC,EAAE;IACzD,IAAA,aAAI,EAAC,qDAAqD,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC3F,MAAM,IAAA,iBAAU,EAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAChC,IAAA,gCAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAEjC,MAAM,cAAc,GAAG,EAAE,CAAC;YAC1B,MAAM,YAAY,GAAG,IAAI,kCAAkB,CACzC,OAAO,CAAC,aAAa,EACrB,cAAc,EACd,iBAAiB,EACjB,IAAA,kCAAkB,EAAC,cAAc,CAAC,CACnC,CAAC;YAEF,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,2BAAW,CAAC,EAAE;gBAC7C,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;aACzD;YAED,CAAC,CAAC,MAAM,CACN,cAAc,CAAC,IAAI,CACjB,CAAC,CAAgB,EAAE,EAAE,CACnB,CAAC,CAAC,IAAI,KAAK,OAAO;gBAClB,CAAC,CAAC,OAAO;oBACP,8DAA8D,CACnE,KAAK,SAAS,CAChB,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;CACJ;AAED,IAAA,aAAI,EAAC,oEAAoE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACrF,MAAM,IAAA,iBAAU,EAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAChC,IAAA,gCAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAEjC,MAAM,cAAc,GAAG,EAAE,CAAC;QAC1B,MAAM,YAAY,GAAG,IAAI,kCAAkB,CACzC,EAAE,IAAI,EAAE,oBAAa,CAAC,MAAM,EAAE,EAC9B,cAAc,EACd,iBAAiB,EACjB,IAAA,kCAAkB,EAAC,cAAc,CAAC,CACnC,CAAC;QAEF,IAAA,0CAA0B,EAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAEpC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,2BAAW,CAAC,EAAE;YAC7C,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;SACzD;QAED,KAAK,MAAM,WAAW,IAAI;YACxB,0BAA0B;YAC1B,4BAA4B;YAC5B,wBAAwB;SACzB,EAAE;YACD,CAAC,CAAC,MAAM,CACN,cAAc,CAAC,IAAI,CACjB,CAAC,CAAgB,EAAE,EAAE,CACnB,CAAC,CAAC,IAAI,KAAK,OAAO;gBAClB,CAAC,CAAC,OAAO;oBACP,iBAAiB,WAAW,uDAAuD,CACxF,KAAK,SAAS,CAChB,CAAC;SACH;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAA,aAAI,EAAC,iEAAiE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAClF,MAAM,IAAA,iBAAU,EAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAChC,IAAA,gCAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAEjC,MAAM,YAAY,GAAG,IAAI,kCAAkB,CACzC,EAAE,IAAI,EAAE,oBAAa,CAAC,MAAM,EAAE,EAC9B,cAAc,EACd,iBAAiB,EACjB,IAAA,yBAAe,EAAC,IAAI,CAAC,CACtB,CAAC;QAEF,IAAA,0CAA0B,EAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAEpC,MAAM,CAAC,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE,CAAC,YAAY,CAAC,mBAAmB,EAAE,EAAE;YAClE,OAAO,EACL,oFAAoF;SACvF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG;IACpB,0BAA0B;IAC1B,4BAA4B;IAC5B,wBAAwB;CACzB,CAAC;AAEF,KAAK,MAAM,WAAW,IAAI,aAAa,EAAE;IACvC,IAAA,aAAI,EAAC,iBAAiB,WAAW,6CAA6C,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC1F,MAAM,IAAA,iBAAU,EAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAChC,IAAA,gCAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAEjC,MAAM,YAAY,GAAG,IAAI,kCAAkB,CACzC,EAAE,IAAI,EAAE,oBAAa,CAAC,MAAM,EAAE,EAC9B,cAAc,EACd,iBAAiB,EACjB,IAAA,yBAAe,EAAC,IAAI,CAAC,CACtB,CAAC;YAEF,MAAM,oBAAoB,GAAG,EAAE,CAAC;YAChC,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE;gBAC7B,oBAAoB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;aACjC;YACD,oBAAoB,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;YACzC,IAAA,0CAA0B,EAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;YAEtD,MAAM,kBAAkB,GAAG;gBACzB,wBAAwB,EAAE,MAAM,YAAY,CAAC,QAAQ,CACnD,2BAAW,CAAC,sBAAsB,CACnC;gBACD,0BAA0B,EAAE,MAAM,YAAY,CAAC,QAAQ,CACrD,2BAAW,CAAC,uBAAuB,CACpC;gBACD,sBAAsB,EAAE,MAAM,YAAY,CAAC,QAAQ,CACjD,2BAAW,CAAC,oBAAoB,CACjC;aACF,CAAC;YAEF,CAAC,CAAC,SAAS,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;CACJ"}
|
||||||
Generated
+5
-1
@@ -18,11 +18,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const commander_1 = require("commander");
|
const commander_1 = require("commander");
|
||||||
|
const del_1 = __importDefault(require("del"));
|
||||||
const analyze_1 = require("./analyze");
|
const analyze_1 = require("./analyze");
|
||||||
const autobuild_1 = require("./autobuild");
|
const autobuild_1 = require("./autobuild");
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
@@ -133,7 +137,7 @@ program
|
|||||||
const checkoutPath = cmd.checkoutPath || process.cwd();
|
const checkoutPath = cmd.checkoutPath || process.cwd();
|
||||||
// Wipe the temp dir
|
// Wipe the temp dir
|
||||||
logger.info(`Cleaning temp directory ${tempDir}`);
|
logger.info(`Cleaning temp directory ${tempDir}`);
|
||||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
await (0, del_1.default)(tempDir, { force: true });
|
||||||
fs.mkdirSync(tempDir, { recursive: true });
|
fs.mkdirSync(tempDir, { recursive: true });
|
||||||
const auth = await (0, util_1.getGitHubAuth)(logger, cmd.githubAuth, cmd.githubAuthStdin);
|
const auth = await (0, util_1.getGitHubAuth)(logger, cmd.githubAuth, cmd.githubAuthStdin);
|
||||||
const apiDetails = {
|
const apiDetails = {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+48
-1
@@ -19,9 +19,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.setupActionsVars = exports.setupTests = void 0;
|
exports.mockFeatureFlagApiEndpoint = exports.getRecordingLogger = exports.setupActionsVars = exports.setupTests = void 0;
|
||||||
|
const github = __importStar(require("@actions/github"));
|
||||||
const sinon = __importStar(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
|
const apiClient = __importStar(require("./api-client"));
|
||||||
const CodeQL = __importStar(require("./codeql"));
|
const CodeQL = __importStar(require("./codeql"));
|
||||||
|
const util_1 = require("./util");
|
||||||
function wrapOutput(context) {
|
function wrapOutput(context) {
|
||||||
// Function signature taken from Socket.write.
|
// Function signature taken from Socket.write.
|
||||||
// Note there are two overloads:
|
// Note there are two overloads:
|
||||||
@@ -89,4 +92,48 @@ function setupActionsVars(tempDir, toolsDir) {
|
|||||||
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
|
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
|
||||||
}
|
}
|
||||||
exports.setupActionsVars = setupActionsVars;
|
exports.setupActionsVars = setupActionsVars;
|
||||||
|
function getRecordingLogger(messages) {
|
||||||
|
return {
|
||||||
|
debug: (message) => {
|
||||||
|
messages.push({ type: "debug", message });
|
||||||
|
console.debug(message);
|
||||||
|
},
|
||||||
|
info: (message) => {
|
||||||
|
messages.push({ type: "info", message });
|
||||||
|
console.info(message);
|
||||||
|
},
|
||||||
|
warning: (message) => {
|
||||||
|
messages.push({ type: "warning", message });
|
||||||
|
console.warn(message);
|
||||||
|
},
|
||||||
|
error: (message) => {
|
||||||
|
messages.push({ type: "error", message });
|
||||||
|
console.error(message);
|
||||||
|
},
|
||||||
|
isDebug: () => true,
|
||||||
|
startGroup: () => undefined,
|
||||||
|
endGroup: () => undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.getRecordingLogger = getRecordingLogger;
|
||||||
|
/** Mock the HTTP request to the feature flags enablement API endpoint. */
|
||||||
|
function mockFeatureFlagApiEndpoint(responseStatusCode, response) {
|
||||||
|
// Passing an auth token is required, so we just use a dummy value
|
||||||
|
const client = github.getOctokit("123");
|
||||||
|
const requestSpy = sinon.stub(client, "request");
|
||||||
|
const optInSpy = requestSpy.withArgs("GET /repos/:owner/:repo/code-scanning/codeql-action/features");
|
||||||
|
if (responseStatusCode < 300) {
|
||||||
|
optInSpy.resolves({
|
||||||
|
status: responseStatusCode,
|
||||||
|
data: response,
|
||||||
|
headers: {},
|
||||||
|
url: "GET /repos/:owner/:repo/code-scanning/codeql-action/features",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
optInSpy.throws(new util_1.HTTPError("some error message", responseStatusCode));
|
||||||
|
}
|
||||||
|
sinon.stub(apiClient, "getApiClient").value(() => client);
|
||||||
|
}
|
||||||
|
exports.mockFeatureFlagApiEndpoint = mockFeatureFlagApiEndpoint;
|
||||||
//# sourceMappingURL=testing-utils.js.map
|
//# sourceMappingURL=testing-utils.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"testing-utils.js","sourceRoot":"","sources":["../src/testing-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,6CAA+B;AAE/B,iDAAmC;AASnC,SAAS,UAAU,CAAC,OAAoB;IACtC,8CAA8C;IAC9C,gCAAgC;IAChC,2EAA2E;IAC3E,2FAA2F;IAC3F,OAAO,CACL,KAA0B,EAC1B,QAAiB,EACjB,EAA0B,EACjB,EAAE;QACX,2CAA2C;QAC3C,IAAI,EAAE,KAAK,SAAS,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;YACtD,EAAE,GAAG,QAAQ,CAAC;YACd,QAAQ,GAAG,SAAS,CAAC;SACtB;QAED,oBAAoB;QACpB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;SAC7B;aAAM;YACL,OAAO,CAAC,UAAU,IAAI,IAAI,WAAW,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SAC1E;QAED,iDAAiD;QACjD,IAAI,EAAE,KAAK,SAAS,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAChD,EAAE,EAAE,CAAC;SACN;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,UAAU,CAAC,IAAwB;IACjD,MAAM,SAAS,GAAG,IAAkC,CAAC;IAErD,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE;QACzB,gEAAgE;QAChE,0CAA0C;QAC1C,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAErB,iEAAiE;QACjE,CAAC,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC;QAC1B,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrE,CAAC,CAAC,OAAO,CAAC,WAAW,GAAG,kBAAkB,CAAC;QAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,OAAO,CAAQ,CAAC;QACpD,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrE,CAAC,CAAC,OAAO,CAAC,WAAW,GAAG,kBAAkB,CAAC;QAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,OAAO,CAAQ,CAAC;QAEpD,mEAAmE;QACnE,wEAAwE;QACxE,kEAAkE;QAClE,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG,EAAE,CAAC;QACnB,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;QAC/B,4BAA4B;QAC5B,0DAA0D;QAC1D,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;QAC7C,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;QAC7C,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE;YACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;SAC5C;QAED,uCAAuC;QACvC,KAAK,CAAC,OAAO,EAAE,CAAC;QAEhB,oCAAoC;QACpC,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAvCD,gCAuCC;AAED,yEAAyE;AACzE,sDAAsD;AACtD,SAAgB,gBAAgB,CAAC,OAAe,EAAE,QAAgB;IAChE,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,QAAQ,CAAC;AAC9C,CAAC;AAHD,4CAGC"}
|
{"version":3,"file":"testing-utils.js","sourceRoot":"","sources":["../src/testing-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wDAA0C;AAE1C,6CAA+B;AAE/B,wDAA0C;AAC1C,iDAAmC;AAEnC,iCAAmC;AASnC,SAAS,UAAU,CAAC,OAAoB;IACtC,8CAA8C;IAC9C,gCAAgC;IAChC,2EAA2E;IAC3E,2FAA2F;IAC3F,OAAO,CACL,KAA0B,EAC1B,QAAiB,EACjB,EAA0B,EACjB,EAAE;QACX,2CAA2C;QAC3C,IAAI,EAAE,KAAK,SAAS,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;YACtD,EAAE,GAAG,QAAQ,CAAC;YACd,QAAQ,GAAG,SAAS,CAAC;SACtB;QAED,oBAAoB;QACpB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;SAC7B;aAAM;YACL,OAAO,CAAC,UAAU,IAAI,IAAI,WAAW,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SAC1E;QAED,iDAAiD;QACjD,IAAI,EAAE,KAAK,SAAS,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAChD,EAAE,EAAE,CAAC;SACN;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,UAAU,CAAC,IAAwB;IACjD,MAAM,SAAS,GAAG,IAAkC,CAAC;IAErD,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE;QACzB,gEAAgE;QAChE,0CAA0C;QAC1C,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAErB,iEAAiE;QACjE,CAAC,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC;QAC1B,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrE,CAAC,CAAC,OAAO,CAAC,WAAW,GAAG,kBAAkB,CAAC;QAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,OAAO,CAAQ,CAAC;QACpD,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrE,CAAC,CAAC,OAAO,CAAC,WAAW,GAAG,kBAAkB,CAAC;QAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,OAAO,CAAQ,CAAC;QAEpD,mEAAmE;QACnE,wEAAwE;QACxE,kEAAkE;QAClE,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG,EAAE,CAAC;QACnB,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;QAC/B,4BAA4B;QAC5B,0DAA0D;QAC1D,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;QAC7C,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;QAC7C,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE;YACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;SAC5C;QAED,uCAAuC;QACvC,KAAK,CAAC,OAAO,EAAE,CAAC;QAEhB,oCAAoC;QACpC,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAvCD,gCAuCC;AAED,yEAAyE;AACzE,sDAAsD;AACtD,SAAgB,gBAAgB,CAAC,OAAe,EAAE,QAAgB;IAChE,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,QAAQ,CAAC;AAC9C,CAAC;AAHD,4CAGC;AAOD,SAAgB,kBAAkB,CAAC,QAAyB;IAC1D,OAAO;QACL,KAAK,EAAE,CAAC,OAAe,EAAE,EAAE;YACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;YAC1C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;QACD,IAAI,EAAE,CAAC,OAAe,EAAE,EAAE;YACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;QACD,OAAO,EAAE,CAAC,OAAuB,EAAE,EAAE;YACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;QACD,KAAK,EAAE,CAAC,OAAuB,EAAE,EAAE;YACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;YAC1C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;QACnB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AAtBD,gDAsBC;AAED,0EAA0E;AAC1E,SAAgB,0BAA0B,CACxC,kBAA0B,EAC1B,QAAyC;IAEzC,kEAAkE;IAClE,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAExC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAEjD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAClC,8DAA8D,CAC/D,CAAC;IACF,IAAI,kBAAkB,GAAG,GAAG,EAAE;QAC5B,QAAQ,CAAC,QAAQ,CAAC;YAChB,MAAM,EAAE,kBAAkB;YAC1B,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE;YACX,GAAG,EAAE,8DAA8D;SACpE,CAAC,CAAC;KACJ;SAAM;QACL,QAAQ,CAAC,MAAM,CAAC,IAAI,gBAAS,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC,CAAC;KAC1E;IAED,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;AAC5D,CAAC;AAxBD,gEAwBC"}
|
||||||
Generated
+8
-4
@@ -18,6 +18,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.downloadTool = exports.findAllVersions = exports.find = exports.cacheDir = exports.extractTar = void 0;
|
exports.downloadTool = exports.findAllVersions = exports.find = exports.cacheDir = exports.extractTar = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
@@ -27,6 +30,7 @@ const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
|||||||
const io = __importStar(require("@actions/io"));
|
const io = __importStar(require("@actions/io"));
|
||||||
const actionsToolcache = __importStar(require("@actions/tool-cache"));
|
const actionsToolcache = __importStar(require("@actions/tool-cache"));
|
||||||
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
||||||
|
const del_1 = __importDefault(require("del"));
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
const uuid_1 = require("uuid");
|
const uuid_1 = require("uuid");
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
@@ -123,7 +127,7 @@ async function cacheDir(sourceDir, tool, version, toolCacheDir, logger) {
|
|||||||
throw new Error("sourceDir is not a directory");
|
throw new Error("sourceDir is not a directory");
|
||||||
}
|
}
|
||||||
// Create the tool dir
|
// Create the tool dir
|
||||||
const destPath = createToolPath(tool, version, arch, toolCacheDir, logger);
|
const destPath = await createToolPath(tool, version, arch, toolCacheDir, logger);
|
||||||
// copy each child item. do not move. move can fail on Windows
|
// copy each child item. do not move. move can fail on Windows
|
||||||
// due to anti-virus software having an open handle on a file.
|
// due to anti-virus software having an open handle on a file.
|
||||||
for (const itemName of fs.readdirSync(sourceDir)) {
|
for (const itemName of fs.readdirSync(sourceDir)) {
|
||||||
@@ -232,12 +236,12 @@ function createExtractFolder(tempDir) {
|
|||||||
}
|
}
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
function createToolPath(tool, version, arch, toolCacheDir, logger) {
|
async function createToolPath(tool, version, arch, toolCacheDir, logger) {
|
||||||
const folderPath = path.join(toolCacheDir, tool, semver.clean(version) || version, arch || "");
|
const folderPath = path.join(toolCacheDir, tool, semver.clean(version) || version, arch || "");
|
||||||
logger.debug(`destination ${folderPath}`);
|
logger.debug(`destination ${folderPath}`);
|
||||||
const markerPath = `${folderPath}.complete`;
|
const markerPath = `${folderPath}.complete`;
|
||||||
fs.rmSync(folderPath, { recursive: true, force: true });
|
await (0, del_1.default)(folderPath, { force: true });
|
||||||
fs.rmSync(markerPath, { recursive: true, force: true });
|
await (0, del_1.default)(markerPath, { force: true });
|
||||||
fs.mkdirSync(folderPath, { recursive: true });
|
fs.mkdirSync(folderPath, { recursive: true });
|
||||||
return folderPath;
|
return folderPath;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
-8
@@ -44,10 +44,6 @@ async function toolrunnerErrorCatcher(commandLine, args, matchers, options) {
|
|||||||
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout) !== undefined) {
|
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout) !== undefined) {
|
||||||
options.listeners.stdout(data);
|
options.listeners.stdout(data);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// if no stdout listener was originally defined then we match default behavior of Toolrunner
|
|
||||||
process.stdout.write(data);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
stderr: (data) => {
|
stderr: (data) => {
|
||||||
var _a;
|
var _a;
|
||||||
@@ -55,10 +51,6 @@ async function toolrunnerErrorCatcher(commandLine, args, matchers, options) {
|
|||||||
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stderr) !== undefined) {
|
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stderr) !== undefined) {
|
||||||
options.listeners.stderr(data);
|
options.listeners.stderr(data);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// if no stderr listener was originally defined then we match default behavior of Toolrunner
|
|
||||||
process.stderr.write(data);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// we capture the original return code or error so that if no match is found we can duplicate the behavior
|
// we capture the original return code or error so that if no match is found we can duplicate the behavior
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"toolrunner-error-catcher.js","sourceRoot":"","sources":["../src/toolrunner-error-catcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,yEAA2D;AAC3D,kEAAoD;AAIpD;;;;;;;;;;GAUG;AACI,KAAK,UAAU,sBAAsB,CAC1C,WAAmB,EACnB,IAAe,EACf,QAAyB,EACzB,OAAwB;;IAExB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,MAAM,SAAS,GAAG;QAChB,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,IAAI,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CAAE,MAAM,MAAK,SAAS,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAChC;iBAAM;gBACL,4FAA4F;gBAC5F,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAC5B;QACH,CAAC;QACD,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,IAAI,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CAAE,MAAM,MAAK,SAAS,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAChC;iBAAM;gBACL,4FAA4F;gBAC5F,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAC5B;QACH,CAAC;KACF,CAAC;IAEF,0GAA0G;IAC1G,IAAI,WAA2B,CAAC;IAChC,IAAI;QACF,WAAW,GAAG,MAAM,IAAI,UAAU,CAAC,UAAU,CAC3C,MAAM,SAAS,CAAC,SAAS,CAAC,WAAW,CAAC,EACtC,IAAI,EACJ;YACE,GAAG,OAAO;YACV,SAAS;YACT,gBAAgB,EAAE,IAAI,EAAE,wDAAwD;SACjF,CACF,CAAC,IAAI,EAAE,CAAC;KACV;IAAC,OAAO,CAAC,EAAE;QACV,WAAW,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;KAC7D;IAED,mEAAmE;IACnE,IAAI,WAAW,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IAE1C,IAAI,QAAQ,EAAE;QACZ,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC9B,IACE,OAAO,CAAC,QAAQ,KAAK,WAAW;iBAChC,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC,MAAM,CAAC,CAAA;iBACjC,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC,MAAM,CAAC,CAAA,EACjC;gBACA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;aAClC;SACF;KACF;IAED,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACnC,qFAAqF;QACrF,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,EAAE;YAC7B,OAAO,WAAW,CAAC;SACpB;aAAM;YACL,MAAM,IAAI,KAAK,CACb,gBAAgB,WAAW,2BAA2B,WAAW,EAAE,CACpE,CAAC;SACH;KACF;SAAM;QACL,MAAM,WAAW,CAAC;KACnB;AACH,CAAC;AAzED,wDAyEC"}
|
{"version":3,"file":"toolrunner-error-catcher.js","sourceRoot":"","sources":["../src/toolrunner-error-catcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,yEAA2D;AAC3D,kEAAoD;AAIpD;;;;;;;;;;GAUG;AACI,KAAK,UAAU,sBAAsB,CAC1C,WAAmB,EACnB,IAAe,EACf,QAAyB,EACzB,OAAwB;;IAExB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,MAAM,SAAS,GAAG;QAChB,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,IAAI,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CAAE,MAAM,MAAK,SAAS,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAChC;QACH,CAAC;QACD,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,IAAI,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CAAE,MAAM,MAAK,SAAS,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAChC;QACH,CAAC;KACF,CAAC;IAEF,0GAA0G;IAC1G,IAAI,WAA2B,CAAC;IAChC,IAAI;QACF,WAAW,GAAG,MAAM,IAAI,UAAU,CAAC,UAAU,CAC3C,MAAM,SAAS,CAAC,SAAS,CAAC,WAAW,CAAC,EACtC,IAAI,EACJ;YACE,GAAG,OAAO;YACV,SAAS;YACT,gBAAgB,EAAE,IAAI,EAAE,wDAAwD;SACjF,CACF,CAAC,IAAI,EAAE,CAAC;KACV;IAAC,OAAO,CAAC,EAAE;QACV,WAAW,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;KAC7D;IAED,mEAAmE;IACnE,IAAI,WAAW,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IAE1C,IAAI,QAAQ,EAAE;QACZ,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC9B,IACE,OAAO,CAAC,QAAQ,KAAK,WAAW;iBAChC,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC,MAAM,CAAC,CAAA;iBACjC,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC,MAAM,CAAC,CAAA,EACjC;gBACA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;aAClC;SACF;KACF;IAED,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACnC,qFAAqF;QACrF,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,EAAE;YAC7B,OAAO,WAAW,CAAC;SACpB;aAAM;YACL,MAAM,IAAI,KAAK,CACb,gBAAgB,WAAW,2BAA2B,WAAW,EAAE,CACpE,CAAC;SACH;KACF;SAAM;QACL,MAAM,WAAW,CAAC;KACnB;AACH,CAAC;AAnED,wDAmEC"}
|
||||||
Generated
+1
-1
@@ -182,7 +182,6 @@ async function getCombinedTracerConfig(config, codeql) {
|
|||||||
tracedLanguageConfigs[language] = await getTracerConfigForLanguage(codeql, config, language);
|
tracedLanguageConfigs[language] = await getTracerConfigForLanguage(codeql, config, language);
|
||||||
}
|
}
|
||||||
mainTracerConfig = concatTracerConfigs(tracedLanguageConfigs, config);
|
mainTracerConfig = concatTracerConfigs(tracedLanguageConfigs, config);
|
||||||
}
|
|
||||||
// Add a couple more variables
|
// Add a couple more variables
|
||||||
mainTracerConfig.env["ODASA_TRACER_CONFIGURATION"] = mainTracerConfig.spec;
|
mainTracerConfig.env["ODASA_TRACER_CONFIGURATION"] = mainTracerConfig.spec;
|
||||||
const codeQLDir = path.dirname(codeql.getPath());
|
const codeQLDir = path.dirname(codeql.getPath());
|
||||||
@@ -192,6 +191,7 @@ async function getCombinedTracerConfig(config, codeql) {
|
|||||||
else if (process.platform !== "win32") {
|
else if (process.platform !== "win32") {
|
||||||
mainTracerConfig.env["LD_PRELOAD"] = path.join(codeQLDir, "tools", "linux64", "${LIB}trace.so");
|
mainTracerConfig.env["LD_PRELOAD"] = path.join(codeQLDir, "tools", "linux64", "${LIB}trace.so");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// On macos it's necessary to prefix the build command with the runner executable
|
// On macos it's necessary to prefix the build command with the runner executable
|
||||||
// on order to trace when System Integrity Protection is enabled.
|
// on order to trace when System Integrity Protection is enabled.
|
||||||
// The executable also exists and works for other platforms so we output this env
|
// The executable also exists and works for other platforms so we output this env
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+82
-10
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.buildPayload = exports.validateSarifFileSchema = exports.countResultsInSarif = exports.uploadFromRunner = exports.uploadFromActions = exports.findSarifFilesInDir = exports.populateRunAutomationDetails = exports.combineSarifFiles = void 0;
|
exports.validateUniqueCategory = exports.waitForProcessing = exports.buildPayload = exports.validateSarifFileSchema = exports.countResultsInSarif = exports.uploadFromRunner = exports.uploadFromActions = exports.findSarifFilesInDir = exports.populateRunAutomationDetails = exports.combineSarifFiles = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const zlib_1 = __importDefault(require("zlib"));
|
const zlib_1 = __importDefault(require("zlib"));
|
||||||
@@ -105,6 +105,7 @@ async function uploadPayload(payload, repositoryNwo, apiDetails, logger) {
|
|||||||
});
|
});
|
||||||
logger.debug(`response status: ${response.status}`);
|
logger.debug(`response status: ${response.status}`);
|
||||||
logger.info("Successfully uploaded results");
|
logger.info("Successfully uploaded results");
|
||||||
|
return response.data.id;
|
||||||
}
|
}
|
||||||
// Recursively walks a directory and returns all SARIF files it finds.
|
// Recursively walks a directory and returns all SARIF files it finds.
|
||||||
// Does not follow symlinks.
|
// Does not follow symlinks.
|
||||||
@@ -243,14 +244,7 @@ exports.buildPayload = buildPayload;
|
|||||||
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, category, analysisName, workflowRunID, sourceRoot, environment, gitHubVersion, apiDetails, logger) {
|
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, category, analysisName, workflowRunID, sourceRoot, environment, gitHubVersion, apiDetails, logger) {
|
||||||
logger.startGroup("Uploading results");
|
logger.startGroup("Uploading results");
|
||||||
logger.info(`Processing sarif files: ${JSON.stringify(sarifFiles)}`);
|
logger.info(`Processing sarif files: ${JSON.stringify(sarifFiles)}`);
|
||||||
if (util.isActions()) {
|
validateUniqueCategory(category);
|
||||||
// This check only works on actions as env vars don't persist between calls to the runner
|
|
||||||
const sentinelEnvVar = "CODEQL_UPLOAD_SARIF";
|
|
||||||
if (process.env[sentinelEnvVar]) {
|
|
||||||
throw new Error("Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job");
|
|
||||||
}
|
|
||||||
core.exportVariable(sentinelEnvVar, sentinelEnvVar);
|
|
||||||
}
|
|
||||||
// Validate that the files we were asked to upload are all valid SARIF files
|
// Validate that the files we were asked to upload are all valid SARIF files
|
||||||
for (const file of sarifFiles) {
|
for (const file of sarifFiles) {
|
||||||
validateSarifFileSchema(file, logger);
|
validateSarifFileSchema(file, logger);
|
||||||
@@ -270,12 +264,90 @@ async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKe
|
|||||||
const numResultInSarif = countResultsInSarif(sarifPayload);
|
const numResultInSarif = countResultsInSarif(sarifPayload);
|
||||||
logger.debug(`Number of results in upload: ${numResultInSarif}`);
|
logger.debug(`Number of results in upload: ${numResultInSarif}`);
|
||||||
// Make the upload
|
// Make the upload
|
||||||
await uploadPayload(payload, repositoryNwo, apiDetails, logger);
|
const sarifID = await uploadPayload(payload, repositoryNwo, apiDetails, logger);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return {
|
return {
|
||||||
|
statusReport: {
|
||||||
raw_upload_size_bytes: rawUploadSizeBytes,
|
raw_upload_size_bytes: rawUploadSizeBytes,
|
||||||
zipped_upload_size_bytes: zippedUploadSizeBytes,
|
zipped_upload_size_bytes: zippedUploadSizeBytes,
|
||||||
num_results_in_sarif: numResultInSarif,
|
num_results_in_sarif: numResultInSarif,
|
||||||
|
},
|
||||||
|
sarifID,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
const STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1000;
|
||||||
|
const STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1000;
|
||||||
|
// Waits until either the analysis is successfully processed, a processing error is reported, or STATUS_CHECK_TIMEOUT_MILLISECONDS elapses.
|
||||||
|
async function waitForProcessing(repositoryNwo, sarifID, apiDetails, logger) {
|
||||||
|
logger.startGroup("Waiting for processing to finish");
|
||||||
|
const client = api.getApiClient(apiDetails);
|
||||||
|
const statusCheckingStarted = Date.now();
|
||||||
|
// eslint-disable-next-line no-constant-condition
|
||||||
|
while (true) {
|
||||||
|
if (Date.now() >
|
||||||
|
statusCheckingStarted + STATUS_CHECK_TIMEOUT_MILLISECONDS) {
|
||||||
|
// If the analysis hasn't finished processing in the allotted time, we continue anyway rather than failing.
|
||||||
|
// It's possible the analysis will eventually finish processing, but it's not worth spending more Actions time waiting.
|
||||||
|
logger.warning("Timed out waiting for analysis to finish processing. Continuing.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const response = await client.request("GET /repos/:owner/:repo/code-scanning/sarifs/:sarif_id", {
|
||||||
|
owner: repositoryNwo.owner,
|
||||||
|
repo: repositoryNwo.repo,
|
||||||
|
sarif_id: sarifID,
|
||||||
|
});
|
||||||
|
const status = response.data.processing_status;
|
||||||
|
logger.info(`Analysis upload status is ${status}.`);
|
||||||
|
if (status === "complete") {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (status === "failed") {
|
||||||
|
throw new Error(`Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (util.isHTTPError(e)) {
|
||||||
|
switch (e.status) {
|
||||||
|
case 404:
|
||||||
|
logger.debug("Analysis is not found yet...");
|
||||||
|
break; // Note this breaks from the case statement, not the outer loop.
|
||||||
|
default:
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await util.delay(STATUS_CHECK_FREQUENCY_MILLISECONDS);
|
||||||
|
}
|
||||||
|
logger.endGroup();
|
||||||
|
}
|
||||||
|
exports.waitForProcessing = waitForProcessing;
|
||||||
|
function validateUniqueCategory(category) {
|
||||||
|
if (util.isActions()) {
|
||||||
|
// This check only works on actions as env vars don't persist between calls to the runner
|
||||||
|
const sentinelEnvVar = `CODEQL_UPLOAD_SARIF${category ? `_${sanitize(category)}` : ""}`;
|
||||||
|
if (process.env[sentinelEnvVar]) {
|
||||||
|
throw new Error("Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job per category. " +
|
||||||
|
"Please specify a unique `category` to call this action multiple times. " +
|
||||||
|
`Category: ${category ? category : "(none)"}`);
|
||||||
|
}
|
||||||
|
core.exportVariable(sentinelEnvVar, sentinelEnvVar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.validateUniqueCategory = validateUniqueCategory;
|
||||||
|
/**
|
||||||
|
* Santizes a string to be used as an environment variable name.
|
||||||
|
* This will replace all non-alphanumeric characters with underscores.
|
||||||
|
* There could still be some false category clashes if two uploads
|
||||||
|
* occur that differ only in their non-alphanumeric characters. This is
|
||||||
|
* unlikely.
|
||||||
|
*
|
||||||
|
* @param str the initial value to sanitize
|
||||||
|
*/
|
||||||
|
function sanitize(str) {
|
||||||
|
return str.replace(/[^a-zA-Z0-9_]/g, "_");
|
||||||
|
}
|
||||||
//# sourceMappingURL=upload-lib.js.map
|
//# sourceMappingURL=upload-lib.js.map
|
||||||
File diff suppressed because one or more lines are too long
Generated
+16
@@ -113,4 +113,20 @@ ava_1.default.beforeEach(() => {
|
|||||||
modifiedSarif = uploadLib.populateRunAutomationDetails(sarif, undefined, analysisKey, '{"os": "linux", "language": "javascript"}');
|
modifiedSarif = uploadLib.populateRunAutomationDetails(sarif, undefined, analysisKey, '{"os": "linux", "language": "javascript"}');
|
||||||
t.deepEqual(modifiedSarif, expectedSarif);
|
t.deepEqual(modifiedSarif, expectedSarif);
|
||||||
});
|
});
|
||||||
|
(0, ava_1.default)("validateUniqueCategory", (t) => {
|
||||||
|
t.notThrows(() => uploadLib.validateUniqueCategory(undefined));
|
||||||
|
t.throws(() => uploadLib.validateUniqueCategory(undefined));
|
||||||
|
t.notThrows(() => uploadLib.validateUniqueCategory("abc"));
|
||||||
|
t.throws(() => uploadLib.validateUniqueCategory("abc"));
|
||||||
|
t.notThrows(() => uploadLib.validateUniqueCategory("def"));
|
||||||
|
t.throws(() => uploadLib.validateUniqueCategory("def"));
|
||||||
|
// Our category sanitization is not perfect. Here are some examples
|
||||||
|
// of where we see false clashes
|
||||||
|
t.notThrows(() => uploadLib.validateUniqueCategory("abc/def"));
|
||||||
|
t.throws(() => uploadLib.validateUniqueCategory("abc@def"));
|
||||||
|
t.throws(() => uploadLib.validateUniqueCategory("abc_def"));
|
||||||
|
t.throws(() => uploadLib.validateUniqueCategory("abc def"));
|
||||||
|
// this one is fine
|
||||||
|
t.notThrows(() => uploadLib.validateUniqueCategory("abc_ def"));
|
||||||
|
});
|
||||||
//# sourceMappingURL=upload-lib.test.js.map
|
//# sourceMappingURL=upload-lib.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
Generated
+6
-2
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
|
const repository_1 = require("./repository");
|
||||||
const upload_lib = __importStar(require("./upload-lib"));
|
const upload_lib = __importStar(require("./upload-lib"));
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
// eslint-disable-next-line import/no-commonjs
|
// eslint-disable-next-line import/no-commonjs
|
||||||
@@ -46,8 +47,11 @@ async function run() {
|
|||||||
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
|
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
|
||||||
};
|
};
|
||||||
const gitHubVersion = await (0, util_1.getGitHubVersion)(apiDetails);
|
const gitHubVersion = await (0, util_1.getGitHubVersion)(apiDetails);
|
||||||
const uploadStats = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, (0, logging_1.getActionsLogger)());
|
const uploadResult = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, (0, logging_1.getActionsLogger)());
|
||||||
await sendSuccessStatusReport(startedAt, uploadStats);
|
if (actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
||||||
|
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)());
|
||||||
|
}
|
||||||
|
await sendSuccessStatusReport(startedAt, uploadResult.statusReport);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
const message = error instanceof Error ? error.message : String(error);
|
const message = error instanceof Error ? error.message : String(error);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,uCAA6C;AAC7C,yDAA2C;AAC3C,iCAKgB;AAEhB,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAMvC,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C;IAE1C,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,cAAc,EACd,SAAS,EACT,SAAS,CACV,CAAC;IACF,MAAM,YAAY,GAA4B;QAC5C,GAAG,gBAAgB;QACnB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,IAAA,4BAAqB,EAAC,WAAI,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IACE,CAAC,CAAC,MAAM,WAAW,CAAC,gBAAgB,CAClC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,UAAU,EACV,SAAS,CACV,CACF,CAAC,EACF;QACA,OAAO;KACR;IAED,IAAI;QACF,MAAM,UAAU,GAAG;YACjB,IAAI,EAAE,WAAW,CAAC,gBAAgB,CAAC,OAAO,CAAC;YAC3C,GAAG,EAAE,IAAA,0BAAmB,EAAC,mBAAmB,CAAC;SAC9C,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,IAAA,uBAAgB,EAAC,UAAU,CAAC,CAAC;QAEzD,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,iBAAiB,CACpD,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAC1C,aAAa,EACb,UAAU,EACV,IAAA,0BAAgB,GAAE,CACnB,CAAC;QACF,MAAM,uBAAuB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;KACvD;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,WAAW,CAAC,gBAAgB,CAChC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,SAAS,EACT,SAAS,EACT,OAAO,EACP,KAAK,CACN,CACF,CAAC;QACF,OAAO;KACR;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,uCAA6C;AAC7C,6CAAkD;AAClD,yDAA2C;AAC3C,iCAKgB;AAEhB,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAMvC,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C;IAE1C,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,cAAc,EACd,SAAS,EACT,SAAS,CACV,CAAC;IACF,MAAM,YAAY,GAA4B;QAC5C,GAAG,gBAAgB;QACnB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,IAAA,4BAAqB,EAAC,WAAI,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IACE,CAAC,CAAC,MAAM,WAAW,CAAC,gBAAgB,CAClC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,UAAU,EACV,SAAS,CACV,CACF,CAAC,EACF;QACA,OAAO;KACR;IAED,IAAI;QACF,MAAM,UAAU,GAAG;YACjB,IAAI,EAAE,WAAW,CAAC,gBAAgB,CAAC,OAAO,CAAC;YAC3C,GAAG,EAAE,IAAA,0BAAmB,EAAC,mBAAmB,CAAC;SAC9C,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,IAAA,uBAAgB,EAAC,UAAU,CAAC,CAAC;QAEzD,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,iBAAiB,CACrD,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAC1C,aAAa,EACb,UAAU,EACV,IAAA,0BAAgB,GAAE,CACnB,CAAC;QACF,IAAI,WAAW,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,KAAK,MAAM,EAAE;YAClE,MAAM,UAAU,CAAC,iBAAiB,CAChC,IAAA,+BAAkB,EAAC,IAAA,0BAAmB,EAAC,mBAAmB,CAAC,CAAC,EAC5D,YAAY,CAAC,OAAO,EACpB,UAAU,EACV,IAAA,0BAAgB,GAAE,CACnB,CAAC;SACH;QACD,MAAM,uBAAuB,CAAC,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;KACrE;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,WAAW,CAAC,gBAAgB,CAChC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,SAAS,EACT,SAAS,EACT,OAAO,EACP,KAAK,CACN,CACF,CAAC;QACF,OAAO;KACR;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||||
Generated
+27
-4
@@ -18,16 +18,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.bundleDb = exports.codeQlVersionAbove = exports.isHTTPError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.isHTTPError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
|
const del_1 = __importDefault(require("del"));
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
const api_client_1 = require("./api-client");
|
const api_client_1 = require("./api-client");
|
||||||
const apiCompatibility = __importStar(require("./api-compatibility.json"));
|
const apiCompatibility = __importStar(require("./api-compatibility.json"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
|
/**
|
||||||
|
* Specifies bundle versions that are known to be broken
|
||||||
|
* and will not be used if found in the toolcache.
|
||||||
|
*/
|
||||||
|
const BROKEN_VERSIONS = ["0.0.0-20211207"];
|
||||||
/**
|
/**
|
||||||
* The URL for github.com.
|
* The URL for github.com.
|
||||||
*/
|
*/
|
||||||
@@ -81,7 +90,7 @@ async function withTmpDir(body) {
|
|||||||
const symlinkSubdir = path.join(tmpDir, "symlink");
|
const symlinkSubdir = path.join(tmpDir, "symlink");
|
||||||
fs.symlinkSync(realSubdir, symlinkSubdir, "dir");
|
fs.symlinkSync(realSubdir, symlinkSubdir, "dir");
|
||||||
const result = await body(symlinkSubdir);
|
const result = await body(symlinkSubdir);
|
||||||
fs.rmSync(tmpDir, { recursive: true, force: true });
|
await (0, del_1.default)(tmpDir, { force: true });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
exports.withTmpDir = withTmpDir;
|
exports.withTmpDir = withTmpDir;
|
||||||
@@ -486,10 +495,24 @@ exports.codeQlVersionAbove = codeQlVersionAbove;
|
|||||||
async function bundleDb(config, language, codeql) {
|
async function bundleDb(config, language, codeql) {
|
||||||
const databasePath = getCodeQLDatabasePath(config, language);
|
const databasePath = getCodeQLDatabasePath(config, language);
|
||||||
const databaseBundlePath = path.resolve(config.dbLocation, `${databasePath}.zip`);
|
const databaseBundlePath = path.resolve(config.dbLocation, `${databasePath}.zip`);
|
||||||
if (!fs.existsSync(databaseBundlePath)) {
|
// For a tiny bit of added safety, delete the file if it exists.
|
||||||
await codeql.databaseBundle(databasePath, databaseBundlePath);
|
// The file is probably from an earlier call to this function, either
|
||||||
|
// as part of this action step or a previous one, but it could also be
|
||||||
|
// from somewhere else or someone trying to make the action upload a
|
||||||
|
// non-database file.
|
||||||
|
if (fs.existsSync(databaseBundlePath)) {
|
||||||
|
await (0, del_1.default)(databaseBundlePath, { force: true });
|
||||||
}
|
}
|
||||||
|
await codeql.databaseBundle(databasePath, databaseBundlePath);
|
||||||
return databaseBundlePath;
|
return databaseBundlePath;
|
||||||
}
|
}
|
||||||
exports.bundleDb = bundleDb;
|
exports.bundleDb = bundleDb;
|
||||||
|
async function delay(milliseconds) {
|
||||||
|
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
||||||
|
}
|
||||||
|
exports.delay = delay;
|
||||||
|
function isGoodVersion(versionSpec) {
|
||||||
|
return !BROKEN_VERSIONS.includes(versionSpec);
|
||||||
|
}
|
||||||
|
exports.isGoodVersion = isGoodVersion;
|
||||||
//# sourceMappingURL=util.js.map
|
//# sourceMappingURL=util.js.map
|
||||||
+1
-1
File diff suppressed because one or more lines are too long
+15
-35
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "1.0.22",
|
"version": "1.0.27",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
@@ -253,7 +253,6 @@
|
|||||||
"node_modules/@nodelib/fs.scandir": {
|
"node_modules/@nodelib/fs.scandir": {
|
||||||
"version": "2.1.3",
|
"version": "2.1.3",
|
||||||
"integrity": "sha512-eGmwYQn3gxo4r7jdQnkrrN6bY478C3P+a/y72IJukF8LjB6ZHeB3c+Ehacj3sYeSmUXGlnA67/PmbM9CVwL7Dw==",
|
"integrity": "sha512-eGmwYQn3gxo4r7jdQnkrrN6bY478C3P+a/y72IJukF8LjB6ZHeB3c+Ehacj3sYeSmUXGlnA67/PmbM9CVwL7Dw==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodelib/fs.stat": "2.0.3",
|
"@nodelib/fs.stat": "2.0.3",
|
||||||
"run-parallel": "^1.1.9"
|
"run-parallel": "^1.1.9"
|
||||||
@@ -265,7 +264,6 @@
|
|||||||
"node_modules/@nodelib/fs.stat": {
|
"node_modules/@nodelib/fs.stat": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"integrity": "sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA==",
|
"integrity": "sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 8"
|
"node": ">= 8"
|
||||||
}
|
}
|
||||||
@@ -273,7 +271,6 @@
|
|||||||
"node_modules/@nodelib/fs.walk": {
|
"node_modules/@nodelib/fs.walk": {
|
||||||
"version": "1.2.4",
|
"version": "1.2.4",
|
||||||
"integrity": "sha512-1V9XOY4rDW0rehzbrcqAmHnz8e7SKvX27gh8Gt2WgB0+pdzdiLV83p72kZPU+jvMbS1qU5mauP2iOvO8rhmurQ==",
|
"integrity": "sha512-1V9XOY4rDW0rehzbrcqAmHnz8e7SKvX27gh8Gt2WgB0+pdzdiLV83p72kZPU+jvMbS1qU5mauP2iOvO8rhmurQ==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodelib/fs.scandir": "2.1.3",
|
"@nodelib/fs.scandir": "2.1.3",
|
||||||
"fastq": "^1.6.0"
|
"fastq": "^1.6.0"
|
||||||
@@ -507,6 +504,16 @@
|
|||||||
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/del": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/del/-/del-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-LDE5atstX5kKnTobWknpmGHC52DH/tp8pIVsD2SSxaOFqW3AQr0EpdzYIfkZ331xe7l9Vn9NlJsBG6viU3mjBA==",
|
||||||
|
"deprecated": "This is a stub types definition. del provides its own type definitions, so you do not need this installed.",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"del": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/json-schema": {
|
"node_modules/@types/json-schema": {
|
||||||
"version": "7.0.8",
|
"version": "7.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.8.tgz",
|
||||||
@@ -544,9 +551,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "16.4.6",
|
"version": "12.12.70",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.70.tgz",
|
||||||
"integrity": "sha512-FKyawK3o5KL16AwbeFajen8G4K3mmqUrQsehn5wNKs8IzlKHE8TfnSmILXVMVziAEcnB23u1RCFU1NT6hSyr7Q=="
|
"integrity": "sha512-i5y7HTbvhonZQE+GnUM2rz1Bi8QkzxdQmEv1LKOv4nWyaQk/gdeiTApuQR3PDJHX7WomAbpx2wlWSEpxXGZ/UQ=="
|
||||||
},
|
},
|
||||||
"node_modules/@types/normalize-package-data": {
|
"node_modules/@types/normalize-package-data": {
|
||||||
"version": "2.4.0",
|
"version": "2.4.0",
|
||||||
@@ -862,7 +869,6 @@
|
|||||||
"node_modules/aggregate-error": {
|
"node_modules/aggregate-error": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"integrity": "sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA==",
|
"integrity": "sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"clean-stack": "^2.0.0",
|
"clean-stack": "^2.0.0",
|
||||||
"indent-string": "^4.0.0"
|
"indent-string": "^4.0.0"
|
||||||
@@ -1376,7 +1382,6 @@
|
|||||||
"node_modules/braces": {
|
"node_modules/braces": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fill-range": "^7.0.1"
|
"fill-range": "^7.0.1"
|
||||||
},
|
},
|
||||||
@@ -1557,7 +1562,6 @@
|
|||||||
"node_modules/clean-stack": {
|
"node_modules/clean-stack": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==",
|
"integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
@@ -1887,7 +1891,6 @@
|
|||||||
"version": "6.0.0",
|
"version": "6.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/del/-/del-6.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/del/-/del-6.0.0.tgz",
|
||||||
"integrity": "sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ==",
|
"integrity": "sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"globby": "^11.0.1",
|
"globby": "^11.0.1",
|
||||||
"graceful-fs": "^4.2.4",
|
"graceful-fs": "^4.2.4",
|
||||||
@@ -1921,7 +1924,6 @@
|
|||||||
"node_modules/dir-glob": {
|
"node_modules/dir-glob": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
|
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"path-type": "^4.0.0"
|
"path-type": "^4.0.0"
|
||||||
},
|
},
|
||||||
@@ -2909,7 +2911,6 @@
|
|||||||
"node_modules/fast-glob": {
|
"node_modules/fast-glob": {
|
||||||
"version": "3.2.2",
|
"version": "3.2.2",
|
||||||
"integrity": "sha512-UDV82o4uQyljznxwMxyVRJgZZt3O5wENYojjzbaGEGZgeOxkLFf+V4cnUD+krzb2F72E18RhamkMZ7AdeggF7A==",
|
"integrity": "sha512-UDV82o4uQyljznxwMxyVRJgZZt3O5wENYojjzbaGEGZgeOxkLFf+V4cnUD+krzb2F72E18RhamkMZ7AdeggF7A==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodelib/fs.stat": "^2.0.2",
|
"@nodelib/fs.stat": "^2.0.2",
|
||||||
"@nodelib/fs.walk": "^1.2.3",
|
"@nodelib/fs.walk": "^1.2.3",
|
||||||
@@ -2936,7 +2937,6 @@
|
|||||||
"node_modules/fastq": {
|
"node_modules/fastq": {
|
||||||
"version": "1.8.0",
|
"version": "1.8.0",
|
||||||
"integrity": "sha512-SMIZoZdLh/fgofivvIkmknUXyPnvxRE3DhtZ5Me3Mrsk5gyPL42F0xr51TdRXskBxHfMp+07bcYzfsYEsSQA9Q==",
|
"integrity": "sha512-SMIZoZdLh/fgofivvIkmknUXyPnvxRE3DhtZ5Me3Mrsk5gyPL42F0xr51TdRXskBxHfMp+07bcYzfsYEsSQA9Q==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"reusify": "^1.0.4"
|
"reusify": "^1.0.4"
|
||||||
}
|
}
|
||||||
@@ -2977,7 +2977,6 @@
|
|||||||
"node_modules/fill-range": {
|
"node_modules/fill-range": {
|
||||||
"version": "7.0.1",
|
"version": "7.0.1",
|
||||||
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"to-regex-range": "^5.0.1"
|
"to-regex-range": "^5.0.1"
|
||||||
},
|
},
|
||||||
@@ -3163,7 +3162,6 @@
|
|||||||
"version": "5.1.2",
|
"version": "5.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
|
||||||
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
|
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"is-glob": "^4.0.1"
|
"is-glob": "^4.0.1"
|
||||||
},
|
},
|
||||||
@@ -3205,7 +3203,6 @@
|
|||||||
"version": "11.0.4",
|
"version": "11.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz",
|
||||||
"integrity": "sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==",
|
"integrity": "sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"array-union": "^2.1.0",
|
"array-union": "^2.1.0",
|
||||||
"dir-glob": "^3.0.1",
|
"dir-glob": "^3.0.1",
|
||||||
@@ -3340,7 +3337,6 @@
|
|||||||
"node_modules/ignore": {
|
"node_modules/ignore": {
|
||||||
"version": "5.1.4",
|
"version": "5.1.4",
|
||||||
"integrity": "sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==",
|
"integrity": "sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 4"
|
"node": ">= 4"
|
||||||
}
|
}
|
||||||
@@ -3420,7 +3416,6 @@
|
|||||||
"node_modules/indent-string": {
|
"node_modules/indent-string": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==",
|
"integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
@@ -3555,7 +3550,6 @@
|
|||||||
"node_modules/is-extglob": {
|
"node_modules/is-extglob": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=",
|
"integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
@@ -3571,7 +3565,6 @@
|
|||||||
"node_modules/is-glob": {
|
"node_modules/is-glob": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==",
|
"integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"is-extglob": "^2.1.1"
|
"is-extglob": "^2.1.1"
|
||||||
},
|
},
|
||||||
@@ -3631,7 +3624,6 @@
|
|||||||
"node_modules/is-number": {
|
"node_modules/is-number": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.0",
|
||||||
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.12.0"
|
"node": ">=0.12.0"
|
||||||
}
|
}
|
||||||
@@ -3661,7 +3653,6 @@
|
|||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz",
|
||||||
"integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==",
|
"integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
@@ -3670,7 +3661,6 @@
|
|||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
|
||||||
"integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==",
|
"integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
@@ -4245,7 +4235,6 @@
|
|||||||
"node_modules/merge2": {
|
"node_modules/merge2": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"integrity": "sha512-2j4DAdlBOkiSZIsaXk4mTE3sRS02yBHAtfy127xRV3bQUFqXkjHCHLW6Scv7DwNRbIWNHH8zpnz9zMaKXIdvYw==",
|
"integrity": "sha512-2j4DAdlBOkiSZIsaXk4mTE3sRS02yBHAtfy127xRV3bQUFqXkjHCHLW6Scv7DwNRbIWNHH8zpnz9zMaKXIdvYw==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 6"
|
"node": ">= 6"
|
||||||
}
|
}
|
||||||
@@ -4254,7 +4243,6 @@
|
|||||||
"version": "4.0.4",
|
"version": "4.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz",
|
||||||
"integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==",
|
"integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"braces": "^3.0.1",
|
"braces": "^3.0.1",
|
||||||
"picomatch": "^2.2.3"
|
"picomatch": "^2.2.3"
|
||||||
@@ -4638,7 +4626,6 @@
|
|||||||
"node_modules/p-map": {
|
"node_modules/p-map": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==",
|
"integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"aggregate-error": "^3.0.0"
|
"aggregate-error": "^3.0.0"
|
||||||
},
|
},
|
||||||
@@ -4782,7 +4769,6 @@
|
|||||||
"node_modules/path-type": {
|
"node_modules/path-type": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
|
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
@@ -4791,7 +4777,6 @@
|
|||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz",
|
||||||
"integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==",
|
"integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.6"
|
"node": ">=8.6"
|
||||||
},
|
},
|
||||||
@@ -5433,7 +5418,6 @@
|
|||||||
"node_modules/reusify": {
|
"node_modules/reusify": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==",
|
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"iojs": ">=1.0.0",
|
"iojs": ">=1.0.0",
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
@@ -5442,7 +5426,6 @@
|
|||||||
"node_modules/rimraf": {
|
"node_modules/rimraf": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
|
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"glob": "^7.1.3"
|
"glob": "^7.1.3"
|
||||||
},
|
},
|
||||||
@@ -5455,8 +5438,7 @@
|
|||||||
},
|
},
|
||||||
"node_modules/run-parallel": {
|
"node_modules/run-parallel": {
|
||||||
"version": "1.1.9",
|
"version": "1.1.9",
|
||||||
"integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==",
|
"integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"node_modules/safe-buffer": {
|
"node_modules/safe-buffer": {
|
||||||
"version": "5.1.2",
|
"version": "5.1.2",
|
||||||
@@ -5603,7 +5585,6 @@
|
|||||||
"node_modules/slash": {
|
"node_modules/slash": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
|
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
@@ -6030,7 +6011,6 @@
|
|||||||
"node_modules/to-regex-range": {
|
"node_modules/to-regex-range": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"is-number": "^7.0.0"
|
"is-number": "^7.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
+21
@@ -0,0 +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
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
This is a stub types definition for del (https://github.com/sindresorhus/del).
|
||||||
|
|
||||||
|
del provides its own type definitions, so you don't need @types/del installed!
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "@types/del",
|
||||||
|
"version": "4.0.0",
|
||||||
|
"typings": null,
|
||||||
|
"description": "Stub TypeScript definitions entry for del, which provides its own types definitions",
|
||||||
|
"main": "",
|
||||||
|
"scripts": {},
|
||||||
|
"author": "",
|
||||||
|
"repository": "https://github.com/sindresorhus/del",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"del": "*"
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-4
@@ -5,12 +5,12 @@
|
|||||||
This package contains type definitions for Node.js (http://nodejs.org/).
|
This package contains type definitions for Node.js (http://nodejs.org/).
|
||||||
|
|
||||||
# Details
|
# Details
|
||||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v12.
|
||||||
|
|
||||||
### Additional Details
|
### Additional Details
|
||||||
* Last updated: Wed, 28 Jul 2021 19:31:18 GMT
|
* Last updated: Wed, 21 Oct 2020 17:47:46 GMT
|
||||||
* Dependencies: none
|
* Dependencies: none
|
||||||
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`
|
* Global values: `Buffer`, `NodeJS`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
|
||||||
|
|
||||||
# Credits
|
# Credits
|
||||||
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).
|
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), [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), [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), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), and [Jason Kwok](https://github.com/JasonHK).
|
||||||
|
|||||||
+71
-1421
File diff suppressed because it is too large
Load Diff
-8
@@ -1,8 +0,0 @@
|
|||||||
declare module 'assert/strict' {
|
|
||||||
import { strict } from 'node:assert';
|
|
||||||
export = strict;
|
|
||||||
}
|
|
||||||
declare module 'node:assert/strict' {
|
|
||||||
import { strict } from 'node:assert';
|
|
||||||
export = strict;
|
|
||||||
}
|
|
||||||
+114
-364
@@ -1,47 +1,16 @@
|
|||||||
/**
|
/**
|
||||||
* The `async_hooks` module provides an API to track asynchronous resources. It
|
* Async Hooks module: https://nodejs.org/api/async_hooks.html
|
||||||
* 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" {
|
||||||
/**
|
/**
|
||||||
* ```js
|
* Returns the asyncId of the current execution context.
|
||||||
* 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;
|
function executionAsyncId(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The resource representing the current execution.
|
||||||
|
* Useful to store data within the resource.
|
||||||
|
*
|
||||||
* Resource objects returned by `executionAsyncResource()` are most often internal
|
* Resource objects returned by `executionAsyncResource()` are most often internal
|
||||||
* Node.js handle objects with undocumented APIs. Using any functions or properties
|
* 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.
|
* on the object is likely to crash your application and should be avoided.
|
||||||
@@ -49,70 +18,14 @@ declare module 'async_hooks' {
|
|||||||
* Using `executionAsyncResource()` in the top-level execution context will
|
* Using `executionAsyncResource()` in the top-level execution context will
|
||||||
* return an empty object as there is no handle or request object to use,
|
* 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.
|
* 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;
|
function executionAsyncResource(): object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ```js
|
* Returns the ID of the resource responsible for calling the callback that is currently being executed.
|
||||||
* 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;
|
function triggerAsyncId(): number;
|
||||||
|
|
||||||
interface HookCallbacks {
|
interface HookCallbacks {
|
||||||
/**
|
/**
|
||||||
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
||||||
@@ -122,133 +35,73 @@ declare module 'async_hooks' {
|
|||||||
* @param resource reference to the resource representing the async operation, needs to be released during destroy
|
* @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.
|
* 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.
|
* 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.
|
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
|
||||||
*/
|
*/
|
||||||
before?(asyncId: number): void;
|
before?(asyncId: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called immediately after the callback specified in before is completed.
|
* Called immediately after the callback specified in before is completed.
|
||||||
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
||||||
*/
|
*/
|
||||||
after?(asyncId: number): void;
|
after?(asyncId: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a promise has resolve() called. This may not be in the same execution id
|
* Called when a promise has resolve() called. This may not be in the same execution id
|
||||||
* as the promise itself.
|
* as the promise itself.
|
||||||
* @param asyncId the unique id for the promise that was resolve()d.
|
* @param asyncId the unique id for the promise that was resolve()d.
|
||||||
*/
|
*/
|
||||||
promiseResolve?(asyncId: number): void;
|
promiseResolve?(asyncId: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after the resource corresponding to asyncId is destroyed
|
* Called after the resource corresponding to asyncId is destroyed
|
||||||
* @param asyncId a unique ID for the async resource
|
* @param asyncId a unique ID for the async resource
|
||||||
*/
|
*/
|
||||||
destroy?(asyncId: number): void;
|
destroy?(asyncId: number): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AsyncHook {
|
interface AsyncHook {
|
||||||
/**
|
/**
|
||||||
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
||||||
*/
|
*/
|
||||||
enable(): this;
|
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 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;
|
disable(): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers functions to be called for different lifetime events of each async
|
* Registers functions to be called for different lifetime events of each async operation.
|
||||||
* operation.
|
* @param options the callbacks to register
|
||||||
*
|
* @return an AsyncHooks instance used for disabling and enabling hooks
|
||||||
* 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(callbacks: HookCallbacks): AsyncHook;
|
function createHook(options: HookCallbacks): AsyncHook;
|
||||||
|
|
||||||
interface AsyncResourceOptions {
|
interface AsyncResourceOptions {
|
||||||
/**
|
/**
|
||||||
* The ID of the execution context that created this async event.
|
* The ID of the execution context that created this async event.
|
||||||
* @default executionAsyncId()
|
* Default: `executionAsyncId()`
|
||||||
*/
|
*/
|
||||||
triggerAsyncId?: number | undefined;
|
triggerAsyncId?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables automatic `emitDestroy` when the object is garbage collected.
|
* Disables automatic `emitDestroy` when the object is garbage collected.
|
||||||
* This usually does not need to be set (even if `emitDestroy` is called
|
* This usually does not need to be set (even if `emitDestroy` is called
|
||||||
* manually), unless the resource's `asyncId` is retrieved and the
|
* manually), unless the resource's `asyncId` is retrieved and the
|
||||||
* sensitive API's `emitDestroy` is called with it.
|
* sensitive API's `emitDestroy` is called with it.
|
||||||
* @default false
|
* Default: `false`
|
||||||
*/
|
*/
|
||||||
requireManualDestroy?: boolean | undefined;
|
requireManualDestroy?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class `AsyncResource` is designed to be extended by the embedder's async
|
* The class AsyncResource was designed to be extended by the embedder's async resources.
|
||||||
* resources. Using this, users can easily trigger the lifetime events of their
|
* Using this users can easily trigger the lifetime events of their own resources.
|
||||||
* 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 {
|
class AsyncResource {
|
||||||
/**
|
/**
|
||||||
@@ -261,237 +114,134 @@ declare module 'async_hooks' {
|
|||||||
* AsyncResourceOptions object (since 9.3)
|
* AsyncResourceOptions object (since 9.3)
|
||||||
*/
|
*/
|
||||||
constructor(type: string, triggerAsyncId?: number|AsyncResourceOptions);
|
constructor(type: string, triggerAsyncId?: number|AsyncResourceOptions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds the given function to the current execution context.
|
* Call the provided function with the provided arguments in the
|
||||||
*
|
* execution context of the async resource. This will establish the
|
||||||
* The returned function will have an `asyncResource` property referencing
|
* context, trigger the AsyncHooks before callbacks, call the function,
|
||||||
* the `AsyncResource` to which the function is bound.
|
* trigger the AsyncHooks after callbacks, and then restore the original
|
||||||
* @since v14.8.0, v12.19.0
|
* execution context.
|
||||||
* @param fn The function to bind to the current execution context.
|
* @param fn The function to call in the execution context of this
|
||||||
* @param type An optional name to associate with the underlying `AsyncResource`.
|
* async resource.
|
||||||
*/
|
|
||||||
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 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;
|
runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call all `destroy` hooks. This should only ever be called once. An error will
|
* Call AsyncHooks destroy callbacks.
|
||||||
* 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(): this;
|
emitDestroy(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The unique `asyncId` assigned to the resource.
|
* @return the unique ID assigned to this AsyncResource instance.
|
||||||
*/
|
*/
|
||||||
asyncId(): number;
|
asyncId(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return the trigger ID for this AsyncResource instance.
|
||||||
* @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor.
|
|
||||||
*/
|
*/
|
||||||
triggerAsyncId(): number;
|
triggerAsyncId(): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class creates stores that stay coherent through asynchronous operations.
|
* When having multiple instances of `AsyncLocalStorage`, they are independent
|
||||||
*
|
* from each other. It is safe to instantiate this class multiple times.
|
||||||
* 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> {
|
class AsyncLocalStorage<T> {
|
||||||
/**
|
/**
|
||||||
* Disables the instance of `AsyncLocalStorage`. All subsequent calls
|
* This method disables the instance of `AsyncLocalStorage`. All subsequent calls
|
||||||
* to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
|
* to `asyncLocalStorage.getStore()` will return `undefined` until
|
||||||
|
* `asyncLocalStorage.run()` or `asyncLocalStorage.runSyncAndReturn()`
|
||||||
|
* is called again.
|
||||||
*
|
*
|
||||||
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
||||||
* instance will be exited.
|
* instance will be exited.
|
||||||
*
|
*
|
||||||
* Calling `asyncLocalStorage.disable()` is required before the`asyncLocalStorage` can be garbage collected. This does not apply to stores
|
* 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
|
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
||||||
* along with the corresponding async resources.
|
* along with the corresponding async resources.
|
||||||
*
|
*
|
||||||
* Use this method when the `asyncLocalStorage` is not in use anymore
|
* This method is to be used when the `asyncLocalStorage` is not in use anymore
|
||||||
* in the current process.
|
* in the current process.
|
||||||
* @since v13.10.0, v12.17.0
|
|
||||||
* @experimental
|
|
||||||
*/
|
*/
|
||||||
disable(): void;
|
disable(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current store.
|
* This method returns the current store.
|
||||||
* If called outside of an asynchronous context initialized by
|
* If this method is called outside of an asynchronous context initialized by
|
||||||
* calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
|
* calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will
|
||||||
* returns `undefined`.
|
* return `undefined`.
|
||||||
* @since v13.10.0, v12.17.0
|
|
||||||
*/
|
*/
|
||||||
getStore(): T | undefined;
|
getStore(): T | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs a function synchronously within a context and returns its
|
* Calling `asyncLocalStorage.run(callback)` will create a new asynchronous
|
||||||
|
* context.
|
||||||
|
* Within the callback function and the asynchronous operations from the callback,
|
||||||
|
* `asyncLocalStorage.getStore()` will return an instance of `Map` known as
|
||||||
|
* "the store". This store will be persistent through the following
|
||||||
|
* asynchronous calls.
|
||||||
|
*
|
||||||
|
* The callback will be ran asynchronously. Optionally, arguments can be passed
|
||||||
|
* to the function. They will be passed to the callback function.
|
||||||
|
*
|
||||||
|
* If an error is thrown by the callback function, it will not be caught by
|
||||||
|
* a `try/catch` block as the callback is ran in a new asynchronous resource.
|
||||||
|
* Also, the stacktrace will be impacted by the asynchronous call.
|
||||||
|
*/
|
||||||
|
// TODO: Apply generic vararg once available
|
||||||
|
run(store: T, callback: (...args: any[]) => void, ...args: any[]): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous
|
||||||
|
* context.
|
||||||
|
* Within the callback function and the asynchronous operations from the callback,
|
||||||
|
* `asyncLocalStorage.getStore()` will return `undefined`.
|
||||||
|
*
|
||||||
|
* The callback will be ran asynchronously. Optionally, arguments can be passed
|
||||||
|
* to the function. They will be passed to the callback function.
|
||||||
|
*
|
||||||
|
* If an error is thrown by the callback function, it will not be caught by
|
||||||
|
* a `try/catch` block as the callback is ran in a new asynchronous resource.
|
||||||
|
* Also, the stacktrace will be impacted by the asynchronous call.
|
||||||
|
*/
|
||||||
|
exit(callback: (...args: any[]) => void, ...args: any[]): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This methods runs a function synchronously within a context and return its
|
||||||
* return value. The store is not accessible outside of the callback function or
|
* return value. The store is not accessible outside of the callback function or
|
||||||
* the asynchronous operations created within the callback.
|
* the asynchronous operations created within the callback.
|
||||||
*
|
*
|
||||||
* The optional `args` are passed to the callback function.
|
* Optionally, arguments can be passed to the function. They will be passed to
|
||||||
|
* the callback function.
|
||||||
*
|
*
|
||||||
* If the callback function throws an error, the error is thrown by `run()` too.
|
* If the callback function throws an error, it will be thrown by
|
||||||
* The stacktrace is not impacted by this call and the context is exited.
|
* `runSyncAndReturn` too. The stacktrace will not be impacted by this call and
|
||||||
*
|
* the context will be 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;
|
runSyncAndReturn<R>(store: T, callback: (...args: any[]) => R, ...args: any[]): R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs a function synchronously outside of a context and returns its
|
* This methods runs a function synchronously outside of a context and return its
|
||||||
* return value. The store is not accessible within the callback function or
|
* 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 asynchronous operations created within the callback.
|
||||||
*
|
*
|
||||||
* The optional `args` are passed to the callback function.
|
* Optionally, arguments can be passed to the function. They will be passed to
|
||||||
|
* the callback function.
|
||||||
*
|
*
|
||||||
* If the callback function throws an error, the error is thrown by `exit()` too.
|
* If the callback function throws an error, it will be thrown by
|
||||||
* The stacktrace is not impacted by this call and the context is re-entered.
|
* `exitSyncAndReturn` too. The stacktrace will not be impacted by this call and
|
||||||
*
|
* the context will be 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;
|
exitSyncAndReturn<R>(callback: (...args: any[]) => R, ...args: any[]): R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transitions into the context for the remainder of the current
|
* Calling `asyncLocalStorage.enterWith(store)` will transition into the context
|
||||||
* synchronous execution and then persists the store through any following
|
* for the remainder of the current synchronous execution and will persist
|
||||||
* asynchronous calls.
|
* 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;
|
enterWith(store: T): void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module 'node:async_hooks' {
|
|
||||||
export * from 'async_hooks';
|
|
||||||
}
|
|
||||||
|
|||||||
+1
@@ -13,6 +13,7 @@
|
|||||||
/// <reference lib="esnext.bigint" />
|
/// <reference lib="esnext.bigint" />
|
||||||
|
|
||||||
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
|
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
|
||||||
|
// tslint:disable-next-line:no-bad-reference
|
||||||
/// <reference path="ts3.6/base.d.ts" />
|
/// <reference path="ts3.6/base.d.ts" />
|
||||||
|
|
||||||
// TypeScript 3.7-specific augmentations:
|
// TypeScript 3.7-specific augmentations:
|
||||||
|
|||||||
+9
-1772
File diff suppressed because it is too large
Load Diff
+300
-1163
File diff suppressed because it is too large
Load Diff
+210
-358
@@ -1,272 +1,37 @@
|
|||||||
/**
|
declare module "cluster" {
|
||||||
* A single instance of Node.js runs in a single thread. To take advantage of
|
import * as child from "child_process";
|
||||||
* multi-core systems, the user will sometimes want to launch a cluster of Node.js
|
import * as events from "events";
|
||||||
* processes to handle the load.
|
import * as net from "net";
|
||||||
*
|
|
||||||
* The cluster module allows easy creation of child processes that all share
|
// interfaces
|
||||||
* server ports.
|
interface ClusterSettings {
|
||||||
*
|
execArgv?: string[]; // default: process.execArgv
|
||||||
* ```js
|
exec?: string;
|
||||||
* const cluster = require('cluster');
|
args?: string[];
|
||||||
* const http = require('http');
|
silent?: boolean;
|
||||||
* const numCPUs = require('os').cpus().length;
|
stdio?: any[];
|
||||||
*
|
uid?: number;
|
||||||
* if (cluster.isPrimary) {
|
gid?: number;
|
||||||
* console.log(`Primary ${process.pid} is running`);
|
inspectPort?: number | (() => number);
|
||||||
*
|
|
||||||
* // 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;
|
|
||||||
}
|
}
|
||||||
export interface Address {
|
|
||||||
|
interface Address {
|
||||||
address: string;
|
address: string;
|
||||||
port: number;
|
port: number;
|
||||||
addressType: number | 'udp4' | 'udp6'; // 4, 6, -1, "udp4", "udp6"
|
addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6"
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* A `Worker` object contains all public information and method about a worker.
|
class Worker extends events.EventEmitter {
|
||||||
* 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;
|
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;
|
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, callback?: (error: Error | null) => void): boolean;
|
|
||||||
send(message: child.Serializable, sendHandle: child.SendHandle, callback?: (error: Error | null) => void): boolean;
|
|
||||||
send(message: child.Serializable, sendHandle: child.SendHandle, options?: child.MessageOptions, 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;
|
kill(signal?: string): void;
|
||||||
destroy(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;
|
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;
|
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;
|
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;
|
exitedAfterDisconnect: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* events.EventEmitter
|
* events.EventEmitter
|
||||||
* 1. disconnect
|
* 1. disconnect
|
||||||
@@ -277,67 +42,68 @@ declare module 'cluster' {
|
|||||||
* 6. online
|
* 6. online
|
||||||
*/
|
*/
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'disconnect', listener: () => void): this;
|
addListener(event: "disconnect", listener: () => void): this;
|
||||||
addListener(event: 'error', listener: (error: Error) => void): this;
|
addListener(event: "error", listener: (error: Error) => void): this;
|
||||||
addListener(event: 'exit', listener: (code: number, signal: string) => void): this;
|
addListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
addListener(event: 'listening', listener: (address: Address) => void): this;
|
addListener(event: "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: "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: "online", listener: () => void): this;
|
||||||
|
|
||||||
emit(event: string | symbol, ...args: any[]): boolean;
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
emit(event: 'disconnect'): boolean;
|
emit(event: "disconnect"): boolean;
|
||||||
emit(event: 'error', error: Error): boolean;
|
emit(event: "error", error: Error): boolean;
|
||||||
emit(event: 'exit', code: number, signal: string): boolean;
|
emit(event: "exit", code: number, signal: string): boolean;
|
||||||
emit(event: 'listening', address: Address): boolean;
|
emit(event: "listening", address: Address): boolean;
|
||||||
emit(event: 'message', message: any, handle: net.Socket | net.Server): boolean;
|
emit(event: "message", message: any, handle: net.Socket | net.Server): boolean;
|
||||||
emit(event: 'online'): boolean;
|
emit(event: "online"): boolean;
|
||||||
|
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
on(event: 'disconnect', listener: () => void): this;
|
on(event: "disconnect", listener: () => void): this;
|
||||||
on(event: 'error', listener: (error: Error) => void): this;
|
on(event: "error", listener: (error: Error) => void): this;
|
||||||
on(event: 'exit', listener: (code: number, signal: string) => void): this;
|
on(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
on(event: 'listening', listener: (address: Address) => void): this;
|
on(event: "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: "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: "online", listener: () => void): this;
|
||||||
|
|
||||||
once(event: string, listener: (...args: any[]) => void): this;
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
once(event: 'disconnect', listener: () => void): this;
|
once(event: "disconnect", listener: () => void): this;
|
||||||
once(event: 'error', listener: (error: Error) => void): this;
|
once(event: "error", listener: (error: Error) => void): this;
|
||||||
once(event: 'exit', listener: (code: number, signal: string) => void): this;
|
once(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
once(event: 'listening', listener: (address: Address) => void): this;
|
once(event: "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: "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: "online", listener: () => void): this;
|
||||||
|
|
||||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependListener(event: 'disconnect', listener: () => void): this;
|
prependListener(event: "disconnect", listener: () => void): this;
|
||||||
prependListener(event: 'error', listener: (error: Error) => void): this;
|
prependListener(event: "error", listener: (error: Error) => void): this;
|
||||||
prependListener(event: 'exit', listener: (code: number, signal: string) => void): this;
|
prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
prependListener(event: 'listening', listener: (address: Address) => void): this;
|
prependListener(event: "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: "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: "online", listener: () => void): this;
|
||||||
|
|
||||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependOnceListener(event: 'disconnect', listener: () => void): this;
|
prependOnceListener(event: "disconnect", listener: () => void): this;
|
||||||
prependOnceListener(event: 'error', listener: (error: Error) => void): this;
|
prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
||||||
prependOnceListener(event: 'exit', listener: (code: number, signal: string) => void): this;
|
prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||||
prependOnceListener(event: 'listening', listener: (address: Address) => void): this;
|
prependOnceListener(event: "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: "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: "online", listener: () => void): this;
|
||||||
}
|
}
|
||||||
export interface Cluster extends EventEmitter {
|
|
||||||
|
interface Cluster extends events.EventEmitter {
|
||||||
|
Worker: Worker;
|
||||||
disconnect(callback?: () => void): void;
|
disconnect(callback?: () => void): void;
|
||||||
fork(env?: any): Worker;
|
fork(env?: any): Worker;
|
||||||
/** @deprecated since v16.0.0 - use setupPrimary. */
|
isMaster: boolean;
|
||||||
readonly isMaster: boolean;
|
isWorker: boolean;
|
||||||
readonly isPrimary: boolean;
|
// TODO: cluster.schedulingPolicy
|
||||||
readonly isWorker: boolean;
|
settings: ClusterSettings;
|
||||||
schedulingPolicy: number;
|
|
||||||
readonly settings: ClusterSettings;
|
|
||||||
/** @deprecated since v16.0.0 - use setupPrimary. */
|
|
||||||
setupMaster(settings?: ClusterSettings): void;
|
setupMaster(settings?: ClusterSettings): void;
|
||||||
/**
|
worker?: Worker;
|
||||||
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings.
|
workers?: {
|
||||||
*/
|
[index: string]: Worker | undefined
|
||||||
setupPrimary(settings?: ClusterSettings): void;
|
};
|
||||||
readonly worker?: Worker | undefined;
|
|
||||||
readonly workers?: NodeJS.Dict<Worker> | undefined;
|
|
||||||
readonly SCHED_NONE: number;
|
|
||||||
readonly SCHED_RR: number;
|
|
||||||
/**
|
/**
|
||||||
* events.EventEmitter
|
* events.EventEmitter
|
||||||
* 1. disconnect
|
* 1. disconnect
|
||||||
@@ -349,60 +115,146 @@ declare module 'cluster' {
|
|||||||
* 7. setup
|
* 7. setup
|
||||||
*/
|
*/
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'disconnect', listener: (worker: Worker) => void): this;
|
addListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
addListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
addListener(event: 'fork', listener: (worker: Worker) => void): this;
|
addListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
addListener(event: 'listening', listener: (worker: Worker, address: Address) => 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: "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: "online", listener: (worker: Worker) => void): this;
|
||||||
addListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
addListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
|
|
||||||
emit(event: string | symbol, ...args: any[]): boolean;
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
emit(event: 'disconnect', worker: Worker): boolean;
|
emit(event: "disconnect", worker: Worker): boolean;
|
||||||
emit(event: 'exit', worker: Worker, code: number, signal: string): boolean;
|
emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
|
||||||
emit(event: 'fork', worker: Worker): boolean;
|
emit(event: "fork", worker: Worker): boolean;
|
||||||
emit(event: 'listening', worker: Worker, address: Address): boolean;
|
emit(event: "listening", worker: Worker, address: Address): boolean;
|
||||||
emit(event: 'message', worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
|
emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
|
||||||
emit(event: 'online', worker: Worker): boolean;
|
emit(event: "online", worker: Worker): boolean;
|
||||||
emit(event: 'setup', settings: ClusterSettings): boolean;
|
emit(event: "setup", settings: ClusterSettings): boolean;
|
||||||
|
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
on(event: 'disconnect', listener: (worker: Worker) => void): this;
|
on(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
on(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
on(event: 'fork', listener: (worker: Worker) => void): this;
|
on(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
on(event: 'listening', listener: (worker: Worker, address: Address) => 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: "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: "online", listener: (worker: Worker) => void): this;
|
||||||
on(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
on(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
|
|
||||||
once(event: string, listener: (...args: any[]) => void): this;
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
once(event: 'disconnect', listener: (worker: Worker) => void): this;
|
once(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
once(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
once(event: 'fork', listener: (worker: Worker) => void): this;
|
once(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
once(event: 'listening', listener: (worker: Worker, address: Address) => 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: "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: "online", listener: (worker: Worker) => void): this;
|
||||||
once(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
once(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
|
|
||||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependListener(event: 'disconnect', listener: (worker: Worker) => void): this;
|
prependListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
prependListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
prependListener(event: 'fork', listener: (worker: Worker) => void): this;
|
prependListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
prependListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||||
// the handle is a net.Socket or net.Server object, or undefined.
|
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: 'message', listener: (worker: Worker, message: any, handle?: net.Socket | net.Server) => void): this;
|
prependListener(event: "online", listener: (worker: Worker) => void): this;
|
||||||
prependListener(event: 'online', listener: (worker: Worker) => void): this;
|
prependListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
prependListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
|
||||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependOnceListener(event: 'disconnect', listener: (worker: Worker) => void): this;
|
prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||||
prependOnceListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||||
prependOnceListener(event: 'fork', listener: (worker: Worker) => void): this;
|
prependOnceListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||||
prependOnceListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||||
// the handle is a net.Socket or net.Server object, or undefined.
|
// 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: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this;
|
||||||
prependOnceListener(event: 'online', listener: (worker: Worker) => void): this;
|
prependOnceListener(event: "online", listener: (worker: Worker) => void): this;
|
||||||
prependOnceListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||||
}
|
}
|
||||||
const cluster: Cluster;
|
|
||||||
export default cluster;
|
function disconnect(callback?: () => void): void;
|
||||||
}
|
function fork(env?: any): Worker;
|
||||||
declare module 'node:cluster' {
|
const isMaster: boolean;
|
||||||
export * from 'cluster';
|
const isWorker: boolean;
|
||||||
export { default as default } from 'cluster';
|
// 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[];
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-405
@@ -1,407 +1,3 @@
|
|||||||
/**
|
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;
|
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;
|
|
||||||
}
|
|
||||||
|
|||||||
+446
-16
@@ -1,18 +1,448 @@
|
|||||||
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
|
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
|
||||||
declare module 'constants' {
|
declare module "constants" {
|
||||||
import { constants as osConstants, SignalConstants } from 'node:os';
|
/** @deprecated since v6.3.0 - use `os.constants.errno.E2BIG` instead. */
|
||||||
import { constants as cryptoConstants } from 'node:crypto';
|
const E2BIG: number;
|
||||||
import { constants as fsConstants } from 'node:fs';
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EACCES` instead. */
|
||||||
|
const EACCES: number;
|
||||||
const exp: typeof osConstants.errno &
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EADDRINUSE` instead. */
|
||||||
typeof osConstants.priority &
|
const EADDRINUSE: number;
|
||||||
SignalConstants &
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EADDRNOTAVAIL` instead. */
|
||||||
typeof cryptoConstants &
|
const EADDRNOTAVAIL: number;
|
||||||
typeof fsConstants;
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EAFNOSUPPORT` instead. */
|
||||||
export = exp;
|
const EAFNOSUPPORT: number;
|
||||||
}
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EAGAIN` instead. */
|
||||||
|
const EAGAIN: number;
|
||||||
declare module 'node:constants' {
|
/** @deprecated since v6.3.0 - use `os.constants.errno.EALREADY` instead. */
|
||||||
import constants = require('constants');
|
const EALREADY: number;
|
||||||
export = constants;
|
/** @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;
|
||||||
}
|
}
|
||||||
|
|||||||
+315
-3527
File diff suppressed because it is too large
Load Diff
+58
-476
@@ -1,490 +1,70 @@
|
|||||||
/**
|
declare module "dgram" {
|
||||||
* The `dgram` module provides an implementation of UDP datagram sockets.
|
import { AddressInfo } from "net";
|
||||||
*
|
import * as dns from "dns";
|
||||||
* ```js
|
import * as events from "events";
|
||||||
* 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 {
|
interface RemoteInfo {
|
||||||
address: string;
|
address: string;
|
||||||
family: 'IPv4' | 'IPv6';
|
family: 'IPv4' | 'IPv6';
|
||||||
port: number;
|
port: number;
|
||||||
size: number;
|
size: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BindOptions {
|
interface BindOptions {
|
||||||
port?: number | undefined;
|
port?: number;
|
||||||
address?: string | undefined;
|
address?: string;
|
||||||
exclusive?: boolean | undefined;
|
exclusive?: boolean;
|
||||||
fd?: number | undefined;
|
fd?: number;
|
||||||
}
|
}
|
||||||
type SocketType = 'udp4' | 'udp6';
|
|
||||||
interface SocketOptions extends Abortable {
|
type SocketType = "udp4" | "udp6";
|
||||||
|
|
||||||
|
interface SocketOptions {
|
||||||
type: SocketType;
|
type: SocketType;
|
||||||
reuseAddr?: boolean | undefined;
|
reuseAddr?: boolean;
|
||||||
/**
|
/**
|
||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
ipv6Only?: boolean | undefined;
|
ipv6Only?: boolean;
|
||||||
recvBufferSize?: number | undefined;
|
recvBufferSize?: number;
|
||||||
sendBufferSize?: number | undefined;
|
sendBufferSize?: number;
|
||||||
lookup?: ((hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void) | undefined;
|
lookup?: (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 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(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
||||||
function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
||||||
/**
|
|
||||||
* Encapsulates the datagram functionality.
|
class Socket extends events.EventEmitter {
|
||||||
*
|
|
||||||
* 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;
|
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;
|
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, address?: string, callback?: () => void): void;
|
||||||
bind(port?: number, callback?: () => void): void;
|
bind(port?: number, callback?: () => void): void;
|
||||||
bind(callback?: () => void): void;
|
bind(callback?: () => void): void;
|
||||||
bind(options: BindOptions, 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;
|
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, address?: string, callback?: () => void): void;
|
||||||
connect(port: number, 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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
remoteAddress(): AddressInfo;
|
||||||
/**
|
|
||||||
* 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, 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>, 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 | 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, 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, 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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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
|
* events.EventEmitter
|
||||||
* 1. close
|
* 1. close
|
||||||
@@ -494,43 +74,45 @@ declare module 'dgram' {
|
|||||||
* 5. message
|
* 5. message
|
||||||
*/
|
*/
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'close', listener: () => void): this;
|
addListener(event: "close", listener: () => void): this;
|
||||||
addListener(event: 'connect', listener: () => void): this;
|
addListener(event: "connect", listener: () => void): this;
|
||||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
addListener(event: "error", listener: (err: Error) => void): this;
|
||||||
addListener(event: 'listening', listener: () => void): this;
|
addListener(event: "listening", listener: () => void): this;
|
||||||
addListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
addListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
|
|
||||||
emit(event: string | symbol, ...args: any[]): boolean;
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
emit(event: 'close'): boolean;
|
emit(event: "close"): boolean;
|
||||||
emit(event: 'connect'): boolean;
|
emit(event: "connect"): boolean;
|
||||||
emit(event: 'error', err: Error): boolean;
|
emit(event: "error", err: Error): boolean;
|
||||||
emit(event: 'listening'): boolean;
|
emit(event: "listening"): boolean;
|
||||||
emit(event: 'message', msg: Buffer, rinfo: RemoteInfo): boolean;
|
emit(event: "message", msg: Buffer, rinfo: RemoteInfo): boolean;
|
||||||
|
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
on(event: 'close', listener: () => void): this;
|
on(event: "close", listener: () => void): this;
|
||||||
on(event: 'connect', listener: () => void): this;
|
on(event: "connect", listener: () => void): this;
|
||||||
on(event: 'error', listener: (err: Error) => void): this;
|
on(event: "error", listener: (err: Error) => void): this;
|
||||||
on(event: 'listening', listener: () => void): this;
|
on(event: "listening", listener: () => void): this;
|
||||||
on(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
|
|
||||||
once(event: string, listener: (...args: any[]) => void): this;
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
once(event: 'close', listener: () => void): this;
|
once(event: "close", listener: () => void): this;
|
||||||
once(event: 'connect', listener: () => void): this;
|
once(event: "connect", listener: () => void): this;
|
||||||
once(event: 'error', listener: (err: Error) => void): this;
|
once(event: "error", listener: (err: Error) => void): this;
|
||||||
once(event: 'listening', listener: () => void): this;
|
once(event: "listening", listener: () => void): this;
|
||||||
once(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
|
|
||||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependListener(event: 'close', listener: () => void): this;
|
prependListener(event: "close", listener: () => void): this;
|
||||||
prependListener(event: 'connect', listener: () => void): this;
|
prependListener(event: "connect", listener: () => void): this;
|
||||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||||
prependListener(event: 'listening', listener: () => void): this;
|
prependListener(event: "listening", listener: () => void): this;
|
||||||
prependListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
prependListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
|
|
||||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependOnceListener(event: 'close', listener: () => void): this;
|
prependOnceListener(event: "close", listener: () => void): this;
|
||||||
prependOnceListener(event: 'connect', listener: () => void): this;
|
prependOnceListener(event: "connect", listener: () => void): this;
|
||||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||||
prependOnceListener(event: 'listening', listener: () => void): this;
|
prependOnceListener(event: "listening", listener: () => void): this;
|
||||||
prependOnceListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module 'node:dgram' {
|
|
||||||
export * from 'dgram';
|
|
||||||
}
|
|
||||||
|
|||||||
-111
@@ -1,111 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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(onMessage: 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(onMessage: ChannelListener): void;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
declare module 'node:diagnostics_channel' {
|
|
||||||
export * from 'diagnostics_channel';
|
|
||||||
}
|
|
||||||
+258
-531
@@ -1,191 +1,81 @@
|
|||||||
/**
|
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.
|
// Supported getaddrinfo flags.
|
||||||
export const ADDRCONFIG: number;
|
const ADDRCONFIG: number;
|
||||||
export const V4MAPPED: number;
|
const V4MAPPED: number;
|
||||||
/**
|
|
||||||
* If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
|
interface LookupOptions {
|
||||||
* well as IPv4 mapped IPv6 addresses.
|
family?: number;
|
||||||
*/
|
hints?: number;
|
||||||
export const ALL: number;
|
all?: boolean;
|
||||||
export interface LookupOptions {
|
verbatim?: boolean;
|
||||||
family?: number | undefined;
|
|
||||||
hints?: number | undefined;
|
|
||||||
all?: boolean | undefined;
|
|
||||||
verbatim?: boolean | undefined;
|
|
||||||
}
|
}
|
||||||
export interface LookupOneOptions extends LookupOptions {
|
|
||||||
all?: false | undefined;
|
interface LookupOneOptions extends LookupOptions {
|
||||||
|
all?: false;
|
||||||
}
|
}
|
||||||
export interface LookupAllOptions extends LookupOptions {
|
|
||||||
|
interface LookupAllOptions extends LookupOptions {
|
||||||
all: true;
|
all: true;
|
||||||
}
|
}
|
||||||
export interface LookupAddress {
|
|
||||||
|
interface LookupAddress {
|
||||||
address: string;
|
address: string;
|
||||||
family: number;
|
family: number;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
|
function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
||||||
* AAAA (IPv6) record. All `option` properties are optional. If `options` is an
|
function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
||||||
* integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
|
function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void): void;
|
||||||
* and IPv6 addresses are both returned if found.
|
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;
|
||||||
* 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`.
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
||||||
*
|
namespace lookup {
|
||||||
* 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: LookupAllOptions): Promise<LookupAddress[]>;
|
||||||
function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<LookupAddress>;
|
function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<LookupAddress>;
|
||||||
function __promisify__(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
function __promisify__(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Resolves the given `address` and `port` into a host name and service using
|
function lookupService(address: string, port: number, callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void): void;
|
||||||
* the operating system's underlying `getnameinfo` implementation.
|
|
||||||
*
|
namespace lookupService {
|
||||||
* If `address` is not a valid IP address, a `TypeError` will be thrown.
|
function __promisify__(address: string, port: number): Promise<{ hostname: string, service: string }>;
|
||||||
* 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;
|
|
||||||
}>;
|
|
||||||
}
|
}
|
||||||
export interface ResolveOptions {
|
|
||||||
|
interface ResolveOptions {
|
||||||
ttl: boolean;
|
ttl: boolean;
|
||||||
}
|
}
|
||||||
export interface ResolveWithTtlOptions extends ResolveOptions {
|
|
||||||
|
interface ResolveWithTtlOptions extends ResolveOptions {
|
||||||
ttl: true;
|
ttl: true;
|
||||||
}
|
}
|
||||||
export interface RecordWithTtl {
|
|
||||||
|
interface RecordWithTtl {
|
||||||
address: string;
|
address: string;
|
||||||
ttl: number;
|
ttl: number;
|
||||||
}
|
}
|
||||||
/** @deprecated Use `AnyARecord` or `AnyAaaaRecord` instead. */
|
|
||||||
export type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
|
/** @deprecated Use AnyARecord or AnyAaaaRecord instead. */
|
||||||
export interface AnyARecord extends RecordWithTtl {
|
type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
|
||||||
type: 'A';
|
|
||||||
|
interface AnyARecord extends RecordWithTtl {
|
||||||
|
type: "A";
|
||||||
}
|
}
|
||||||
export interface AnyAaaaRecord extends RecordWithTtl {
|
|
||||||
type: 'AAAA';
|
interface AnyAaaaRecord extends RecordWithTtl {
|
||||||
|
type: "AAAA";
|
||||||
}
|
}
|
||||||
export interface CaaRecord {
|
|
||||||
critial: number;
|
interface MxRecord {
|
||||||
issue?: string | undefined;
|
|
||||||
issuewild?: string | undefined;
|
|
||||||
iodef?: string | undefined;
|
|
||||||
contactemail?: string | undefined;
|
|
||||||
contactphone?: string | undefined;
|
|
||||||
}
|
|
||||||
export interface MxRecord {
|
|
||||||
priority: number;
|
priority: number;
|
||||||
exchange: string;
|
exchange: string;
|
||||||
}
|
}
|
||||||
export interface AnyMxRecord extends MxRecord {
|
|
||||||
type: 'MX';
|
interface AnyMxRecord extends MxRecord {
|
||||||
|
type: "MX";
|
||||||
}
|
}
|
||||||
export interface NaptrRecord {
|
|
||||||
|
interface NaptrRecord {
|
||||||
flags: string;
|
flags: string;
|
||||||
service: string;
|
service: string;
|
||||||
regexp: string;
|
regexp: string;
|
||||||
@@ -193,10 +83,12 @@ declare module 'dns' {
|
|||||||
order: number;
|
order: number;
|
||||||
preference: number;
|
preference: number;
|
||||||
}
|
}
|
||||||
export interface AnyNaptrRecord extends NaptrRecord {
|
|
||||||
type: 'NAPTR';
|
interface AnyNaptrRecord extends NaptrRecord {
|
||||||
|
type: "NAPTR";
|
||||||
}
|
}
|
||||||
export interface SoaRecord {
|
|
||||||
|
interface SoaRecord {
|
||||||
nsname: string;
|
nsname: string;
|
||||||
hostmaster: string;
|
hostmaster: string;
|
||||||
serial: number;
|
serial: number;
|
||||||
@@ -205,401 +97,255 @@ declare module 'dns' {
|
|||||||
expire: number;
|
expire: number;
|
||||||
minttl: number;
|
minttl: number;
|
||||||
}
|
}
|
||||||
export interface AnySoaRecord extends SoaRecord {
|
|
||||||
type: 'SOA';
|
interface AnySoaRecord extends SoaRecord {
|
||||||
|
type: "SOA";
|
||||||
}
|
}
|
||||||
export interface SrvRecord {
|
|
||||||
|
interface SrvRecord {
|
||||||
priority: number;
|
priority: number;
|
||||||
weight: number;
|
weight: number;
|
||||||
port: number;
|
port: number;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
export interface AnySrvRecord extends SrvRecord {
|
|
||||||
type: 'SRV';
|
interface AnySrvRecord extends SrvRecord {
|
||||||
|
type: "SRV";
|
||||||
}
|
}
|
||||||
export interface AnyTxtRecord {
|
|
||||||
type: 'TXT';
|
interface AnyTxtRecord {
|
||||||
|
type: "TXT";
|
||||||
entries: string[];
|
entries: string[];
|
||||||
}
|
}
|
||||||
export interface AnyNsRecord {
|
|
||||||
type: 'NS';
|
interface AnyNsRecord {
|
||||||
|
type: "NS";
|
||||||
value: string;
|
value: string;
|
||||||
}
|
}
|
||||||
export interface AnyPtrRecord {
|
|
||||||
type: 'PTR';
|
interface AnyPtrRecord {
|
||||||
|
type: "PTR";
|
||||||
value: string;
|
value: string;
|
||||||
}
|
}
|
||||||
export interface AnyCnameRecord {
|
|
||||||
type: 'CNAME';
|
interface AnyCnameRecord {
|
||||||
|
type: "CNAME";
|
||||||
value: string;
|
value: string;
|
||||||
}
|
}
|
||||||
export type AnyRecord = AnyARecord | AnyAaaaRecord | AnyCnameRecord | AnyMxRecord | AnyNaptrRecord | AnyNsRecord | AnyPtrRecord | AnySoaRecord | AnySrvRecord | AnyTxtRecord;
|
|
||||||
/**
|
type AnyRecord = AnyARecord |
|
||||||
* Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
|
AnyAaaaRecord |
|
||||||
* of the resource records. The `callback` function has arguments`(err, records)`. When successful, `records` will be an array of resource
|
AnyCnameRecord |
|
||||||
* records. The type and structure of individual results varies based on `rrtype`:
|
AnyMxRecord |
|
||||||
*
|
AnyNaptrRecord |
|
||||||
* <omitted>
|
AnyNsRecord |
|
||||||
*
|
AnyPtrRecord |
|
||||||
* On error, `err` is an `Error` object, where `err.code` is one of the `DNS error codes`.
|
AnySoaRecord |
|
||||||
* @since v0.1.27
|
AnySrvRecord |
|
||||||
* @param hostname Host name to resolve.
|
AnyTxtRecord;
|
||||||
* @param rrtype Resource record type.
|
|
||||||
*/
|
function resolve(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
export 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;
|
||||||
export 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;
|
||||||
export 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;
|
||||||
export 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;
|
||||||
export 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;
|
||||||
export 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;
|
||||||
export 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;
|
||||||
export 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;
|
||||||
export 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;
|
||||||
export 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;
|
||||||
export 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;
|
||||||
export function resolve(hostname: string, rrtype: 'TXT', callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
function resolve(
|
||||||
export function resolve(
|
|
||||||
hostname: string,
|
hostname: string,
|
||||||
rrtype: 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;
|
): void;
|
||||||
export namespace resolve {
|
|
||||||
function __promisify__(hostname: string, rrtype?: 'A' | 'AAAA' | 'CNAME' | 'NS' | 'PTR'): Promise<string[]>;
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
||||||
function __promisify__(hostname: string, rrtype: 'ANY'): Promise<AnyRecord[]>;
|
namespace resolve {
|
||||||
function __promisify__(hostname: string, rrtype: 'MX'): Promise<MxRecord[]>;
|
function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
|
||||||
function __promisify__(hostname: string, rrtype: 'NAPTR'): Promise<NaptrRecord[]>;
|
function __promisify__(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
||||||
function __promisify__(hostname: string, rrtype: 'SOA'): Promise<SoaRecord>;
|
function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
||||||
function __promisify__(hostname: string, rrtype: 'SRV'): Promise<SrvRecord[]>;
|
function __promisify__(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
||||||
function __promisify__(hostname: string, rrtype: 'TXT'): Promise<string[][]>;
|
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 __promisify__(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
* will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
||||||
* @since v0.1.16
|
function resolve4(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
||||||
* @param hostname Host name to resolve.
|
|
||||||
*/
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
||||||
export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
namespace resolve4 {
|
||||||
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): Promise<string[]>;
|
||||||
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||||
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
* will contain an array of IPv6 addresses.
|
function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
||||||
* @since v0.1.16
|
function resolve6(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
||||||
* @param hostname Host name to resolve.
|
|
||||||
*/
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
||||||
export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
namespace resolve6 {
|
||||||
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): Promise<string[]>;
|
||||||
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||||
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The`addresses` argument passed to the `callback` function
|
function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
* will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`).
|
namespace resolveCname {
|
||||||
* @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 __promisify__(hostname: string): Promise<string[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. The`addresses` argument passed to the `callback` function
|
function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
|
||||||
* will contain an array of certification authority authorization records
|
namespace resolveMx {
|
||||||
* 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 __promisify__(hostname: string): Promise<MxRecord[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 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
|
function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
|
||||||
* objects with the following properties:
|
namespace resolveNaptr {
|
||||||
*
|
|
||||||
* * `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 __promisify__(hostname: string): Promise<NaptrRecord[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
* contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`).
|
namespace resolveNs {
|
||||||
* @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 __promisify__(hostname: string): Promise<string[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
||||||
* be an array of strings containing the reply records.
|
namespace resolvePtr {
|
||||||
* @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 __promisify__(hostname: string): Promise<string[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
|
||||||
* the `hostname`. The `address` argument passed to the `callback` function will
|
namespace resolveSoa {
|
||||||
* 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 __promisify__(hostname: string): Promise<SoaRecord>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
|
||||||
* be an array of objects with the following properties:
|
namespace resolveSrv {
|
||||||
*
|
|
||||||
* * `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 __promisify__(hostname: string): Promise<SrvRecord[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. The `records` argument passed to the `callback` function is a
|
function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
||||||
* 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
|
namespace resolveTxt {
|
||||||
* 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 __promisify__(hostname: string): Promise<string[][]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
|
function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
|
||||||
* The `ret` argument passed to the `callback` function will be an array containing
|
namespace resolveAny {
|
||||||
* 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 __promisify__(hostname: string): Promise<AnyRecord[]>;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void): void;
|
||||||
* array of host names.
|
function setServers(servers: ReadonlyArray<string>): void;
|
||||||
*
|
function getServers(): string[];
|
||||||
* 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
|
// Error codes
|
||||||
export const NODATA: string;
|
const NODATA: string;
|
||||||
export const FORMERR: string;
|
const FORMERR: string;
|
||||||
export const SERVFAIL: string;
|
const SERVFAIL: string;
|
||||||
export const NOTFOUND: string;
|
const NOTFOUND: string;
|
||||||
export const NOTIMP: string;
|
const NOTIMP: string;
|
||||||
export const REFUSED: string;
|
const REFUSED: string;
|
||||||
export const BADQUERY: string;
|
const BADQUERY: string;
|
||||||
export const BADNAME: string;
|
const BADNAME: string;
|
||||||
export const BADFAMILY: string;
|
const BADFAMILY: string;
|
||||||
export const BADRESP: string;
|
const BADRESP: string;
|
||||||
export const CONNREFUSED: string;
|
const CONNREFUSED: string;
|
||||||
export const TIMEOUT: string;
|
const TIMEOUT: string;
|
||||||
export const EOF: string;
|
const EOF: string;
|
||||||
export const FILE: string;
|
const FILE: string;
|
||||||
export const NOMEM: string;
|
const NOMEM: string;
|
||||||
export const DESTRUCTION: string;
|
const DESTRUCTION: string;
|
||||||
export const BADSTR: string;
|
const BADSTR: string;
|
||||||
export const BADFLAGS: string;
|
const BADFLAGS: string;
|
||||||
export const NONAME: string;
|
const NONAME: string;
|
||||||
export const BADHINTS: string;
|
const BADHINTS: string;
|
||||||
export const NOTINITIALIZED: string;
|
const NOTINITIALIZED: string;
|
||||||
export const LOADIPHLPAPI: string;
|
const LOADIPHLPAPI: string;
|
||||||
export const ADDRGETNETWORKPARAMS: string;
|
const ADDRGETNETWORKPARAMS: string;
|
||||||
export const CANCELLED: string;
|
const CANCELLED: string;
|
||||||
export interface ResolverOptions {
|
|
||||||
timeout?: number | undefined;
|
class Resolver {
|
||||||
}
|
getServers: typeof getServers;
|
||||||
/**
|
setServers: typeof setServers;
|
||||||
* An independent resolver for DNS requests.
|
resolve: typeof resolve;
|
||||||
*
|
resolve4: typeof resolve4;
|
||||||
* Creating a new resolver uses the default server settings. Setting
|
resolve6: typeof resolve6;
|
||||||
* the servers used for a resolver using `resolver.setServers()` does not affect
|
resolveAny: typeof resolveAny;
|
||||||
* other resolvers:
|
resolveCname: typeof resolveCname;
|
||||||
*
|
resolveMx: typeof resolveMx;
|
||||||
* ```js
|
resolveNaptr: typeof resolveNaptr;
|
||||||
* const { Resolver } = require('dns');
|
resolveNs: typeof resolveNs;
|
||||||
* const resolver = new Resolver();
|
resolvePtr: typeof resolvePtr;
|
||||||
* resolver.setServers(['4.4.4.4']);
|
resolveSoa: typeof resolveSoa;
|
||||||
*
|
resolveSrv: typeof resolveSrv;
|
||||||
* // This request will use the server at 4.4.4.4, independent of global settings.
|
resolveTxt: typeof resolveTxt;
|
||||||
* resolver.resolve4('example.org', (err, addresses) => {
|
reverse: typeof reverse;
|
||||||
* // ...
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* 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;
|
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;
|
getServers: typeof getServers;
|
||||||
resolve: typeof resolve;
|
resolve: typeof resolve;
|
||||||
resolve4: typeof resolve4;
|
resolve4: typeof resolve4;
|
||||||
@@ -614,26 +360,7 @@ declare module 'dns' {
|
|||||||
resolveSrv: typeof resolveSrv;
|
resolveSrv: typeof resolveSrv;
|
||||||
resolveTxt: typeof resolveTxt;
|
resolveTxt: typeof resolveTxt;
|
||||||
reverse: typeof reverse;
|
reverse: typeof reverse;
|
||||||
/**
|
|
||||||
* 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;
|
setServers: typeof setServers;
|
||||||
}
|
}
|
||||||
export { dnsPromises as promises };
|
|
||||||
}
|
}
|
||||||
declare module 'node:dns' {
|
|
||||||
export * from 'dns';
|
|
||||||
}
|
}
|
||||||
|
|||||||
-357
@@ -1,357 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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';
|
|
||||||
}
|
|
||||||
+12
-165
@@ -1,169 +1,16 @@
|
|||||||
/**
|
declare module "domain" {
|
||||||
* **This module is pending deprecation**. Once a replacement API has been
|
import * as events from "events";
|
||||||
* 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
|
class Domain extends events.EventEmitter implements NodeJS.Domain {
|
||||||
* 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;
|
run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
|
||||||
/**
|
add(emitter: events.EventEmitter | NodeJS.Timer): void;
|
||||||
* Explicitly adds an emitter to the domain. If any event handlers called by
|
remove(emitter: events.EventEmitter | NodeJS.Timer): void;
|
||||||
* the emitter throw an error, or if the emitter emits an `'error'` event, it
|
bind<T extends Function>(cb: T): T;
|
||||||
* will be routed to the domain's `'error'` event, just like with implicit
|
intercept<T extends Function>(cb: T): T;
|
||||||
* binding.
|
members: Array<events.EventEmitter | NodeJS.Timer>;
|
||||||
*
|
enter(): void;
|
||||||
* This also works with timers that are returned from `setInterval()` and `setTimeout()`. If their callback function throws, it will be caught by
|
exit(): void;
|
||||||
* 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>(callback: 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>(callback: T): T;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function create(): Domain;
|
function create(): Domain;
|
||||||
}
|
}
|
||||||
declare module 'node:domain' {
|
|
||||||
export * from 'domain';
|
|
||||||
}
|
|
||||||
|
|||||||
+30
-423
@@ -1,86 +1,18 @@
|
|||||||
/**
|
declare module "events" {
|
||||||
* Much of the Node.js core API is built around an idiomatic asynchronous
|
class internal extends NodeJS.EventEmitter { }
|
||||||
* 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 {
|
interface NodeEventTarget {
|
||||||
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DOMEventTarget {
|
interface DOMEventTarget {
|
||||||
addEventListener(
|
addEventListener(event: string, listener: (...args: any[]) => void, opts?: { once: boolean }): any;
|
||||||
eventName: string,
|
|
||||||
listener: (...args: any[]) => void,
|
|
||||||
opts?: {
|
|
||||||
once: boolean;
|
|
||||||
}
|
}
|
||||||
): any;
|
|
||||||
}
|
namespace internal {
|
||||||
interface StaticEventEmitterOptions {
|
function once(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>;
|
||||||
signal?: AbortSignal | undefined;
|
function once(emitter: DOMEventTarget, event: string): Promise<any[]>;
|
||||||
}
|
|
||||||
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, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>;
|
|
||||||
static once(emitter: DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
|
||||||
static on(emitter: NodeJS.EventEmitter, eventName: string, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>;
|
|
||||||
/** @deprecated since v4.0.0 */
|
|
||||||
static listenerCount(emitter: NodeJS.EventEmitter, eventName: 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'`
|
* This symbol shall be used to install a listener for only monitoring `'error'`
|
||||||
* events. Listeners installed using this symbol are called before the regular
|
* events. Listeners installed using this symbol are called before the regular
|
||||||
@@ -90,355 +22,30 @@ declare module 'events' {
|
|||||||
* `'error'` event is emitted, therefore the process will still crash if no
|
* `'error'` event is emitted, therefore the process will still crash if no
|
||||||
* regular `'error'` listener is installed.
|
* regular `'error'` listener is installed.
|
||||||
*/
|
*/
|
||||||
static readonly errorMonitor: unique symbol;
|
const errorMonitor: unique symbol;
|
||||||
static readonly captureRejectionSymbol: unique symbol;
|
|
||||||
/**
|
class EventEmitter extends internal {
|
||||||
* Sets or gets the default captureRejection value for all emitters.
|
/** @deprecated since v4.0.0 */
|
||||||
*/
|
static listenerCount(emitter: EventEmitter, event: string | symbol): number;
|
||||||
// TODO: These should be described using static getter/setter pairs:
|
|
||||||
static captureRejections: boolean;
|
|
||||||
static defaultMaxListeners: number;
|
static defaultMaxListeners: number;
|
||||||
}
|
|
||||||
import internal = require('node:events');
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
namespace EventEmitter {
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
// Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
export { internal as EventEmitter };
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
export interface Abortable {
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
/**
|
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
* When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
|
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
*/
|
|
||||||
signal?: AbortSignal | undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
global {
|
|
||||||
namespace NodeJS {
|
|
||||||
interface EventEmitter {
|
|
||||||
/**
|
|
||||||
* Alias for `emitter.on(eventName, listener)`.
|
|
||||||
* @since v0.1.26
|
|
||||||
*/
|
|
||||||
addListener(eventName: 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(eventName: 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(eventName: 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(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
||||||
/**
|
|
||||||
* Alias for `emitter.removeListener()`.
|
|
||||||
* @since v10.0.0
|
|
||||||
*/
|
|
||||||
off(eventName: 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;
|
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;
|
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;
|
getMaxListeners(): number;
|
||||||
/**
|
listeners(event: string | symbol): Function[];
|
||||||
* Returns a copy of the array of listeners for the event named `eventName`.
|
rawListeners(event: string | symbol): Function[];
|
||||||
*
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
* ```js
|
|
||||||
* server.on('connection', (stream) => {
|
|
||||||
* console.log('someone connected!');
|
|
||||||
* });
|
|
||||||
* console.log(util.inspect(server.listeners('connection')));
|
|
||||||
* // Prints: [ [Function] ]
|
|
||||||
* ```
|
|
||||||
* @since v0.1.26
|
|
||||||
*/
|
|
||||||
listeners(eventName: 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(eventName: 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(eventName: 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(eventName: 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(eventName: 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(eventName: 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>;
|
eventNames(): Array<string | symbol>;
|
||||||
|
listenerCount(type: string | symbol): number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
export = EventEmitter;
|
export = internal;
|
||||||
}
|
|
||||||
declare module 'node:events' {
|
|
||||||
import events = require('events');
|
|
||||||
export = events;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1558
-2734
File diff suppressed because it is too large
Load Diff
-972
@@ -1,972 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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 `buffer` to the file.
|
|
||||||
*
|
|
||||||
* The promise is resolved with an object containing two properties:
|
|
||||||
*
|
|
||||||
* It is unsafe to use `filehandle.write()` multiple times on the same file
|
|
||||||
* without waiting for the promise to be resolved (or rejected). For this
|
|
||||||
* scenario, use `fs.createWriteStream()`.
|
|
||||||
*
|
|
||||||
* On Linux, positional writes do not 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 v10.0.0
|
|
||||||
* @param offset The start position from within `buffer` where the data to write begins.
|
|
||||||
* @param length The number of bytes from `buffer` to write.
|
|
||||||
* @param position The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current position.
|
|
||||||
* See the POSIX pwrite(2) documentation for more detail.
|
|
||||||
*/
|
|
||||||
write<TBuffer extends Uint8Array>(
|
|
||||||
buffer: TBuffer,
|
|
||||||
offset?: number | null,
|
|
||||||
length?: number | null,
|
|
||||||
position?: number | null
|
|
||||||
): Promise<{
|
|
||||||
bytesWritten: number;
|
|
||||||
buffer: TBuffer;
|
|
||||||
}>;
|
|
||||||
write(
|
|
||||||
data: string,
|
|
||||||
position?: number | null,
|
|
||||||
encoding?: BufferEncoding | null
|
|
||||||
): Promise<{
|
|
||||||
bytesWritten: number;
|
|
||||||
buffer: string;
|
|
||||||
}>;
|
|
||||||
/**
|
|
||||||
* 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, mode?: 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(
|
|
||||||
file: 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';
|
|
||||||
}
|
|
||||||
+1016
-94
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -1 +1 @@
|
|||||||
declare var global: typeof globalThis;
|
declare var global: NodeJS.Global & typeof globalThis;
|
||||||
|
|||||||
+164
-1033
File diff suppressed because it is too large
Load Diff
+529
-1628
File diff suppressed because it is too large
Load Diff
+32
-269
@@ -1,290 +1,53 @@
|
|||||||
/**
|
declare module "https" {
|
||||||
* HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a
|
import * as tls from "tls";
|
||||||
* separate module.
|
import * as events from "events";
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/https.js)
|
import * as http from "http";
|
||||||
*/
|
import { URL } from "url";
|
||||||
declare module 'https' {
|
|
||||||
import * as tls from 'node:tls';
|
|
||||||
import * as http from 'node:http';
|
|
||||||
import { URL } from 'node:url';
|
|
||||||
type ServerOptions = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions;
|
type ServerOptions = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions;
|
||||||
type RequestOptions = http.RequestOptions &
|
|
||||||
tls.SecureContextOptions & {
|
type RequestOptions = http.RequestOptions & tls.SecureContextOptions & {
|
||||||
rejectUnauthorized?: boolean | undefined; // Defaults to true
|
rejectUnauthorized?: boolean; // Defaults to true
|
||||||
servername?: string | undefined; // SNI TLS Extension
|
servername?: string; // SNI TLS Extension
|
||||||
};
|
};
|
||||||
|
|
||||||
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
|
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
|
||||||
rejectUnauthorized?: boolean | undefined;
|
rejectUnauthorized?: boolean;
|
||||||
maxCachedSessions?: number | undefined;
|
maxCachedSessions?: number;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* An `Agent` object for HTTPS similar to `http.Agent`. See {@link request} for more information.
|
|
||||||
* @since v0.4.5
|
|
||||||
*/
|
|
||||||
class Agent extends http.Agent {
|
class Agent extends http.Agent {
|
||||||
constructor(options?: AgentOptions);
|
constructor(options?: AgentOptions);
|
||||||
options: AgentOptions;
|
options: AgentOptions;
|
||||||
}
|
}
|
||||||
interface Server extends http.HttpBase {}
|
|
||||||
/**
|
|
||||||
* * Extends: `<tls.Server>`
|
|
||||||
*
|
|
||||||
* See `http.Server` for more information.
|
|
||||||
* @since v0.3.4
|
|
||||||
*/
|
|
||||||
class Server extends tls.Server {
|
class Server extends tls.Server {
|
||||||
constructor(requestListener?: http.RequestListener);
|
constructor(requestListener?: http.RequestListener);
|
||||||
constructor(options: ServerOptions, requestListener?: http.RequestListener);
|
constructor(options: ServerOptions, requestListener?: http.RequestListener);
|
||||||
}
|
|
||||||
|
setTimeout(callback: () => void): this;
|
||||||
|
setTimeout(msecs?: number, callback?: () => void): this;
|
||||||
/**
|
/**
|
||||||
* ```js
|
* Limits maximum incoming headers count. If set to 0, no limit will be applied.
|
||||||
* // curl -k https://localhost:8000/
|
* @default 2000
|
||||||
* const https = require('https');
|
* {@link https://nodejs.org/api/http.html#http_server_maxheaderscount}
|
||||||
* const fs = require('fs');
|
|
||||||
*
|
|
||||||
* const options = {
|
|
||||||
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
|
||||||
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* https.createServer(options, (req, res) => {
|
|
||||||
* res.writeHead(200);
|
|
||||||
* res.end('hello world\n');
|
|
||||||
* }).listen(8000);
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Or
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const https = require('https');
|
|
||||||
* const fs = require('fs');
|
|
||||||
*
|
|
||||||
* const options = {
|
|
||||||
* pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
|
|
||||||
* passphrase: 'sample'
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* https.createServer(options, (req, res) => {
|
|
||||||
* res.writeHead(200);
|
|
||||||
* res.end('hello world\n');
|
|
||||||
* }).listen(8000);
|
|
||||||
* ```
|
|
||||||
* @since v0.3.4
|
|
||||||
* @param options Accepts `options` from `createServer`, `createSecureContext` and `createServer`.
|
|
||||||
* @param requestListener A listener to be added to the `'request'` event.
|
|
||||||
*/
|
*/
|
||||||
|
maxHeadersCount: number | null;
|
||||||
|
timeout: number;
|
||||||
|
/**
|
||||||
|
* Limit the amount of time the parser will wait to receive the complete HTTP headers.
|
||||||
|
* @default 40000
|
||||||
|
* {@link https://nodejs.org/api/http.html#http_server_headerstimeout}
|
||||||
|
*/
|
||||||
|
headersTimeout: number;
|
||||||
|
keepAliveTimeout: number;
|
||||||
|
}
|
||||||
|
|
||||||
function createServer(requestListener?: http.RequestListener): Server;
|
function createServer(requestListener?: http.RequestListener): Server;
|
||||||
function createServer(options: ServerOptions, requestListener?: http.RequestListener): Server;
|
function createServer(options: ServerOptions, requestListener?: http.RequestListener): Server;
|
||||||
/**
|
|
||||||
* Makes a request to a secure web server.
|
|
||||||
*
|
|
||||||
* The following additional `options` from `tls.connect()` are also accepted:`ca`, `cert`, `ciphers`, `clientCertEngine`, `crl`, `dhparam`, `ecdhCurve`,`honorCipherOrder`, `key`, `passphrase`,
|
|
||||||
* `pfx`, `rejectUnauthorized`,`secureOptions`, `secureProtocol`, `servername`, `sessionIdContext`,`highWaterMark`.
|
|
||||||
*
|
|
||||||
* `options` can be an object, a string, or a `URL` object. If `options` is a
|
|
||||||
* string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
|
|
||||||
*
|
|
||||||
* `https.request()` returns an instance of the `http.ClientRequest` class. The `ClientRequest` instance is a writable stream. If one needs to
|
|
||||||
* upload a file with a POST request, then write to the `ClientRequest` object.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const https = require('https');
|
|
||||||
*
|
|
||||||
* const options = {
|
|
||||||
* hostname: 'encrypted.google.com',
|
|
||||||
* port: 443,
|
|
||||||
* path: '/',
|
|
||||||
* method: 'GET'
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* const req = https.request(options, (res) => {
|
|
||||||
* console.log('statusCode:', res.statusCode);
|
|
||||||
* console.log('headers:', res.headers);
|
|
||||||
*
|
|
||||||
* res.on('data', (d) => {
|
|
||||||
* process.stdout.write(d);
|
|
||||||
* });
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* req.on('error', (e) => {
|
|
||||||
* console.error(e);
|
|
||||||
* });
|
|
||||||
* req.end();
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Example using options from `tls.connect()`:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const options = {
|
|
||||||
* hostname: 'encrypted.google.com',
|
|
||||||
* port: 443,
|
|
||||||
* path: '/',
|
|
||||||
* method: 'GET',
|
|
||||||
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
|
||||||
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
|
|
||||||
* };
|
|
||||||
* options.agent = new https.Agent(options);
|
|
||||||
*
|
|
||||||
* const req = https.request(options, (res) => {
|
|
||||||
* // ...
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Alternatively, opt out of connection pooling by not using an `Agent`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const options = {
|
|
||||||
* hostname: 'encrypted.google.com',
|
|
||||||
* port: 443,
|
|
||||||
* path: '/',
|
|
||||||
* method: 'GET',
|
|
||||||
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
|
||||||
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
|
|
||||||
* agent: false
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* const req = https.request(options, (res) => {
|
|
||||||
* // ...
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Example using a `URL` as `options`:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const options = new URL('https://abc:xyz@example.com');
|
|
||||||
*
|
|
||||||
* const req = https.request(options, (res) => {
|
|
||||||
* // ...
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`):
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const tls = require('tls');
|
|
||||||
* const https = require('https');
|
|
||||||
* const crypto = require('crypto');
|
|
||||||
*
|
|
||||||
* function sha256(s) {
|
|
||||||
* return crypto.createHash('sha256').update(s).digest('base64');
|
|
||||||
* }
|
|
||||||
* const options = {
|
|
||||||
* hostname: 'github.com',
|
|
||||||
* port: 443,
|
|
||||||
* path: '/',
|
|
||||||
* method: 'GET',
|
|
||||||
* checkServerIdentity: function(host, cert) {
|
|
||||||
* // Make sure the certificate is issued to the host we are connected to
|
|
||||||
* const err = tls.checkServerIdentity(host, cert);
|
|
||||||
* if (err) {
|
|
||||||
* return err;
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* // Pin the public key, similar to HPKP pin-sha25 pinning
|
|
||||||
* const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=';
|
|
||||||
* if (sha256(cert.pubkey) !== pubkey256) {
|
|
||||||
* const msg = 'Certificate verification error: ' +
|
|
||||||
* `The public key of '${cert.subject.CN}' ` +
|
|
||||||
* 'does not match our pinned fingerprint';
|
|
||||||
* return new Error(msg);
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* // Pin the exact certificate, rather than the pub key
|
|
||||||
* const cert256 = '25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:' +
|
|
||||||
* 'D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16';
|
|
||||||
* if (cert.fingerprint256 !== cert256) {
|
|
||||||
* const msg = 'Certificate verification error: ' +
|
|
||||||
* `The certificate of '${cert.subject.CN}' ` +
|
|
||||||
* 'does not match our pinned fingerprint';
|
|
||||||
* return new Error(msg);
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* // This loop is informational only.
|
|
||||||
* // Print the certificate and public key fingerprints of all certs in the
|
|
||||||
* // chain. Its common to pin the public key of the issuer on the public
|
|
||||||
* // internet, while pinning the public key of the service in sensitive
|
|
||||||
* // environments.
|
|
||||||
* do {
|
|
||||||
* console.log('Subject Common Name:', cert.subject.CN);
|
|
||||||
* console.log(' Certificate SHA256 fingerprint:', cert.fingerprint256);
|
|
||||||
*
|
|
||||||
* hash = crypto.createHash('sha256');
|
|
||||||
* console.log(' Public key ping-sha256:', sha256(cert.pubkey));
|
|
||||||
*
|
|
||||||
* lastprint256 = cert.fingerprint256;
|
|
||||||
* cert = cert.issuerCertificate;
|
|
||||||
* } while (cert.fingerprint256 !== lastprint256);
|
|
||||||
*
|
|
||||||
* },
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
* options.agent = new https.Agent(options);
|
|
||||||
* const req = https.request(options, (res) => {
|
|
||||||
* console.log('All OK. Server matched our pinned cert or public key');
|
|
||||||
* console.log('statusCode:', res.statusCode);
|
|
||||||
* // Print the HPKP values
|
|
||||||
* console.log('headers:', res.headers['public-key-pins']);
|
|
||||||
*
|
|
||||||
* res.on('data', (d) => {});
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* req.on('error', (e) => {
|
|
||||||
* console.error(e.message);
|
|
||||||
* });
|
|
||||||
* req.end();
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Outputs for example:
|
|
||||||
*
|
|
||||||
* ```text
|
|
||||||
* Subject Common Name: github.com
|
|
||||||
* Certificate SHA256 fingerprint: 25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16
|
|
||||||
* Public key ping-sha256: pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=
|
|
||||||
* Subject Common Name: DigiCert SHA2 Extended Validation Server CA
|
|
||||||
* Certificate SHA256 fingerprint: 40:3E:06:2A:26:53:05:91:13:28:5B:AF:80:A0:D4:AE:42:2C:84:8C:9F:78:FA:D0:1F:C9:4B:C5:B8:7F:EF:1A
|
|
||||||
* Public key ping-sha256: RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=
|
|
||||||
* Subject Common Name: DigiCert High Assurance EV Root CA
|
|
||||||
* Certificate SHA256 fingerprint: 74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF
|
|
||||||
* Public key ping-sha256: WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=
|
|
||||||
* All OK. Server matched our pinned cert or public key
|
|
||||||
* statusCode: 200
|
|
||||||
* headers: max-age=0; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=";
|
|
||||||
* pin-sha256="k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws="; pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="IQBnNBEiFuhj+8x6X8XLgh01V9Ic5/V3IRQLNFFc7v4=";
|
|
||||||
* pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0="; pin-sha256="LvRiGEjRqfzurezaWuj8Wie2gyHMrW5Q06LspMnox7A="; includeSubDomains
|
|
||||||
* ```
|
|
||||||
* @since v0.3.6
|
|
||||||
* @param options Accepts all `options` from `request`, with some differences in default values:
|
|
||||||
*/
|
|
||||||
function request(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
function request(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
||||||
function request(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
function request(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
||||||
/**
|
|
||||||
* Like `http.get()` but for HTTPS.
|
|
||||||
*
|
|
||||||
* `options` can be an object, a string, or a `URL` object. If `options` is a
|
|
||||||
* string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const https = require('https');
|
|
||||||
*
|
|
||||||
* https.get('https://encrypted.google.com/', (res) => {
|
|
||||||
* console.log('statusCode:', res.statusCode);
|
|
||||||
* console.log('headers:', res.headers);
|
|
||||||
*
|
|
||||||
* res.on('data', (d) => {
|
|
||||||
* process.stdout.write(d);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* }).on('error', (e) => {
|
|
||||||
* console.error(e);
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @since v0.3.6
|
|
||||||
* @param options Accepts the same `options` as {@link request}, with the `method` always set to `GET`.
|
|
||||||
*/
|
|
||||||
function get(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
function get(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
||||||
function get(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
function get(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
||||||
let globalAgent: Agent;
|
let globalAgent: Agent;
|
||||||
}
|
}
|
||||||
declare module 'node:https' {
|
|
||||||
export * from 'https';
|
|
||||||
}
|
|
||||||
|
|||||||
+8
-41
@@ -1,15 +1,18 @@
|
|||||||
// Type definitions for non-npm package Node.js 16.4
|
// Type definitions for non-npm package Node.js 12.12
|
||||||
// Project: http://nodejs.org/
|
// Project: http://nodejs.org/
|
||||||
// Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
|
// Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
|
||||||
// DefinitelyTyped <https://github.com/DefinitelyTyped>
|
// DefinitelyTyped <https://github.com/DefinitelyTyped>
|
||||||
// Alberto Schiabel <https://github.com/jkomyno>
|
// Alberto Schiabel <https://github.com/jkomyno>
|
||||||
|
// Alexander T. <https://github.com/a-tarasyuk>
|
||||||
// Alvis HT Tang <https://github.com/alvis>
|
// Alvis HT Tang <https://github.com/alvis>
|
||||||
// Andrew Makarov <https://github.com/r3nya>
|
// Andrew Makarov <https://github.com/r3nya>
|
||||||
// Benjamin Toueg <https://github.com/btoueg>
|
// Benjamin Toueg <https://github.com/btoueg>
|
||||||
|
// Bruno Scheufler <https://github.com/brunoscheufler>
|
||||||
// Chigozirim C. <https://github.com/smac89>
|
// Chigozirim C. <https://github.com/smac89>
|
||||||
// David Junger <https://github.com/touffy>
|
// David Junger <https://github.com/touffy>
|
||||||
// Deividas Bakanas <https://github.com/DeividasBakanas>
|
// Deividas Bakanas <https://github.com/DeividasBakanas>
|
||||||
// Eugene Y. Q. Shen <https://github.com/eyqs>
|
// Eugene Y. Q. Shen <https://github.com/eyqs>
|
||||||
|
// Flarna <https://github.com/Flarna>
|
||||||
// Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
|
// Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
|
||||||
// Hoàng Văn Khải <https://github.com/KSXGitHub>
|
// Hoàng Văn Khải <https://github.com/KSXGitHub>
|
||||||
// Huw <https://github.com/hoo29>
|
// Huw <https://github.com/hoo29>
|
||||||
@@ -26,8 +29,10 @@
|
|||||||
// Thomas den Hollander <https://github.com/ThomasdenH>
|
// Thomas den Hollander <https://github.com/ThomasdenH>
|
||||||
// Wilco Bakker <https://github.com/WilcoBakker>
|
// Wilco Bakker <https://github.com/WilcoBakker>
|
||||||
// wwwy3y3 <https://github.com/wwwy3y3>
|
// wwwy3y3 <https://github.com/wwwy3y3>
|
||||||
|
// Zane Hannan AU <https://github.com/ZaneHannanAU>
|
||||||
// Samuel Ainsworth <https://github.com/samuela>
|
// Samuel Ainsworth <https://github.com/samuela>
|
||||||
// Kyle Uehlein <https://github.com/kuehlein>
|
// Kyle Uehlein <https://github.com/kuehlein>
|
||||||
|
// Jordi Oliveras Rovira <https://github.com/j-oliveras>
|
||||||
// Thanik Bhongbhibhat <https://github.com/bhongy>
|
// Thanik Bhongbhibhat <https://github.com/bhongy>
|
||||||
// Marcin Kopacz <https://github.com/chyzwar>
|
// Marcin Kopacz <https://github.com/chyzwar>
|
||||||
// Trivikram Kamat <https://github.com/trivikr>
|
// Trivikram Kamat <https://github.com/trivikr>
|
||||||
@@ -35,49 +40,11 @@
|
|||||||
// Junxiao Shi <https://github.com/yoursunny>
|
// Junxiao Shi <https://github.com/yoursunny>
|
||||||
// Ilia Baryshnikov <https://github.com/qwelias>
|
// Ilia Baryshnikov <https://github.com/qwelias>
|
||||||
// ExE Boss <https://github.com/ExE-Boss>
|
// 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>
|
// Jason Kwok <https://github.com/JasonHK>
|
||||||
// Victor Perin <https://github.com/victorperin>
|
|
||||||
// Yongsheng Zhang <https://github.com/ZYSzys>
|
|
||||||
// NodeJS Contributors <https://github.com/NodeJS>
|
|
||||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
|
||||||
/**
|
|
||||||
* License for programmatically and manually incorporated
|
|
||||||
* documentation aka. `JSDoc` from https://github.com/nodejs/node/tree/master/doc
|
|
||||||
*
|
|
||||||
* Copyright Node.js contributors. 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// NOTE: These definitions support NodeJS and TypeScript 3.7.
|
// NOTE: These definitions support NodeJS and TypeScript 3.7.
|
||||||
// Typically type modifications should be made in base.d.ts instead of here
|
// This isn't strictly needed since 3.7 has the assert module, but this way we're consistent.
|
||||||
|
// Typically type modificatons should be made in base.d.ts instead of here
|
||||||
|
|
||||||
/// <reference path="base.d.ts" />
|
/// <reference path="base.d.ts" />
|
||||||
|
|
||||||
// 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 3.7
|
|
||||||
// - ~/ts3.6/index.d.ts - Definitions specific to TypeScript 3.6
|
|
||||||
|
|
||||||
// NOTE: Augmentations for TypeScript 3.6 and later should use individual files for overrides
|
|
||||||
// within the respective ~/ts3.6 (or later) folder. However, this is disallowed for versions
|
|
||||||
// prior to TypeScript 3.6, so the older definitions will be found here.
|
|
||||||
|
|||||||
+807
-512
File diff suppressed because it is too large
Load Diff
+2
-110
@@ -1,111 +1,3 @@
|
|||||||
/**
|
declare module "module" {
|
||||||
* @since v0.3.7
|
export = NodeJS.Module;
|
||||||
*/
|
|
||||||
declare module 'module' {
|
|
||||||
import { URL } from 'node:url';
|
|
||||||
namespace Module {
|
|
||||||
/**
|
|
||||||
* The `module.syncBuiltinESMExports()` method updates all the live bindings for
|
|
||||||
* builtin `ES Modules` to match the properties of the `CommonJS` exports. It
|
|
||||||
* does not add or remove exported names from the `ES Modules`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const fs = require('fs');
|
|
||||||
* const assert = require('assert');
|
|
||||||
* const { syncBuiltinESMExports } = require('module');
|
|
||||||
*
|
|
||||||
* fs.readFile = newAPI;
|
|
||||||
*
|
|
||||||
* delete fs.readFileSync;
|
|
||||||
*
|
|
||||||
* function newAPI() {
|
|
||||||
* // ...
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* fs.newAPI = newAPI;
|
|
||||||
*
|
|
||||||
* syncBuiltinESMExports();
|
|
||||||
*
|
|
||||||
* import('fs').then((esmFS) => {
|
|
||||||
* // It syncs the existing readFile property with the new value
|
|
||||||
* assert.strictEqual(esmFS.readFile, newAPI);
|
|
||||||
* // readFileSync has been deleted from the required fs
|
|
||||||
* assert.strictEqual('readFileSync' in fs, false);
|
|
||||||
* // syncBuiltinESMExports() does not remove readFileSync from esmFS
|
|
||||||
* assert.strictEqual('readFileSync' in esmFS, true);
|
|
||||||
* // syncBuiltinESMExports() does not add names
|
|
||||||
* assert.strictEqual(esmFS.newAPI, undefined);
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @since v12.12.0
|
|
||||||
*/
|
|
||||||
function syncBuiltinESMExports(): void;
|
|
||||||
/**
|
|
||||||
* `path` is the resolved path for the file for which a corresponding source map
|
|
||||||
* should be fetched.
|
|
||||||
* @since v13.7.0, v12.17.0
|
|
||||||
*/
|
|
||||||
function findSourceMap(path: string, error?: Error): SourceMap;
|
|
||||||
interface SourceMapPayload {
|
|
||||||
file: string;
|
|
||||||
version: number;
|
|
||||||
sources: string[];
|
|
||||||
sourcesContent: string[];
|
|
||||||
names: string[];
|
|
||||||
mappings: string;
|
|
||||||
sourceRoot: string;
|
|
||||||
}
|
|
||||||
interface SourceMapping {
|
|
||||||
generatedLine: number;
|
|
||||||
generatedColumn: number;
|
|
||||||
originalSource: string;
|
|
||||||
originalLine: number;
|
|
||||||
originalColumn: number;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @since v13.7.0, v12.17.0
|
|
||||||
*/
|
|
||||||
class SourceMap {
|
|
||||||
readonly payload: SourceMapPayload;
|
|
||||||
constructor(payload: SourceMapPayload);
|
|
||||||
/**
|
|
||||||
* Given a line number and column number in the generated source file, returns
|
|
||||||
* an object representing the position in the original file. The object returned
|
|
||||||
* consists of the following keys:
|
|
||||||
*/
|
|
||||||
findEntry(line: number, column: number): SourceMapping;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
interface Module extends NodeModule {}
|
|
||||||
class Module {
|
|
||||||
static runMain(): void;
|
|
||||||
static wrap(code: string): string;
|
|
||||||
static createRequire(path: string | URL): NodeRequire;
|
|
||||||
static builtinModules: string[];
|
|
||||||
static Module: typeof Module;
|
|
||||||
constructor(id: string, parent?: Module);
|
|
||||||
}
|
|
||||||
global {
|
|
||||||
interface ImportMeta {
|
|
||||||
url: string;
|
|
||||||
/**
|
|
||||||
* @experimental
|
|
||||||
* This feature is only available with the `--experimental-import-meta-resolve`
|
|
||||||
* command flag enabled.
|
|
||||||
*
|
|
||||||
* Provides a module-relative resolution function scoped to each module, returning
|
|
||||||
* the URL string.
|
|
||||||
*
|
|
||||||
* @param specified The module specifier to resolve relative to `parent`.
|
|
||||||
* @param parent The absolute parent module URL to resolve from. If none
|
|
||||||
* is specified, the value of `import.meta.url` is used as the default.
|
|
||||||
*/
|
|
||||||
resolve?(specified: string, parent?: string | URL): Promise<string>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export = Module;
|
|
||||||
}
|
|
||||||
declare module 'node:module' {
|
|
||||||
import module = require('module');
|
|
||||||
export = module;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+148
-656
@@ -1,33 +1,23 @@
|
|||||||
/**
|
declare module "net" {
|
||||||
* > Stability: 2 - Stable
|
import * as stream from "stream";
|
||||||
*
|
import * as events from "events";
|
||||||
* The `net` module provides an asynchronous network API for creating stream-based
|
import * as dns from "dns";
|
||||||
* TCP or `IPC` servers ({@link createServer}) and clients
|
|
||||||
* ({@link createConnection}).
|
|
||||||
*
|
|
||||||
* It can be accessed using:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const net = require('net');
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/net.js)
|
|
||||||
*/
|
|
||||||
declare module 'net' {
|
|
||||||
import * as stream from 'node:stream';
|
|
||||||
import { Abortable, EventEmitter } from 'node:events';
|
|
||||||
import * as dns from 'node:dns';
|
|
||||||
type LookupFunction = (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
|
type LookupFunction = (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
|
||||||
|
|
||||||
interface AddressInfo {
|
interface AddressInfo {
|
||||||
address: string;
|
address: string;
|
||||||
family: string;
|
family: string;
|
||||||
port: number;
|
port: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SocketConstructorOpts {
|
interface SocketConstructorOpts {
|
||||||
fd?: number | undefined;
|
fd?: number;
|
||||||
allowHalfOpen?: boolean | undefined;
|
allowHalfOpen?: boolean;
|
||||||
readable?: boolean | undefined;
|
readable?: boolean;
|
||||||
writable?: boolean | undefined;
|
writable?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OnReadOpts {
|
interface OnReadOpts {
|
||||||
buffer: Uint8Array | (() => Uint8Array);
|
buffer: Uint8Array | (() => Uint8Array);
|
||||||
/**
|
/**
|
||||||
@@ -37,258 +27,70 @@ declare module 'net' {
|
|||||||
*/
|
*/
|
||||||
callback(bytesWritten: number, buf: Uint8Array): boolean;
|
callback(bytesWritten: number, buf: Uint8Array): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ConnectOpts {
|
interface ConnectOpts {
|
||||||
/**
|
/**
|
||||||
* If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket.
|
* If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket.
|
||||||
* Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will
|
* Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will
|
||||||
* still be emitted as normal and methods like pause() and resume() will also behave as expected.
|
* still be emitted as normal and methods like pause() and resume() will also behave as expected.
|
||||||
*/
|
*/
|
||||||
onread?: OnReadOpts | undefined;
|
onread?: OnReadOpts;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TcpSocketConnectOpts extends ConnectOpts {
|
interface TcpSocketConnectOpts extends ConnectOpts {
|
||||||
port: number;
|
port: number;
|
||||||
host?: string | undefined;
|
host?: string;
|
||||||
localAddress?: string | undefined;
|
localAddress?: string;
|
||||||
localPort?: number | undefined;
|
localPort?: number;
|
||||||
hints?: number | undefined;
|
hints?: number;
|
||||||
family?: number | undefined;
|
family?: number;
|
||||||
lookup?: LookupFunction | undefined;
|
lookup?: LookupFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IpcSocketConnectOpts extends ConnectOpts {
|
interface IpcSocketConnectOpts extends ConnectOpts {
|
||||||
path: string;
|
path: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
|
type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
|
||||||
/**
|
|
||||||
* * Extends: `<stream.Duplex>`
|
|
||||||
*
|
|
||||||
* This class is an abstraction of a TCP socket or a streaming `IPC` endpoint
|
|
||||||
* (uses named pipes on Windows, and Unix domain sockets otherwise). It is also
|
|
||||||
* an `EventEmitter`.
|
|
||||||
*
|
|
||||||
* A `net.Socket` can be created by the user and used directly to interact with
|
|
||||||
* a server. For example, it is returned by {@link createConnection},
|
|
||||||
* so the user can use it to talk to the server.
|
|
||||||
*
|
|
||||||
* It can also be created by Node.js and passed to the user when a connection
|
|
||||||
* is received. For example, it is passed to the listeners of a `'connection'` event emitted on a {@link Server}, so the user can use
|
|
||||||
* it to interact with the client.
|
|
||||||
* @since v0.3.4
|
|
||||||
*/
|
|
||||||
class Socket extends stream.Duplex {
|
class Socket extends stream.Duplex {
|
||||||
constructor(options?: SocketConstructorOpts);
|
constructor(options?: SocketConstructorOpts);
|
||||||
/**
|
|
||||||
* Sends data on the socket. The second parameter specifies the encoding in the
|
// Extended base methods
|
||||||
* case of a string. It defaults to UTF8 encoding.
|
|
||||||
*
|
|
||||||
* Returns `true` if the entire data was flushed successfully to the kernel
|
|
||||||
* buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is again free.
|
|
||||||
*
|
|
||||||
* The optional `callback` parameter will be executed when the data is finally
|
|
||||||
* written out, which may not be immediately.
|
|
||||||
*
|
|
||||||
* See `Writable` stream `write()` method for more
|
|
||||||
* information.
|
|
||||||
* @since v0.1.90
|
|
||||||
* @param encoding Only used when data is `string`.
|
|
||||||
*/
|
|
||||||
write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
||||||
write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean;
|
write(str: Uint8Array | string, encoding?: string, cb?: (err?: Error) => void): boolean;
|
||||||
/**
|
|
||||||
* Initiate a connection on a given socket.
|
|
||||||
*
|
|
||||||
* Possible signatures:
|
|
||||||
*
|
|
||||||
* * `socket.connect(options[, connectListener])`
|
|
||||||
* * `socket.connect(path[, connectListener])` for `IPC` connections.
|
|
||||||
* * `socket.connect(port[, host][, connectListener])` for TCP connections.
|
|
||||||
* * Returns: `<net.Socket>` The socket itself.
|
|
||||||
*
|
|
||||||
* This function is asynchronous. When the connection is established, the `'connect'` event will be emitted. If there is a problem connecting,
|
|
||||||
* instead of a `'connect'` event, an `'error'` event will be emitted with
|
|
||||||
* the error passed to the `'error'` listener.
|
|
||||||
* The last parameter `connectListener`, if supplied, will be added as a listener
|
|
||||||
* for the `'connect'` event **once**.
|
|
||||||
*
|
|
||||||
* This function should only be used for reconnecting a socket after`'close'` has been emitted or otherwise it may lead to undefined
|
|
||||||
* behavior.
|
|
||||||
*/
|
|
||||||
connect(options: SocketConnectOpts, connectionListener?: () => void): this;
|
connect(options: SocketConnectOpts, connectionListener?: () => void): this;
|
||||||
connect(port: number, host: string, connectionListener?: () => void): this;
|
connect(port: number, host: string, connectionListener?: () => void): this;
|
||||||
connect(port: number, connectionListener?: () => void): this;
|
connect(port: number, connectionListener?: () => void): this;
|
||||||
connect(path: string, connectionListener?: () => void): this;
|
connect(path: string, connectionListener?: () => void): this;
|
||||||
/**
|
|
||||||
* Set the encoding for the socket as a `Readable Stream`. See `readable.setEncoding()` for more information.
|
setEncoding(encoding?: string): this;
|
||||||
* @since v0.1.90
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
setEncoding(encoding?: BufferEncoding): this;
|
|
||||||
/**
|
|
||||||
* Pauses the reading of data. That is, `'data'` events will not be emitted.
|
|
||||||
* Useful to throttle back an upload.
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
pause(): this;
|
pause(): this;
|
||||||
/**
|
|
||||||
* Resumes reading after a call to `socket.pause()`.
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
resume(): this;
|
resume(): this;
|
||||||
/**
|
|
||||||
* Sets the socket to timeout after `timeout` milliseconds of inactivity on
|
|
||||||
* the socket. By default `net.Socket` do not have a timeout.
|
|
||||||
*
|
|
||||||
* When an idle timeout is triggered the socket will receive a `'timeout'` event but the connection will not be severed. The user must manually call `socket.end()` or `socket.destroy()` to
|
|
||||||
* end the connection.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* socket.setTimeout(3000);
|
|
||||||
* socket.on('timeout', () => {
|
|
||||||
* console.log('socket timeout');
|
|
||||||
* socket.end();
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If `timeout` is 0, then the existing idle timeout is disabled.
|
|
||||||
*
|
|
||||||
* The optional `callback` parameter will be added as a one-time listener for the `'timeout'` event.
|
|
||||||
* @since v0.1.90
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
setTimeout(timeout: number, callback?: () => void): this;
|
setTimeout(timeout: number, callback?: () => void): this;
|
||||||
/**
|
|
||||||
* Enable/disable the use of Nagle's algorithm.
|
|
||||||
*
|
|
||||||
* When a TCP connection is created, it will have Nagle's algorithm enabled.
|
|
||||||
*
|
|
||||||
* Nagle's algorithm delays data before it is sent via the network. It attempts
|
|
||||||
* to optimize throughput at the expense of latency.
|
|
||||||
*
|
|
||||||
* Passing `true` for `noDelay` or not passing an argument will disable Nagle's
|
|
||||||
* algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's
|
|
||||||
* algorithm.
|
|
||||||
* @since v0.1.90
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
setNoDelay(noDelay?: boolean): this;
|
setNoDelay(noDelay?: boolean): this;
|
||||||
/**
|
|
||||||
* Enable/disable keep-alive functionality, and optionally set the initial
|
|
||||||
* delay before the first keepalive probe is sent on an idle socket.
|
|
||||||
*
|
|
||||||
* Set `initialDelay` (in milliseconds) to set the delay between the last
|
|
||||||
* data packet received and the first keepalive probe. Setting `0` for`initialDelay` will leave the value unchanged from the default
|
|
||||||
* (or previous) setting.
|
|
||||||
*
|
|
||||||
* Enabling the keep-alive functionality will set the following socket options:
|
|
||||||
*
|
|
||||||
* * `SO_KEEPALIVE=1`
|
|
||||||
* * `TCP_KEEPIDLE=initialDelay`
|
|
||||||
* * `TCP_KEEPCNT=10`
|
|
||||||
* * `TCP_KEEPINTVL=1`
|
|
||||||
* @since v0.1.92
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
setKeepAlive(enable?: boolean, initialDelay?: number): this;
|
setKeepAlive(enable?: boolean, initialDelay?: number): this;
|
||||||
/**
|
address(): AddressInfo | string;
|
||||||
* Returns the bound `address`, the address `family` name and `port` of the
|
unref(): void;
|
||||||
* socket as reported by the operating system:`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
|
ref(): void;
|
||||||
* @since v0.1.90
|
|
||||||
*/
|
|
||||||
address(): AddressInfo | {};
|
|
||||||
/**
|
|
||||||
* Calling `unref()` on a socket will allow the program to exit if this is the only
|
|
||||||
* active socket in the event system. If the socket is already `unref`ed calling`unref()` again will have no effect.
|
|
||||||
* @since v0.9.1
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
unref(): this;
|
|
||||||
/**
|
|
||||||
* Opposite of `unref()`, calling `ref()` on a previously `unref`ed socket will_not_ let the program exit if it's the only socket left (the default behavior).
|
|
||||||
* If the socket is `ref`ed calling `ref` again will have no effect.
|
|
||||||
* @since v0.9.1
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
ref(): this;
|
|
||||||
/**
|
|
||||||
* This property shows the number of characters buffered for writing. The buffer
|
|
||||||
* may contain strings whose length after encoding is not yet known. So this number
|
|
||||||
* is only an approximation of the number of bytes in the buffer.
|
|
||||||
*
|
|
||||||
* `net.Socket` has the property that `socket.write()` always works. This is to
|
|
||||||
* help users get up and running quickly. The computer cannot always keep up
|
|
||||||
* with the amount of data that is written to a socket. The network connection
|
|
||||||
* simply might be too slow. Node.js will internally queue up the data written to a
|
|
||||||
* socket and send it out over the wire when it is possible.
|
|
||||||
*
|
|
||||||
* The consequence of this internal buffering is that memory may grow.
|
|
||||||
* Users who experience large or growing `bufferSize` should attempt to
|
|
||||||
* "throttle" the data flows in their program with `socket.pause()` and `socket.resume()`.
|
|
||||||
* @since v0.3.8
|
|
||||||
* @deprecated Since v14.6.0 - Use `writableLength` instead.
|
|
||||||
*/
|
|
||||||
readonly bufferSize: number;
|
readonly bufferSize: number;
|
||||||
/**
|
|
||||||
* The amount of received bytes.
|
|
||||||
* @since v0.5.3
|
|
||||||
*/
|
|
||||||
readonly bytesRead: number;
|
readonly bytesRead: number;
|
||||||
/**
|
|
||||||
* The amount of bytes sent.
|
|
||||||
* @since v0.5.3
|
|
||||||
*/
|
|
||||||
readonly bytesWritten: number;
|
readonly bytesWritten: number;
|
||||||
/**
|
|
||||||
* If `true`,`socket.connect(options[, connectListener])` was
|
|
||||||
* called and has not yet finished. It will stay `true` until the socket becomes
|
|
||||||
* connected, then it is set to `false` and the `'connect'` event is emitted. Note
|
|
||||||
* that the `socket.connect(options[, connectListener])` callback is a listener for the `'connect'` event.
|
|
||||||
* @since v6.1.0
|
|
||||||
*/
|
|
||||||
readonly connecting: boolean;
|
readonly connecting: boolean;
|
||||||
/**
|
|
||||||
* See `writable.destroyed` for further details.
|
|
||||||
*/
|
|
||||||
readonly destroyed: boolean;
|
readonly destroyed: boolean;
|
||||||
/**
|
|
||||||
* The string representation of the local IP address the remote client is
|
|
||||||
* connecting on. For example, in a server listening on `'0.0.0.0'`, if a client
|
|
||||||
* connects on `'192.168.1.1'`, the value of `socket.localAddress` would be`'192.168.1.1'`.
|
|
||||||
* @since v0.9.6
|
|
||||||
*/
|
|
||||||
readonly localAddress: string;
|
readonly localAddress: string;
|
||||||
/**
|
|
||||||
* The numeric representation of the local port. For example, `80` or `21`.
|
|
||||||
* @since v0.9.6
|
|
||||||
*/
|
|
||||||
readonly localPort: number;
|
readonly localPort: number;
|
||||||
/**
|
readonly remoteAddress?: string;
|
||||||
* The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if
|
readonly remoteFamily?: string;
|
||||||
* the socket is destroyed (for example, if the client disconnected).
|
readonly remotePort?: number;
|
||||||
* @since v0.5.10
|
|
||||||
*/
|
// Extended base methods
|
||||||
readonly remoteAddress?: string | undefined;
|
end(cb?: () => void): void;
|
||||||
/**
|
end(buffer: Uint8Array | string, cb?: () => void): void;
|
||||||
* The string representation of the remote IP family. `'IPv4'` or `'IPv6'`.
|
end(str: Uint8Array | string, encoding?: string, cb?: () => void): void;
|
||||||
* @since v0.11.14
|
|
||||||
*/
|
|
||||||
readonly remoteFamily?: string | undefined;
|
|
||||||
/**
|
|
||||||
* The numeric representation of the remote port. For example, `80` or `21`.
|
|
||||||
* @since v0.5.10
|
|
||||||
*/
|
|
||||||
readonly remotePort?: number | undefined;
|
|
||||||
/**
|
|
||||||
* Half-closes the socket. i.e., it sends a FIN packet. It is possible the
|
|
||||||
* server will still send some data.
|
|
||||||
*
|
|
||||||
* See `writable.end()` for further details.
|
|
||||||
* @since v0.1.90
|
|
||||||
* @param encoding Only used when data is `string`.
|
|
||||||
* @param callback Optional callback for when the socket is finished.
|
|
||||||
* @return The socket itself.
|
|
||||||
*/
|
|
||||||
end(callback?: () => void): void;
|
|
||||||
end(buffer: Uint8Array | string, callback?: () => void): void;
|
|
||||||
end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): void;
|
|
||||||
/**
|
/**
|
||||||
* events.EventEmitter
|
* events.EventEmitter
|
||||||
* 1. close
|
* 1. close
|
||||||
@@ -301,133 +103,85 @@ declare module 'net' {
|
|||||||
* 8. timeout
|
* 8. timeout
|
||||||
*/
|
*/
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'close', listener: (hadError: boolean) => void): this;
|
addListener(event: "close", listener: (had_error: boolean) => void): this;
|
||||||
addListener(event: 'connect', listener: () => void): this;
|
addListener(event: "connect", listener: () => void): this;
|
||||||
addListener(event: 'data', listener: (data: Buffer) => void): this;
|
addListener(event: "data", listener: (data: Buffer) => void): this;
|
||||||
addListener(event: 'drain', listener: () => void): this;
|
addListener(event: "drain", listener: () => void): this;
|
||||||
addListener(event: 'end', listener: () => void): this;
|
addListener(event: "end", listener: () => void): this;
|
||||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
addListener(event: "error", listener: (err: Error) => void): this;
|
||||||
addListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
addListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||||
addListener(event: 'timeout', listener: () => void): this;
|
addListener(event: "timeout", listener: () => void): this;
|
||||||
|
|
||||||
emit(event: string | symbol, ...args: any[]): boolean;
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
emit(event: 'close', hadError: boolean): boolean;
|
emit(event: "close", had_error: boolean): boolean;
|
||||||
emit(event: 'connect'): boolean;
|
emit(event: "connect"): boolean;
|
||||||
emit(event: 'data', data: Buffer): boolean;
|
emit(event: "data", data: Buffer): boolean;
|
||||||
emit(event: 'drain'): boolean;
|
emit(event: "drain"): boolean;
|
||||||
emit(event: 'end'): boolean;
|
emit(event: "end"): boolean;
|
||||||
emit(event: 'error', err: Error): boolean;
|
emit(event: "error", err: Error): boolean;
|
||||||
emit(event: 'lookup', err: Error, address: string, family: string | number, host: string): boolean;
|
emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean;
|
||||||
emit(event: 'timeout'): boolean;
|
emit(event: "timeout"): boolean;
|
||||||
|
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
on(event: 'close', listener: (hadError: boolean) => void): this;
|
on(event: "close", listener: (had_error: boolean) => void): this;
|
||||||
on(event: 'connect', listener: () => void): this;
|
on(event: "connect", listener: () => void): this;
|
||||||
on(event: 'data', listener: (data: Buffer) => void): this;
|
on(event: "data", listener: (data: Buffer) => void): this;
|
||||||
on(event: 'drain', listener: () => void): this;
|
on(event: "drain", listener: () => void): this;
|
||||||
on(event: 'end', listener: () => void): this;
|
on(event: "end", listener: () => void): this;
|
||||||
on(event: 'error', listener: (err: Error) => void): this;
|
on(event: "error", listener: (err: Error) => void): this;
|
||||||
on(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||||
on(event: 'timeout', listener: () => void): this;
|
on(event: "timeout", listener: () => void): this;
|
||||||
|
|
||||||
once(event: string, listener: (...args: any[]) => void): this;
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
once(event: 'close', listener: (hadError: boolean) => void): this;
|
once(event: "close", listener: (had_error: boolean) => void): this;
|
||||||
once(event: 'connect', listener: () => void): this;
|
once(event: "connect", listener: () => void): this;
|
||||||
once(event: 'data', listener: (data: Buffer) => void): this;
|
once(event: "data", listener: (data: Buffer) => void): this;
|
||||||
once(event: 'drain', listener: () => void): this;
|
once(event: "drain", listener: () => void): this;
|
||||||
once(event: 'end', listener: () => void): this;
|
once(event: "end", listener: () => void): this;
|
||||||
once(event: 'error', listener: (err: Error) => void): this;
|
once(event: "error", listener: (err: Error) => void): this;
|
||||||
once(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||||
once(event: 'timeout', listener: () => void): this;
|
once(event: "timeout", listener: () => void): this;
|
||||||
|
|
||||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependListener(event: 'close', listener: (hadError: boolean) => void): this;
|
prependListener(event: "close", listener: (had_error: boolean) => void): this;
|
||||||
prependListener(event: 'connect', listener: () => void): this;
|
prependListener(event: "connect", listener: () => void): this;
|
||||||
prependListener(event: 'data', listener: (data: Buffer) => void): this;
|
prependListener(event: "data", listener: (data: Buffer) => void): this;
|
||||||
prependListener(event: 'drain', listener: () => void): this;
|
prependListener(event: "drain", listener: () => void): this;
|
||||||
prependListener(event: 'end', listener: () => void): this;
|
prependListener(event: "end", listener: () => void): this;
|
||||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||||
prependListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||||
prependListener(event: 'timeout', listener: () => void): this;
|
prependListener(event: "timeout", listener: () => void): this;
|
||||||
|
|
||||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependOnceListener(event: 'close', listener: (hadError: boolean) => void): this;
|
prependOnceListener(event: "close", listener: (had_error: boolean) => void): this;
|
||||||
prependOnceListener(event: 'connect', listener: () => void): this;
|
prependOnceListener(event: "connect", listener: () => void): this;
|
||||||
prependOnceListener(event: 'data', listener: (data: Buffer) => void): this;
|
prependOnceListener(event: "data", listener: (data: Buffer) => void): this;
|
||||||
prependOnceListener(event: 'drain', listener: () => void): this;
|
prependOnceListener(event: "drain", listener: () => void): this;
|
||||||
prependOnceListener(event: 'end', listener: () => void): this;
|
prependOnceListener(event: "end", listener: () => void): this;
|
||||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||||
prependOnceListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
prependOnceListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
||||||
prependOnceListener(event: 'timeout', listener: () => void): this;
|
prependOnceListener(event: "timeout", listener: () => void): this;
|
||||||
}
|
}
|
||||||
interface ListenOptions extends Abortable {
|
|
||||||
port?: number | undefined;
|
interface ListenOptions {
|
||||||
host?: string | undefined;
|
port?: number;
|
||||||
backlog?: number | undefined;
|
host?: string;
|
||||||
path?: string | undefined;
|
backlog?: number;
|
||||||
exclusive?: boolean | undefined;
|
path?: string;
|
||||||
readableAll?: boolean | undefined;
|
exclusive?: boolean;
|
||||||
writableAll?: boolean | undefined;
|
readableAll?: boolean;
|
||||||
|
writableAll?: boolean;
|
||||||
/**
|
/**
|
||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
ipv6Only?: boolean | undefined;
|
ipv6Only?: boolean;
|
||||||
}
|
}
|
||||||
interface ServerOpts {
|
|
||||||
/**
|
// https://github.com/nodejs/node/blob/master/lib/net.js
|
||||||
* Indicates whether half-opened TCP connections are allowed.
|
class Server extends events.EventEmitter {
|
||||||
* @default false
|
|
||||||
*/
|
|
||||||
allowHalfOpen?: boolean | undefined;
|
|
||||||
/**
|
|
||||||
* Indicates whether the socket should be paused on incoming connections.
|
|
||||||
* @default false
|
|
||||||
*/
|
|
||||||
pauseOnConnect?: boolean | undefined;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* This class is used to create a TCP or `IPC` server.
|
|
||||||
* @since v0.1.90
|
|
||||||
*/
|
|
||||||
class Server extends EventEmitter {
|
|
||||||
constructor(connectionListener?: (socket: Socket) => void);
|
constructor(connectionListener?: (socket: Socket) => void);
|
||||||
constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void);
|
constructor(options?: { allowHalfOpen?: boolean, pauseOnConnect?: boolean }, connectionListener?: (socket: Socket) => void);
|
||||||
/**
|
|
||||||
* Start a server listening for connections. A `net.Server` can be a TCP or
|
|
||||||
* an `IPC` server depending on what it listens to.
|
|
||||||
*
|
|
||||||
* Possible signatures:
|
|
||||||
*
|
|
||||||
* * `server.listen(handle[, backlog][, callback])`
|
|
||||||
* * `server.listen(options[, callback])`
|
|
||||||
* * `server.listen(path[, backlog][, callback])` for `IPC` servers
|
|
||||||
* * `server.listen([port[, host[, backlog]]][, callback])` for TCP servers
|
|
||||||
*
|
|
||||||
* This function is asynchronous. When the server starts listening, the `'listening'` event will be emitted. The last parameter `callback`will be added as a listener for the `'listening'`
|
|
||||||
* event.
|
|
||||||
*
|
|
||||||
* All `listen()` methods can take a `backlog` parameter to specify the maximum
|
|
||||||
* length of the queue of pending connections. The actual length will be determined
|
|
||||||
* by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn`on Linux. The default value of this parameter is 511 (not 512).
|
|
||||||
*
|
|
||||||
* All {@link Socket} are set to `SO_REUSEADDR` (see [`socket(7)`](https://man7.org/linux/man-pages/man7/socket.7.html) for
|
|
||||||
* details).
|
|
||||||
*
|
|
||||||
* The `server.listen()` method can be called again if and only if there was an
|
|
||||||
* error during the first `server.listen()` call or `server.close()` has been
|
|
||||||
* called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN` error will be thrown.
|
|
||||||
*
|
|
||||||
* One of the most common errors raised when listening is `EADDRINUSE`.
|
|
||||||
* This happens when another server is already listening on the requested`port`/`path`/`handle`. One way to handle this would be to retry
|
|
||||||
* after a certain amount of time:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* server.on('error', (e) => {
|
|
||||||
* if (e.code === 'EADDRINUSE') {
|
|
||||||
* console.log('Address in use, retrying...');
|
|
||||||
* setTimeout(() => {
|
|
||||||
* server.close();
|
|
||||||
* server.listen(PORT, HOST);
|
|
||||||
* }, 1000);
|
|
||||||
* }
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;
|
listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;
|
||||||
listen(port?: number, hostname?: string, listeningListener?: () => void): this;
|
listen(port?: number, hostname?: string, listeningListener?: () => void): this;
|
||||||
listen(port?: number, backlog?: number, listeningListener?: () => void): this;
|
listen(port?: number, backlog?: number, listeningListener?: () => void): this;
|
||||||
@@ -437,79 +191,15 @@ declare module 'net' {
|
|||||||
listen(options: ListenOptions, listeningListener?: () => void): this;
|
listen(options: ListenOptions, listeningListener?: () => void): this;
|
||||||
listen(handle: any, backlog?: number, listeningListener?: () => void): this;
|
listen(handle: any, backlog?: number, listeningListener?: () => void): this;
|
||||||
listen(handle: any, listeningListener?: () => void): this;
|
listen(handle: any, listeningListener?: () => void): this;
|
||||||
/**
|
|
||||||
* Stops the server from accepting new connections and keeps existing
|
|
||||||
* connections. This function is asynchronous, the server is finally closed
|
|
||||||
* when all connections are ended and the server emits a `'close'` event.
|
|
||||||
* The optional `callback` will be called once the `'close'` event occurs. Unlike
|
|
||||||
* that event, it will be called with an `Error` as its only argument if the server
|
|
||||||
* was not open when it was closed.
|
|
||||||
* @since v0.1.90
|
|
||||||
* @param callback Called when the server is closed.
|
|
||||||
*/
|
|
||||||
close(callback?: (err?: Error) => void): this;
|
close(callback?: (err?: Error) => void): this;
|
||||||
/**
|
|
||||||
* Returns the bound `address`, the address `family` name, and `port` of the server
|
|
||||||
* as reported by the operating system if listening on an IP socket
|
|
||||||
* (useful to find which port was assigned when getting an OS-assigned address):`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
|
|
||||||
*
|
|
||||||
* For a server listening on a pipe or Unix domain socket, the name is returned
|
|
||||||
* as a string.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const server = net.createServer((socket) => {
|
|
||||||
* socket.end('goodbye\n');
|
|
||||||
* }).on('error', (err) => {
|
|
||||||
* // Handle errors here.
|
|
||||||
* throw err;
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* // Grab an arbitrary unused port.
|
|
||||||
* server.listen(() => {
|
|
||||||
* console.log('opened server on', server.address());
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* `server.address()` returns `null` before the `'listening'` event has been
|
|
||||||
* emitted or after calling `server.close()`.
|
|
||||||
* @since v0.1.90
|
|
||||||
*/
|
|
||||||
address(): AddressInfo | string | null;
|
address(): AddressInfo | string | null;
|
||||||
/**
|
|
||||||
* Asynchronously get the number of concurrent connections on the server. Works
|
|
||||||
* when sockets were sent to forks.
|
|
||||||
*
|
|
||||||
* Callback should take two arguments `err` and `count`.
|
|
||||||
* @since v0.9.7
|
|
||||||
*/
|
|
||||||
getConnections(cb: (error: Error | null, count: number) => void): void;
|
getConnections(cb: (error: Error | null, count: number) => void): void;
|
||||||
/**
|
|
||||||
* Opposite of `unref()`, calling `ref()` on a previously `unref`ed server will_not_ let the program exit if it's the only server left (the default behavior).
|
|
||||||
* If the server is `ref`ed calling `ref()` again will have no effect.
|
|
||||||
* @since v0.9.1
|
|
||||||
*/
|
|
||||||
ref(): this;
|
ref(): this;
|
||||||
/**
|
|
||||||
* Calling `unref()` on a server will allow the program to exit if this is the only
|
|
||||||
* active server in the event system. If the server is already `unref`ed calling`unref()` again will have no effect.
|
|
||||||
* @since v0.9.1
|
|
||||||
*/
|
|
||||||
unref(): this;
|
unref(): this;
|
||||||
/**
|
|
||||||
* Set this property to reject connections when the server's connection count gets
|
|
||||||
* high.
|
|
||||||
*
|
|
||||||
* It is not recommended to use this option once a socket has been sent to a child
|
|
||||||
* with `child_process.fork()`.
|
|
||||||
* @since v0.2.0
|
|
||||||
*/
|
|
||||||
maxConnections: number;
|
maxConnections: number;
|
||||||
connections: number;
|
connections: number;
|
||||||
/**
|
|
||||||
* Indicates whether or not the server is listening for connections.
|
|
||||||
* @since v5.7.0
|
|
||||||
*/
|
|
||||||
listening: boolean;
|
listening: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* events.EventEmitter
|
* events.EventEmitter
|
||||||
* 1. close
|
* 1. close
|
||||||
@@ -518,259 +208,61 @@ declare module 'net' {
|
|||||||
* 4. listening
|
* 4. listening
|
||||||
*/
|
*/
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'close', listener: () => void): this;
|
addListener(event: "close", listener: () => void): this;
|
||||||
addListener(event: 'connection', listener: (socket: Socket) => void): this;
|
addListener(event: "connection", listener: (socket: Socket) => void): this;
|
||||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
addListener(event: "error", listener: (err: Error) => void): this;
|
||||||
addListener(event: 'listening', listener: () => void): this;
|
addListener(event: "listening", listener: () => void): this;
|
||||||
|
|
||||||
emit(event: string | symbol, ...args: any[]): boolean;
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
emit(event: 'close'): boolean;
|
emit(event: "close"): boolean;
|
||||||
emit(event: 'connection', socket: Socket): boolean;
|
emit(event: "connection", socket: Socket): boolean;
|
||||||
emit(event: 'error', err: Error): boolean;
|
emit(event: "error", err: Error): boolean;
|
||||||
emit(event: 'listening'): boolean;
|
emit(event: "listening"): boolean;
|
||||||
|
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
on(event: 'close', listener: () => void): this;
|
on(event: "close", listener: () => void): this;
|
||||||
on(event: 'connection', listener: (socket: Socket) => void): this;
|
on(event: "connection", listener: (socket: Socket) => void): this;
|
||||||
on(event: 'error', listener: (err: Error) => void): this;
|
on(event: "error", listener: (err: Error) => void): this;
|
||||||
on(event: 'listening', listener: () => void): this;
|
on(event: "listening", listener: () => void): this;
|
||||||
|
|
||||||
once(event: string, listener: (...args: any[]) => void): this;
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
once(event: 'close', listener: () => void): this;
|
once(event: "close", listener: () => void): this;
|
||||||
once(event: 'connection', listener: (socket: Socket) => void): this;
|
once(event: "connection", listener: (socket: Socket) => void): this;
|
||||||
once(event: 'error', listener: (err: Error) => void): this;
|
once(event: "error", listener: (err: Error) => void): this;
|
||||||
once(event: 'listening', listener: () => void): this;
|
once(event: "listening", listener: () => void): this;
|
||||||
|
|
||||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependListener(event: 'close', listener: () => void): this;
|
prependListener(event: "close", listener: () => void): this;
|
||||||
prependListener(event: 'connection', listener: (socket: Socket) => void): this;
|
prependListener(event: "connection", listener: (socket: Socket) => void): this;
|
||||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||||
prependListener(event: 'listening', listener: () => void): this;
|
prependListener(event: "listening", listener: () => void): this;
|
||||||
|
|
||||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependOnceListener(event: 'close', listener: () => void): this;
|
prependOnceListener(event: "close", listener: () => void): this;
|
||||||
prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
|
prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
|
||||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||||
prependOnceListener(event: 'listening', listener: () => void): this;
|
prependOnceListener(event: "listening", listener: () => void): this;
|
||||||
}
|
|
||||||
type IPVersion = 'ipv4' | 'ipv6';
|
|
||||||
/**
|
|
||||||
* The `BlockList` object can be used with some network APIs to specify rules for
|
|
||||||
* disabling inbound or outbound access to specific IP addresses, IP ranges, or
|
|
||||||
* IP subnets.
|
|
||||||
* @since v15.0.0
|
|
||||||
*/
|
|
||||||
class BlockList {
|
|
||||||
/**
|
|
||||||
* Adds a rule to block the given IP address.
|
|
||||||
* @since v15.0.0
|
|
||||||
* @param address An IPv4 or IPv6 address.
|
|
||||||
* @param type Either `'ipv4'` or `'ipv6'`.
|
|
||||||
*/
|
|
||||||
addAddress(address: string, type?: IPVersion): void;
|
|
||||||
addAddress(address: SocketAddress): void;
|
|
||||||
/**
|
|
||||||
* Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive).
|
|
||||||
* @since v15.0.0
|
|
||||||
* @param start The starting IPv4 or IPv6 address in the range.
|
|
||||||
* @param end The ending IPv4 or IPv6 address in the range.
|
|
||||||
* @param type Either `'ipv4'` or `'ipv6'`.
|
|
||||||
*/
|
|
||||||
addRange(start: string, end: string, type?: IPVersion): void;
|
|
||||||
addRange(start: SocketAddress, end: SocketAddress): void;
|
|
||||||
/**
|
|
||||||
* Adds a rule to block a range of IP addresses specified as a subnet mask.
|
|
||||||
* @since v15.0.0
|
|
||||||
* @param net The network IPv4 or IPv6 address.
|
|
||||||
* @param prefix The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`.
|
|
||||||
* @param type Either `'ipv4'` or `'ipv6'`.
|
|
||||||
*/
|
|
||||||
addSubnet(net: SocketAddress, prefix: number): void;
|
|
||||||
addSubnet(net: string, prefix: number, type?: IPVersion): void;
|
|
||||||
/**
|
|
||||||
* Returns `true` if the given IP address matches any of the rules added to the`BlockList`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const blockList = new net.BlockList();
|
|
||||||
* blockList.addAddress('123.123.123.123');
|
|
||||||
* blockList.addRange('10.0.0.1', '10.0.0.10');
|
|
||||||
* blockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6');
|
|
||||||
*
|
|
||||||
* console.log(blockList.check('123.123.123.123')); // Prints: true
|
|
||||||
* console.log(blockList.check('10.0.0.3')); // Prints: true
|
|
||||||
* console.log(blockList.check('222.111.111.222')); // Prints: false
|
|
||||||
*
|
|
||||||
* // IPv6 notation for IPv4 addresses works:
|
|
||||||
* console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true
|
|
||||||
* console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true
|
|
||||||
* ```
|
|
||||||
* @since v15.0.0
|
|
||||||
* @param address The IP address to check
|
|
||||||
* @param type Either `'ipv4'` or `'ipv6'`.
|
|
||||||
*/
|
|
||||||
check(address: SocketAddress): boolean;
|
|
||||||
check(address: string, type?: IPVersion): boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
|
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
|
||||||
timeout?: number | undefined;
|
timeout?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
|
interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
|
||||||
timeout?: number | undefined;
|
timeout?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts;
|
type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts;
|
||||||
/**
|
|
||||||
* Creates a new TCP or `IPC` server.
|
|
||||||
*
|
|
||||||
* If `allowHalfOpen` is set to `true`, when the other end of the socket
|
|
||||||
* signals the end of transmission, the server will only send back the end of
|
|
||||||
* transmission when `socket.end()` is explicitly called. For example, in the
|
|
||||||
* context of TCP, when a FIN packed is received, a FIN packed is sent
|
|
||||||
* back only when `socket.end()` is explicitly called. Until then the
|
|
||||||
* connection is half-closed (non-readable but still writable). See `'end'` event and [RFC 1122](https://tools.ietf.org/html/rfc1122) (section 4.2.2.13) for more information.
|
|
||||||
*
|
|
||||||
* If `pauseOnConnect` is set to `true`, then the socket associated with each
|
|
||||||
* incoming connection will be paused, and no data will be read from its handle.
|
|
||||||
* This allows connections to be passed between processes without any data being
|
|
||||||
* read by the original process. To begin reading data from a paused socket, call `socket.resume()`.
|
|
||||||
*
|
|
||||||
* The server can be a TCP server or an `IPC` server, depending on what it `listen()` to.
|
|
||||||
*
|
|
||||||
* Here is an example of an TCP echo server which listens for connections
|
|
||||||
* on port 8124:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const net = require('net');
|
|
||||||
* const server = net.createServer((c) => {
|
|
||||||
* // 'connection' listener.
|
|
||||||
* console.log('client connected');
|
|
||||||
* c.on('end', () => {
|
|
||||||
* console.log('client disconnected');
|
|
||||||
* });
|
|
||||||
* c.write('hello\r\n');
|
|
||||||
* c.pipe(c);
|
|
||||||
* });
|
|
||||||
* server.on('error', (err) => {
|
|
||||||
* throw err;
|
|
||||||
* });
|
|
||||||
* server.listen(8124, () => {
|
|
||||||
* console.log('server bound');
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Test this by using `telnet`:
|
|
||||||
*
|
|
||||||
* ```console
|
|
||||||
* $ telnet localhost 8124
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* To listen on the socket `/tmp/echo.sock`:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* server.listen('/tmp/echo.sock', () => {
|
|
||||||
* console.log('server bound');
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Use `nc` to connect to a Unix domain socket server:
|
|
||||||
*
|
|
||||||
* ```console
|
|
||||||
* $ nc -U /tmp/echo.sock
|
|
||||||
* ```
|
|
||||||
* @since v0.5.0
|
|
||||||
* @param connectionListener Automatically set as a listener for the {@link 'connection'} event.
|
|
||||||
*/
|
|
||||||
function createServer(connectionListener?: (socket: Socket) => void): Server;
|
function createServer(connectionListener?: (socket: Socket) => void): Server;
|
||||||
function createServer(options?: ServerOpts, connectionListener?: (socket: Socket) => void): Server;
|
function createServer(options?: { allowHalfOpen?: boolean, pauseOnConnect?: boolean }, connectionListener?: (socket: Socket) => void): Server;
|
||||||
/**
|
|
||||||
* Aliases to {@link createConnection}.
|
|
||||||
*
|
|
||||||
* Possible signatures:
|
|
||||||
*
|
|
||||||
* * {@link connect}
|
|
||||||
* * {@link connect} for `IPC` connections.
|
|
||||||
* * {@link connect} for TCP connections.
|
|
||||||
*/
|
|
||||||
function connect(options: NetConnectOpts, connectionListener?: () => void): Socket;
|
function connect(options: NetConnectOpts, connectionListener?: () => void): Socket;
|
||||||
function connect(port: number, host?: string, connectionListener?: () => void): Socket;
|
function connect(port: number, host?: string, connectionListener?: () => void): Socket;
|
||||||
function connect(path: string, connectionListener?: () => void): Socket;
|
function connect(path: string, connectionListener?: () => void): Socket;
|
||||||
/**
|
|
||||||
* A factory function, which creates a new {@link Socket},
|
|
||||||
* immediately initiates connection with `socket.connect()`,
|
|
||||||
* then returns the `net.Socket` that starts the connection.
|
|
||||||
*
|
|
||||||
* When the connection is established, a `'connect'` event will be emitted
|
|
||||||
* on the returned socket. The last parameter `connectListener`, if supplied,
|
|
||||||
* will be added as a listener for the `'connect'` event **once**.
|
|
||||||
*
|
|
||||||
* Possible signatures:
|
|
||||||
*
|
|
||||||
* * {@link createConnection}
|
|
||||||
* * {@link createConnection} for `IPC` connections.
|
|
||||||
* * {@link createConnection} for TCP connections.
|
|
||||||
*
|
|
||||||
* The {@link connect} function is an alias to this function.
|
|
||||||
*/
|
|
||||||
function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
|
function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
|
||||||
function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
|
function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
|
||||||
function createConnection(path: string, connectionListener?: () => void): Socket;
|
function createConnection(path: string, connectionListener?: () => void): Socket;
|
||||||
/**
|
|
||||||
* Tests if input is an IP address. Returns `0` for invalid strings,
|
|
||||||
* returns `4` for IP version 4 addresses, and returns `6` for IP version 6
|
|
||||||
* addresses.
|
|
||||||
* @since v0.3.0
|
|
||||||
*/
|
|
||||||
function isIP(input: string): number;
|
function isIP(input: string): number;
|
||||||
/**
|
|
||||||
* Returns `true` if input is a version 4 IP address, otherwise returns `false`.
|
|
||||||
* @since v0.3.0
|
|
||||||
*/
|
|
||||||
function isIPv4(input: string): boolean;
|
function isIPv4(input: string): boolean;
|
||||||
/**
|
|
||||||
* Returns `true` if input is a version 6 IP address, otherwise returns `false`.
|
|
||||||
* @since v0.3.0
|
|
||||||
*/
|
|
||||||
function isIPv6(input: string): boolean;
|
function isIPv6(input: string): boolean;
|
||||||
interface SocketAddressInitOptions {
|
|
||||||
/**
|
|
||||||
* The network address as either an IPv4 or IPv6 string.
|
|
||||||
* @default 127.0.0.1
|
|
||||||
*/
|
|
||||||
address?: string | undefined;
|
|
||||||
/**
|
|
||||||
* @default `'ipv4'`
|
|
||||||
*/
|
|
||||||
family?: IPVersion | undefined;
|
|
||||||
/**
|
|
||||||
* An IPv6 flow-label used only if `family` is `'ipv6'`.
|
|
||||||
* @default 0
|
|
||||||
*/
|
|
||||||
flowlabel?: number | undefined;
|
|
||||||
/**
|
|
||||||
* An IP port.
|
|
||||||
* @default 0
|
|
||||||
*/
|
|
||||||
port?: number | undefined;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @since v15.14.0
|
|
||||||
*/
|
|
||||||
class SocketAddress {
|
|
||||||
constructor(options: SocketAddressInitOptions);
|
|
||||||
/**
|
|
||||||
* Either \`'ipv4'\` or \`'ipv6'\`.
|
|
||||||
* @since v15.14.0
|
|
||||||
*/
|
|
||||||
readonly address: string;
|
|
||||||
/**
|
|
||||||
* Either \`'ipv4'\` or \`'ipv6'\`.
|
|
||||||
* @since v15.14.0
|
|
||||||
*/
|
|
||||||
readonly family: IPVersion;
|
|
||||||
/**
|
|
||||||
* @since v15.14.0
|
|
||||||
*/
|
|
||||||
readonly port: number;
|
|
||||||
/**
|
|
||||||
* @since v15.14.0
|
|
||||||
*/
|
|
||||||
readonly flowlabel: number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
declare module 'node:net' {
|
|
||||||
export * from 'net';
|
|
||||||
}
|
}
|
||||||
|
|||||||
+209
-401
@@ -1,13 +1,4 @@
|
|||||||
/**
|
declare module "os" {
|
||||||
* The `os` module provides operating system-related utility methods and
|
|
||||||
* properties. It can be accessed using:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const os = require('os');
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/os.js)
|
|
||||||
*/
|
|
||||||
declare module 'os' {
|
|
||||||
interface CpuInfo {
|
interface CpuInfo {
|
||||||
model: string;
|
model: string;
|
||||||
speed: number;
|
speed: number;
|
||||||
@@ -19,6 +10,7 @@ declare module 'os' {
|
|||||||
irq: number;
|
irq: number;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NetworkInterfaceBase {
|
interface NetworkInterfaceBase {
|
||||||
address: string;
|
address: string;
|
||||||
netmask: string;
|
netmask: string;
|
||||||
@@ -26,13 +18,16 @@ declare module 'os' {
|
|||||||
internal: boolean;
|
internal: boolean;
|
||||||
cidr: string | null;
|
cidr: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
|
interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
|
||||||
family: 'IPv4';
|
family: "IPv4";
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
|
interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
|
||||||
family: 'IPv6';
|
family: "IPv6";
|
||||||
scopeid: number;
|
scopeid: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UserInfo<T> {
|
interface UserInfo<T> {
|
||||||
username: T;
|
username: T;
|
||||||
uid: number;
|
uid: number;
|
||||||
@@ -40,416 +35,229 @@ declare module 'os' {
|
|||||||
shell: T;
|
shell: T;
|
||||||
homedir: T;
|
homedir: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;
|
type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;
|
||||||
/**
|
|
||||||
* Returns the host name of the operating system as a string.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function hostname(): string;
|
function hostname(): string;
|
||||||
/**
|
|
||||||
* Returns an array containing the 1, 5, and 15 minute load averages.
|
|
||||||
*
|
|
||||||
* The load average is a measure of system activity calculated by the operating
|
|
||||||
* system and expressed as a fractional number.
|
|
||||||
*
|
|
||||||
* The load average is a Unix-specific concept. On Windows, the return value is
|
|
||||||
* always `[0, 0, 0]`.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function loadavg(): number[];
|
function loadavg(): number[];
|
||||||
/**
|
|
||||||
* Returns the system uptime in number of seconds.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function uptime(): number;
|
function uptime(): number;
|
||||||
/**
|
|
||||||
* Returns the amount of free system memory in bytes as an integer.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function freemem(): number;
|
function freemem(): number;
|
||||||
/**
|
|
||||||
* Returns the total amount of system memory in bytes as an integer.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function totalmem(): number;
|
function totalmem(): number;
|
||||||
/**
|
|
||||||
* Returns an array of objects containing information about each logical CPU core.
|
|
||||||
*
|
|
||||||
* The properties included on each object include:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* [
|
|
||||||
* {
|
|
||||||
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
|
||||||
* speed: 2926,
|
|
||||||
* times: {
|
|
||||||
* user: 252020,
|
|
||||||
* nice: 0,
|
|
||||||
* sys: 30340,
|
|
||||||
* idle: 1070356870,
|
|
||||||
* irq: 0
|
|
||||||
* }
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
|
||||||
* speed: 2926,
|
|
||||||
* times: {
|
|
||||||
* user: 306960,
|
|
||||||
* nice: 0,
|
|
||||||
* sys: 26980,
|
|
||||||
* idle: 1071569080,
|
|
||||||
* irq: 0
|
|
||||||
* }
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
|
||||||
* speed: 2926,
|
|
||||||
* times: {
|
|
||||||
* user: 248450,
|
|
||||||
* nice: 0,
|
|
||||||
* sys: 21750,
|
|
||||||
* idle: 1070919370,
|
|
||||||
* irq: 0
|
|
||||||
* }
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
|
||||||
* speed: 2926,
|
|
||||||
* times: {
|
|
||||||
* user: 256880,
|
|
||||||
* nice: 0,
|
|
||||||
* sys: 19430,
|
|
||||||
* idle: 1070905480,
|
|
||||||
* irq: 20
|
|
||||||
* }
|
|
||||||
* },
|
|
||||||
* ]
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* `nice` values are POSIX-only. On Windows, the `nice` values of all processors
|
|
||||||
* are always 0.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function cpus(): CpuInfo[];
|
function cpus(): CpuInfo[];
|
||||||
/**
|
|
||||||
* Returns the operating system name as returned by [`uname(3)`](https://linux.die.net/man/3/uname). For example, it
|
|
||||||
* returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows.
|
|
||||||
*
|
|
||||||
* See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for additional information
|
|
||||||
* about the output of running [`uname(3)`](https://linux.die.net/man/3/uname) on various operating systems.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function type(): string;
|
function type(): string;
|
||||||
/**
|
|
||||||
* Returns the operating system as a string.
|
|
||||||
*
|
|
||||||
* On POSIX systems, the operating system release is determined by calling[`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `GetVersionExW()` is used.
|
|
||||||
* See[https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
|
|
||||||
* @since v0.3.3
|
|
||||||
*/
|
|
||||||
function release(): string;
|
function release(): string;
|
||||||
/**
|
function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] };
|
||||||
* Returns an object containing network interfaces that have been assigned a
|
|
||||||
* network address.
|
|
||||||
*
|
|
||||||
* Each key on the returned object identifies a network interface. The associated
|
|
||||||
* value is an array of objects that each describe an assigned network address.
|
|
||||||
*
|
|
||||||
* The properties available on the assigned network address object include:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* {
|
|
||||||
* lo: [
|
|
||||||
* {
|
|
||||||
* address: '127.0.0.1',
|
|
||||||
* netmask: '255.0.0.0',
|
|
||||||
* family: 'IPv4',
|
|
||||||
* mac: '00:00:00:00:00:00',
|
|
||||||
* internal: true,
|
|
||||||
* cidr: '127.0.0.1/8'
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* address: '::1',
|
|
||||||
* netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
|
|
||||||
* family: 'IPv6',
|
|
||||||
* mac: '00:00:00:00:00:00',
|
|
||||||
* scopeid: 0,
|
|
||||||
* internal: true,
|
|
||||||
* cidr: '::1/128'
|
|
||||||
* }
|
|
||||||
* ],
|
|
||||||
* eth0: [
|
|
||||||
* {
|
|
||||||
* address: '192.168.1.108',
|
|
||||||
* netmask: '255.255.255.0',
|
|
||||||
* family: 'IPv4',
|
|
||||||
* mac: '01:02:03:0a:0b:0c',
|
|
||||||
* internal: false,
|
|
||||||
* cidr: '192.168.1.108/24'
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* address: 'fe80::a00:27ff:fe4e:66a1',
|
|
||||||
* netmask: 'ffff:ffff:ffff:ffff::',
|
|
||||||
* family: 'IPv6',
|
|
||||||
* mac: '01:02:03:0a:0b:0c',
|
|
||||||
* scopeid: 1,
|
|
||||||
* internal: false,
|
|
||||||
* cidr: 'fe80::a00:27ff:fe4e:66a1/64'
|
|
||||||
* }
|
|
||||||
* ]
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @since v0.6.0
|
|
||||||
*/
|
|
||||||
function networkInterfaces(): NodeJS.Dict<NetworkInterfaceInfo[]>;
|
|
||||||
/**
|
|
||||||
* Returns the string path of the current user's home directory.
|
|
||||||
*
|
|
||||||
* On POSIX, it uses the `$HOME` environment variable if defined. Otherwise it
|
|
||||||
* uses the [effective UID](https://en.wikipedia.org/wiki/User_identifier#Effective_user_ID) to look up the user's home directory.
|
|
||||||
*
|
|
||||||
* On Windows, it uses the `USERPROFILE` environment variable if defined.
|
|
||||||
* Otherwise it uses the path to the profile directory of the current user.
|
|
||||||
* @since v2.3.0
|
|
||||||
*/
|
|
||||||
function homedir(): string;
|
function homedir(): string;
|
||||||
/**
|
|
||||||
* Returns information about the currently effective user. On POSIX platforms,
|
|
||||||
* this is typically a subset of the password file. The returned object includes
|
|
||||||
* the `username`, `uid`, `gid`, `shell`, and `homedir`. On Windows, the `uid` and`gid` fields are `-1`, and `shell` is `null`.
|
|
||||||
*
|
|
||||||
* The value of `homedir` returned by `os.userInfo()` is provided by the operating
|
|
||||||
* system. This differs from the result of `os.homedir()`, which queries
|
|
||||||
* environment variables for the home directory before falling back to the
|
|
||||||
* operating system response.
|
|
||||||
*
|
|
||||||
* Throws a `SystemError` if a user has no `username` or `homedir`.
|
|
||||||
* @since v6.0.0
|
|
||||||
*/
|
|
||||||
function userInfo(options: { encoding: 'buffer' }): UserInfo<Buffer>;
|
function userInfo(options: { encoding: 'buffer' }): UserInfo<Buffer>;
|
||||||
function userInfo(options?: { encoding: BufferEncoding }): UserInfo<string>;
|
function userInfo(options?: { encoding: string }): UserInfo<string>;
|
||||||
type SignalConstants = {
|
const constants: {
|
||||||
[key in NodeJS.Signals]: number;
|
UV_UDP_REUSEADDR: number;
|
||||||
|
// signals: { [key in NodeJS.Signals]: number; }; @todo: change after migration to typescript 2.1
|
||||||
|
signals: {
|
||||||
|
SIGHUP: number;
|
||||||
|
SIGINT: number;
|
||||||
|
SIGQUIT: number;
|
||||||
|
SIGILL: number;
|
||||||
|
SIGTRAP: number;
|
||||||
|
SIGABRT: number;
|
||||||
|
SIGIOT: number;
|
||||||
|
SIGBUS: number;
|
||||||
|
SIGFPE: number;
|
||||||
|
SIGKILL: number;
|
||||||
|
SIGUSR1: number;
|
||||||
|
SIGSEGV: number;
|
||||||
|
SIGUSR2: number;
|
||||||
|
SIGPIPE: number;
|
||||||
|
SIGALRM: number;
|
||||||
|
SIGTERM: number;
|
||||||
|
SIGCHLD: number;
|
||||||
|
SIGSTKFLT: number;
|
||||||
|
SIGCONT: number;
|
||||||
|
SIGSTOP: number;
|
||||||
|
SIGTSTP: number;
|
||||||
|
SIGBREAK: number;
|
||||||
|
SIGTTIN: number;
|
||||||
|
SIGTTOU: number;
|
||||||
|
SIGURG: number;
|
||||||
|
SIGXCPU: number;
|
||||||
|
SIGXFSZ: number;
|
||||||
|
SIGVTALRM: number;
|
||||||
|
SIGPROF: number;
|
||||||
|
SIGWINCH: number;
|
||||||
|
SIGIO: number;
|
||||||
|
SIGPOLL: number;
|
||||||
|
SIGLOST: number;
|
||||||
|
SIGPWR: number;
|
||||||
|
SIGINFO: number;
|
||||||
|
SIGSYS: number;
|
||||||
|
SIGUNUSED: number;
|
||||||
};
|
};
|
||||||
namespace constants {
|
errno: {
|
||||||
const UV_UDP_REUSEADDR: number;
|
E2BIG: number;
|
||||||
namespace signals {}
|
EACCES: number;
|
||||||
const signals: SignalConstants;
|
EADDRINUSE: number;
|
||||||
namespace errno {
|
EADDRNOTAVAIL: number;
|
||||||
const E2BIG: number;
|
EAFNOSUPPORT: number;
|
||||||
const EACCES: number;
|
EAGAIN: number;
|
||||||
const EADDRINUSE: number;
|
EALREADY: number;
|
||||||
const EADDRNOTAVAIL: number;
|
EBADF: number;
|
||||||
const EAFNOSUPPORT: number;
|
EBADMSG: number;
|
||||||
const EAGAIN: number;
|
EBUSY: number;
|
||||||
const EALREADY: number;
|
ECANCELED: number;
|
||||||
const EBADF: number;
|
ECHILD: number;
|
||||||
const EBADMSG: number;
|
ECONNABORTED: number;
|
||||||
const EBUSY: number;
|
ECONNREFUSED: number;
|
||||||
const ECANCELED: number;
|
ECONNRESET: number;
|
||||||
const ECHILD: number;
|
EDEADLK: number;
|
||||||
const ECONNABORTED: number;
|
EDESTADDRREQ: number;
|
||||||
const ECONNREFUSED: number;
|
EDOM: number;
|
||||||
const ECONNRESET: number;
|
EDQUOT: number;
|
||||||
const EDEADLK: number;
|
EEXIST: number;
|
||||||
const EDESTADDRREQ: number;
|
EFAULT: number;
|
||||||
const EDOM: number;
|
EFBIG: number;
|
||||||
const EDQUOT: number;
|
EHOSTUNREACH: number;
|
||||||
const EEXIST: number;
|
EIDRM: number;
|
||||||
const EFAULT: number;
|
EILSEQ: number;
|
||||||
const EFBIG: number;
|
EINPROGRESS: number;
|
||||||
const EHOSTUNREACH: number;
|
EINTR: number;
|
||||||
const EIDRM: number;
|
EINVAL: number;
|
||||||
const EILSEQ: number;
|
EIO: number;
|
||||||
const EINPROGRESS: number;
|
EISCONN: number;
|
||||||
const EINTR: number;
|
EISDIR: number;
|
||||||
const EINVAL: number;
|
ELOOP: number;
|
||||||
const EIO: number;
|
EMFILE: number;
|
||||||
const EISCONN: number;
|
EMLINK: number;
|
||||||
const EISDIR: number;
|
EMSGSIZE: number;
|
||||||
const ELOOP: number;
|
EMULTIHOP: number;
|
||||||
const EMFILE: number;
|
ENAMETOOLONG: number;
|
||||||
const EMLINK: number;
|
ENETDOWN: number;
|
||||||
const EMSGSIZE: number;
|
ENETRESET: number;
|
||||||
const EMULTIHOP: number;
|
ENETUNREACH: number;
|
||||||
const ENAMETOOLONG: number;
|
ENFILE: number;
|
||||||
const ENETDOWN: number;
|
ENOBUFS: number;
|
||||||
const ENETRESET: number;
|
ENODATA: number;
|
||||||
const ENETUNREACH: number;
|
ENODEV: number;
|
||||||
const ENFILE: number;
|
ENOENT: number;
|
||||||
const ENOBUFS: number;
|
ENOEXEC: number;
|
||||||
const ENODATA: number;
|
ENOLCK: number;
|
||||||
const ENODEV: number;
|
ENOLINK: number;
|
||||||
const ENOENT: number;
|
ENOMEM: number;
|
||||||
const ENOEXEC: number;
|
ENOMSG: number;
|
||||||
const ENOLCK: number;
|
ENOPROTOOPT: number;
|
||||||
const ENOLINK: number;
|
ENOSPC: number;
|
||||||
const ENOMEM: number;
|
ENOSR: number;
|
||||||
const ENOMSG: number;
|
ENOSTR: number;
|
||||||
const ENOPROTOOPT: number;
|
ENOSYS: number;
|
||||||
const ENOSPC: number;
|
ENOTCONN: number;
|
||||||
const ENOSR: number;
|
ENOTDIR: number;
|
||||||
const ENOSTR: number;
|
ENOTEMPTY: number;
|
||||||
const ENOSYS: number;
|
ENOTSOCK: number;
|
||||||
const ENOTCONN: number;
|
ENOTSUP: number;
|
||||||
const ENOTDIR: number;
|
ENOTTY: number;
|
||||||
const ENOTEMPTY: number;
|
ENXIO: number;
|
||||||
const ENOTSOCK: number;
|
EOPNOTSUPP: number;
|
||||||
const ENOTSUP: number;
|
EOVERFLOW: number;
|
||||||
const ENOTTY: number;
|
EPERM: number;
|
||||||
const ENXIO: number;
|
EPIPE: number;
|
||||||
const EOPNOTSUPP: number;
|
EPROTO: number;
|
||||||
const EOVERFLOW: number;
|
EPROTONOSUPPORT: number;
|
||||||
const EPERM: number;
|
EPROTOTYPE: number;
|
||||||
const EPIPE: number;
|
ERANGE: number;
|
||||||
const EPROTO: number;
|
EROFS: number;
|
||||||
const EPROTONOSUPPORT: number;
|
ESPIPE: number;
|
||||||
const EPROTOTYPE: number;
|
ESRCH: number;
|
||||||
const ERANGE: number;
|
ESTALE: number;
|
||||||
const EROFS: number;
|
ETIME: number;
|
||||||
const ESPIPE: number;
|
ETIMEDOUT: number;
|
||||||
const ESRCH: number;
|
ETXTBSY: number;
|
||||||
const ESTALE: number;
|
EWOULDBLOCK: number;
|
||||||
const ETIME: number;
|
EXDEV: number;
|
||||||
const ETIMEDOUT: number;
|
WSAEINTR: number;
|
||||||
const ETXTBSY: number;
|
WSAEBADF: number;
|
||||||
const EWOULDBLOCK: number;
|
WSAEACCES: number;
|
||||||
const EXDEV: number;
|
WSAEFAULT: number;
|
||||||
const WSAEINTR: number;
|
WSAEINVAL: number;
|
||||||
const WSAEBADF: number;
|
WSAEMFILE: number;
|
||||||
const WSAEACCES: number;
|
WSAEWOULDBLOCK: number;
|
||||||
const WSAEFAULT: number;
|
WSAEINPROGRESS: number;
|
||||||
const WSAEINVAL: number;
|
WSAEALREADY: number;
|
||||||
const WSAEMFILE: number;
|
WSAENOTSOCK: number;
|
||||||
const WSAEWOULDBLOCK: number;
|
WSAEDESTADDRREQ: number;
|
||||||
const WSAEINPROGRESS: number;
|
WSAEMSGSIZE: number;
|
||||||
const WSAEALREADY: number;
|
WSAEPROTOTYPE: number;
|
||||||
const WSAENOTSOCK: number;
|
WSAENOPROTOOPT: number;
|
||||||
const WSAEDESTADDRREQ: number;
|
WSAEPROTONOSUPPORT: number;
|
||||||
const WSAEMSGSIZE: number;
|
WSAESOCKTNOSUPPORT: number;
|
||||||
const WSAEPROTOTYPE: number;
|
WSAEOPNOTSUPP: number;
|
||||||
const WSAENOPROTOOPT: number;
|
WSAEPFNOSUPPORT: number;
|
||||||
const WSAEPROTONOSUPPORT: number;
|
WSAEAFNOSUPPORT: number;
|
||||||
const WSAESOCKTNOSUPPORT: number;
|
WSAEADDRINUSE: number;
|
||||||
const WSAEOPNOTSUPP: number;
|
WSAEADDRNOTAVAIL: number;
|
||||||
const WSAEPFNOSUPPORT: number;
|
WSAENETDOWN: number;
|
||||||
const WSAEAFNOSUPPORT: number;
|
WSAENETUNREACH: number;
|
||||||
const WSAEADDRINUSE: number;
|
WSAENETRESET: number;
|
||||||
const WSAEADDRNOTAVAIL: number;
|
WSAECONNABORTED: number;
|
||||||
const WSAENETDOWN: number;
|
WSAECONNRESET: number;
|
||||||
const WSAENETUNREACH: number;
|
WSAENOBUFS: number;
|
||||||
const WSAENETRESET: number;
|
WSAEISCONN: number;
|
||||||
const WSAECONNABORTED: number;
|
WSAENOTCONN: number;
|
||||||
const WSAECONNRESET: number;
|
WSAESHUTDOWN: number;
|
||||||
const WSAENOBUFS: number;
|
WSAETOOMANYREFS: number;
|
||||||
const WSAEISCONN: number;
|
WSAETIMEDOUT: number;
|
||||||
const WSAENOTCONN: number;
|
WSAECONNREFUSED: number;
|
||||||
const WSAESHUTDOWN: number;
|
WSAELOOP: number;
|
||||||
const WSAETOOMANYREFS: number;
|
WSAENAMETOOLONG: number;
|
||||||
const WSAETIMEDOUT: number;
|
WSAEHOSTDOWN: number;
|
||||||
const WSAECONNREFUSED: number;
|
WSAEHOSTUNREACH: number;
|
||||||
const WSAELOOP: number;
|
WSAENOTEMPTY: number;
|
||||||
const WSAENAMETOOLONG: number;
|
WSAEPROCLIM: number;
|
||||||
const WSAEHOSTDOWN: number;
|
WSAEUSERS: number;
|
||||||
const WSAEHOSTUNREACH: number;
|
WSAEDQUOT: number;
|
||||||
const WSAENOTEMPTY: number;
|
WSAESTALE: number;
|
||||||
const WSAEPROCLIM: number;
|
WSAEREMOTE: number;
|
||||||
const WSAEUSERS: number;
|
WSASYSNOTREADY: number;
|
||||||
const WSAEDQUOT: number;
|
WSAVERNOTSUPPORTED: number;
|
||||||
const WSAESTALE: number;
|
WSANOTINITIALISED: number;
|
||||||
const WSAEREMOTE: number;
|
WSAEDISCON: number;
|
||||||
const WSASYSNOTREADY: number;
|
WSAENOMORE: number;
|
||||||
const WSAVERNOTSUPPORTED: number;
|
WSAECANCELLED: number;
|
||||||
const WSANOTINITIALISED: number;
|
WSAEINVALIDPROCTABLE: number;
|
||||||
const WSAEDISCON: number;
|
WSAEINVALIDPROVIDER: number;
|
||||||
const WSAENOMORE: number;
|
WSAEPROVIDERFAILEDINIT: number;
|
||||||
const WSAECANCELLED: number;
|
WSASYSCALLFAILURE: number;
|
||||||
const WSAEINVALIDPROCTABLE: number;
|
WSASERVICE_NOT_FOUND: number;
|
||||||
const WSAEINVALIDPROVIDER: number;
|
WSATYPE_NOT_FOUND: number;
|
||||||
const WSAEPROVIDERFAILEDINIT: number;
|
WSA_E_NO_MORE: number;
|
||||||
const WSASYSCALLFAILURE: number;
|
WSA_E_CANCELLED: number;
|
||||||
const WSASERVICE_NOT_FOUND: number;
|
WSAEREFUSED: number;
|
||||||
const WSATYPE_NOT_FOUND: number;
|
};
|
||||||
const WSA_E_NO_MORE: number;
|
priority: {
|
||||||
const WSA_E_CANCELLED: number;
|
PRIORITY_LOW: number;
|
||||||
const WSAEREFUSED: number;
|
PRIORITY_BELOW_NORMAL: number;
|
||||||
|
PRIORITY_NORMAL: number;
|
||||||
|
PRIORITY_ABOVE_NORMAL: number;
|
||||||
|
PRIORITY_HIGH: number;
|
||||||
|
PRIORITY_HIGHEST: number;
|
||||||
}
|
}
|
||||||
namespace priority {
|
};
|
||||||
const PRIORITY_LOW: number;
|
|
||||||
const PRIORITY_BELOW_NORMAL: number;
|
|
||||||
const PRIORITY_NORMAL: number;
|
|
||||||
const PRIORITY_ABOVE_NORMAL: number;
|
|
||||||
const PRIORITY_HIGH: number;
|
|
||||||
const PRIORITY_HIGHEST: number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const devNull: string;
|
|
||||||
const EOL: string;
|
|
||||||
/**
|
|
||||||
* Returns the operating system CPU architecture for which the Node.js binary was
|
|
||||||
* compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, `'x32'`, and `'x64'`.
|
|
||||||
*
|
|
||||||
* The return value is equivalent to `process.arch`.
|
|
||||||
* @since v0.5.0
|
|
||||||
*/
|
|
||||||
function arch(): string;
|
function arch(): string;
|
||||||
/**
|
|
||||||
* Returns a string identifying the kernel version.
|
|
||||||
*
|
|
||||||
* On POSIX systems, the operating system release is determined by calling[`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not
|
|
||||||
* available, `GetVersionExW()` will be used. See[https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
|
|
||||||
* @since v13.11.0, v12.17.0
|
|
||||||
*/
|
|
||||||
function version(): string;
|
|
||||||
/**
|
|
||||||
* Returns a string identifying the operating system platform. The value is set
|
|
||||||
* at compile time. Possible values are `'aix'`, `'darwin'`, `'freebsd'`,`'linux'`, `'openbsd'`, `'sunos'`, and `'win32'`.
|
|
||||||
*
|
|
||||||
* The return value is equivalent to `process.platform`.
|
|
||||||
*
|
|
||||||
* The value `'android'` may also be returned if Node.js is built on the Android
|
|
||||||
* operating system. [Android support is experimental](https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os).
|
|
||||||
* @since v0.5.0
|
|
||||||
*/
|
|
||||||
function platform(): NodeJS.Platform;
|
function platform(): NodeJS.Platform;
|
||||||
/**
|
|
||||||
* Returns the operating system's default directory for temporary files as a
|
|
||||||
* string.
|
|
||||||
* @since v0.9.9
|
|
||||||
*/
|
|
||||||
function tmpdir(): string;
|
function tmpdir(): string;
|
||||||
|
const EOL: string;
|
||||||
|
function endianness(): "BE" | "LE";
|
||||||
/**
|
/**
|
||||||
* Returns a string identifying the endianness of the CPU for which the Node.js
|
* Gets the priority of a process.
|
||||||
* binary was compiled.
|
* Defaults to current process.
|
||||||
*
|
|
||||||
* Possible values are `'BE'` for big endian and `'LE'` for little endian.
|
|
||||||
* @since v0.9.4
|
|
||||||
*/
|
|
||||||
function endianness(): 'BE' | 'LE';
|
|
||||||
/**
|
|
||||||
* Returns the scheduling priority for the process specified by `pid`. If `pid` is
|
|
||||||
* not provided or is `0`, the priority of the current process is returned.
|
|
||||||
* @since v10.10.0
|
|
||||||
* @param pid The process ID to retrieve scheduling priority for.
|
|
||||||
*/
|
*/
|
||||||
function getPriority(pid?: number): number;
|
function getPriority(pid?: number): number;
|
||||||
/**
|
/**
|
||||||
* Attempts to set the scheduling priority for the process specified by `pid`. If`pid` is not provided or is `0`, the process ID of the current process is used.
|
* Sets the priority of the current process.
|
||||||
*
|
* @param priority Must be in range of -20 to 19
|
||||||
* The `priority` input must be an integer between `-20` (high priority) and `19`(low priority). Due to differences between Unix priority levels and Windows
|
|
||||||
* priority classes, `priority` is mapped to one of six priority constants in`os.constants.priority`. When retrieving a process priority level, this range
|
|
||||||
* mapping may cause the return value to be slightly different on Windows. To avoid
|
|
||||||
* confusion, set `priority` to one of the priority constants.
|
|
||||||
*
|
|
||||||
* On Windows, setting priority to `PRIORITY_HIGHEST` requires elevated user
|
|
||||||
* privileges. Otherwise the set priority will be silently reduced to`PRIORITY_HIGH`.
|
|
||||||
* @since v10.10.0
|
|
||||||
* @param pid The process ID to set scheduling priority for.
|
|
||||||
* @param priority The scheduling priority to assign to the process.
|
|
||||||
*/
|
*/
|
||||||
function setPriority(priority: number): void;
|
function setPriority(priority: number): void;
|
||||||
|
/**
|
||||||
|
* Sets the priority of the process specified process.
|
||||||
|
* @param priority Must be in range of -20 to 19
|
||||||
|
*/
|
||||||
function setPriority(pid: number, priority: number): void;
|
function setPriority(pid: number, priority: number): void;
|
||||||
}
|
}
|
||||||
declare module 'node:os' {
|
|
||||||
export * from 'os';
|
|
||||||
}
|
|
||||||
|
|||||||
+33
-34
@@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@types/node",
|
"name": "@types/node",
|
||||||
"version": "16.4.6",
|
"version": "12.12.70",
|
||||||
"description": "TypeScript definitions for Node.js",
|
"description": "TypeScript definitions for Node.js",
|
||||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
@@ -20,6 +19,11 @@
|
|||||||
"url": "https://github.com/jkomyno",
|
"url": "https://github.com/jkomyno",
|
||||||
"githubUsername": "jkomyno"
|
"githubUsername": "jkomyno"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Alexander T.",
|
||||||
|
"url": "https://github.com/a-tarasyuk",
|
||||||
|
"githubUsername": "a-tarasyuk"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Alvis HT Tang",
|
"name": "Alvis HT Tang",
|
||||||
"url": "https://github.com/alvis",
|
"url": "https://github.com/alvis",
|
||||||
@@ -35,6 +39,11 @@
|
|||||||
"url": "https://github.com/btoueg",
|
"url": "https://github.com/btoueg",
|
||||||
"githubUsername": "btoueg"
|
"githubUsername": "btoueg"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Bruno Scheufler",
|
||||||
|
"url": "https://github.com/brunoscheufler",
|
||||||
|
"githubUsername": "brunoscheufler"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Chigozirim C.",
|
"name": "Chigozirim C.",
|
||||||
"url": "https://github.com/smac89",
|
"url": "https://github.com/smac89",
|
||||||
@@ -55,6 +64,11 @@
|
|||||||
"url": "https://github.com/eyqs",
|
"url": "https://github.com/eyqs",
|
||||||
"githubUsername": "eyqs"
|
"githubUsername": "eyqs"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Flarna",
|
||||||
|
"url": "https://github.com/Flarna",
|
||||||
|
"githubUsername": "Flarna"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Hannes Magnusson",
|
"name": "Hannes Magnusson",
|
||||||
"url": "https://github.com/Hannes-Magnusson-CK",
|
"url": "https://github.com/Hannes-Magnusson-CK",
|
||||||
@@ -135,6 +149,11 @@
|
|||||||
"url": "https://github.com/wwwy3y3",
|
"url": "https://github.com/wwwy3y3",
|
||||||
"githubUsername": "wwwy3y3"
|
"githubUsername": "wwwy3y3"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Zane Hannan AU",
|
||||||
|
"url": "https://github.com/ZaneHannanAU",
|
||||||
|
"githubUsername": "ZaneHannanAU"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Samuel Ainsworth",
|
"name": "Samuel Ainsworth",
|
||||||
"url": "https://github.com/samuela",
|
"url": "https://github.com/samuela",
|
||||||
@@ -145,6 +164,11 @@
|
|||||||
"url": "https://github.com/kuehlein",
|
"url": "https://github.com/kuehlein",
|
||||||
"githubUsername": "kuehlein"
|
"githubUsername": "kuehlein"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Jordi Oliveras Rovira",
|
||||||
|
"url": "https://github.com/j-oliveras",
|
||||||
|
"githubUsername": "j-oliveras"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Thanik Bhongbhibhat",
|
"name": "Thanik Bhongbhibhat",
|
||||||
"url": "https://github.com/bhongy",
|
"url": "https://github.com/bhongy",
|
||||||
@@ -180,45 +204,20 @@
|
|||||||
"url": "https://github.com/ExE-Boss",
|
"url": "https://github.com/ExE-Boss",
|
||||||
"githubUsername": "ExE-Boss"
|
"githubUsername": "ExE-Boss"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "Surasak Chaisurin",
|
|
||||||
"url": "https://github.com/Ryan-Willpower",
|
|
||||||
"githubUsername": "Ryan-Willpower"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Piotr Błażejewicz",
|
|
||||||
"url": "https://github.com/peterblazejewicz",
|
|
||||||
"githubUsername": "peterblazejewicz"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Anna Henningsen",
|
|
||||||
"url": "https://github.com/addaleax",
|
|
||||||
"githubUsername": "addaleax"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "Jason Kwok",
|
"name": "Jason Kwok",
|
||||||
"url": "https://github.com/JasonHK",
|
"url": "https://github.com/JasonHK",
|
||||||
"githubUsername": "JasonHK"
|
"githubUsername": "JasonHK"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Victor Perin",
|
|
||||||
"url": "https://github.com/victorperin",
|
|
||||||
"githubUsername": "victorperin"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Yongsheng Zhang",
|
|
||||||
"url": "https://github.com/ZYSzys",
|
|
||||||
"githubUsername": "ZYSzys"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "NodeJS Contributors",
|
|
||||||
"url": "https://github.com/NodeJS",
|
|
||||||
"githubUsername": "NodeJS"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"main": "",
|
"main": "",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"typesVersions": {
|
"typesVersions": {
|
||||||
|
"<=3.3": {
|
||||||
|
"*": [
|
||||||
|
"ts3.3/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
"<=3.6": {
|
"<=3.6": {
|
||||||
"*": [
|
"*": [
|
||||||
"ts3.6/*"
|
"ts3.6/*"
|
||||||
@@ -232,6 +231,6 @@
|
|||||||
},
|
},
|
||||||
"scripts": {},
|
"scripts": {},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"typesPublisherContentHash": "409fea0ec0757dc100114c6d35fe3b616cdf1e1095e08f5e2f83bd9336035435",
|
"typesPublisherContentHash": "86d21f1f394b808863aabd5045402fca03a666e6e4c13c81302c4c82c28462bd",
|
||||||
"typeScriptVersion": "3.6"
|
"typeScriptVersion": "3.2"
|
||||||
}
|
}
|
||||||
+48
-61
@@ -1,22 +1,4 @@
|
|||||||
declare module 'path/posix' {
|
declare module "path" {
|
||||||
import path = require('path');
|
|
||||||
export = path;
|
|
||||||
}
|
|
||||||
declare module 'path/win32' {
|
|
||||||
import path = require('path');
|
|
||||||
export = path;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* The `path` module provides utilities for working with file and directory paths.
|
|
||||||
* It can be accessed using:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const path = require('path');
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/path.js)
|
|
||||||
*/
|
|
||||||
declare module 'path' {
|
|
||||||
namespace path {
|
|
||||||
/**
|
/**
|
||||||
* A parsed path object generated by path.parse() or consumed by path.format().
|
* A parsed path object generated by path.parse() or consumed by path.format().
|
||||||
*/
|
*/
|
||||||
@@ -46,39 +28,39 @@ declare module 'path' {
|
|||||||
/**
|
/**
|
||||||
* The root of the path such as '/' or 'c:\'
|
* The root of the path such as '/' or 'c:\'
|
||||||
*/
|
*/
|
||||||
root?: string | undefined;
|
root?: string;
|
||||||
/**
|
/**
|
||||||
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
|
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
|
||||||
*/
|
*/
|
||||||
dir?: string | undefined;
|
dir?: string;
|
||||||
/**
|
/**
|
||||||
* The file name including extension (if any) such as 'index.html'
|
* The file name including extension (if any) such as 'index.html'
|
||||||
*/
|
*/
|
||||||
base?: string | undefined;
|
base?: string;
|
||||||
/**
|
/**
|
||||||
* The file extension (if any) such as '.html'
|
* The file extension (if any) such as '.html'
|
||||||
*/
|
*/
|
||||||
ext?: string | undefined;
|
ext?: string;
|
||||||
/**
|
/**
|
||||||
* The file name without extension (if any) such as 'index'
|
* The file name without extension (if any) such as 'index'
|
||||||
*/
|
*/
|
||||||
name?: string | undefined;
|
name?: string;
|
||||||
}
|
}
|
||||||
interface PlatformPath {
|
|
||||||
/**
|
/**
|
||||||
* Normalize a string path, reducing '..' and '.' parts.
|
* Normalize a string path, reducing '..' and '.' parts.
|
||||||
* When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
|
* When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
|
||||||
*
|
*
|
||||||
* @param p string path to normalize.
|
* @param p string path to normalize.
|
||||||
*/
|
*/
|
||||||
normalize(p: string): string;
|
function normalize(p: string): string;
|
||||||
/**
|
/**
|
||||||
* Join all arguments together and normalize the resulting path.
|
* Join all arguments together and normalize the resulting path.
|
||||||
* Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
|
* Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
|
||||||
*
|
*
|
||||||
* @param paths paths to join.
|
* @param paths paths to join.
|
||||||
*/
|
*/
|
||||||
join(...paths: string[]): string;
|
function join(...paths: string[]): string;
|
||||||
/**
|
/**
|
||||||
* The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
|
* The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
|
||||||
*
|
*
|
||||||
@@ -91,24 +73,24 @@ declare module 'path' {
|
|||||||
*
|
*
|
||||||
* @param pathSegments string paths to join. Non-string arguments are ignored.
|
* @param pathSegments string paths to join. Non-string arguments are ignored.
|
||||||
*/
|
*/
|
||||||
resolve(...pathSegments: string[]): string;
|
function resolve(...pathSegments: string[]): string;
|
||||||
/**
|
/**
|
||||||
* Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
|
* Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
|
||||||
*
|
*
|
||||||
* @param path path to test.
|
* @param path path to test.
|
||||||
*/
|
*/
|
||||||
isAbsolute(p: string): boolean;
|
function isAbsolute(path: string): boolean;
|
||||||
/**
|
/**
|
||||||
* Solve the relative path from {from} to {to}.
|
* Solve the relative path from {from} to {to}.
|
||||||
* At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
|
* At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
|
||||||
*/
|
*/
|
||||||
relative(from: string, to: string): string;
|
function relative(from: string, to: string): string;
|
||||||
/**
|
/**
|
||||||
* Return the directory name of a path. Similar to the Unix dirname command.
|
* Return the directory name of a path. Similar to the Unix dirname command.
|
||||||
*
|
*
|
||||||
* @param p the path to evaluate.
|
* @param p the path to evaluate.
|
||||||
*/
|
*/
|
||||||
dirname(p: string): string;
|
function dirname(p: string): string;
|
||||||
/**
|
/**
|
||||||
* Return the last portion of a path. Similar to the Unix basename command.
|
* Return the last portion of a path. Similar to the Unix basename command.
|
||||||
* Often used to extract the file name from a fully qualified path.
|
* Often used to extract the file name from a fully qualified path.
|
||||||
@@ -116,57 +98,62 @@ declare module 'path' {
|
|||||||
* @param p the path to evaluate.
|
* @param p the path to evaluate.
|
||||||
* @param ext optionally, an extension to remove from the result.
|
* @param ext optionally, an extension to remove from the result.
|
||||||
*/
|
*/
|
||||||
basename(p: string, ext?: string): string;
|
function basename(p: string, ext?: string): string;
|
||||||
/**
|
/**
|
||||||
* Return the extension of the path, from the last '.' to end of string in the last portion of the path.
|
* Return the extension of the path, from the last '.' to end of string in the last portion of the path.
|
||||||
* If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
|
* If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
|
||||||
*
|
*
|
||||||
* @param p the path to evaluate.
|
* @param p the path to evaluate.
|
||||||
*/
|
*/
|
||||||
extname(p: string): string;
|
function extname(p: string): string;
|
||||||
/**
|
/**
|
||||||
* The platform-specific file separator. '\\' or '/'.
|
* The platform-specific file separator. '\\' or '/'.
|
||||||
*/
|
*/
|
||||||
readonly sep: string;
|
const sep: '\\' | '/';
|
||||||
/**
|
/**
|
||||||
* The platform-specific file delimiter. ';' or ':'.
|
* The platform-specific file delimiter. ';' or ':'.
|
||||||
*/
|
*/
|
||||||
readonly delimiter: string;
|
const delimiter: ';' | ':';
|
||||||
/**
|
/**
|
||||||
* Returns an object from a path string - the opposite of format().
|
* Returns an object from a path string - the opposite of format().
|
||||||
*
|
*
|
||||||
* @param pathString path to evaluate.
|
* @param pathString path to evaluate.
|
||||||
*/
|
*/
|
||||||
parse(p: string): ParsedPath;
|
function parse(pathString: string): ParsedPath;
|
||||||
/**
|
/**
|
||||||
* Returns a path string from an object - the opposite of parse().
|
* Returns a path string from an object - the opposite of parse().
|
||||||
*
|
*
|
||||||
* @param pathString path to evaluate.
|
* @param pathString path to evaluate.
|
||||||
*/
|
*/
|
||||||
format(pP: FormatInputPathObject): string;
|
function format(pathObject: FormatInputPathObject): string;
|
||||||
/**
|
|
||||||
* On Windows systems only, returns an equivalent namespace-prefixed path for the given path.
|
namespace posix {
|
||||||
* If path is not a string, path will be returned without modifications.
|
function normalize(p: string): string;
|
||||||
* This method is meaningful only on Windows system.
|
function join(...paths: string[]): string;
|
||||||
* On POSIX systems, the method is non-operational and always returns path without modifications.
|
function resolve(...pathSegments: string[]): string;
|
||||||
*/
|
function isAbsolute(p: string): boolean;
|
||||||
toNamespacedPath(path: string): string;
|
function relative(from: string, to: string): string;
|
||||||
/**
|
function dirname(p: string): string;
|
||||||
* Posix specific pathing.
|
function basename(p: string, ext?: string): string;
|
||||||
* Same as parent object on posix.
|
function extname(p: string): string;
|
||||||
*/
|
const sep: string;
|
||||||
readonly posix: PlatformPath;
|
const delimiter: string;
|
||||||
/**
|
function parse(p: string): ParsedPath;
|
||||||
* Windows specific pathing.
|
function format(pP: FormatInputPathObject): string;
|
||||||
* Same as parent object on windows
|
}
|
||||||
*/
|
|
||||||
readonly win32: PlatformPath;
|
namespace win32 {
|
||||||
|
function normalize(p: string): string;
|
||||||
|
function join(...paths: string[]): string;
|
||||||
|
function resolve(...pathSegments: string[]): string;
|
||||||
|
function isAbsolute(p: string): boolean;
|
||||||
|
function relative(from: string, to: string): string;
|
||||||
|
function dirname(p: string): string;
|
||||||
|
function basename(p: string, ext?: string): string;
|
||||||
|
function extname(p: string): string;
|
||||||
|
const sep: string;
|
||||||
|
const delimiter: string;
|
||||||
|
function parse(p: string): ParsedPath;
|
||||||
|
function format(pP: FormatInputPathObject): string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const path: path.PlatformPath;
|
|
||||||
export = path;
|
|
||||||
}
|
|
||||||
declare module 'node:path' {
|
|
||||||
import path = require('path');
|
|
||||||
export = path;
|
|
||||||
}
|
|
||||||
|
|||||||
+120
-437
@@ -1,189 +1,74 @@
|
|||||||
|
declare module "perf_hooks" {
|
||||||
|
import { AsyncResource } from "async_hooks";
|
||||||
|
|
||||||
|
interface PerformanceEntry {
|
||||||
/**
|
/**
|
||||||
* This module provides an implementation of a subset of the W3C[Web Performance APIs](https://w3c.github.io/perf-timing-primer/) as well as additional APIs for
|
* The total number of milliseconds elapsed for this entry.
|
||||||
* Node.js-specific performance measurements.
|
* This value will not be meaningful for all Performance Entry types.
|
||||||
*
|
|
||||||
* Node.js supports the following [Web Performance APIs](https://w3c.github.io/perf-timing-primer/):
|
|
||||||
*
|
|
||||||
* * [High Resolution Time](https://www.w3.org/TR/hr-time-2)
|
|
||||||
* * [Performance Timeline](https://w3c.github.io/performance-timeline/)
|
|
||||||
* * [User Timing](https://www.w3.org/TR/user-timing/)
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { PerformanceObserver, performance } = require('perf_hooks');
|
|
||||||
*
|
|
||||||
* const obs = new PerformanceObserver((items) => {
|
|
||||||
* console.log(items.getEntries()[0].duration);
|
|
||||||
* performance.clearMarks();
|
|
||||||
* });
|
|
||||||
* obs.observe({ type: 'measure' });
|
|
||||||
* performance.measure('Start to Now');
|
|
||||||
*
|
|
||||||
* performance.mark('A');
|
|
||||||
* doSomeLongRunningProcess(() => {
|
|
||||||
* performance.measure('A to Now', 'A');
|
|
||||||
*
|
|
||||||
* performance.mark('B');
|
|
||||||
* performance.measure('A to B', 'A', 'B');
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/perf_hooks.js)
|
|
||||||
*/
|
|
||||||
declare module 'perf_hooks' {
|
|
||||||
import { AsyncResource } from 'node:async_hooks';
|
|
||||||
type EntryType = 'node' | 'mark' | 'measure' | 'gc' | 'function' | 'http2' | 'http';
|
|
||||||
interface NodeGCPerformanceDetail {
|
|
||||||
/**
|
|
||||||
* When `performanceEntry.entryType` is equal to 'gc', `the performance.kind` property identifies
|
|
||||||
* the type of garbage collection operation that occurred.
|
|
||||||
* See perf_hooks.constants for valid values.
|
|
||||||
*/
|
|
||||||
readonly kind?: number | undefined;
|
|
||||||
/**
|
|
||||||
* When `performanceEntry.entryType` is equal to 'gc', the `performance.flags`
|
|
||||||
* property contains additional information about garbage collection operation.
|
|
||||||
* See perf_hooks.constants for valid values.
|
|
||||||
*/
|
|
||||||
readonly flags?: number | undefined;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
|
||||||
class PerformanceEntry {
|
|
||||||
protected constructor();
|
|
||||||
/**
|
|
||||||
* The total number of milliseconds elapsed for this entry. This value will not
|
|
||||||
* be meaningful for all Performance Entry types.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly duration: number;
|
readonly duration: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the performance entry.
|
* The name of the performance entry.
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The high resolution millisecond timestamp marking the starting time of the
|
* The high resolution millisecond timestamp marking the starting time of the Performance Entry.
|
||||||
* Performance Entry.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly startTime: number;
|
readonly startTime: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the performance entry. It may be one of:
|
* The type of the performance entry.
|
||||||
*
|
* Currently it may be one of: 'node', 'mark', 'measure', 'gc', or 'function'.
|
||||||
* * `'node'` (Node.js only)
|
|
||||||
* * `'mark'` (available on the Web)
|
|
||||||
* * `'measure'` (available on the Web)
|
|
||||||
* * `'gc'` (Node.js only)
|
|
||||||
* * `'function'` (Node.js only)
|
|
||||||
* * `'http2'` (Node.js only)
|
|
||||||
* * `'http'` (Node.js only)
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly entryType: EntryType;
|
readonly entryType: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional detail specific to the `entryType`.
|
* When performanceEntry.entryType is equal to 'gc', the performance.kind property identifies
|
||||||
* @since v16.0.0
|
* the type of garbage collection operation that occurred.
|
||||||
|
* The value may be one of perf_hooks.constants.
|
||||||
*/
|
*/
|
||||||
readonly details?: NodeGCPerformanceDetail | unknown | undefined; // TODO: Narrow this based on entry type.
|
readonly kind?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface PerformanceNodeTiming extends PerformanceEntry {
|
||||||
/**
|
/**
|
||||||
* _This property is an extension by Node.js. It is not available in Web browsers._
|
* The high resolution millisecond timestamp at which the Node.js process completed bootstrap.
|
||||||
*
|
* If bootstrapping has not yet finished, the property has the value of -1.
|
||||||
* Provides timing details for Node.js itself. The constructor of this class
|
|
||||||
* is not exposed to users.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
|
||||||
class PerformanceNodeTiming extends PerformanceEntry {
|
|
||||||
/**
|
|
||||||
* The high resolution millisecond timestamp at which the Node.js process
|
|
||||||
* completed bootstrapping. If bootstrapping has not yet finished, the property
|
|
||||||
* has the value of -1.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly bootstrapComplete: number;
|
readonly bootstrapComplete: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The high resolution millisecond timestamp at which the Node.js environment was
|
* The high resolution millisecond timestamp at which the Node.js process completed bootstrapping.
|
||||||
* initialized.
|
* If bootstrapping has not yet finished, the property has the value of -1.
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly environment: number;
|
readonly environment: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The high resolution millisecond timestamp of the amount of time the event loop
|
* The high resolution millisecond timestamp at which the Node.js event loop exited.
|
||||||
* has been idle within the event loop's event provider (e.g. `epoll_wait`). This
|
* If the event loop has not yet exited, the property has the value of -1.
|
||||||
* does not take CPU usage into consideration. If the event loop has not yet
|
* It can only have a value of not -1 in a handler of the 'exit' event.
|
||||||
* started (e.g., in the first tick of the main script), the property has the
|
|
||||||
* value of 0.
|
|
||||||
* @since v14.10.0, v12.19.0
|
|
||||||
*/
|
|
||||||
readonly idleTime: number;
|
|
||||||
/**
|
|
||||||
* The high resolution millisecond timestamp at which the Node.js event loop
|
|
||||||
* exited. If the event loop has not yet exited, the property has the value of -1\.
|
|
||||||
* It can only have a value of not -1 in a handler of the `'exit'` event.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly loopExit: number;
|
readonly loopExit: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The high resolution millisecond timestamp at which the Node.js event loop
|
* The high resolution millisecond timestamp at which the Node.js event loop started.
|
||||||
* started. If the event loop has not yet started (e.g., in the first tick of the
|
* If the event loop has not yet started (e.g., in the first tick of the main script), the property has the value of -1.
|
||||||
* main script), the property has the value of -1.
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
readonly loopStart: number;
|
readonly loopStart: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The high resolution millisecond timestamp at which the V8 platform was
|
* The high resolution millisecond timestamp at which the Node.js process was initialized.
|
||||||
* initialized.
|
*/
|
||||||
* @since v8.5.0
|
readonly nodeStart: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The high resolution millisecond timestamp at which the V8 platform was initialized.
|
||||||
*/
|
*/
|
||||||
readonly v8Start: number;
|
readonly v8Start: number;
|
||||||
}
|
}
|
||||||
interface EventLoopUtilization {
|
|
||||||
idle: number;
|
|
||||||
active: number;
|
|
||||||
utilization: number;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param util1 The result of a previous call to eventLoopUtilization()
|
|
||||||
* @param util2 The result of a previous call to eventLoopUtilization() prior to util1
|
|
||||||
*/
|
|
||||||
type EventLoopUtilityFunction = (util1?: EventLoopUtilization, util2?: EventLoopUtilization) => EventLoopUtilization;
|
|
||||||
interface MarkOptions {
|
|
||||||
/**
|
|
||||||
* Additional optional detail to include with the mark.
|
|
||||||
*/
|
|
||||||
detail?: unknown | undefined;
|
|
||||||
/**
|
|
||||||
* An optional timestamp to be used as the mark time.
|
|
||||||
* @default `performance.now()`.
|
|
||||||
*/
|
|
||||||
startTime?: number | undefined;
|
|
||||||
}
|
|
||||||
interface MeasureOptions {
|
|
||||||
/**
|
|
||||||
* Additional optional detail to include with the mark.
|
|
||||||
*/
|
|
||||||
detail?: unknown | undefined;
|
|
||||||
/**
|
|
||||||
* Duration between start and end times.
|
|
||||||
*/
|
|
||||||
duration?: number | undefined;
|
|
||||||
/**
|
|
||||||
* Timestamp to be used as the end time, or a string identifying a previously recorded mark.
|
|
||||||
*/
|
|
||||||
end?: number | string | undefined;
|
|
||||||
/**
|
|
||||||
* Timestamp to be used as the start time, or a string identifying a previously recorded mark.
|
|
||||||
*/
|
|
||||||
start?: number | string | undefined;
|
|
||||||
}
|
|
||||||
interface TimerifyOptions {
|
|
||||||
/**
|
|
||||||
* A histogram object created using
|
|
||||||
* `perf_hooks.createHistogram()` that will record runtime durations in
|
|
||||||
* nanoseconds.
|
|
||||||
*/
|
|
||||||
histogram?: RecordableHistogram | undefined;
|
|
||||||
}
|
|
||||||
interface Performance {
|
interface Performance {
|
||||||
/**
|
/**
|
||||||
* If name is not provided, removes all PerformanceMark objects from the Performance Timeline.
|
* If name is not provided, removes all PerformanceMark objects from the Performance Timeline.
|
||||||
@@ -191,6 +76,7 @@ declare module 'perf_hooks' {
|
|||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
clearMarks(name?: string): void;
|
clearMarks(name?: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new PerformanceMark entry in the Performance Timeline.
|
* Creates a new PerformanceMark entry in the Performance Timeline.
|
||||||
* A PerformanceMark is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'mark',
|
* A PerformanceMark is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'mark',
|
||||||
@@ -198,7 +84,8 @@ declare module 'perf_hooks' {
|
|||||||
* Performance marks are used to mark specific significant moments in the Performance Timeline.
|
* Performance marks are used to mark specific significant moments in the Performance Timeline.
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
mark(name?: string, options?: MarkOptions): void;
|
mark(name?: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new PerformanceMeasure entry in the Performance Timeline.
|
* Creates a new PerformanceMeasure entry in the Performance Timeline.
|
||||||
* A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
|
* A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
|
||||||
@@ -214,342 +101,138 @@ declare module 'perf_hooks' {
|
|||||||
* @param startMark
|
* @param startMark
|
||||||
* @param endMark
|
* @param endMark
|
||||||
*/
|
*/
|
||||||
measure(name: string, startMark?: string, endMark?: string): void;
|
measure(name: string, startMark: string, endMark: string): void;
|
||||||
measure(name: string, options: MeasureOptions): void;
|
|
||||||
/**
|
/**
|
||||||
* An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones.
|
* An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones.
|
||||||
*/
|
*/
|
||||||
readonly nodeTiming: PerformanceNodeTiming;
|
readonly nodeTiming: PerformanceNodeTiming;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the current high resolution millisecond timestamp
|
* @return the current high resolution millisecond timestamp
|
||||||
*/
|
*/
|
||||||
now(): number;
|
now(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The timeOrigin specifies the high resolution millisecond timestamp from which all performance metric durations are measured.
|
* The timeOrigin specifies the high resolution millisecond timestamp from which all performance metric durations are measured.
|
||||||
*/
|
*/
|
||||||
readonly timeOrigin: number;
|
readonly timeOrigin: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps a function within a new function that measures the running time of the wrapped function.
|
* Wraps a function within a new function that measures the running time of the wrapped function.
|
||||||
* A PerformanceObserver must be subscribed to the 'function' event type in order for the timing details to be accessed.
|
* A PerformanceObserver must be subscribed to the 'function' event type in order for the timing details to be accessed.
|
||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
timerify<T extends (...params: any[]) => any>(fn: T, options?: TimerifyOptions): T;
|
timerify<T extends (...optionalParams: any[]) => any>(fn: T): T;
|
||||||
/**
|
|
||||||
* eventLoopUtilization is similar to CPU utilization except that it is calculated using high precision wall-clock time.
|
|
||||||
* It represents the percentage of time the event loop has spent outside the event loop's event provider (e.g. epoll_wait).
|
|
||||||
* No other CPU idle time is taken into consideration.
|
|
||||||
*/
|
|
||||||
eventLoopUtilization: EventLoopUtilityFunction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PerformanceObserverEntryList {
|
interface PerformanceObserverEntryList {
|
||||||
/**
|
/**
|
||||||
* Returns a list of `PerformanceEntry` objects in chronological order
|
* @return a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime.
|
||||||
* with respect to `performanceEntry.startTime`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const {
|
|
||||||
* performance,
|
|
||||||
* PerformanceObserver
|
|
||||||
* } = require('perf_hooks');
|
|
||||||
*
|
|
||||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
|
||||||
* console.log(perfObserverList.getEntries());
|
|
||||||
*
|
|
||||||
* * [
|
|
||||||
* * PerformanceEntry {
|
|
||||||
* * name: 'test',
|
|
||||||
* * entryType: 'mark',
|
|
||||||
* * startTime: 81.465639,
|
|
||||||
* * duration: 0
|
|
||||||
* * },
|
|
||||||
* * PerformanceEntry {
|
|
||||||
* * name: 'meow',
|
|
||||||
* * entryType: 'mark',
|
|
||||||
* * startTime: 81.860064,
|
|
||||||
* * duration: 0
|
|
||||||
* * }
|
|
||||||
* * ]
|
|
||||||
*
|
|
||||||
* observer.disconnect();
|
|
||||||
* });
|
|
||||||
* obs.observe({ type: 'mark' });
|
|
||||||
*
|
|
||||||
* performance.mark('test');
|
|
||||||
* performance.mark('meow');
|
|
||||||
* ```
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
getEntries(): PerformanceEntry[];
|
getEntries(): PerformanceEntry[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of `PerformanceEntry` objects in chronological order
|
* @return a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime
|
||||||
* with respect to `performanceEntry.startTime` whose `performanceEntry.name` is
|
* whose performanceEntry.name is equal to name, and optionally, whose performanceEntry.entryType is equal to type.
|
||||||
* equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to`type`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const {
|
|
||||||
* performance,
|
|
||||||
* PerformanceObserver
|
|
||||||
* } = require('perf_hooks');
|
|
||||||
*
|
|
||||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
|
||||||
* console.log(perfObserverList.getEntriesByName('meow'));
|
|
||||||
*
|
|
||||||
* * [
|
|
||||||
* * PerformanceEntry {
|
|
||||||
* * name: 'meow',
|
|
||||||
* * entryType: 'mark',
|
|
||||||
* * startTime: 98.545991,
|
|
||||||
* * duration: 0
|
|
||||||
* * }
|
|
||||||
* * ]
|
|
||||||
*
|
|
||||||
* console.log(perfObserverList.getEntriesByName('nope')); // []
|
|
||||||
*
|
|
||||||
* console.log(perfObserverList.getEntriesByName('test', 'mark'));
|
|
||||||
*
|
|
||||||
* * [
|
|
||||||
* * PerformanceEntry {
|
|
||||||
* * name: 'test',
|
|
||||||
* * entryType: 'mark',
|
|
||||||
* * startTime: 63.518931,
|
|
||||||
* * duration: 0
|
|
||||||
* * }
|
|
||||||
* * ]
|
|
||||||
*
|
|
||||||
* console.log(perfObserverList.getEntriesByName('test', 'measure')); // []
|
|
||||||
* observer.disconnect();
|
|
||||||
* });
|
|
||||||
* obs.observe({ entryTypes: ['mark', 'measure'] });
|
|
||||||
*
|
|
||||||
* performance.mark('test');
|
|
||||||
* performance.mark('meow');
|
|
||||||
* ```
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
getEntriesByName(name: string, type?: EntryType): PerformanceEntry[];
|
getEntriesByName(name: string, type?: string): PerformanceEntry[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of `PerformanceEntry` objects in chronological order
|
* @return Returns a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime
|
||||||
* with respect to `performanceEntry.startTime` whose `performanceEntry.entryType`is equal to `type`.
|
* whose performanceEntry.entryType is equal to type.
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const {
|
|
||||||
* performance,
|
|
||||||
* PerformanceObserver
|
|
||||||
* } = require('perf_hooks');
|
|
||||||
*
|
|
||||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
|
||||||
* console.log(perfObserverList.getEntriesByType('mark'));
|
|
||||||
*
|
|
||||||
* * [
|
|
||||||
* * PerformanceEntry {
|
|
||||||
* * name: 'test',
|
|
||||||
* * entryType: 'mark',
|
|
||||||
* * startTime: 55.897834,
|
|
||||||
* * duration: 0
|
|
||||||
* * },
|
|
||||||
* * PerformanceEntry {
|
|
||||||
* * name: 'meow',
|
|
||||||
* * entryType: 'mark',
|
|
||||||
* * startTime: 56.350146,
|
|
||||||
* * duration: 0
|
|
||||||
* * }
|
|
||||||
* * ]
|
|
||||||
*
|
|
||||||
* observer.disconnect();
|
|
||||||
* });
|
|
||||||
* obs.observe({ type: 'mark' });
|
|
||||||
*
|
|
||||||
* performance.mark('test');
|
|
||||||
* performance.mark('meow');
|
|
||||||
* ```
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
getEntriesByType(type: EntryType): PerformanceEntry[];
|
getEntriesByType(type: string): PerformanceEntry[];
|
||||||
}
|
}
|
||||||
|
|
||||||
type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void;
|
type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void;
|
||||||
|
|
||||||
class PerformanceObserver extends AsyncResource {
|
class PerformanceObserver extends AsyncResource {
|
||||||
constructor(callback: PerformanceObserverCallback);
|
constructor(callback: PerformanceObserverCallback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects the `PerformanceObserver` instance from all notifications.
|
* Disconnects the PerformanceObserver instance from all notifications.
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
disconnect(): void;
|
disconnect(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribes the `<PerformanceObserver>` instance to notifications of new `<PerformanceEntry>` instances identified either by `options.entryTypes`or `options.type`:
|
* Subscribes the PerformanceObserver instance to notifications of new PerformanceEntry instances identified by options.entryTypes.
|
||||||
*
|
* When options.buffered is false, the callback will be invoked once for every PerformanceEntry instance.
|
||||||
* ```js
|
* Property buffered defaults to false.
|
||||||
* const {
|
* @param options
|
||||||
* performance,
|
|
||||||
* PerformanceObserver
|
|
||||||
* } = require('perf_hooks');
|
|
||||||
*
|
|
||||||
* const obs = new PerformanceObserver((list, observer) => {
|
|
||||||
* // Called three times synchronously. `list` contains one item.
|
|
||||||
* });
|
|
||||||
* obs.observe({ type: 'mark' });
|
|
||||||
*
|
|
||||||
* for (let n = 0; n < 3; n++)
|
|
||||||
* performance.mark(`test${n}`);
|
|
||||||
* ```
|
|
||||||
* @since v8.5.0
|
|
||||||
*/
|
*/
|
||||||
observe(
|
observe(options: { entryTypes: ReadonlyArray<string>, buffered?: boolean }): void;
|
||||||
options:
|
|
||||||
| {
|
|
||||||
entryTypes: ReadonlyArray<EntryType>;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: EntryType;
|
|
||||||
}
|
|
||||||
): void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace constants {
|
namespace constants {
|
||||||
const NODE_PERFORMANCE_GC_MAJOR: number;
|
const NODE_PERFORMANCE_GC_MAJOR: number;
|
||||||
const NODE_PERFORMANCE_GC_MINOR: number;
|
const NODE_PERFORMANCE_GC_MINOR: number;
|
||||||
const NODE_PERFORMANCE_GC_INCREMENTAL: number;
|
const NODE_PERFORMANCE_GC_INCREMENTAL: number;
|
||||||
const NODE_PERFORMANCE_GC_WEAKCB: number;
|
const NODE_PERFORMANCE_GC_WEAKCB: number;
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_NO: number;
|
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number;
|
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_FORCED: number;
|
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number;
|
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number;
|
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number;
|
|
||||||
const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const performance: Performance;
|
const performance: Performance;
|
||||||
|
|
||||||
interface EventLoopMonitorOptions {
|
interface EventLoopMonitorOptions {
|
||||||
/**
|
/**
|
||||||
* The sampling rate in milliseconds.
|
* The sampling rate in milliseconds.
|
||||||
* Must be greater than zero.
|
* Must be greater than zero.
|
||||||
* @default 10
|
* @default 10
|
||||||
*/
|
*/
|
||||||
resolution?: number | undefined;
|
resolution?: number;
|
||||||
}
|
}
|
||||||
interface Histogram {
|
|
||||||
|
interface EventLoopDelayMonitor {
|
||||||
/**
|
/**
|
||||||
* Returns a `Map` object detailing the accumulated percentile distribution.
|
* Enables the event loop delay sample timer. Returns `true` if the timer was started, `false` if it was already started.
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
readonly percentiles: Map<number, number>;
|
|
||||||
/**
|
|
||||||
* The number of times the event loop delay exceeded the maximum 1 hour event
|
|
||||||
* loop delay threshold.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
readonly exceeds: number;
|
|
||||||
/**
|
|
||||||
* The minimum recorded event loop delay.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
readonly min: number;
|
|
||||||
/**
|
|
||||||
* The maximum recorded event loop delay.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
readonly max: number;
|
|
||||||
/**
|
|
||||||
* The mean of the recorded event loop delays.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
readonly mean: number;
|
|
||||||
/**
|
|
||||||
* The standard deviation of the recorded event loop delays.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
readonly stddev: number;
|
|
||||||
/**
|
|
||||||
* Resets the collected histogram data.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
reset(): void;
|
|
||||||
/**
|
|
||||||
* Returns the value at the given percentile.
|
|
||||||
* @since v11.10.0
|
|
||||||
* @param percentile A percentile value in the range (0, 100].
|
|
||||||
*/
|
|
||||||
percentile(percentile: number): number;
|
|
||||||
}
|
|
||||||
interface IntervalHistogram extends Histogram {
|
|
||||||
/**
|
|
||||||
* Enables the update interval timer. Returns `true` if the timer was
|
|
||||||
* started, `false` if it was already started.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
*/
|
||||||
enable(): boolean;
|
enable(): boolean;
|
||||||
/**
|
/**
|
||||||
* Disables the update interval timer. Returns `true` if the timer was
|
* Disables the event loop delay sample timer. Returns `true` if the timer was stopped, `false` if it was already stopped.
|
||||||
* stopped, `false` if it was already stopped.
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
*/
|
||||||
disable(): boolean;
|
disable(): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the collected histogram data.
|
||||||
|
*/
|
||||||
|
reset(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value at the given percentile.
|
||||||
|
* @param percentile A percentile value between 1 and 100.
|
||||||
|
*/
|
||||||
|
percentile(percentile: number): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A `Map` object detailing the accumulated percentile distribution.
|
||||||
|
*/
|
||||||
|
readonly percentiles: Map<number, number>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of times the event loop delay exceeded the maximum 1 hour eventloop delay threshold.
|
||||||
|
*/
|
||||||
|
readonly exceeds: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum recorded event loop delay.
|
||||||
|
*/
|
||||||
|
readonly min: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum recorded event loop delay.
|
||||||
|
*/
|
||||||
|
readonly max: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mean of the recorded event loop delays.
|
||||||
|
*/
|
||||||
|
readonly mean: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The standard deviation of the recorded event loop delays.
|
||||||
|
*/
|
||||||
|
readonly stddev: number;
|
||||||
}
|
}
|
||||||
interface RecordableHistogram extends Histogram {
|
|
||||||
/**
|
function monitorEventLoopDelay(options?: EventLoopMonitorOptions): EventLoopDelayMonitor;
|
||||||
* @since v15.9.0
|
|
||||||
* @param val The amount to record in the histogram.
|
|
||||||
*/
|
|
||||||
record(val: number | bigint): void;
|
|
||||||
/**
|
|
||||||
* Calculates the amount of time (in nanoseconds) that has passed since the
|
|
||||||
* previous call to `recordDelta()` and records that amount in the histogram.
|
|
||||||
*
|
|
||||||
* ## Examples
|
|
||||||
* @since v15.9.0
|
|
||||||
*/
|
|
||||||
recordDelta(): void;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* _This property is an extension by Node.js. It is not available in Web browsers._
|
|
||||||
*
|
|
||||||
* Creates an `IntervalHistogram` object that samples and reports the event loop
|
|
||||||
* delay over time. The delays will be reported in nanoseconds.
|
|
||||||
*
|
|
||||||
* Using a timer to detect approximate event loop delay works because the
|
|
||||||
* execution of timers is tied specifically to the lifecycle of the libuv
|
|
||||||
* event loop. That is, a delay in the loop will cause a delay in the execution
|
|
||||||
* of the timer, and those delays are specifically what this API is intended to
|
|
||||||
* detect.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { monitorEventLoopDelay } = require('perf_hooks');
|
|
||||||
* const h = monitorEventLoopDelay({ resolution: 20 });
|
|
||||||
* h.enable();
|
|
||||||
* // Do something.
|
|
||||||
* h.disable();
|
|
||||||
* console.log(h.min);
|
|
||||||
* console.log(h.max);
|
|
||||||
* console.log(h.mean);
|
|
||||||
* console.log(h.stddev);
|
|
||||||
* console.log(h.percentiles);
|
|
||||||
* console.log(h.percentile(50));
|
|
||||||
* console.log(h.percentile(99));
|
|
||||||
* ```
|
|
||||||
* @since v11.10.0
|
|
||||||
*/
|
|
||||||
function monitorEventLoopDelay(options?: EventLoopMonitorOptions): IntervalHistogram;
|
|
||||||
interface CreateHistogramOptions {
|
|
||||||
/**
|
|
||||||
* The minimum recordable value. Must be an integer value greater than 0.
|
|
||||||
* @default 1
|
|
||||||
*/
|
|
||||||
min?: number | bigint | undefined;
|
|
||||||
/**
|
|
||||||
* The maximum recordable value. Must be an integer value greater than min.
|
|
||||||
* @default Number.MAX_SAFE_INTEGER
|
|
||||||
*/
|
|
||||||
max?: number | bigint | undefined;
|
|
||||||
/**
|
|
||||||
* The number of accuracy digits. Must be a number between 1 and 5.
|
|
||||||
* @default 3
|
|
||||||
*/
|
|
||||||
figures?: number | undefined;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns a `<RecordableHistogram>`.
|
|
||||||
* @since v15.9.0
|
|
||||||
*/
|
|
||||||
function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
|
|
||||||
}
|
|
||||||
declare module 'node:perf_hooks' {
|
|
||||||
export * from 'perf_hooks';
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1391
File diff suppressed because it is too large
Load Diff
+21
-71
@@ -1,81 +1,34 @@
|
|||||||
|
declare module "punycode" {
|
||||||
/**
|
/**
|
||||||
* **The version of the punycode module bundled in Node.js is being deprecated**.
|
* @deprecated since v7.0.0
|
||||||
* In a future major version of Node.js this module will be removed. Users
|
* The version of the punycode module bundled in Node.js is being deprecated.
|
||||||
* currently depending on the `punycode` module should switch to using the
|
* In a future major version of Node.js this module will be removed.
|
||||||
* userland-provided [Punycode.js](https://github.com/bestiejs/punycode.js) module instead. For punycode-based URL
|
* Users currently depending on the punycode module should switch to using
|
||||||
* encoding, see `url.domainToASCII` or, more generally, the `WHATWG URL API`.
|
* the userland-provided Punycode.js module instead.
|
||||||
*
|
|
||||||
* The `punycode` module is a bundled version of the [Punycode.js](https://github.com/bestiejs/punycode.js) module. It
|
|
||||||
* can be accessed using:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const punycode = require('punycode');
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* [Punycode](https://tools.ietf.org/html/rfc3492) is a character encoding scheme defined by RFC 3492 that is
|
|
||||||
* primarily intended for use in Internationalized Domain Names. Because host
|
|
||||||
* names in URLs are limited to ASCII characters only, Domain Names that contain
|
|
||||||
* non-ASCII characters must be converted into ASCII using the Punycode scheme.
|
|
||||||
* For instance, the Japanese character that translates into the English word,`'example'` is `'例'`. The Internationalized Domain Name, `'例.com'` (equivalent
|
|
||||||
* to `'example.com'`) is represented by Punycode as the ASCII string`'xn--fsq.com'`.
|
|
||||||
*
|
|
||||||
* The `punycode` module provides a simple implementation of the Punycode standard.
|
|
||||||
*
|
|
||||||
* The `punycode` module is a third-party dependency used by Node.js and
|
|
||||||
* made available to developers as a convenience. Fixes or other modifications to
|
|
||||||
* the module must be directed to the [Punycode.js](https://github.com/bestiejs/punycode.js) project.
|
|
||||||
* @deprecated Since v7.0.0 - Deprecated
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/punycode.js)
|
|
||||||
*/
|
|
||||||
declare module 'punycode' {
|
|
||||||
/**
|
|
||||||
* The `punycode.decode()` method converts a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only
|
|
||||||
* characters to the equivalent string of Unicode codepoints.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* punycode.decode('maana-pta'); // 'mañana'
|
|
||||||
* punycode.decode('--dqo34k'); // '☃-⌘'
|
|
||||||
* ```
|
|
||||||
* @since v0.5.1
|
|
||||||
*/
|
*/
|
||||||
function decode(string: string): string;
|
function decode(string: string): string;
|
||||||
/**
|
/**
|
||||||
* The `punycode.encode()` method converts a string of Unicode codepoints to a[Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only characters.
|
* @deprecated since v7.0.0
|
||||||
*
|
* The version of the punycode module bundled in Node.js is being deprecated.
|
||||||
* ```js
|
* In a future major version of Node.js this module will be removed.
|
||||||
* punycode.encode('mañana'); // 'maana-pta'
|
* Users currently depending on the punycode module should switch to using
|
||||||
* punycode.encode('☃-⌘'); // '--dqo34k'
|
* the userland-provided Punycode.js module instead.
|
||||||
* ```
|
|
||||||
* @since v0.5.1
|
|
||||||
*/
|
*/
|
||||||
function encode(string: string): string;
|
function encode(string: string): string;
|
||||||
/**
|
/**
|
||||||
* The `punycode.toUnicode()` method converts a string representing a domain name
|
* @deprecated since v7.0.0
|
||||||
* containing [Punycode](https://tools.ietf.org/html/rfc3492) encoded characters into Unicode. Only the [Punycode](https://tools.ietf.org/html/rfc3492)encoded parts of the domain name are be
|
* The version of the punycode module bundled in Node.js is being deprecated.
|
||||||
* converted.
|
* In a future major version of Node.js this module will be removed.
|
||||||
*
|
* Users currently depending on the punycode module should switch to using
|
||||||
* ```js
|
* the userland-provided Punycode.js module instead.
|
||||||
* // decode domain names
|
|
||||||
* punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com'
|
|
||||||
* punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com'
|
|
||||||
* punycode.toUnicode('example.com'); // 'example.com'
|
|
||||||
* ```
|
|
||||||
* @since v0.6.1
|
|
||||||
*/
|
*/
|
||||||
function toUnicode(domain: string): string;
|
function toUnicode(domain: string): string;
|
||||||
/**
|
/**
|
||||||
* The `punycode.toASCII()` method converts a Unicode string representing an
|
* @deprecated since v7.0.0
|
||||||
* Internationalized Domain Name to [Punycode](https://tools.ietf.org/html/rfc3492). Only the non-ASCII parts of the
|
* The version of the punycode module bundled in Node.js is being deprecated.
|
||||||
* domain name will be converted. Calling `punycode.toASCII()` on a string that
|
* In a future major version of Node.js this module will be removed.
|
||||||
* already only contains ASCII characters will have no effect.
|
* Users currently depending on the punycode module should switch to using
|
||||||
*
|
* the userland-provided Punycode.js module instead.
|
||||||
* ```js
|
|
||||||
* // encode domain names
|
|
||||||
* punycode.toASCII('mañana.com'); // 'xn--maana-pta.com'
|
|
||||||
* punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com'
|
|
||||||
* punycode.toASCII('example.com'); // 'example.com'
|
|
||||||
* ```
|
|
||||||
* @since v0.6.1
|
|
||||||
*/
|
*/
|
||||||
function toASCII(domain: string): string;
|
function toASCII(domain: string): string;
|
||||||
/**
|
/**
|
||||||
@@ -113,6 +66,3 @@ declare module 'punycode' {
|
|||||||
*/
|
*/
|
||||||
const version: string;
|
const version: string;
|
||||||
}
|
}
|
||||||
declare module 'node:punycode' {
|
|
||||||
export * from 'punycode';
|
|
||||||
}
|
|
||||||
|
|||||||
+12
-114
@@ -1,95 +1,20 @@
|
|||||||
/**
|
declare module "querystring" {
|
||||||
* The `querystring` module provides utilities for parsing and formatting URL
|
|
||||||
* query strings. It can be accessed using:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const querystring = require('querystring');
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* The `querystring` API is considered Legacy. While it is still maintained,
|
|
||||||
* new code should use the `<URLSearchParams>` API instead.
|
|
||||||
* @deprecated Legacy
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/querystring.js)
|
|
||||||
*/
|
|
||||||
declare module 'querystring' {
|
|
||||||
interface StringifyOptions {
|
interface StringifyOptions {
|
||||||
encodeURIComponent?: ((str: string) => string) | undefined;
|
encodeURIComponent?: (str: string) => string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ParseOptions {
|
interface ParseOptions {
|
||||||
maxKeys?: number | undefined;
|
maxKeys?: number;
|
||||||
decodeURIComponent?: ((str: string) => string) | undefined;
|
decodeURIComponent?: (str: string) => string;
|
||||||
}
|
}
|
||||||
interface ParsedUrlQuery extends NodeJS.Dict<string | string[]> {}
|
|
||||||
interface ParsedUrlQueryInput extends NodeJS.Dict<string | number | boolean | ReadonlyArray<string> | ReadonlyArray<number> | ReadonlyArray<boolean> | null> {}
|
interface ParsedUrlQuery { [key: string]: string | string[]; }
|
||||||
/**
|
|
||||||
* The `querystring.stringify()` method produces a URL query string from a
|
interface ParsedUrlQueryInput {
|
||||||
* given `obj` by iterating through the object's "own properties".
|
[key: string]: string | number | boolean | ReadonlyArray<string> | ReadonlyArray<number> | ReadonlyArray<boolean> | undefined | null;
|
||||||
*
|
}
|
||||||
* It serializes the following types of values passed in `obj`:[<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
|
|
||||||
* [<number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) |
|
|
||||||
* [<bigint>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) |
|
|
||||||
* [<boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) |
|
|
||||||
* [<string\[\]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
|
|
||||||
* [<number\[\]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) |
|
|
||||||
* [<bigint\[\]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) |
|
|
||||||
* [<boolean\[\]>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)The numeric values must be finite. Any other input values will be coerced to
|
|
||||||
* empty strings.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' });
|
|
||||||
* // Returns 'foo=bar&baz=qux&baz=quux&corge='
|
|
||||||
*
|
|
||||||
* querystring.stringify({ foo: 'bar', baz: 'qux' }, ';', ':');
|
|
||||||
* // Returns 'foo:bar;baz:qux'
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* By default, characters requiring percent-encoding within the query string will
|
|
||||||
* be encoded as UTF-8\. If an alternative encoding is required, then an alternative`encodeURIComponent` option will need to be specified:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* // Assuming gbkEncodeURIComponent function already exists,
|
|
||||||
*
|
|
||||||
* querystring.stringify({ w: '中文', foo: 'bar' }, null, null,
|
|
||||||
* { encodeURIComponent: gbkEncodeURIComponent });
|
|
||||||
* ```
|
|
||||||
* @since v0.1.25
|
|
||||||
* @param obj The object to serialize into a URL query string
|
|
||||||
* @param sep The substring used to delimit key and value pairs in the query string.
|
|
||||||
* @param eq . The substring used to delimit keys and values in the query string.
|
|
||||||
*/
|
|
||||||
function stringify(obj?: ParsedUrlQueryInput, sep?: string, eq?: string, options?: StringifyOptions): string;
|
function stringify(obj?: ParsedUrlQueryInput, sep?: string, eq?: string, options?: StringifyOptions): string;
|
||||||
/**
|
|
||||||
* The `querystring.parse()` method parses a URL query string (`str`) into a
|
|
||||||
* collection of key and value pairs.
|
|
||||||
*
|
|
||||||
* For example, the query string `'foo=bar&abc=xyz&abc=123'` is parsed into:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* {
|
|
||||||
* foo: 'bar',
|
|
||||||
* abc: ['xyz', '123']
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* The object returned by the `querystring.parse()` method _does not_prototypically inherit from the JavaScript `Object`. This means that typical`Object` methods such as `obj.toString()`,
|
|
||||||
* `obj.hasOwnProperty()`, and others
|
|
||||||
* are not defined and _will not work_.
|
|
||||||
*
|
|
||||||
* By default, percent-encoded characters within the query string will be assumed
|
|
||||||
* to use UTF-8 encoding. If an alternative character encoding is used, then an
|
|
||||||
* alternative `decodeURIComponent` option will need to be specified:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* // Assuming gbkDecodeURIComponent function already exists...
|
|
||||||
*
|
|
||||||
* querystring.parse('w=%D6%D0%CE%C4&foo=bar', null, null,
|
|
||||||
* { decodeURIComponent: gbkDecodeURIComponent });
|
|
||||||
* ```
|
|
||||||
* @since v0.1.25
|
|
||||||
* @param str The URL query string to parse
|
|
||||||
* @param sep The substring used to delimit key and value pairs in the query string.
|
|
||||||
* @param eq . The substring used to delimit keys and values in the query string.
|
|
||||||
*/
|
|
||||||
function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): ParsedUrlQuery;
|
function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): ParsedUrlQuery;
|
||||||
/**
|
/**
|
||||||
* The querystring.encode() function is an alias for querystring.stringify().
|
* The querystring.encode() function is an alias for querystring.stringify().
|
||||||
@@ -99,33 +24,6 @@ declare module 'querystring' {
|
|||||||
* The querystring.decode() function is an alias for querystring.parse().
|
* The querystring.decode() function is an alias for querystring.parse().
|
||||||
*/
|
*/
|
||||||
const decode: typeof parse;
|
const decode: typeof parse;
|
||||||
/**
|
|
||||||
* The `querystring.escape()` method performs URL percent-encoding on the given`str` in a manner that is optimized for the specific requirements of URL
|
|
||||||
* query strings.
|
|
||||||
*
|
|
||||||
* The `querystring.escape()` method is used by `querystring.stringify()` and is
|
|
||||||
* generally not expected to be used directly. It is exported primarily to allow
|
|
||||||
* application code to provide a replacement percent-encoding implementation if
|
|
||||||
* necessary by assigning `querystring.escape` to an alternative function.
|
|
||||||
* @since v0.1.25
|
|
||||||
*/
|
|
||||||
function escape(str: string): string;
|
function escape(str: string): string;
|
||||||
/**
|
|
||||||
* The `querystring.unescape()` method performs decoding of URL percent-encoded
|
|
||||||
* characters on the given `str`.
|
|
||||||
*
|
|
||||||
* The `querystring.unescape()` method is used by `querystring.parse()` and is
|
|
||||||
* generally not expected to be used directly. It is exported primarily to allow
|
|
||||||
* application code to provide a replacement decoding implementation if
|
|
||||||
* necessary by assigning `querystring.unescape` to an alternative function.
|
|
||||||
*
|
|
||||||
* By default, the `querystring.unescape()` method will attempt to use the
|
|
||||||
* JavaScript built-in `decodeURIComponent()` method to decode. If that fails,
|
|
||||||
* a safer equivalent that does not throw on malformed URLs will be used.
|
|
||||||
* @since v0.1.25
|
|
||||||
*/
|
|
||||||
function unescape(str: string): string;
|
function unescape(str: string): string;
|
||||||
}
|
}
|
||||||
declare module 'node:querystring' {
|
|
||||||
export * from 'querystring';
|
|
||||||
}
|
|
||||||
|
|||||||
+88
-472
@@ -1,92 +1,25 @@
|
|||||||
/**
|
declare module "readline" {
|
||||||
* The `readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) one line at a time. It can be accessed
|
import * as events from "events";
|
||||||
* using:
|
import * as stream from "stream";
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const readline = require('readline');
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* The following simple example illustrates the basic use of the `readline` module.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const readline = require('readline');
|
|
||||||
*
|
|
||||||
* const rl = readline.createInterface({
|
|
||||||
* input: process.stdin,
|
|
||||||
* output: process.stdout
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* rl.question('What do you think of Node.js? ', (answer) => {
|
|
||||||
* // TODO: Log the answer in a database
|
|
||||||
* console.log(`Thank you for your valuable feedback: ${answer}`);
|
|
||||||
*
|
|
||||||
* rl.close();
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Once this code is invoked, the Node.js application will not terminate until the`readline.Interface` is closed because the interface waits for data to be
|
|
||||||
* received on the `input` stream.
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/readline.js)
|
|
||||||
*/
|
|
||||||
declare module 'readline' {
|
|
||||||
import { Abortable, EventEmitter } from 'node:events';
|
|
||||||
interface Key {
|
interface Key {
|
||||||
sequence?: string | undefined;
|
sequence?: string;
|
||||||
name?: string | undefined;
|
name?: string;
|
||||||
ctrl?: boolean | undefined;
|
ctrl?: boolean;
|
||||||
meta?: boolean | undefined;
|
meta?: boolean;
|
||||||
shift?: boolean | undefined;
|
shift?: boolean;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Instances of the `readline.Interface` class are constructed using the`readline.createInterface()` method. Every instance is associated with a
|
class Interface extends events.EventEmitter {
|
||||||
* single `input` `Readable` stream and a single `output` `Writable` stream.
|
|
||||||
* The `output` stream is used to print prompts for user input that arrives on,
|
|
||||||
* and is read from, the `input` stream.
|
|
||||||
* @since v0.1.104
|
|
||||||
*/
|
|
||||||
class Interface extends EventEmitter {
|
|
||||||
readonly terminal: boolean;
|
readonly terminal: boolean;
|
||||||
/**
|
|
||||||
* The current input data being processed by node.
|
// Need direct access to line/cursor data, for use in external processes
|
||||||
*
|
// see: https://github.com/nodejs/node/issues/30347
|
||||||
* This can be used when collecting input from a TTY stream to retrieve the
|
/** The current input data */
|
||||||
* current value that has been processed thus far, prior to the `line` event
|
|
||||||
* being emitted. Once the `line` event has been emitted, this property will
|
|
||||||
* be an empty string.
|
|
||||||
*
|
|
||||||
* Be aware that modifying the value during the instance runtime may have
|
|
||||||
* unintended consequences if `rl.cursor` is not also controlled.
|
|
||||||
*
|
|
||||||
* **If not using a TTY stream for input, use the `'line'` event.**
|
|
||||||
*
|
|
||||||
* One possible use case would be as follows:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const values = ['lorem ipsum', 'dolor sit amet'];
|
|
||||||
* const rl = readline.createInterface(process.stdin);
|
|
||||||
* const showResults = debounce(() => {
|
|
||||||
* console.log(
|
|
||||||
* '\n',
|
|
||||||
* values.filter((val) => val.startsWith(rl.line)).join(' ')
|
|
||||||
* );
|
|
||||||
* }, 300);
|
|
||||||
* process.stdin.on('keypress', (c, k) => {
|
|
||||||
* showResults();
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @since v0.1.98
|
|
||||||
*/
|
|
||||||
readonly line: string;
|
readonly line: string;
|
||||||
/**
|
/** The current cursor position in the input line */
|
||||||
* The cursor position relative to `rl.line`.
|
|
||||||
*
|
|
||||||
* This will track where the current cursor lands in the input string, when
|
|
||||||
* reading input from a TTY stream. The position of cursor determines the
|
|
||||||
* portion of the input string that will be modified as input is processed,
|
|
||||||
* as well as the column where the terminal caret will be rendered.
|
|
||||||
* @since v0.1.98
|
|
||||||
*/
|
|
||||||
readonly cursor: number;
|
readonly cursor: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE: According to the documentation:
|
* NOTE: According to the documentation:
|
||||||
*
|
*
|
||||||
@@ -105,144 +38,15 @@ declare module 'readline' {
|
|||||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
|
* @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
|
||||||
*/
|
*/
|
||||||
protected constructor(options: ReadLineOptions);
|
protected constructor(options: ReadLineOptions);
|
||||||
/**
|
|
||||||
* The `rl.getPrompt()` method returns the current prompt used by `rl.prompt()`.
|
|
||||||
* @since v15.3.0
|
|
||||||
* @return the current prompt string
|
|
||||||
*/
|
|
||||||
getPrompt(): string;
|
|
||||||
/**
|
|
||||||
* The `rl.setPrompt()` method sets the prompt that will be written to `output`whenever `rl.prompt()` is called.
|
|
||||||
* @since v0.1.98
|
|
||||||
*/
|
|
||||||
setPrompt(prompt: string): void;
|
setPrompt(prompt: string): void;
|
||||||
/**
|
|
||||||
* The `rl.prompt()` method writes the `readline.Interface` instances configured`prompt` to a new line in `output` in order to provide a user with a new
|
|
||||||
* location at which to provide input.
|
|
||||||
*
|
|
||||||
* When called, `rl.prompt()` will resume the `input` stream if it has been
|
|
||||||
* paused.
|
|
||||||
*
|
|
||||||
* If the `readline.Interface` was created with `output` set to `null` or`undefined` the prompt is not written.
|
|
||||||
* @since v0.1.98
|
|
||||||
* @param preserveCursor If `true`, prevents the cursor placement from being reset to `0`.
|
|
||||||
*/
|
|
||||||
prompt(preserveCursor?: boolean): void;
|
prompt(preserveCursor?: boolean): void;
|
||||||
/**
|
|
||||||
* The `rl.question()` method displays the `query` by writing it to the `output`,
|
|
||||||
* waits for user input to be provided on `input`, then invokes the `callback`function passing the provided input as the first argument.
|
|
||||||
*
|
|
||||||
* When called, `rl.question()` will resume the `input` stream if it has been
|
|
||||||
* paused.
|
|
||||||
*
|
|
||||||
* If the `readline.Interface` was created with `output` set to `null` or`undefined` the `query` is not written.
|
|
||||||
*
|
|
||||||
* The `callback` function passed to `rl.question()` does not follow the typical
|
|
||||||
* pattern of accepting an `Error` object or `null` as the first argument.
|
|
||||||
* The `callback` is called with the provided answer as the only argument.
|
|
||||||
*
|
|
||||||
* Example usage:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* rl.question('What is your favorite food? ', (answer) => {
|
|
||||||
* console.log(`Oh, so your favorite food is ${answer}`);
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Using an `AbortController` to cancel a question.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const ac = new AbortController();
|
|
||||||
* const signal = ac.signal;
|
|
||||||
*
|
|
||||||
* rl.question('What is your favorite food? ', { signal }, (answer) => {
|
|
||||||
* console.log(`Oh, so your favorite food is ${answer}`);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* signal.addEventListener('abort', () => {
|
|
||||||
* console.log('The food question timed out');
|
|
||||||
* }, { once: true });
|
|
||||||
*
|
|
||||||
* setTimeout(() => ac.abort(), 10000);
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If this method is invoked as it's util.promisify()ed version, it returns a
|
|
||||||
* Promise that fulfills with the answer. If the question is canceled using
|
|
||||||
* an `AbortController` it will reject with an `AbortError`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const util = require('util');
|
|
||||||
* const question = util.promisify(rl.question).bind(rl);
|
|
||||||
*
|
|
||||||
* async function questionExample() {
|
|
||||||
* try {
|
|
||||||
* const answer = await question('What is you favorite food? ');
|
|
||||||
* console.log(`Oh, so your favorite food is ${answer}`);
|
|
||||||
* } catch (err) {
|
|
||||||
* console.error('Question rejected', err);
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* questionExample();
|
|
||||||
* ```
|
|
||||||
* @since v0.3.3
|
|
||||||
* @param query A statement or query to write to `output`, prepended to the prompt.
|
|
||||||
* @param callback A callback function that is invoked with the user's input in response to the `query`.
|
|
||||||
*/
|
|
||||||
question(query: string, callback: (answer: string) => void): void;
|
question(query: string, callback: (answer: string) => void): void;
|
||||||
question(query: string, options: Abortable, callback: (answer: string) => void): void;
|
|
||||||
/**
|
|
||||||
* The `rl.pause()` method pauses the `input` stream, allowing it to be resumed
|
|
||||||
* later if necessary.
|
|
||||||
*
|
|
||||||
* Calling `rl.pause()` does not immediately pause other events (including`'line'`) from being emitted by the `readline.Interface` instance.
|
|
||||||
* @since v0.3.4
|
|
||||||
*/
|
|
||||||
pause(): this;
|
pause(): this;
|
||||||
/**
|
|
||||||
* The `rl.resume()` method resumes the `input` stream if it has been paused.
|
|
||||||
* @since v0.3.4
|
|
||||||
*/
|
|
||||||
resume(): this;
|
resume(): this;
|
||||||
/**
|
|
||||||
* The `rl.close()` method closes the `readline.Interface` instance and
|
|
||||||
* relinquishes control over the `input` and `output` streams. When called,
|
|
||||||
* the `'close'` event will be emitted.
|
|
||||||
*
|
|
||||||
* Calling `rl.close()` does not immediately stop other events (including `'line'`)
|
|
||||||
* from being emitted by the `readline.Interface` instance.
|
|
||||||
* @since v0.1.98
|
|
||||||
*/
|
|
||||||
close(): void;
|
close(): void;
|
||||||
/**
|
|
||||||
* The `rl.write()` method will write either `data` or a key sequence identified
|
|
||||||
* by `key` to the `output`. The `key` argument is supported only if `output` is
|
|
||||||
* a `TTY` text terminal. See `TTY keybindings` for a list of key
|
|
||||||
* combinations.
|
|
||||||
*
|
|
||||||
* If `key` is specified, `data` is ignored.
|
|
||||||
*
|
|
||||||
* When called, `rl.write()` will resume the `input` stream if it has been
|
|
||||||
* paused.
|
|
||||||
*
|
|
||||||
* If the `readline.Interface` was created with `output` set to `null` or`undefined` the `data` and `key` are not written.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* rl.write('Delete this!');
|
|
||||||
* // Simulate Ctrl+U to delete the line written previously
|
|
||||||
* rl.write(null, { ctrl: true, name: 'u' });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* The `rl.write()` method will write the data to the `readline` `Interface`'s`input`_as if it were provided by the user_.
|
|
||||||
* @since v0.1.98
|
|
||||||
*/
|
|
||||||
write(data: string | Buffer, key?: Key): void;
|
write(data: string | Buffer, key?: Key): void;
|
||||||
/**
|
|
||||||
* Returns the real position of the cursor in relation to the input
|
|
||||||
* prompt + string. Long input (wrapping) strings, as well as multiple
|
|
||||||
* line prompts are included in the calculations.
|
|
||||||
* @since v13.5.0, v12.16.0
|
|
||||||
*/
|
|
||||||
getCursorPos(): CursorPos;
|
|
||||||
/**
|
/**
|
||||||
* events.EventEmitter
|
* events.EventEmitter
|
||||||
* 1. close
|
* 1. close
|
||||||
@@ -252,291 +56,103 @@ declare module 'readline' {
|
|||||||
* 5. SIGCONT
|
* 5. SIGCONT
|
||||||
* 6. SIGINT
|
* 6. SIGINT
|
||||||
* 7. SIGTSTP
|
* 7. SIGTSTP
|
||||||
* 8. history
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'close', listener: () => void): this;
|
addListener(event: "close", listener: () => void): this;
|
||||||
addListener(event: 'line', listener: (input: string) => void): this;
|
addListener(event: "line", listener: (input: string) => void): this;
|
||||||
addListener(event: 'pause', listener: () => void): this;
|
addListener(event: "pause", listener: () => void): this;
|
||||||
addListener(event: 'resume', listener: () => void): this;
|
addListener(event: "resume", listener: () => void): this;
|
||||||
addListener(event: 'SIGCONT', listener: () => void): this;
|
addListener(event: "SIGCONT", listener: () => void): this;
|
||||||
addListener(event: 'SIGINT', listener: () => void): this;
|
addListener(event: "SIGINT", listener: () => void): this;
|
||||||
addListener(event: 'SIGTSTP', listener: () => void): this;
|
addListener(event: "SIGTSTP", listener: () => void): this;
|
||||||
addListener(event: 'history', listener: (history: string[]) => void): this;
|
|
||||||
emit(event: string | symbol, ...args: any[]): boolean;
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
emit(event: 'close'): boolean;
|
emit(event: "close"): boolean;
|
||||||
emit(event: 'line', input: string): boolean;
|
emit(event: "line", input: string): boolean;
|
||||||
emit(event: 'pause'): boolean;
|
emit(event: "pause"): boolean;
|
||||||
emit(event: 'resume'): boolean;
|
emit(event: "resume"): boolean;
|
||||||
emit(event: 'SIGCONT'): boolean;
|
emit(event: "SIGCONT"): boolean;
|
||||||
emit(event: 'SIGINT'): boolean;
|
emit(event: "SIGINT"): boolean;
|
||||||
emit(event: 'SIGTSTP'): boolean;
|
emit(event: "SIGTSTP"): boolean;
|
||||||
emit(event: 'history', history: string[]): boolean;
|
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
on(event: 'close', listener: () => void): this;
|
on(event: "close", listener: () => void): this;
|
||||||
on(event: 'line', listener: (input: string) => void): this;
|
on(event: "line", listener: (input: string) => void): this;
|
||||||
on(event: 'pause', listener: () => void): this;
|
on(event: "pause", listener: () => void): this;
|
||||||
on(event: 'resume', listener: () => void): this;
|
on(event: "resume", listener: () => void): this;
|
||||||
on(event: 'SIGCONT', listener: () => void): this;
|
on(event: "SIGCONT", listener: () => void): this;
|
||||||
on(event: 'SIGINT', listener: () => void): this;
|
on(event: "SIGINT", listener: () => void): this;
|
||||||
on(event: 'SIGTSTP', listener: () => void): this;
|
on(event: "SIGTSTP", listener: () => void): this;
|
||||||
on(event: 'history', listener: (history: string[]) => void): this;
|
|
||||||
once(event: string, listener: (...args: any[]) => void): this;
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
once(event: 'close', listener: () => void): this;
|
once(event: "close", listener: () => void): this;
|
||||||
once(event: 'line', listener: (input: string) => void): this;
|
once(event: "line", listener: (input: string) => void): this;
|
||||||
once(event: 'pause', listener: () => void): this;
|
once(event: "pause", listener: () => void): this;
|
||||||
once(event: 'resume', listener: () => void): this;
|
once(event: "resume", listener: () => void): this;
|
||||||
once(event: 'SIGCONT', listener: () => void): this;
|
once(event: "SIGCONT", listener: () => void): this;
|
||||||
once(event: 'SIGINT', listener: () => void): this;
|
once(event: "SIGINT", listener: () => void): this;
|
||||||
once(event: 'SIGTSTP', listener: () => void): this;
|
once(event: "SIGTSTP", listener: () => void): this;
|
||||||
once(event: 'history', listener: (history: string[]) => void): this;
|
|
||||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependListener(event: 'close', listener: () => void): this;
|
prependListener(event: "close", listener: () => void): this;
|
||||||
prependListener(event: 'line', listener: (input: string) => void): this;
|
prependListener(event: "line", listener: (input: string) => void): this;
|
||||||
prependListener(event: 'pause', listener: () => void): this;
|
prependListener(event: "pause", listener: () => void): this;
|
||||||
prependListener(event: 'resume', listener: () => void): this;
|
prependListener(event: "resume", listener: () => void): this;
|
||||||
prependListener(event: 'SIGCONT', listener: () => void): this;
|
prependListener(event: "SIGCONT", listener: () => void): this;
|
||||||
prependListener(event: 'SIGINT', listener: () => void): this;
|
prependListener(event: "SIGINT", listener: () => void): this;
|
||||||
prependListener(event: 'SIGTSTP', listener: () => void): this;
|
prependListener(event: "SIGTSTP", listener: () => void): this;
|
||||||
prependListener(event: 'history', listener: (history: string[]) => void): this;
|
|
||||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependOnceListener(event: 'close', listener: () => void): this;
|
prependOnceListener(event: "close", listener: () => void): this;
|
||||||
prependOnceListener(event: 'line', listener: (input: string) => void): this;
|
prependOnceListener(event: "line", listener: (input: string) => void): this;
|
||||||
prependOnceListener(event: 'pause', listener: () => void): this;
|
prependOnceListener(event: "pause", listener: () => void): this;
|
||||||
prependOnceListener(event: 'resume', listener: () => void): this;
|
prependOnceListener(event: "resume", listener: () => void): this;
|
||||||
prependOnceListener(event: 'SIGCONT', listener: () => void): this;
|
prependOnceListener(event: "SIGCONT", listener: () => void): this;
|
||||||
prependOnceListener(event: 'SIGINT', listener: () => void): this;
|
prependOnceListener(event: "SIGINT", listener: () => void): this;
|
||||||
prependOnceListener(event: 'SIGTSTP', listener: () => void): this;
|
prependOnceListener(event: "SIGTSTP", listener: () => void): this;
|
||||||
prependOnceListener(event: 'history', listener: (history: string[]) => void): this;
|
|
||||||
[Symbol.asyncIterator](): AsyncIterableIterator<string>;
|
[Symbol.asyncIterator](): AsyncIterableIterator<string>;
|
||||||
}
|
}
|
||||||
type ReadLine = Interface; // type forwarded for backwards compatibility
|
|
||||||
|
type ReadLine = Interface; // type forwarded for backwards compatiblity
|
||||||
|
|
||||||
type Completer = (line: string) => CompleterResult;
|
type Completer = (line: string) => CompleterResult;
|
||||||
type AsyncCompleter = (line: string, callback: (err?: null | Error, result?: CompleterResult) => void) => void;
|
type AsyncCompleter = (line: string, callback: (err?: null | Error, result?: CompleterResult) => void) => any;
|
||||||
|
|
||||||
type CompleterResult = [string[], string];
|
type CompleterResult = [string[], string];
|
||||||
|
|
||||||
interface ReadLineOptions {
|
interface ReadLineOptions {
|
||||||
input: NodeJS.ReadableStream;
|
input: NodeJS.ReadableStream;
|
||||||
output?: NodeJS.WritableStream | undefined;
|
output?: NodeJS.WritableStream;
|
||||||
completer?: Completer | AsyncCompleter | undefined;
|
completer?: Completer | AsyncCompleter;
|
||||||
terminal?: boolean | undefined;
|
terminal?: boolean;
|
||||||
/**
|
historySize?: number;
|
||||||
* Initial list of history lines. This option makes sense
|
prompt?: string;
|
||||||
* only if `terminal` is set to `true` by the user or by an internal `output`
|
crlfDelay?: number;
|
||||||
* check, otherwise the history caching mechanism is not initialized at all.
|
removeHistoryDuplicates?: boolean;
|
||||||
* @default []
|
escapeCodeTimeout?: number;
|
||||||
*/
|
|
||||||
history?: string[] | undefined;
|
|
||||||
historySize?: number | undefined;
|
|
||||||
prompt?: string | undefined;
|
|
||||||
crlfDelay?: number | undefined;
|
|
||||||
/**
|
|
||||||
* If `true`, when a new input line added
|
|
||||||
* to the history list duplicates an older one, this removes the older line
|
|
||||||
* from the list.
|
|
||||||
* @default false
|
|
||||||
*/
|
|
||||||
removeHistoryDuplicates?: boolean | undefined;
|
|
||||||
escapeCodeTimeout?: number | undefined;
|
|
||||||
tabSize?: number | undefined;
|
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* The `readline.createInterface()` method creates a new `readline.Interface`instance.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const readline = require('readline');
|
|
||||||
* const rl = readline.createInterface({
|
|
||||||
* input: process.stdin,
|
|
||||||
* output: process.stdout
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Once the `readline.Interface` instance is created, the most common case is to
|
|
||||||
* listen for the `'line'` event:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* rl.on('line', (line) => {
|
|
||||||
* console.log(`Received: ${line}`);
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If `terminal` is `true` for this instance then the `output` stream will get
|
|
||||||
* the best compatibility if it defines an `output.columns` property and emits
|
|
||||||
* a `'resize'` event on the `output` if or when the columns ever change
|
|
||||||
* (`process.stdout` does this automatically when it is a TTY).
|
|
||||||
*
|
|
||||||
* When creating a `readline.Interface` using `stdin` as input, the program
|
|
||||||
* will not terminate until it receives `EOF` (Ctrl+D on
|
|
||||||
* Linux/macOS, Ctrl+Z followed by Return on
|
|
||||||
* Windows).
|
|
||||||
* If you want your application to exit without waiting for user input, you can `unref()` the standard input stream:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* process.stdin.unref();
|
|
||||||
* ```
|
|
||||||
* @since v0.1.98
|
|
||||||
*/
|
|
||||||
function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface;
|
function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface;
|
||||||
function createInterface(options: ReadLineOptions): Interface;
|
function createInterface(options: ReadLineOptions): Interface;
|
||||||
/**
|
|
||||||
* The `readline.emitKeypressEvents()` method causes the given `Readable` stream to begin emitting `'keypress'` events corresponding to received input.
|
|
||||||
*
|
|
||||||
* Optionally, `interface` specifies a `readline.Interface` instance for which
|
|
||||||
* autocompletion is disabled when copy-pasted input is detected.
|
|
||||||
*
|
|
||||||
* If the `stream` is a `TTY`, then it must be in raw mode.
|
|
||||||
*
|
|
||||||
* This is automatically called by any readline instance on its `input` if the`input` is a terminal. Closing the `readline` instance does not stop
|
|
||||||
* the `input` from emitting `'keypress'` events.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* readline.emitKeypressEvents(process.stdin);
|
|
||||||
* if (process.stdin.isTTY)
|
|
||||||
* process.stdin.setRawMode(true);
|
|
||||||
* ```
|
|
||||||
* @since v0.7.7
|
|
||||||
*/
|
|
||||||
function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
|
function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
|
||||||
|
|
||||||
type Direction = -1 | 0 | 1;
|
type Direction = -1 | 0 | 1;
|
||||||
interface CursorPos {
|
|
||||||
rows: number;
|
|
||||||
cols: number;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* The `readline.clearLine()` method clears current line of given `TTY` stream
|
* Clears the current line of this WriteStream in a direction identified by `dir`.
|
||||||
* in a specified direction identified by `dir`.
|
|
||||||
* @since v0.7.7
|
|
||||||
* @param callback Invoked once the operation completes.
|
|
||||||
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
|
||||||
*/
|
*/
|
||||||
function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
|
function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
|
||||||
/**
|
/**
|
||||||
* The `readline.clearScreenDown()` method clears the given `TTY` stream from
|
* Clears this `WriteStream` from the current cursor down.
|
||||||
* the current position of the cursor down.
|
|
||||||
* @since v0.7.7
|
|
||||||
* @param callback Invoked once the operation completes.
|
|
||||||
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
|
||||||
*/
|
*/
|
||||||
function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
|
function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
|
||||||
/**
|
/**
|
||||||
* The `readline.cursorTo()` method moves cursor to the specified position in a
|
* Moves this WriteStream's cursor to the specified position.
|
||||||
* given `TTY` `stream`.
|
|
||||||
* @since v0.7.7
|
|
||||||
* @param callback Invoked once the operation completes.
|
|
||||||
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
|
||||||
*/
|
*/
|
||||||
function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean;
|
function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean;
|
||||||
/**
|
/**
|
||||||
* The `readline.moveCursor()` method moves the cursor _relative_ to its current
|
* Moves this WriteStream's cursor relative to its current position.
|
||||||
* position in a given `TTY` `stream`.
|
|
||||||
*
|
|
||||||
* ## Example: Tiny CLI
|
|
||||||
*
|
|
||||||
* The following example illustrates the use of `readline.Interface` class to
|
|
||||||
* implement a small command-line interface:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const readline = require('readline');
|
|
||||||
* const rl = readline.createInterface({
|
|
||||||
* input: process.stdin,
|
|
||||||
* output: process.stdout,
|
|
||||||
* prompt: 'OHAI> '
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* rl.prompt();
|
|
||||||
*
|
|
||||||
* rl.on('line', (line) => {
|
|
||||||
* switch (line.trim()) {
|
|
||||||
* case 'hello':
|
|
||||||
* console.log('world!');
|
|
||||||
* break;
|
|
||||||
* default:
|
|
||||||
* console.log(`Say what? I might have heard '${line.trim()}'`);
|
|
||||||
* break;
|
|
||||||
* }
|
|
||||||
* rl.prompt();
|
|
||||||
* }).on('close', () => {
|
|
||||||
* console.log('Have a great day!');
|
|
||||||
* process.exit(0);
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* ## Example: Read file stream line-by-Line
|
|
||||||
*
|
|
||||||
* A common use case for `readline` is to consume an input file one line at a
|
|
||||||
* time. The easiest way to do so is leveraging the `fs.ReadStream` API as
|
|
||||||
* well as a `for await...of` loop:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const fs = require('fs');
|
|
||||||
* const readline = require('readline');
|
|
||||||
*
|
|
||||||
* async function processLineByLine() {
|
|
||||||
* const fileStream = fs.createReadStream('input.txt');
|
|
||||||
*
|
|
||||||
* const rl = readline.createInterface({
|
|
||||||
* input: fileStream,
|
|
||||||
* crlfDelay: Infinity
|
|
||||||
* });
|
|
||||||
* // Note: we use the crlfDelay option to recognize all instances of CR LF
|
|
||||||
* // ('\r\n') in input.txt as a single line break.
|
|
||||||
*
|
|
||||||
* for await (const line of rl) {
|
|
||||||
* // Each line in input.txt will be successively available here as `line`.
|
|
||||||
* console.log(`Line from file: ${line}`);
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* processLineByLine();
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Alternatively, one could use the `'line'` event:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const fs = require('fs');
|
|
||||||
* const readline = require('readline');
|
|
||||||
*
|
|
||||||
* const rl = readline.createInterface({
|
|
||||||
* input: fs.createReadStream('sample.txt'),
|
|
||||||
* crlfDelay: Infinity
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* rl.on('line', (line) => {
|
|
||||||
* console.log(`Line from file: ${line}`);
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Currently, `for await...of` loop can be a bit slower. If `async` / `await`flow and speed are both essential, a mixed approach can be applied:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { once } = require('events');
|
|
||||||
* const { createReadStream } = require('fs');
|
|
||||||
* const { createInterface } = require('readline');
|
|
||||||
*
|
|
||||||
* (async function processLineByLine() {
|
|
||||||
* try {
|
|
||||||
* const rl = createInterface({
|
|
||||||
* input: createReadStream('big-file.txt'),
|
|
||||||
* crlfDelay: Infinity
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* rl.on('line', (line) => {
|
|
||||||
* // Process the line.
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* await once(rl, 'close');
|
|
||||||
*
|
|
||||||
* console.log('File processed.');
|
|
||||||
* } catch (err) {
|
|
||||||
* console.error(err);
|
|
||||||
* }
|
|
||||||
* })();
|
|
||||||
* ```
|
|
||||||
* @since v0.7.7
|
|
||||||
* @param callback Invoked once the operation completes.
|
|
||||||
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
|
||||||
*/
|
*/
|
||||||
function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean;
|
function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean;
|
||||||
}
|
}
|
||||||
declare module 'node:readline' {
|
|
||||||
export * from 'readline';
|
|
||||||
}
|
|
||||||
|
|||||||
+134
-176
@@ -1,40 +1,31 @@
|
|||||||
/**
|
declare module "repl" {
|
||||||
* The `repl` module provides a Read-Eval-Print-Loop (REPL) implementation that
|
import { Interface, Completer, AsyncCompleter } from "readline";
|
||||||
* is available both as a standalone program or includible in other applications.
|
import { Context } from "vm";
|
||||||
* It can be accessed using:
|
import { InspectOptions } from "util";
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const repl = require('repl');
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/repl.js)
|
|
||||||
*/
|
|
||||||
declare module 'repl' {
|
|
||||||
import { Interface, Completer, AsyncCompleter } from 'node:readline';
|
|
||||||
import { Context } from 'node:vm';
|
|
||||||
import { InspectOptions } from 'node:util';
|
|
||||||
interface ReplOptions {
|
interface ReplOptions {
|
||||||
/**
|
/**
|
||||||
* The input prompt to display.
|
* The input prompt to display.
|
||||||
* @default "> "
|
* Default: `"> "`
|
||||||
*/
|
*/
|
||||||
prompt?: string | undefined;
|
prompt?: string;
|
||||||
/**
|
/**
|
||||||
* The `Readable` stream from which REPL input will be read.
|
* The `Readable` stream from which REPL input will be read.
|
||||||
* @default process.stdin
|
* Default: `process.stdin`
|
||||||
*/
|
*/
|
||||||
input?: NodeJS.ReadableStream | undefined;
|
input?: NodeJS.ReadableStream;
|
||||||
/**
|
/**
|
||||||
* The `Writable` stream to which REPL output will be written.
|
* The `Writable` stream to which REPL output will be written.
|
||||||
* @default process.stdout
|
* Default: `process.stdout`
|
||||||
*/
|
*/
|
||||||
output?: NodeJS.WritableStream | undefined;
|
output?: NodeJS.WritableStream;
|
||||||
/**
|
/**
|
||||||
* If `true`, specifies that the output should be treated as a TTY terminal, and have
|
* If `true`, specifies that the output should be treated as a TTY terminal, and have
|
||||||
* ANSI/VT100 escape codes written to it.
|
* ANSI/VT100 escape codes written to it.
|
||||||
* Default: checking the value of the `isTTY` property on the output stream upon
|
* Default: checking the value of the `isTTY` property on the output stream upon
|
||||||
* instantiation.
|
* instantiation.
|
||||||
*/
|
*/
|
||||||
terminal?: boolean | undefined;
|
terminal?: boolean;
|
||||||
/**
|
/**
|
||||||
* The function to be used when evaluating each given line of input.
|
* The function to be used when evaluating each given line of input.
|
||||||
* Default: an async wrapper for the JavaScript `eval()` function. An `eval` function can
|
* Default: an async wrapper for the JavaScript `eval()` function. An `eval` function can
|
||||||
@@ -44,45 +35,40 @@ declare module 'repl' {
|
|||||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_default_evaluation
|
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_default_evaluation
|
||||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_custom_evaluation_functions
|
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_custom_evaluation_functions
|
||||||
*/
|
*/
|
||||||
eval?: REPLEval | undefined;
|
eval?: REPLEval;
|
||||||
/**
|
|
||||||
* Defines if the repl prints output previews or not.
|
|
||||||
* @default `true` Always `false` in case `terminal` is falsy.
|
|
||||||
*/
|
|
||||||
preview?: boolean | undefined;
|
|
||||||
/**
|
/**
|
||||||
* If `true`, specifies that the default `writer` function should include ANSI color
|
* If `true`, specifies that the default `writer` function should include ANSI color
|
||||||
* styling to REPL output. If a custom `writer` function is provided then this has no
|
* styling to REPL output. If a custom `writer` function is provided then this has no
|
||||||
* effect.
|
* effect.
|
||||||
* Default: the REPL instance's `terminal` value.
|
* Default: the REPL instance's `terminal` value.
|
||||||
*/
|
*/
|
||||||
useColors?: boolean | undefined;
|
useColors?: boolean;
|
||||||
/**
|
/**
|
||||||
* If `true`, specifies that the default evaluation function will use the JavaScript
|
* If `true`, specifies that the default evaluation function will use the JavaScript
|
||||||
* `global` as the context as opposed to creating a new separate context for the REPL
|
* `global` as the context as opposed to creating a new separate context for the REPL
|
||||||
* instance. The node CLI REPL sets this value to `true`.
|
* instance. The node CLI REPL sets this value to `true`.
|
||||||
* Default: `false`.
|
* Default: `false`.
|
||||||
*/
|
*/
|
||||||
useGlobal?: boolean | undefined;
|
useGlobal?: boolean;
|
||||||
/**
|
/**
|
||||||
* If `true`, specifies that the default writer will not output the return value of a
|
* If `true`, specifies that the default writer will not output the return value of a
|
||||||
* command if it evaluates to `undefined`.
|
* command if it evaluates to `undefined`.
|
||||||
* Default: `false`.
|
* Default: `false`.
|
||||||
*/
|
*/
|
||||||
ignoreUndefined?: boolean | undefined;
|
ignoreUndefined?: boolean;
|
||||||
/**
|
/**
|
||||||
* The function to invoke to format the output of each command before writing to `output`.
|
* The function to invoke to format the output of each command before writing to `output`.
|
||||||
* Default: a wrapper for `util.inspect`.
|
* Default: a wrapper for `util.inspect`.
|
||||||
*
|
*
|
||||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_customizing_repl_output
|
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_customizing_repl_output
|
||||||
*/
|
*/
|
||||||
writer?: REPLWriter | undefined;
|
writer?: REPLWriter;
|
||||||
/**
|
/**
|
||||||
* An optional function used for custom Tab auto completion.
|
* An optional function used for custom Tab auto completion.
|
||||||
*
|
*
|
||||||
* @see https://nodejs.org/dist/latest-v11.x/docs/api/readline.html#readline_use_of_the_completer_function
|
* @see https://nodejs.org/dist/latest-v11.x/docs/api/readline.html#readline_use_of_the_completer_function
|
||||||
*/
|
*/
|
||||||
completer?: Completer | AsyncCompleter | undefined;
|
completer?: Completer | AsyncCompleter;
|
||||||
/**
|
/**
|
||||||
* A flag that specifies whether the default evaluator executes all JavaScript commands in
|
* A flag that specifies whether the default evaluator executes all JavaScript commands in
|
||||||
* strict mode or default (sloppy) mode.
|
* strict mode or default (sloppy) mode.
|
||||||
@@ -91,47 +77,52 @@ declare module 'repl' {
|
|||||||
* - `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is equivalent to
|
* - `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is equivalent to
|
||||||
* prefacing every repl statement with `'use strict'`.
|
* prefacing every repl statement with `'use strict'`.
|
||||||
*/
|
*/
|
||||||
replMode?: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT | undefined;
|
replMode?: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT;
|
||||||
/**
|
/**
|
||||||
* Stop evaluating the current piece of code when `SIGINT` is received, i.e. `Ctrl+C` is
|
* Stop evaluating the current piece of code when `SIGINT` is received, i.e. `Ctrl+C` is
|
||||||
* pressed. This cannot be used together with a custom `eval` function.
|
* pressed. This cannot be used together with a custom `eval` function.
|
||||||
* Default: `false`.
|
* Default: `false`.
|
||||||
*/
|
*/
|
||||||
breakEvalOnSigint?: boolean | undefined;
|
breakEvalOnSigint?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type REPLEval = (this: REPLServer, evalCmd: string, context: Context, file: string, cb: (err: Error | null, result: any) => void) => void;
|
type REPLEval = (this: REPLServer, evalCmd: string, context: Context, file: string, cb: (err: Error | null, result: any) => void) => void;
|
||||||
type REPLWriter = (this: REPLServer, obj: any) => string;
|
type REPLWriter = (this: REPLServer, obj: any) => string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the default "writer" value, if none is passed in the REPL options,
|
* This is the default "writer" value, if none is passed in the REPL options,
|
||||||
* and it can be overridden by custom print functions.
|
* and it can be overridden by custom print functions.
|
||||||
*/
|
*/
|
||||||
const writer: REPLWriter & {
|
const writer: REPLWriter & { options: InspectOptions };
|
||||||
options: InspectOptions;
|
|
||||||
};
|
|
||||||
type REPLCommandAction = (this: REPLServer, text: string) => void;
|
type REPLCommandAction = (this: REPLServer, text: string) => void;
|
||||||
|
|
||||||
interface REPLCommand {
|
interface REPLCommand {
|
||||||
/**
|
/**
|
||||||
* Help text to be displayed when `.help` is entered.
|
* Help text to be displayed when `.help` is entered.
|
||||||
*/
|
*/
|
||||||
help?: string | undefined;
|
help?: string;
|
||||||
/**
|
/**
|
||||||
* The function to execute, optionally accepting a single string argument.
|
* The function to execute, optionally accepting a single string argument.
|
||||||
*/
|
*/
|
||||||
action: REPLCommandAction;
|
action: REPLCommandAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instances of `repl.REPLServer` are created using the {@link start} method
|
* Provides a customizable Read-Eval-Print-Loop (REPL).
|
||||||
* or directly using the JavaScript `new` keyword.
|
|
||||||
*
|
*
|
||||||
* ```js
|
* Instances of `repl.REPLServer` will accept individual lines of user input, evaluate those
|
||||||
* const repl = require('repl');
|
* according to a user-defined evaluation function, then output the result. Input and output
|
||||||
|
* may be from `stdin` and `stdout`, respectively, or may be connected to any Node.js `stream`.
|
||||||
*
|
*
|
||||||
* const options = { useColors: true };
|
* Instances of `repl.REPLServer` support automatic completion of inputs, simplistic Emacs-style
|
||||||
|
* line editing, multi-line inputs, ANSI-styled output, saving and restoring current REPL session
|
||||||
|
* state, error recovery, and customizable evaluation functions.
|
||||||
*
|
*
|
||||||
* const firstInstance = repl.start(options);
|
* Instances of `repl.REPLServer` are created using the `repl.start()` method and _should not_
|
||||||
* const secondInstance = new repl.REPLServer(options);
|
* be created directly using the JavaScript `new` keyword.
|
||||||
* ```
|
*
|
||||||
* @since v0.1.91
|
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_repl
|
||||||
*/
|
*/
|
||||||
class REPLServer extends Interface {
|
class REPLServer extends Interface {
|
||||||
/**
|
/**
|
||||||
@@ -140,25 +131,17 @@ declare module 'repl' {
|
|||||||
*/
|
*/
|
||||||
readonly context: Context;
|
readonly context: Context;
|
||||||
/**
|
/**
|
||||||
* @deprecated since v14.3.0 - Use `input` instead.
|
* The `Readable` stream from which REPL input will be read.
|
||||||
*/
|
*/
|
||||||
readonly inputStream: NodeJS.ReadableStream;
|
readonly inputStream: NodeJS.ReadableStream;
|
||||||
/**
|
/**
|
||||||
* @deprecated since v14.3.0 - Use `output` instead.
|
* The `Writable` stream to which REPL output will be written.
|
||||||
*/
|
*/
|
||||||
readonly outputStream: NodeJS.WritableStream;
|
readonly outputStream: NodeJS.WritableStream;
|
||||||
/**
|
|
||||||
* The `Readable` stream from which REPL input will be read.
|
|
||||||
*/
|
|
||||||
readonly input: NodeJS.ReadableStream;
|
|
||||||
/**
|
|
||||||
* The `Writable` stream to which REPL output will be written.
|
|
||||||
*/
|
|
||||||
readonly output: NodeJS.WritableStream;
|
|
||||||
/**
|
/**
|
||||||
* The commands registered via `replServer.defineCommand()`.
|
* The commands registered via `replServer.defineCommand()`.
|
||||||
*/
|
*/
|
||||||
readonly commands: NodeJS.ReadOnlyDict<REPLCommand>;
|
readonly commands: { readonly [name: string]: REPLCommand | undefined };
|
||||||
/**
|
/**
|
||||||
* A value indicating whether the REPL is currently in "editor mode".
|
* A value indicating whether the REPL is currently in "editor mode".
|
||||||
*
|
*
|
||||||
@@ -232,6 +215,7 @@ declare module 'repl' {
|
|||||||
* prefacing every repl statement with `'use strict'`.
|
* prefacing every repl statement with `'use strict'`.
|
||||||
*/
|
*/
|
||||||
readonly replMode: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT;
|
readonly replMode: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE: According to the documentation:
|
* NOTE: According to the documentation:
|
||||||
*
|
*
|
||||||
@@ -243,76 +227,49 @@ declare module 'repl' {
|
|||||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_class_replserver
|
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_class_replserver
|
||||||
*/
|
*/
|
||||||
private constructor();
|
private constructor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `replServer.defineCommand()` method is used to add new `.`\-prefixed commands
|
* Used to add new `.`-prefixed commands to the REPL instance. Such commands are invoked
|
||||||
* to the REPL instance. Such commands are invoked by typing a `.` followed by the`keyword`. The `cmd` is either a `Function` or an `Object` with the following
|
* by typing a `.` followed by the `keyword`.
|
||||||
* properties:
|
|
||||||
*
|
*
|
||||||
* The following example shows two new commands added to the REPL instance:
|
* @param keyword The command keyword (_without_ a leading `.` character).
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const repl = require('repl');
|
|
||||||
*
|
|
||||||
* const replServer = repl.start({ prompt: '> ' });
|
|
||||||
* replServer.defineCommand('sayhello', {
|
|
||||||
* help: 'Say hello',
|
|
||||||
* action(name) {
|
|
||||||
* this.clearBufferedCommand();
|
|
||||||
* console.log(`Hello, ${name}!`);
|
|
||||||
* this.displayPrompt();
|
|
||||||
* }
|
|
||||||
* });
|
|
||||||
* replServer.defineCommand('saybye', function saybye() {
|
|
||||||
* console.log('Goodbye!');
|
|
||||||
* this.close();
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* The new commands can then be used from within the REPL instance:
|
|
||||||
*
|
|
||||||
* ```console
|
|
||||||
* > .sayhello Node.js User
|
|
||||||
* Hello, Node.js User!
|
|
||||||
* > .saybye
|
|
||||||
* Goodbye!
|
|
||||||
* ```
|
|
||||||
* @since v0.3.0
|
|
||||||
* @param keyword The command keyword (*without* a leading `.` character).
|
|
||||||
* @param cmd The function to invoke when the command is processed.
|
* @param cmd The function to invoke when the command is processed.
|
||||||
|
*
|
||||||
|
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_replserver_definecommand_keyword_cmd
|
||||||
*/
|
*/
|
||||||
defineCommand(keyword: string, cmd: REPLCommandAction | REPLCommand): void;
|
defineCommand(keyword: string, cmd: REPLCommandAction | REPLCommand): void;
|
||||||
/**
|
/**
|
||||||
* The `replServer.displayPrompt()` method readies the REPL instance for input
|
* Readies the REPL instance for input from the user, printing the configured `prompt` to a
|
||||||
* from the user, printing the configured `prompt` to a new line in the `output`and resuming the `input` to accept new input.
|
* new line in the `output` and resuming the `input` to accept new input.
|
||||||
*
|
*
|
||||||
* When multi-line input is being entered, an ellipsis is printed rather than the
|
* When multi-line input is being entered, an ellipsis is printed rather than the 'prompt'.
|
||||||
* 'prompt'.
|
|
||||||
*
|
*
|
||||||
* When `preserveCursor` is `true`, the cursor placement will not be reset to `0`.
|
* This method is primarily intended to be called from within the action function for
|
||||||
|
* commands registered using the `replServer.defineCommand()` method.
|
||||||
*
|
*
|
||||||
* The `replServer.displayPrompt` method is primarily intended to be called from
|
* @param preserveCursor When `true`, the cursor placement will not be reset to `0`.
|
||||||
* within the action function for commands registered using the`replServer.defineCommand()` method.
|
|
||||||
* @since v0.1.91
|
|
||||||
*/
|
*/
|
||||||
displayPrompt(preserveCursor?: boolean): void;
|
displayPrompt(preserveCursor?: boolean): void;
|
||||||
/**
|
/**
|
||||||
* The `replServer.clearBufferedCommand()` method clears any command that has been
|
* Clears any command that has been buffered but not yet executed.
|
||||||
* buffered but not yet executed. This method is primarily intended to be
|
*
|
||||||
* called from within the action function for commands registered using the`replServer.defineCommand()` method.
|
* This method is primarily intended to be called from within the action function for
|
||||||
|
* commands registered using the `replServer.defineCommand()` method.
|
||||||
|
*
|
||||||
* @since v9.0.0
|
* @since v9.0.0
|
||||||
*/
|
*/
|
||||||
clearBufferedCommand(): void;
|
clearBufferedCommand(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a history log file for the REPL instance. When executing the
|
* Initializes a history log file for the REPL instance. When executing the
|
||||||
* Node.js binary and using the command-line REPL, a history file is initialized
|
* Node.js binary and using the command line REPL, a history file is initialized
|
||||||
* by default. However, this is not the case when creating a REPL
|
* by default. However, this is not the case when creating a REPL
|
||||||
* programmatically. Use this method to initialize a history log file when working
|
* programmatically. Use this method to initialize a history log file when working
|
||||||
* with REPL instances programmatically.
|
* with REPL instances programmatically.
|
||||||
* @since v11.10.0
|
* @param path The path to the history file
|
||||||
* @param historyPath the path to the history file
|
|
||||||
* @param callback called when history writes are ready or upon error
|
|
||||||
*/
|
*/
|
||||||
setupHistory(path: string, callback: (err: Error | null, repl: this) => void): void;
|
setupHistory(path: string, cb: (err: Error | null, repl: this) => void): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* events.EventEmitter
|
* events.EventEmitter
|
||||||
* 1. close - inherited from `readline.Interface`
|
* 1. close - inherited from `readline.Interface`
|
||||||
@@ -325,90 +282,93 @@ declare module 'repl' {
|
|||||||
* 8. exit
|
* 8. exit
|
||||||
* 9. reset
|
* 9. reset
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
addListener(event: 'close', listener: () => void): this;
|
addListener(event: "close", listener: () => void): this;
|
||||||
addListener(event: 'line', listener: (input: string) => void): this;
|
addListener(event: "line", listener: (input: string) => void): this;
|
||||||
addListener(event: 'pause', listener: () => void): this;
|
addListener(event: "pause", listener: () => void): this;
|
||||||
addListener(event: 'resume', listener: () => void): this;
|
addListener(event: "resume", listener: () => void): this;
|
||||||
addListener(event: 'SIGCONT', listener: () => void): this;
|
addListener(event: "SIGCONT", listener: () => void): this;
|
||||||
addListener(event: 'SIGINT', listener: () => void): this;
|
addListener(event: "SIGINT", listener: () => void): this;
|
||||||
addListener(event: 'SIGTSTP', listener: () => void): this;
|
addListener(event: "SIGTSTP", listener: () => void): this;
|
||||||
addListener(event: 'exit', listener: () => void): this;
|
addListener(event: "exit", listener: () => void): this;
|
||||||
addListener(event: 'reset', listener: (context: Context) => void): this;
|
addListener(event: "reset", listener: (context: Context) => void): this;
|
||||||
|
|
||||||
emit(event: string | symbol, ...args: any[]): boolean;
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
emit(event: 'close'): boolean;
|
emit(event: "close"): boolean;
|
||||||
emit(event: 'line', input: string): boolean;
|
emit(event: "line", input: string): boolean;
|
||||||
emit(event: 'pause'): boolean;
|
emit(event: "pause"): boolean;
|
||||||
emit(event: 'resume'): boolean;
|
emit(event: "resume"): boolean;
|
||||||
emit(event: 'SIGCONT'): boolean;
|
emit(event: "SIGCONT"): boolean;
|
||||||
emit(event: 'SIGINT'): boolean;
|
emit(event: "SIGINT"): boolean;
|
||||||
emit(event: 'SIGTSTP'): boolean;
|
emit(event: "SIGTSTP"): boolean;
|
||||||
emit(event: 'exit'): boolean;
|
emit(event: "exit"): boolean;
|
||||||
emit(event: 'reset', context: Context): boolean;
|
emit(event: "reset", context: Context): boolean;
|
||||||
|
|
||||||
on(event: string, listener: (...args: any[]) => void): this;
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
on(event: 'close', listener: () => void): this;
|
on(event: "close", listener: () => void): this;
|
||||||
on(event: 'line', listener: (input: string) => void): this;
|
on(event: "line", listener: (input: string) => void): this;
|
||||||
on(event: 'pause', listener: () => void): this;
|
on(event: "pause", listener: () => void): this;
|
||||||
on(event: 'resume', listener: () => void): this;
|
on(event: "resume", listener: () => void): this;
|
||||||
on(event: 'SIGCONT', listener: () => void): this;
|
on(event: "SIGCONT", listener: () => void): this;
|
||||||
on(event: 'SIGINT', listener: () => void): this;
|
on(event: "SIGINT", listener: () => void): this;
|
||||||
on(event: 'SIGTSTP', listener: () => void): this;
|
on(event: "SIGTSTP", listener: () => void): this;
|
||||||
on(event: 'exit', listener: () => void): this;
|
on(event: "exit", listener: () => void): this;
|
||||||
on(event: 'reset', listener: (context: Context) => void): this;
|
on(event: "reset", listener: (context: Context) => void): this;
|
||||||
|
|
||||||
once(event: string, listener: (...args: any[]) => void): this;
|
once(event: string, listener: (...args: any[]) => void): this;
|
||||||
once(event: 'close', listener: () => void): this;
|
once(event: "close", listener: () => void): this;
|
||||||
once(event: 'line', listener: (input: string) => void): this;
|
once(event: "line", listener: (input: string) => void): this;
|
||||||
once(event: 'pause', listener: () => void): this;
|
once(event: "pause", listener: () => void): this;
|
||||||
once(event: 'resume', listener: () => void): this;
|
once(event: "resume", listener: () => void): this;
|
||||||
once(event: 'SIGCONT', listener: () => void): this;
|
once(event: "SIGCONT", listener: () => void): this;
|
||||||
once(event: 'SIGINT', listener: () => void): this;
|
once(event: "SIGINT", listener: () => void): this;
|
||||||
once(event: 'SIGTSTP', listener: () => void): this;
|
once(event: "SIGTSTP", listener: () => void): this;
|
||||||
once(event: 'exit', listener: () => void): this;
|
once(event: "exit", listener: () => void): this;
|
||||||
once(event: 'reset', listener: (context: Context) => void): this;
|
once(event: "reset", listener: (context: Context) => void): this;
|
||||||
|
|
||||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependListener(event: 'close', listener: () => void): this;
|
prependListener(event: "close", listener: () => void): this;
|
||||||
prependListener(event: 'line', listener: (input: string) => void): this;
|
prependListener(event: "line", listener: (input: string) => void): this;
|
||||||
prependListener(event: 'pause', listener: () => void): this;
|
prependListener(event: "pause", listener: () => void): this;
|
||||||
prependListener(event: 'resume', listener: () => void): this;
|
prependListener(event: "resume", listener: () => void): this;
|
||||||
prependListener(event: 'SIGCONT', listener: () => void): this;
|
prependListener(event: "SIGCONT", listener: () => void): this;
|
||||||
prependListener(event: 'SIGINT', listener: () => void): this;
|
prependListener(event: "SIGINT", listener: () => void): this;
|
||||||
prependListener(event: 'SIGTSTP', listener: () => void): this;
|
prependListener(event: "SIGTSTP", listener: () => void): this;
|
||||||
prependListener(event: 'exit', listener: () => void): this;
|
prependListener(event: "exit", listener: () => void): this;
|
||||||
prependListener(event: 'reset', listener: (context: Context) => void): this;
|
prependListener(event: "reset", listener: (context: Context) => void): this;
|
||||||
|
|
||||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||||
prependOnceListener(event: 'close', listener: () => void): this;
|
prependOnceListener(event: "close", listener: () => void): this;
|
||||||
prependOnceListener(event: 'line', listener: (input: string) => void): this;
|
prependOnceListener(event: "line", listener: (input: string) => void): this;
|
||||||
prependOnceListener(event: 'pause', listener: () => void): this;
|
prependOnceListener(event: "pause", listener: () => void): this;
|
||||||
prependOnceListener(event: 'resume', listener: () => void): this;
|
prependOnceListener(event: "resume", listener: () => void): this;
|
||||||
prependOnceListener(event: 'SIGCONT', listener: () => void): this;
|
prependOnceListener(event: "SIGCONT", listener: () => void): this;
|
||||||
prependOnceListener(event: 'SIGINT', listener: () => void): this;
|
prependOnceListener(event: "SIGINT", listener: () => void): this;
|
||||||
prependOnceListener(event: 'SIGTSTP', listener: () => void): this;
|
prependOnceListener(event: "SIGTSTP", listener: () => void): this;
|
||||||
prependOnceListener(event: 'exit', listener: () => void): this;
|
prependOnceListener(event: "exit", listener: () => void): this;
|
||||||
prependOnceListener(event: 'reset', listener: (context: Context) => void): this;
|
prependOnceListener(event: "reset", listener: (context: Context) => void): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A flag passed in the REPL options. Evaluates expressions in sloppy mode.
|
* A flag passed in the REPL options. Evaluates expressions in sloppy mode.
|
||||||
*/
|
*/
|
||||||
const REPL_MODE_SLOPPY: unique symbol;
|
const REPL_MODE_SLOPPY: symbol; // TODO: unique symbol
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A flag passed in the REPL options. Evaluates expressions in strict mode.
|
* A flag passed in the REPL options. Evaluates expressions in strict mode.
|
||||||
* This is equivalent to prefacing every repl statement with `'use strict'`.
|
* This is equivalent to prefacing every repl statement with `'use strict'`.
|
||||||
*/
|
*/
|
||||||
const REPL_MODE_STRICT: unique symbol;
|
const REPL_MODE_STRICT: symbol; // TODO: unique symbol
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `repl.start()` method creates and starts a {@link REPLServer} instance.
|
* Creates and starts a `repl.REPLServer` instance.
|
||||||
*
|
*
|
||||||
* If `options` is a string, then it specifies the input prompt:
|
* @param options The options for the `REPLServer`. If `options` is a string, then it specifies
|
||||||
*
|
* the input prompt.
|
||||||
* ```js
|
|
||||||
* const repl = require('repl');
|
|
||||||
*
|
|
||||||
* // a Unix style prompt
|
|
||||||
* repl.start('$ ');
|
|
||||||
* ```
|
|
||||||
* @since v0.1.91
|
|
||||||
*/
|
*/
|
||||||
function start(options?: string | ReplOptions): REPLServer;
|
function start(options?: string | ReplOptions): REPLServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates a recoverable error that a `REPLServer` can use to support multi-line input.
|
* Indicates a recoverable error that a `REPLServer` can use to support multi-line input.
|
||||||
*
|
*
|
||||||
@@ -416,9 +376,7 @@ declare module 'repl' {
|
|||||||
*/
|
*/
|
||||||
class Recoverable extends SyntaxError {
|
class Recoverable extends SyntaxError {
|
||||||
err: Error;
|
err: Error;
|
||||||
|
|
||||||
constructor(err: Error);
|
constructor(err: Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module 'node:repl' {
|
|
||||||
export * from 'repl';
|
|
||||||
}
|
|
||||||
|
|||||||
+193
-1038
File diff suppressed because it is too large
Load Diff
-42
@@ -1,42 +0,0 @@
|
|||||||
declare module 'stream/promises' {
|
|
||||||
import { FinishedOptions, PipelineSource, PipelineTransform, PipelineDestination, PipelinePromise, PipelineOptions } from 'node:stream';
|
|
||||||
function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, options?: FinishedOptions): Promise<void>;
|
|
||||||
function pipeline<A extends PipelineSource<any>, B extends PipelineDestination<A, any>>(source: A, destination: B, options?: PipelineOptions): PipelinePromise<B>;
|
|
||||||
function pipeline<A extends PipelineSource<any>, T1 extends PipelineTransform<A, any>, B extends PipelineDestination<T1, any>>(
|
|
||||||
source: A,
|
|
||||||
transform1: T1,
|
|
||||||
destination: B,
|
|
||||||
options?: PipelineOptions
|
|
||||||
): PipelinePromise<B>;
|
|
||||||
function pipeline<A extends PipelineSource<any>, T1 extends PipelineTransform<A, any>, T2 extends PipelineTransform<T1, any>, B extends PipelineDestination<T2, any>>(
|
|
||||||
source: A,
|
|
||||||
transform1: T1,
|
|
||||||
transform2: T2,
|
|
||||||
destination: B,
|
|
||||||
options?: PipelineOptions
|
|
||||||
): PipelinePromise<B>;
|
|
||||||
function pipeline<
|
|
||||||
A extends PipelineSource<any>,
|
|
||||||
T1 extends PipelineTransform<A, any>,
|
|
||||||
T2 extends PipelineTransform<T1, any>,
|
|
||||||
T3 extends PipelineTransform<T2, any>,
|
|
||||||
B extends PipelineDestination<T3, any>
|
|
||||||
>(source: A, transform1: T1, transform2: T2, transform3: T3, destination: B, options?: PipelineOptions): PipelinePromise<B>;
|
|
||||||
function pipeline<
|
|
||||||
A extends PipelineSource<any>,
|
|
||||||
T1 extends PipelineTransform<A, any>,
|
|
||||||
T2 extends PipelineTransform<T1, any>,
|
|
||||||
T3 extends PipelineTransform<T2, any>,
|
|
||||||
T4 extends PipelineTransform<T3, any>,
|
|
||||||
B extends PipelineDestination<T4, any>
|
|
||||||
>(source: A, transform1: T1, transform2: T2, transform3: T3, transform4: T4, destination: B, options?: PipelineOptions): PipelinePromise<B>;
|
|
||||||
function pipeline(streams: ReadonlyArray<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>, options?: PipelineOptions): Promise<void>;
|
|
||||||
function pipeline(
|
|
||||||
stream1: NodeJS.ReadableStream,
|
|
||||||
stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
|
|
||||||
...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | PipelineOptions>
|
|
||||||
): Promise<void>;
|
|
||||||
}
|
|
||||||
declare module 'node:stream/promises' {
|
|
||||||
export * from 'stream/promises';
|
|
||||||
}
|
|
||||||
+2
-62
@@ -1,67 +1,7 @@
|
|||||||
/**
|
declare module "string_decoder" {
|
||||||
* The `string_decoder` module provides an API for decoding `Buffer` objects into
|
|
||||||
* strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16
|
|
||||||
* characters. It can be accessed using:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { StringDecoder } = require('string_decoder');
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* The following example shows the basic use of the `StringDecoder` class.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { StringDecoder } = require('string_decoder');
|
|
||||||
* const decoder = new StringDecoder('utf8');
|
|
||||||
*
|
|
||||||
* const cent = Buffer.from([0xC2, 0xA2]);
|
|
||||||
* console.log(decoder.write(cent));
|
|
||||||
*
|
|
||||||
* const euro = Buffer.from([0xE2, 0x82, 0xAC]);
|
|
||||||
* console.log(decoder.write(euro));
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* When a `Buffer` instance is written to the `StringDecoder` instance, an
|
|
||||||
* internal buffer is used to ensure that the decoded string does not contain
|
|
||||||
* any incomplete multibyte characters. These are held in the buffer until the
|
|
||||||
* next call to `stringDecoder.write()` or until `stringDecoder.end()` is called.
|
|
||||||
*
|
|
||||||
* In the following example, the three UTF-8 encoded bytes of the European Euro
|
|
||||||
* symbol (`€`) are written over three separate operations:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { StringDecoder } = require('string_decoder');
|
|
||||||
* const decoder = new StringDecoder('utf8');
|
|
||||||
*
|
|
||||||
* decoder.write(Buffer.from([0xE2]));
|
|
||||||
* decoder.write(Buffer.from([0x82]));
|
|
||||||
* console.log(decoder.end(Buffer.from([0xAC])));
|
|
||||||
* ```
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/string_decoder.js)
|
|
||||||
*/
|
|
||||||
declare module 'string_decoder' {
|
|
||||||
class StringDecoder {
|
class StringDecoder {
|
||||||
constructor(encoding?: BufferEncoding);
|
constructor(encoding?: string);
|
||||||
/**
|
|
||||||
* Returns a decoded string, ensuring that any incomplete multibyte characters at
|
|
||||||
* the end of the `Buffer`, or `TypedArray`, or `DataView` are omitted from the
|
|
||||||
* returned string and stored in an internal buffer for the next call to`stringDecoder.write()` or `stringDecoder.end()`.
|
|
||||||
* @since v0.1.99
|
|
||||||
* @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode.
|
|
||||||
*/
|
|
||||||
write(buffer: Buffer): string;
|
write(buffer: Buffer): string;
|
||||||
/**
|
|
||||||
* Returns any remaining input stored in the internal buffer as a string. Bytes
|
|
||||||
* representing incomplete UTF-8 and UTF-16 characters will be replaced with
|
|
||||||
* substitution characters appropriate for the character encoding.
|
|
||||||
*
|
|
||||||
* If the `buffer` argument is provided, one final call to `stringDecoder.write()`is performed before returning the remaining input.
|
|
||||||
* After `end()` is called, the `stringDecoder` object can be reused for new input.
|
|
||||||
* @since v0.9.3
|
|
||||||
* @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode.
|
|
||||||
*/
|
|
||||||
end(buffer?: Buffer): string;
|
end(buffer?: Buffer): string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module 'node:string_decoder' {
|
|
||||||
export * from 'string_decoder';
|
|
||||||
}
|
|
||||||
|
|||||||
+8
-86
@@ -1,94 +1,16 @@
|
|||||||
/**
|
declare module "timers" {
|
||||||
* The `timer` module exposes a global API for scheduling functions to
|
function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout;
|
||||||
* be called at some future period of time. Because the timer functions are
|
|
||||||
* globals, there is no need to call `require('timers')` to use the API.
|
|
||||||
*
|
|
||||||
* The timer functions within Node.js implement a similar API as the timers API
|
|
||||||
* provided by Web Browsers but use a different internal implementation that is
|
|
||||||
* built around the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout).
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/timers.js)
|
|
||||||
*/
|
|
||||||
declare module 'timers' {
|
|
||||||
import { Abortable } from 'node:events';
|
|
||||||
import { setTimeout as setTimeoutPromise, setImmediate as setImmediatePromise, setInterval as setIntervalPromise } from 'node:timers/promises';
|
|
||||||
interface TimerOptions extends Abortable {
|
|
||||||
/**
|
|
||||||
* Set to `false` to indicate that the scheduled `Timeout`
|
|
||||||
* should not require the Node.js event loop to remain active.
|
|
||||||
* @default true
|
|
||||||
*/
|
|
||||||
ref?: boolean | undefined;
|
|
||||||
}
|
|
||||||
let setTimeout: typeof global.setTimeout;
|
|
||||||
let clearTimeout: typeof global.clearTimeout;
|
|
||||||
let setInterval: typeof global.setInterval;
|
|
||||||
let clearInterval: typeof global.clearInterval;
|
|
||||||
let setImmediate: typeof global.setImmediate;
|
|
||||||
let clearImmediate: typeof global.clearImmediate;
|
|
||||||
global {
|
|
||||||
namespace NodeJS {
|
|
||||||
// compatibility with older typings
|
|
||||||
interface Timer extends RefCounted {
|
|
||||||
hasRef(): boolean;
|
|
||||||
refresh(): this;
|
|
||||||
[Symbol.toPrimitive](): number;
|
|
||||||
}
|
|
||||||
interface Immediate extends RefCounted {
|
|
||||||
/**
|
|
||||||
* If true, the `Immediate` object will keep the Node.js event loop active.
|
|
||||||
* @since v11.0.0
|
|
||||||
*/
|
|
||||||
hasRef(): boolean;
|
|
||||||
_onImmediate: Function; // to distinguish it from the Timeout class
|
|
||||||
}
|
|
||||||
interface Timeout extends Timer {
|
|
||||||
/**
|
|
||||||
* If true, the `Timeout` object will keep the Node.js event loop active.
|
|
||||||
* @since v11.0.0
|
|
||||||
*/
|
|
||||||
hasRef(): boolean;
|
|
||||||
/**
|
|
||||||
* Sets the timer's start time to the current time, and reschedules the timer to
|
|
||||||
* call its callback at the previously specified duration adjusted to the current
|
|
||||||
* time. This is useful for refreshing a timer without allocating a new
|
|
||||||
* JavaScript object.
|
|
||||||
*
|
|
||||||
* Using this on a timer that has already called its callback will reactivate the
|
|
||||||
* timer.
|
|
||||||
* @since v10.2.0
|
|
||||||
* @return a reference to `timeout`
|
|
||||||
*/
|
|
||||||
refresh(): this;
|
|
||||||
[Symbol.toPrimitive](): number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function setTimeout<TArgs extends any[]>(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timeout;
|
|
||||||
// util.promisify no rest args compability
|
|
||||||
// tslint:disable-next-line void-return
|
|
||||||
function setTimeout(callback: (args: void) => void, ms?: number): NodeJS.Timeout;
|
|
||||||
namespace setTimeout {
|
namespace setTimeout {
|
||||||
const __promisify__: typeof setTimeoutPromise;
|
function __promisify__(ms: number): Promise<void>;
|
||||||
|
function __promisify__<T>(ms: number, value: T): Promise<T>;
|
||||||
}
|
}
|
||||||
function clearTimeout(timeoutId: NodeJS.Timeout): void;
|
function clearTimeout(timeoutId: NodeJS.Timeout): void;
|
||||||
function setInterval<TArgs extends any[]>(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timer;
|
function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout;
|
||||||
// util.promisify no rest args compability
|
|
||||||
// tslint:disable-next-line void-return
|
|
||||||
function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timer;
|
|
||||||
namespace setInterval {
|
|
||||||
const __promisify__: typeof setIntervalPromise;
|
|
||||||
}
|
|
||||||
function clearInterval(intervalId: NodeJS.Timeout): void;
|
function clearInterval(intervalId: NodeJS.Timeout): void;
|
||||||
function setImmediate<TArgs extends any[]>(callback: (...args: TArgs) => void, ...args: TArgs): NodeJS.Immediate;
|
function setImmediate(callback: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate;
|
||||||
// util.promisify no rest args compability
|
|
||||||
// tslint:disable-next-line void-return
|
|
||||||
function setImmediate(callback: (args: void) => void): NodeJS.Immediate;
|
|
||||||
namespace setImmediate {
|
namespace setImmediate {
|
||||||
const __promisify__: typeof setImmediatePromise;
|
function __promisify__(): Promise<void>;
|
||||||
|
function __promisify__<T>(value: T): Promise<T>;
|
||||||
}
|
}
|
||||||
function clearImmediate(immediateId: NodeJS.Immediate): void;
|
function clearImmediate(immediateId: NodeJS.Immediate): void;
|
||||||
function queueMicrotask(callback: () => void): void;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
declare module 'node:timers' {
|
|
||||||
export * from 'timers';
|
|
||||||
}
|
}
|
||||||
|
|||||||
-113
@@ -1,113 +0,0 @@
|
|||||||
/**
|
|
||||||
* The `timers/promises` API provides an alternative set of timer functions
|
|
||||||
* that return `Promise` objects. The API is accessible via`require('timers/promises')`.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import {
|
|
||||||
* setTimeout,
|
|
||||||
* setImmediate,
|
|
||||||
* setInterval,
|
|
||||||
* } from 'timers/promises';
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const {
|
|
||||||
* setTimeout,
|
|
||||||
* setImmediate,
|
|
||||||
* setInterval,
|
|
||||||
* } = require('timers/promises');
|
|
||||||
* ```
|
|
||||||
* @since v15.0.0
|
|
||||||
*/
|
|
||||||
declare module 'timers/promises' {
|
|
||||||
import { TimerOptions } from 'node:timers';
|
|
||||||
/**
|
|
||||||
* ```js
|
|
||||||
* import {
|
|
||||||
* setTimeout,
|
|
||||||
* } from 'timers/promises';
|
|
||||||
*
|
|
||||||
* const res = await setTimeout(100, 'result');
|
|
||||||
*
|
|
||||||
* console.log(res); // Prints 'result'
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const {
|
|
||||||
* setTimeout,
|
|
||||||
* } = require('timers/promises');
|
|
||||||
*
|
|
||||||
* setTimeout(100, 'result').then((res) => {
|
|
||||||
* console.log(res); // Prints 'result'
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @since v15.0.0
|
|
||||||
* @param delay The number of milliseconds to wait before fulfilling the promise.
|
|
||||||
* @param value A value with which the promise is fulfilled.
|
|
||||||
*/
|
|
||||||
function setTimeout<T = void>(delay?: number, value?: T, options?: TimerOptions): Promise<T>;
|
|
||||||
/**
|
|
||||||
* ```js
|
|
||||||
* import {
|
|
||||||
* setImmediate,
|
|
||||||
* } from 'timers/promises';
|
|
||||||
*
|
|
||||||
* const res = await setImmediate('result');
|
|
||||||
*
|
|
||||||
* console.log(res); // Prints 'result'
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const {
|
|
||||||
* setImmediate,
|
|
||||||
* } = require('timers/promises');
|
|
||||||
*
|
|
||||||
* setImmediate('result').then((res) => {
|
|
||||||
* console.log(res); // Prints 'result'
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
* @since v15.0.0
|
|
||||||
* @param value A value with which the promise is fulfilled.
|
|
||||||
*/
|
|
||||||
function setImmediate<T = void>(value?: T, options?: TimerOptions): Promise<T>;
|
|
||||||
/**
|
|
||||||
* Returns an async iterator that generates values in an interval of `delay` ms.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import {
|
|
||||||
* setInterval,
|
|
||||||
* } from 'timers/promises';
|
|
||||||
*
|
|
||||||
* const interval = 100;
|
|
||||||
* for await (const startTime of setInterval(interval, Date.now())) {
|
|
||||||
* const now = Date.now();
|
|
||||||
* console.log(now);
|
|
||||||
* if ((now - startTime) > 1000)
|
|
||||||
* break;
|
|
||||||
* }
|
|
||||||
* console.log(Date.now());
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const {
|
|
||||||
* setInterval,
|
|
||||||
* } = require('timers/promises');
|
|
||||||
* const interval = 100;
|
|
||||||
*
|
|
||||||
* (async function() {
|
|
||||||
* for await (const startTime of setInterval(interval, Date.now())) {
|
|
||||||
* const now = Date.now();
|
|
||||||
* console.log(now);
|
|
||||||
* if ((now - startTime) > 1000)
|
|
||||||
* break;
|
|
||||||
* }
|
|
||||||
* console.log(Date.now());
|
|
||||||
* })();
|
|
||||||
* ```
|
|
||||||
* @since v15.9.0
|
|
||||||
*/
|
|
||||||
function setInterval<T = void>(delay?: number, value?: T, options?: TimerOptions): AsyncIterable<T>;
|
|
||||||
}
|
|
||||||
declare module 'node:timers/promises' {
|
|
||||||
export * from 'timers/promises';
|
|
||||||
}
|
|
||||||
+259
-576
File diff suppressed because it is too large
Load Diff
+11
-111
@@ -1,81 +1,4 @@
|
|||||||
/**
|
declare module "trace_events" {
|
||||||
* The `trace_events` module provides a mechanism to centralize tracing information
|
|
||||||
* generated by V8, Node.js core, and userspace code.
|
|
||||||
*
|
|
||||||
* Tracing can be enabled with the `--trace-event-categories` command-line flag
|
|
||||||
* or by using the `trace_events` module. The `--trace-event-categories` flag
|
|
||||||
* accepts a list of comma-separated category names.
|
|
||||||
*
|
|
||||||
* The available categories are:
|
|
||||||
*
|
|
||||||
* * `node`: An empty placeholder.
|
|
||||||
* * `node.async_hooks`: Enables capture of detailed `async_hooks` trace data.
|
|
||||||
* The `async_hooks` events have a unique `asyncId` and a special `triggerId` `triggerAsyncId` property.
|
|
||||||
* * `node.bootstrap`: Enables capture of Node.js bootstrap milestones.
|
|
||||||
* * `node.console`: Enables capture of `console.time()` and `console.count()`output.
|
|
||||||
* * `node.dns.native`: Enables capture of trace data for DNS queries.
|
|
||||||
* * `node.environment`: Enables capture of Node.js Environment milestones.
|
|
||||||
* * `node.fs.sync`: Enables capture of trace data for file system sync methods.
|
|
||||||
* * `node.perf`: Enables capture of `Performance API` measurements.
|
|
||||||
* * `node.perf.usertiming`: Enables capture of only Performance API User Timing
|
|
||||||
* measures and marks.
|
|
||||||
* * `node.perf.timerify`: Enables capture of only Performance API timerify
|
|
||||||
* measurements.
|
|
||||||
* * `node.promises.rejections`: Enables capture of trace data tracking the number
|
|
||||||
* of unhandled Promise rejections and handled-after-rejections.
|
|
||||||
* * `node.vm.script`: Enables capture of trace data for the `vm` module's`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods.
|
|
||||||
* * `v8`: The `V8` events are GC, compiling, and execution related.
|
|
||||||
*
|
|
||||||
* By default the `node`, `node.async_hooks`, and `v8` categories are enabled.
|
|
||||||
*
|
|
||||||
* ```bash
|
|
||||||
* node --trace-event-categories v8,node,node.async_hooks server.js
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Prior versions of Node.js required the use of the `--trace-events-enabled`flag to enable trace events. This requirement has been removed. However, the`--trace-events-enabled` flag _may_ still be
|
|
||||||
* used and will enable the`node`, `node.async_hooks`, and `v8` trace event categories by default.
|
|
||||||
*
|
|
||||||
* ```bash
|
|
||||||
* node --trace-events-enabled
|
|
||||||
*
|
|
||||||
* # is equivalent to
|
|
||||||
*
|
|
||||||
* node --trace-event-categories v8,node,node.async_hooks
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Alternatively, trace events may be enabled using the `trace_events` module:
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const trace_events = require('trace_events');
|
|
||||||
* const tracing = trace_events.createTracing({ categories: ['node.perf'] });
|
|
||||||
* tracing.enable(); // Enable trace event capture for the 'node.perf' category
|
|
||||||
*
|
|
||||||
* // do work
|
|
||||||
*
|
|
||||||
* tracing.disable(); // Disable trace event capture for the 'node.perf' category
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Running Node.js with tracing enabled will produce log files that can be opened
|
|
||||||
* in the [`chrome://tracing`](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool)tab of Chrome.
|
|
||||||
*
|
|
||||||
* The logging file is by default called `node_trace.${rotation}.log`, where`${rotation}` is an incrementing log-rotation id. The filepath pattern can
|
|
||||||
* be specified with `--trace-event-file-pattern` that accepts a template
|
|
||||||
* string that supports `${rotation}` and `${pid}`:
|
|
||||||
*
|
|
||||||
* ```bash
|
|
||||||
* node --trace-event-categories v8 --trace-event-file-pattern '${pid}-${rotation}.log' server.js
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* The tracing system uses the same time source
|
|
||||||
* as the one used by `process.hrtime()`.
|
|
||||||
* However the trace-event timestamps are expressed in microseconds,
|
|
||||||
* unlike `process.hrtime()` which returns nanoseconds.
|
|
||||||
*
|
|
||||||
* The features from this module are not available in `Worker` threads.
|
|
||||||
* @experimental
|
|
||||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/trace_events.js)
|
|
||||||
*/
|
|
||||||
declare module 'trace_events' {
|
|
||||||
/**
|
/**
|
||||||
* The `Tracing` object is used to enable or disable tracing for sets of
|
* The `Tracing` object is used to enable or disable tracing for sets of
|
||||||
* categories. Instances are created using the
|
* categories. Instances are created using the
|
||||||
@@ -92,6 +15,7 @@ declare module 'trace_events' {
|
|||||||
* `Tracing` object.
|
* `Tracing` object.
|
||||||
*/
|
*/
|
||||||
readonly categories: string;
|
readonly categories: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables this `Tracing` object.
|
* Disables this `Tracing` object.
|
||||||
*
|
*
|
||||||
@@ -100,16 +24,19 @@ declare module 'trace_events' {
|
|||||||
* will be disabled.
|
* will be disabled.
|
||||||
*/
|
*/
|
||||||
disable(): void;
|
disable(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables this `Tracing` object for the set of categories covered by
|
* Enables this `Tracing` object for the set of categories covered by
|
||||||
* the `Tracing` object.
|
* the `Tracing` object.
|
||||||
*/
|
*/
|
||||||
enable(): void;
|
enable(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `true` only if the `Tracing` object has been enabled.
|
* `true` only if the `Tracing` object has been enabled.
|
||||||
*/
|
*/
|
||||||
readonly enabled: boolean;
|
readonly enabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CreateTracingOptions {
|
interface CreateTracingOptions {
|
||||||
/**
|
/**
|
||||||
* An array of trace category names. Values included in the array are
|
* An array of trace category names. Values included in the array are
|
||||||
@@ -118,44 +45,17 @@ declare module 'trace_events' {
|
|||||||
*/
|
*/
|
||||||
categories: string[];
|
categories: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a `Tracing` object for the given set of `categories`.
|
* Creates and returns a Tracing object for the given set of categories.
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const trace_events = require('trace_events');
|
|
||||||
* const categories = ['node.perf', 'node.async_hooks'];
|
|
||||||
* const tracing = trace_events.createTracing({ categories });
|
|
||||||
* tracing.enable();
|
|
||||||
* // do stuff
|
|
||||||
* tracing.disable();
|
|
||||||
* ```
|
|
||||||
* @since v10.0.0
|
|
||||||
* @return .
|
|
||||||
*/
|
*/
|
||||||
function createTracing(options: CreateTracingOptions): Tracing;
|
function createTracing(options: CreateTracingOptions): Tracing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a comma-separated list of all currently-enabled trace event
|
* Returns a comma-separated list of all currently-enabled trace event
|
||||||
* categories. The current set of enabled trace event categories is determined
|
* categories. The current set of enabled trace event categories is
|
||||||
* by the _union_ of all currently-enabled `Tracing` objects and any categories
|
* determined by the union of all currently-enabled `Tracing` objects and
|
||||||
* enabled using the `--trace-event-categories` flag.
|
* any categories enabled using the `--trace-event-categories` flag.
|
||||||
*
|
|
||||||
* Given the file `test.js` below, the command`node --trace-event-categories node.perf test.js` will print`'node.async_hooks,node.perf'` to the console.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const trace_events = require('trace_events');
|
|
||||||
* const t1 = trace_events.createTracing({ categories: ['node.async_hooks'] });
|
|
||||||
* const t2 = trace_events.createTracing({ categories: ['node.perf'] });
|
|
||||||
* const t3 = trace_events.createTracing({ categories: ['v8'] });
|
|
||||||
*
|
|
||||||
* t1.enable();
|
|
||||||
* t2.enable();
|
|
||||||
*
|
|
||||||
* console.log(trace_events.getEnabledCategories());
|
|
||||||
* ```
|
|
||||||
* @since v10.0.0
|
|
||||||
*/
|
*/
|
||||||
function getEnabledCategories(): string | undefined;
|
function getEnabledCategories(): string | undefined;
|
||||||
}
|
}
|
||||||
declare module 'node:trace_events' {
|
|
||||||
export * from 'trace_events';
|
|
||||||
}
|
|
||||||
|
|||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
declare module 'assert' {
|
||||||
|
function assert(value: any, message?: string | Error): void;
|
||||||
|
namespace assert {
|
||||||
|
class AssertionError implements Error {
|
||||||
|
name: string;
|
||||||
|
message: string;
|
||||||
|
actual: any;
|
||||||
|
expected: any;
|
||||||
|
operator: string;
|
||||||
|
generatedMessage: boolean;
|
||||||
|
code: 'ERR_ASSERTION';
|
||||||
|
|
||||||
|
constructor(options?: {
|
||||||
|
message?: string;
|
||||||
|
actual?: any;
|
||||||
|
expected?: any;
|
||||||
|
operator?: string;
|
||||||
|
stackStartFn?: Function;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function fail(message?: string | Error): never;
|
||||||
|
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
|
||||||
|
function fail(
|
||||||
|
actual: any,
|
||||||
|
expected: any,
|
||||||
|
message?: string | Error,
|
||||||
|
operator?: string,
|
||||||
|
stackStartFn?: Function,
|
||||||
|
): never;
|
||||||
|
function ok(value: any, message?: string | Error): void;
|
||||||
|
/** @deprecated since v9.9.0 - use strictEqual() instead. */
|
||||||
|
function equal(actual: any, expected: any, message?: string | Error): void;
|
||||||
|
/** @deprecated since v9.9.0 - use notStrictEqual() instead. */
|
||||||
|
function notEqual(actual: any, expected: any, message?: string | Error): void;
|
||||||
|
/** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
|
||||||
|
function deepEqual(actual: any, expected: any, message?: string | Error): void;
|
||||||
|
/** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
|
||||||
|
function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
|
||||||
|
function strictEqual(actual: any, expected: any, message?: string | Error): void;
|
||||||
|
function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
|
||||||
|
function deepStrictEqual(actual: any, expected: any, message?: string | Error): void;
|
||||||
|
function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void;
|
||||||
|
|
||||||
|
function throws(block: () => any, message?: string | Error): void;
|
||||||
|
function throws(block: () => any, error: RegExp | Function | Object | Error, message?: string | Error): void;
|
||||||
|
function doesNotThrow(block: () => any, message?: string | Error): void;
|
||||||
|
function doesNotThrow(block: () => any, error: RegExp | Function, message?: string | Error): void;
|
||||||
|
|
||||||
|
function ifError(value: any): void;
|
||||||
|
|
||||||
|
function rejects(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
|
||||||
|
function rejects(
|
||||||
|
block: (() => Promise<any>) | Promise<any>,
|
||||||
|
error: RegExp | Function | Object | Error,
|
||||||
|
message?: string | Error,
|
||||||
|
): Promise<void>;
|
||||||
|
function doesNotReject(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
|
||||||
|
function doesNotReject(
|
||||||
|
block: (() => Promise<any>) | Promise<any>,
|
||||||
|
error: RegExp | Function,
|
||||||
|
message?: string | Error,
|
||||||
|
): Promise<void>;
|
||||||
|
|
||||||
|
const strict: typeof assert;
|
||||||
|
}
|
||||||
|
|
||||||
|
export = assert;
|
||||||
|
}
|
||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
// NOTE: These definitions support NodeJS and TypeScript 3.2.
|
||||||
|
|
||||||
|
// 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.2/base.d.ts - Definitions specific to TypeScript 3.2
|
||||||
|
// - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2 with global and 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="../globals.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" />
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
declare var global: NodeJS.Global;
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
// NOTE: These definitions support NodeJS and TypeScript 3.2.
|
||||||
|
// This is requried to enable globalThis support for global in ts3.4 without causing errors
|
||||||
|
// This is requried to enable typing assert in ts3.7 without causing errors
|
||||||
|
// Typically type modifiations should be made in base.d.ts instead of here
|
||||||
|
|
||||||
|
/// <reference path="base.d.ts" />
|
||||||
|
/// <reference path="assert.d.ts" />
|
||||||
|
/// <reference path="globals.global.d.ts" />
|
||||||
-103
@@ -1,103 +0,0 @@
|
|||||||
declare module 'assert' {
|
|
||||||
/** An alias of `assert.ok()`. */
|
|
||||||
function assert(value: unknown, message?: string | Error): void;
|
|
||||||
namespace assert {
|
|
||||||
class AssertionError extends Error {
|
|
||||||
actual: unknown;
|
|
||||||
expected: unknown;
|
|
||||||
operator: string;
|
|
||||||
generatedMessage: boolean;
|
|
||||||
code: 'ERR_ASSERTION';
|
|
||||||
|
|
||||||
constructor(options?: {
|
|
||||||
/** If provided, the error message is set to this value. */
|
|
||||||
message?: string;
|
|
||||||
/** The `actual` property on the error instance. */
|
|
||||||
actual?: unknown;
|
|
||||||
/** The `expected` property on the error instance. */
|
|
||||||
expected?: unknown;
|
|
||||||
/** The `operator` property on the error instance. */
|
|
||||||
operator?: string;
|
|
||||||
/** If provided, the generated stack trace omits frames before this function. */
|
|
||||||
// tslint:disable-next-line:ban-types
|
|
||||||
stackStartFn?: Function;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
class CallTracker {
|
|
||||||
calls(exact?: number): () => void;
|
|
||||||
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
|
|
||||||
report(): CallTrackerReportInformation[];
|
|
||||||
verify(): void;
|
|
||||||
}
|
|
||||||
interface CallTrackerReportInformation {
|
|
||||||
message: string;
|
|
||||||
/** The actual number of times the function was called. */
|
|
||||||
actual: number;
|
|
||||||
/** The number of times the function was expected to be called. */
|
|
||||||
expected: number;
|
|
||||||
/** The name of the function that is wrapped. */
|
|
||||||
operator: string;
|
|
||||||
/** A stack trace of the function. */
|
|
||||||
stack: object;
|
|
||||||
}
|
|
||||||
|
|
||||||
type AssertPredicate = RegExp | (new () => object) | ((thrown: unknown) => boolean) | object | Error;
|
|
||||||
|
|
||||||
function fail(message?: string | Error): never;
|
|
||||||
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
|
|
||||||
function fail(
|
|
||||||
actual: unknown,
|
|
||||||
expected: unknown,
|
|
||||||
message?: string | Error,
|
|
||||||
operator?: string,
|
|
||||||
// tslint:disable-next-line:ban-types
|
|
||||||
stackStartFn?: Function,
|
|
||||||
): never;
|
|
||||||
function ok(value: unknown, message?: string | Error): void;
|
|
||||||
/** @deprecated since v9.9.0 - use strictEqual() instead. */
|
|
||||||
function equal(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
/** @deprecated since v9.9.0 - use notStrictEqual() instead. */
|
|
||||||
function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
/** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
|
|
||||||
function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
/** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
|
|
||||||
function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
function strictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
function deepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
|
||||||
|
|
||||||
function throws(block: () => unknown, message?: string | Error): void;
|
|
||||||
function throws(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
|
||||||
function doesNotThrow(block: () => unknown, message?: string | Error): void;
|
|
||||||
function doesNotThrow(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
|
||||||
|
|
||||||
function ifError(value: unknown): void;
|
|
||||||
|
|
||||||
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
|
||||||
function rejects(
|
|
||||||
block: (() => Promise<unknown>) | Promise<unknown>,
|
|
||||||
error: AssertPredicate,
|
|
||||||
message?: string | Error,
|
|
||||||
): Promise<void>;
|
|
||||||
function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
|
||||||
function doesNotReject(
|
|
||||||
block: (() => Promise<unknown>) | Promise<unknown>,
|
|
||||||
error: AssertPredicate,
|
|
||||||
message?: string | Error,
|
|
||||||
): Promise<void>;
|
|
||||||
|
|
||||||
function match(value: string, regExp: RegExp, message?: string | Error): void;
|
|
||||||
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
|
|
||||||
|
|
||||||
const strict: typeof assert;
|
|
||||||
}
|
|
||||||
|
|
||||||
export = assert;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module 'node:assert' {
|
|
||||||
import assert = require('assert');
|
|
||||||
export = assert;
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user