mirror of
https://github.com/github/codeql-action.git
synced 2026-04-13 18:13:30 +00:00
Merge pull request #3001 from github/dependabot/npm_and_yarn/npm-5c47c8ab2f
Bump the npm group with 5 updates
This commit is contained in:
259
node_modules/.package-lock.json
generated
vendored
259
node_modules/.package-lock.json
generated
vendored
@@ -1015,9 +1015,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@mswjs/interceptors": {
|
||||
"version": "0.39.3",
|
||||
"resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.39.3.tgz",
|
||||
"integrity": "sha512-9bw/wBL7pblsnOCIqvn1788S9o4h+cC5HWXg0Xhh0dOzsZ53IyfmBM+FYqpDDPbm0xjCqEqvCITloF3Dm4TXRQ==",
|
||||
"version": "0.39.5",
|
||||
"resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.39.5.tgz",
|
||||
"integrity": "sha512-B9nHSJYtsv79uo7QdkZ/b/WoKm20IkVSmTc/WCKarmDtFwM0dRx2ouEniqwNkzCSLn3fydzKmnMzjtfdOWt3VQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -1943,10 +1943,12 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.9.0",
|
||||
"version": "20.19.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.9.tgz",
|
||||
"integrity": "sha512-cuVNgarYWZqxRJDQHEB58GEONhOK79QVR/qYx4S7kcUObQvUwvFnYxJuuHUKm2aieN9X3yZB4LZsuYNU1Qphsw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node-forge": {
|
||||
@@ -1994,17 +1996,17 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.38.0.tgz",
|
||||
"integrity": "sha512-CPoznzpuAnIOl4nhj4tRr4gIPj5AfKgkiJmGQDaq+fQnRJTYlcBjbX3wbciGmpoPf8DREufuPRe1tNMZnGdanA==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.39.0.tgz",
|
||||
"integrity": "sha512-bhEz6OZeUR+O/6yx9Jk6ohX6H9JSFTaiY0v9/PuKT3oGK0rn0jNplLmyFUGV+a9gfYnVNwGDwS/UkLIuXNb2Rw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/regexpp": "^4.10.0",
|
||||
"@typescript-eslint/scope-manager": "8.38.0",
|
||||
"@typescript-eslint/type-utils": "8.38.0",
|
||||
"@typescript-eslint/utils": "8.38.0",
|
||||
"@typescript-eslint/visitor-keys": "8.38.0",
|
||||
"@typescript-eslint/scope-manager": "8.39.0",
|
||||
"@typescript-eslint/type-utils": "8.39.0",
|
||||
"@typescript-eslint/utils": "8.39.0",
|
||||
"@typescript-eslint/visitor-keys": "8.39.0",
|
||||
"graphemer": "^1.4.0",
|
||||
"ignore": "^7.0.0",
|
||||
"natural-compare": "^1.4.0",
|
||||
@@ -2018,20 +2020,20 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@typescript-eslint/parser": "^8.38.0",
|
||||
"@typescript-eslint/parser": "^8.39.0",
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <5.9.0"
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.38.0.tgz",
|
||||
"integrity": "sha512-WJw3AVlFFcdT9Ri1xs/lg8LwDqgekWXWhH3iAF+1ZM+QPd7oxQ6jvtW/JPwzAScxitILUIFs0/AnQ/UWHzbATQ==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.39.0.tgz",
|
||||
"integrity": "sha512-8QOzff9UKxOh6npZQ/4FQu4mjdOCGSdO3p44ww0hk8Vu+IGbg0tB/H1LcTARRDzGCC8pDGbh2rissBuuoPgH8A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.38.0",
|
||||
"@typescript-eslint/visitor-keys": "8.38.0"
|
||||
"@typescript-eslint/types": "8.39.0",
|
||||
"@typescript-eslint/visitor-keys": "8.39.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -2042,9 +2044,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.38.0.tgz",
|
||||
"integrity": "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.39.0.tgz",
|
||||
"integrity": "sha512-ArDdaOllnCj3yn/lzKn9s0pBQYmmyme/v1HbGIGB0GB/knFI3fWMHloC+oYTJW46tVbYnGKTMDK4ah1sC2v0Kg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -2056,16 +2058,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.38.0.tgz",
|
||||
"integrity": "sha512-fooELKcAKzxux6fA6pxOflpNS0jc+nOQEEOipXFNjSlBS6fqrJOVY/whSn70SScHrcJ2LDsxWrneFoWYSVfqhQ==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.39.0.tgz",
|
||||
"integrity": "sha512-ndWdiflRMvfIgQRpckQQLiB5qAKQ7w++V4LlCHwp62eym1HLB/kw7D9f2e8ytONls/jt89TEasgvb+VwnRprsw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/project-service": "8.38.0",
|
||||
"@typescript-eslint/tsconfig-utils": "8.38.0",
|
||||
"@typescript-eslint/types": "8.38.0",
|
||||
"@typescript-eslint/visitor-keys": "8.38.0",
|
||||
"@typescript-eslint/project-service": "8.39.0",
|
||||
"@typescript-eslint/tsconfig-utils": "8.39.0",
|
||||
"@typescript-eslint/types": "8.39.0",
|
||||
"@typescript-eslint/visitor-keys": "8.39.0",
|
||||
"debug": "^4.3.4",
|
||||
"fast-glob": "^3.3.2",
|
||||
"is-glob": "^4.0.3",
|
||||
@@ -2081,20 +2083,20 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=4.8.4 <5.9.0"
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.38.0.tgz",
|
||||
"integrity": "sha512-hHcMA86Hgt+ijJlrD8fX0j1j8w4C92zue/8LOPAFioIno+W0+L7KqE8QZKCcPGc/92Vs9x36w/4MPTJhqXdyvg==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.39.0.tgz",
|
||||
"integrity": "sha512-4GVSvNA0Vx1Ktwvf4sFE+exxJ3QGUorQG1/A5mRfRNZtkBT2xrA/BCO2H0eALx/PnvCS6/vmYwRdDA41EoffkQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.7.0",
|
||||
"@typescript-eslint/scope-manager": "8.38.0",
|
||||
"@typescript-eslint/types": "8.38.0",
|
||||
"@typescript-eslint/typescript-estree": "8.38.0"
|
||||
"@typescript-eslint/scope-manager": "8.39.0",
|
||||
"@typescript-eslint/types": "8.39.0",
|
||||
"@typescript-eslint/typescript-estree": "8.39.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -2105,17 +2107,17 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <5.9.0"
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.38.0.tgz",
|
||||
"integrity": "sha512-pWrTcoFNWuwHlA9CvlfSsGWs14JxfN1TH25zM5L7o0pRLhsoZkDnTsXfQRJBEWJoV5DL0jf+Z+sxiud+K0mq1g==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.39.0.tgz",
|
||||
"integrity": "sha512-ldgiJ+VAhQCfIjeOgu8Kj5nSxds0ktPOSO9p4+0VDH2R2pLvQraaM5Oen2d7NxzMCm+Sn/vJT+mv2H5u6b/3fA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.38.0",
|
||||
"@typescript-eslint/types": "8.39.0",
|
||||
"eslint-visitor-keys": "^4.2.1"
|
||||
},
|
||||
"engines": {
|
||||
@@ -2188,16 +2190,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.38.0.tgz",
|
||||
"integrity": "sha512-Zhy8HCvBUEfBECzIl1PKqF4p11+d0aUJS1GeUiuqK9WmOug8YCmC4h4bjyBvMyAMI9sbRczmrYL5lKg/YMbrcQ==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.39.0.tgz",
|
||||
"integrity": "sha512-g3WpVQHngx0aLXn6kfIYCZxM6rRJlWzEkVpqEFLT3SgEDsp9cpCbxxgwnE504q4H+ruSDh/VGS6nqZIDynP+vg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "8.38.0",
|
||||
"@typescript-eslint/types": "8.38.0",
|
||||
"@typescript-eslint/typescript-estree": "8.38.0",
|
||||
"@typescript-eslint/visitor-keys": "8.38.0",
|
||||
"@typescript-eslint/scope-manager": "8.39.0",
|
||||
"@typescript-eslint/types": "8.39.0",
|
||||
"@typescript-eslint/typescript-estree": "8.39.0",
|
||||
"@typescript-eslint/visitor-keys": "8.39.0",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
@@ -2209,18 +2211,18 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <5.9.0"
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.38.0.tgz",
|
||||
"integrity": "sha512-WJw3AVlFFcdT9Ri1xs/lg8LwDqgekWXWhH3iAF+1ZM+QPd7oxQ6jvtW/JPwzAScxitILUIFs0/AnQ/UWHzbATQ==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.39.0.tgz",
|
||||
"integrity": "sha512-8QOzff9UKxOh6npZQ/4FQu4mjdOCGSdO3p44ww0hk8Vu+IGbg0tB/H1LcTARRDzGCC8pDGbh2rissBuuoPgH8A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.38.0",
|
||||
"@typescript-eslint/visitor-keys": "8.38.0"
|
||||
"@typescript-eslint/types": "8.39.0",
|
||||
"@typescript-eslint/visitor-keys": "8.39.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -2231,9 +2233,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.38.0.tgz",
|
||||
"integrity": "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.39.0.tgz",
|
||||
"integrity": "sha512-ArDdaOllnCj3yn/lzKn9s0pBQYmmyme/v1HbGIGB0GB/knFI3fWMHloC+oYTJW46tVbYnGKTMDK4ah1sC2v0Kg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -2245,16 +2247,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.38.0.tgz",
|
||||
"integrity": "sha512-fooELKcAKzxux6fA6pxOflpNS0jc+nOQEEOipXFNjSlBS6fqrJOVY/whSn70SScHrcJ2LDsxWrneFoWYSVfqhQ==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.39.0.tgz",
|
||||
"integrity": "sha512-ndWdiflRMvfIgQRpckQQLiB5qAKQ7w++V4LlCHwp62eym1HLB/kw7D9f2e8ytONls/jt89TEasgvb+VwnRprsw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/project-service": "8.38.0",
|
||||
"@typescript-eslint/tsconfig-utils": "8.38.0",
|
||||
"@typescript-eslint/types": "8.38.0",
|
||||
"@typescript-eslint/visitor-keys": "8.38.0",
|
||||
"@typescript-eslint/project-service": "8.39.0",
|
||||
"@typescript-eslint/tsconfig-utils": "8.39.0",
|
||||
"@typescript-eslint/types": "8.39.0",
|
||||
"@typescript-eslint/visitor-keys": "8.39.0",
|
||||
"debug": "^4.3.4",
|
||||
"fast-glob": "^3.3.2",
|
||||
"is-glob": "^4.0.3",
|
||||
@@ -2270,17 +2272,17 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=4.8.4 <5.9.0"
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.38.0.tgz",
|
||||
"integrity": "sha512-pWrTcoFNWuwHlA9CvlfSsGWs14JxfN1TH25zM5L7o0pRLhsoZkDnTsXfQRJBEWJoV5DL0jf+Z+sxiud+K0mq1g==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.39.0.tgz",
|
||||
"integrity": "sha512-ldgiJ+VAhQCfIjeOgu8Kj5nSxds0ktPOSO9p4+0VDH2R2pLvQraaM5Oen2d7NxzMCm+Sn/vJT+mv2H5u6b/3fA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.38.0",
|
||||
"@typescript-eslint/types": "8.39.0",
|
||||
"eslint-visitor-keys": "^4.2.1"
|
||||
},
|
||||
"engines": {
|
||||
@@ -2344,14 +2346,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/project-service": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.38.0.tgz",
|
||||
"integrity": "sha512-dbK7Jvqcb8c9QfH01YB6pORpqX1mn5gDZc9n63Ak/+jD67oWXn3Gs0M6vddAN+eDXBCS5EmNWzbSxsn9SzFWWg==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.39.0.tgz",
|
||||
"integrity": "sha512-CTzJqaSq30V/Z2Og9jogzZt8lJRR5TKlAdXmWgdu4hgcC9Kww5flQ+xFvMxIBWVNdxJO7OifgdOK4PokMIWPew==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/tsconfig-utils": "^8.38.0",
|
||||
"@typescript-eslint/types": "^8.38.0",
|
||||
"@typescript-eslint/tsconfig-utils": "^8.39.0",
|
||||
"@typescript-eslint/types": "^8.39.0",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
@@ -2362,13 +2364,13 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=4.8.4 <5.9.0"
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/project-service/node_modules/@typescript-eslint/types": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.38.0.tgz",
|
||||
"integrity": "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.39.0.tgz",
|
||||
"integrity": "sha512-ArDdaOllnCj3yn/lzKn9s0pBQYmmyme/v1HbGIGB0GB/knFI3fWMHloC+oYTJW46tVbYnGKTMDK4ah1sC2v0Kg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -2398,9 +2400,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/tsconfig-utils": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.38.0.tgz",
|
||||
"integrity": "sha512-Lum9RtSE3EroKk/bYns+sPOodqb2Fv50XOl/gMviMKNvanETUuUcC9ObRbzrJ4VSd2JalPqgSAavwrPiPvnAiQ==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.39.0.tgz",
|
||||
"integrity": "sha512-Fd3/QjmFV2sKmvv3Mrj8r6N8CryYiCS8Wdb/6/rgOXAWGcFuc+VkQuG28uk/4kVNVZBQuuDHEDUpo/pQ32zsIQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -2411,19 +2413,19 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=4.8.4 <5.9.0"
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.38.0.tgz",
|
||||
"integrity": "sha512-c7jAvGEZVf0ao2z+nnz8BUaHZD09Agbh+DY7qvBQqLiz8uJzRgVPj5YvOh8I8uEiH8oIUGIfHzMwUcGVco/SJg==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.39.0.tgz",
|
||||
"integrity": "sha512-6B3z0c1DXVT2vYA9+z9axjtc09rqKUPRmijD5m9iv8iQpHBRYRMBcgxSiKTZKm6FwWw1/cI4v6em35OsKCiN5Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.38.0",
|
||||
"@typescript-eslint/typescript-estree": "8.38.0",
|
||||
"@typescript-eslint/utils": "8.38.0",
|
||||
"@typescript-eslint/types": "8.39.0",
|
||||
"@typescript-eslint/typescript-estree": "8.39.0",
|
||||
"@typescript-eslint/utils": "8.39.0",
|
||||
"debug": "^4.3.4",
|
||||
"ts-api-utils": "^2.1.0"
|
||||
},
|
||||
@@ -2436,18 +2438,18 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <5.9.0"
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.38.0.tgz",
|
||||
"integrity": "sha512-WJw3AVlFFcdT9Ri1xs/lg8LwDqgekWXWhH3iAF+1ZM+QPd7oxQ6jvtW/JPwzAScxitILUIFs0/AnQ/UWHzbATQ==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.39.0.tgz",
|
||||
"integrity": "sha512-8QOzff9UKxOh6npZQ/4FQu4mjdOCGSdO3p44ww0hk8Vu+IGbg0tB/H1LcTARRDzGCC8pDGbh2rissBuuoPgH8A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.38.0",
|
||||
"@typescript-eslint/visitor-keys": "8.38.0"
|
||||
"@typescript-eslint/types": "8.39.0",
|
||||
"@typescript-eslint/visitor-keys": "8.39.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -2458,9 +2460,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/types": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.38.0.tgz",
|
||||
"integrity": "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.39.0.tgz",
|
||||
"integrity": "sha512-ArDdaOllnCj3yn/lzKn9s0pBQYmmyme/v1HbGIGB0GB/knFI3fWMHloC+oYTJW46tVbYnGKTMDK4ah1sC2v0Kg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -2472,16 +2474,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.38.0.tgz",
|
||||
"integrity": "sha512-fooELKcAKzxux6fA6pxOflpNS0jc+nOQEEOipXFNjSlBS6fqrJOVY/whSn70SScHrcJ2LDsxWrneFoWYSVfqhQ==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.39.0.tgz",
|
||||
"integrity": "sha512-ndWdiflRMvfIgQRpckQQLiB5qAKQ7w++V4LlCHwp62eym1HLB/kw7D9f2e8ytONls/jt89TEasgvb+VwnRprsw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/project-service": "8.38.0",
|
||||
"@typescript-eslint/tsconfig-utils": "8.38.0",
|
||||
"@typescript-eslint/types": "8.38.0",
|
||||
"@typescript-eslint/visitor-keys": "8.38.0",
|
||||
"@typescript-eslint/project-service": "8.39.0",
|
||||
"@typescript-eslint/tsconfig-utils": "8.39.0",
|
||||
"@typescript-eslint/types": "8.39.0",
|
||||
"@typescript-eslint/visitor-keys": "8.39.0",
|
||||
"debug": "^4.3.4",
|
||||
"fast-glob": "^3.3.2",
|
||||
"is-glob": "^4.0.3",
|
||||
@@ -2497,20 +2499,20 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=4.8.4 <5.9.0"
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/utils": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.38.0.tgz",
|
||||
"integrity": "sha512-hHcMA86Hgt+ijJlrD8fX0j1j8w4C92zue/8LOPAFioIno+W0+L7KqE8QZKCcPGc/92Vs9x36w/4MPTJhqXdyvg==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.39.0.tgz",
|
||||
"integrity": "sha512-4GVSvNA0Vx1Ktwvf4sFE+exxJ3QGUorQG1/A5mRfRNZtkBT2xrA/BCO2H0eALx/PnvCS6/vmYwRdDA41EoffkQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.7.0",
|
||||
"@typescript-eslint/scope-manager": "8.38.0",
|
||||
"@typescript-eslint/types": "8.38.0",
|
||||
"@typescript-eslint/typescript-estree": "8.38.0"
|
||||
"@typescript-eslint/scope-manager": "8.39.0",
|
||||
"@typescript-eslint/types": "8.39.0",
|
||||
"@typescript-eslint/typescript-estree": "8.39.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -2521,17 +2523,17 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.57.0 || ^9.0.0",
|
||||
"typescript": ">=4.8.4 <5.9.0"
|
||||
"typescript": ">=4.8.4 <6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "8.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.38.0.tgz",
|
||||
"integrity": "sha512-pWrTcoFNWuwHlA9CvlfSsGWs14JxfN1TH25zM5L7o0pRLhsoZkDnTsXfQRJBEWJoV5DL0jf+Z+sxiud+K0mq1g==",
|
||||
"version": "8.39.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.39.0.tgz",
|
||||
"integrity": "sha512-ldgiJ+VAhQCfIjeOgu8Kj5nSxds0ktPOSO9p4+0VDH2R2pLvQraaM5Oen2d7NxzMCm+Sn/vJT+mv2H5u6b/3fA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.38.0",
|
||||
"@typescript-eslint/types": "8.39.0",
|
||||
"eslint-visitor-keys": "^4.2.1"
|
||||
},
|
||||
"engines": {
|
||||
@@ -5213,9 +5215,9 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.9",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
|
||||
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
|
||||
"version": "1.15.11",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz",
|
||||
"integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
@@ -6502,13 +6504,13 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/nock": {
|
||||
"version": "14.0.7",
|
||||
"resolved": "https://registry.npmjs.org/nock/-/nock-14.0.7.tgz",
|
||||
"integrity": "sha512-ubwvvhSzNPqc7Nm3a/iYolwqb7lo1zfllDKO1ODsYu3KnarmQEya5yV70ZUwhVxYIl1ePuX3W+lHw2un+pUfpQ==",
|
||||
"version": "14.0.8",
|
||||
"resolved": "https://registry.npmjs.org/nock/-/nock-14.0.8.tgz",
|
||||
"integrity": "sha512-5DCGrkwK1f8kxUvqvzLWb97XuDUY4/t5M3ZcogPfLGvC2wO8wjRQsIDSXj2L6e1J0Dv8xscf9wWSvGnS3OL29Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@mswjs/interceptors": "^0.39.3",
|
||||
"@mswjs/interceptors": "^0.39.5",
|
||||
"json-stringify-safe": "^5.0.1",
|
||||
"propagate": "^2.0.0"
|
||||
},
|
||||
@@ -8209,10 +8211,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.8.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
|
||||
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
|
||||
"version": "5.9.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz",
|
||||
"integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
@@ -8362,7 +8365,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "5.26.5",
|
||||
"version": "6.21.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/unicorn-magic": {
|
||||
|
||||
4
node_modules/@mswjs/interceptors/lib/node/RemoteHttpInterceptor.js
generated
vendored
4
node_modules/@mswjs/interceptors/lib/node/RemoteHttpInterceptor.js
generated
vendored
@@ -3,7 +3,7 @@
|
||||
var _chunkR6JVCM7Xjs = require('./chunk-R6JVCM7X.js');
|
||||
|
||||
|
||||
var _chunkF6CVST3Sjs = require('./chunk-F6CVST3S.js');
|
||||
var _chunkATZKM2BZjs = require('./chunk-ATZKM2BZ.js');
|
||||
require('./chunk-4YBV77DG.js');
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ var RemoteHttpInterceptor = class extends _chunkR6JVCM7Xjs.BatchInterceptor {
|
||||
super({
|
||||
name: "remote-interceptor",
|
||||
interceptors: [
|
||||
new (0, _chunkF6CVST3Sjs.ClientRequestInterceptor)(),
|
||||
new (0, _chunkATZKM2BZjs.ClientRequestInterceptor)(),
|
||||
new (0, _chunk4WG2AM2Tjs.XMLHttpRequestInterceptor)(),
|
||||
new (0, _chunkYAIEISARjs.FetchInterceptor)()
|
||||
]
|
||||
|
||||
2
node_modules/@mswjs/interceptors/lib/node/RemoteHttpInterceptor.mjs
generated
vendored
2
node_modules/@mswjs/interceptors/lib/node/RemoteHttpInterceptor.mjs
generated
vendored
@@ -3,7 +3,7 @@ import {
|
||||
} from "./chunk-RC2XPCC4.mjs";
|
||||
import {
|
||||
ClientRequestInterceptor
|
||||
} from "./chunk-HGTNS5VM.mjs";
|
||||
} from "./chunk-WA2XMLKW.mjs";
|
||||
import "./chunk-TJDMZZXE.mjs";
|
||||
import {
|
||||
XMLHttpRequestInterceptor
|
||||
|
||||
@@ -305,6 +305,7 @@ var MockHttpSocket = class extends MockSocket {
|
||||
}
|
||||
});
|
||||
this.requestRawHeadersBuffer = [];
|
||||
this.responseRawHeadersBuffer = [];
|
||||
this.writeBuffer = [];
|
||||
this.socketState = "unknown";
|
||||
/**
|
||||
@@ -367,8 +368,22 @@ var MockHttpSocket = class extends MockSocket {
|
||||
socket: this
|
||||
});
|
||||
};
|
||||
/**
|
||||
* This callback might be called when the response is "slow":
|
||||
* - Response headers were fragmented across multiple TCP packages;
|
||||
* - Response headers were too large to be processed in a single run
|
||||
* (e.g. more than 30 response headers).
|
||||
* @note This is called before response start.
|
||||
*/
|
||||
this.onResponseHeaders = (rawHeaders) => {
|
||||
this.responseRawHeadersBuffer.push(...rawHeaders);
|
||||
};
|
||||
this.onResponseStart = (versionMajor, versionMinor, rawHeaders, method, url, status, statusText) => {
|
||||
const headers = _chunkA7U44ARPjs.FetchResponse.parseRawHeaders(rawHeaders);
|
||||
const headers = _chunkA7U44ARPjs.FetchResponse.parseRawHeaders([
|
||||
...this.responseRawHeadersBuffer,
|
||||
...rawHeaders || []
|
||||
]);
|
||||
this.responseRawHeadersBuffer.length = 0;
|
||||
const response = new (0, _chunkA7U44ARPjs.FetchResponse)(
|
||||
/**
|
||||
* @note The Fetch API response instance exposed to the consumer
|
||||
@@ -417,6 +432,7 @@ var MockHttpSocket = class extends MockSocket {
|
||||
this.requestParser[__http_common.HTTPParser.kOnMessageComplete] = this.onRequestEnd.bind(this);
|
||||
this.responseParser = new (0, __http_common.HTTPParser)();
|
||||
this.responseParser.initialize(__http_common.HTTPParser.RESPONSE, {});
|
||||
this.responseParser[__http_common.HTTPParser.kOnHeaders] = this.onResponseHeaders.bind(this);
|
||||
this.responseParser[__http_common.HTTPParser.kOnHeadersComplete] = this.onResponseStart.bind(this);
|
||||
this.responseParser[__http_common.HTTPParser.kOnBody] = this.onResponseBody.bind(this);
|
||||
this.responseParser[__http_common.HTTPParser.kOnMessageComplete] = this.onResponseEnd.bind(this);
|
||||
@@ -687,8 +703,8 @@ var MockHttpsAgent = class extends _https2.default.Agent {
|
||||
this.onResponse = options.onResponse;
|
||||
}
|
||||
createConnection(options, callback) {
|
||||
const createConnection = this.customAgent instanceof _https2.default.Agent ? this.customAgent.createConnection : super.createConnection;
|
||||
const createConnectionOptions = this.customAgent instanceof _https2.default.Agent ? {
|
||||
const createConnection = this.customAgent instanceof _http2.default.Agent ? this.customAgent.createConnection : super.createConnection;
|
||||
const createConnectionOptions = this.customAgent instanceof _http2.default.Agent ? {
|
||||
...options,
|
||||
...this.customAgent.options
|
||||
} : options;
|
||||
@@ -1096,4 +1112,4 @@ ClientRequestInterceptor.symbol = Symbol("client-request-interceptor");
|
||||
|
||||
|
||||
exports.ClientRequestInterceptor = ClientRequestInterceptor;
|
||||
//# sourceMappingURL=chunk-F6CVST3S.js.map
|
||||
//# sourceMappingURL=chunk-ATZKM2BZ.js.map
|
||||
1
node_modules/@mswjs/interceptors/lib/node/chunk-ATZKM2BZ.js.map
generated
vendored
Normal file
1
node_modules/@mswjs/interceptors/lib/node/chunk-ATZKM2BZ.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@mswjs/interceptors/lib/node/chunk-F6CVST3S.js.map
generated
vendored
1
node_modules/@mswjs/interceptors/lib/node/chunk-F6CVST3S.js.map
generated
vendored
File diff suppressed because one or more lines are too long
1
node_modules/@mswjs/interceptors/lib/node/chunk-HGTNS5VM.mjs.map
generated
vendored
1
node_modules/@mswjs/interceptors/lib/node/chunk-HGTNS5VM.mjs.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -305,6 +305,7 @@ var MockHttpSocket = class extends MockSocket {
|
||||
}
|
||||
});
|
||||
this.requestRawHeadersBuffer = [];
|
||||
this.responseRawHeadersBuffer = [];
|
||||
this.writeBuffer = [];
|
||||
this.socketState = "unknown";
|
||||
/**
|
||||
@@ -367,8 +368,22 @@ var MockHttpSocket = class extends MockSocket {
|
||||
socket: this
|
||||
});
|
||||
};
|
||||
/**
|
||||
* This callback might be called when the response is "slow":
|
||||
* - Response headers were fragmented across multiple TCP packages;
|
||||
* - Response headers were too large to be processed in a single run
|
||||
* (e.g. more than 30 response headers).
|
||||
* @note This is called before response start.
|
||||
*/
|
||||
this.onResponseHeaders = (rawHeaders) => {
|
||||
this.responseRawHeadersBuffer.push(...rawHeaders);
|
||||
};
|
||||
this.onResponseStart = (versionMajor, versionMinor, rawHeaders, method, url, status, statusText) => {
|
||||
const headers = FetchResponse.parseRawHeaders(rawHeaders);
|
||||
const headers = FetchResponse.parseRawHeaders([
|
||||
...this.responseRawHeadersBuffer,
|
||||
...rawHeaders || []
|
||||
]);
|
||||
this.responseRawHeadersBuffer.length = 0;
|
||||
const response = new FetchResponse(
|
||||
/**
|
||||
* @note The Fetch API response instance exposed to the consumer
|
||||
@@ -417,6 +432,7 @@ var MockHttpSocket = class extends MockSocket {
|
||||
this.requestParser[HTTPParser.kOnMessageComplete] = this.onRequestEnd.bind(this);
|
||||
this.responseParser = new HTTPParser();
|
||||
this.responseParser.initialize(HTTPParser.RESPONSE, {});
|
||||
this.responseParser[HTTPParser.kOnHeaders] = this.onResponseHeaders.bind(this);
|
||||
this.responseParser[HTTPParser.kOnHeadersComplete] = this.onResponseStart.bind(this);
|
||||
this.responseParser[HTTPParser.kOnBody] = this.onResponseBody.bind(this);
|
||||
this.responseParser[HTTPParser.kOnMessageComplete] = this.onResponseEnd.bind(this);
|
||||
@@ -687,8 +703,8 @@ var MockHttpsAgent = class extends https.Agent {
|
||||
this.onResponse = options.onResponse;
|
||||
}
|
||||
createConnection(options, callback) {
|
||||
const createConnection = this.customAgent instanceof https.Agent ? this.customAgent.createConnection : super.createConnection;
|
||||
const createConnectionOptions = this.customAgent instanceof https.Agent ? {
|
||||
const createConnection = this.customAgent instanceof http.Agent ? this.customAgent.createConnection : super.createConnection;
|
||||
const createConnectionOptions = this.customAgent instanceof http.Agent ? {
|
||||
...options,
|
||||
...this.customAgent.options
|
||||
} : options;
|
||||
@@ -1096,4 +1112,4 @@ ClientRequestInterceptor.symbol = Symbol("client-request-interceptor");
|
||||
export {
|
||||
ClientRequestInterceptor
|
||||
};
|
||||
//# sourceMappingURL=chunk-HGTNS5VM.mjs.map
|
||||
//# sourceMappingURL=chunk-WA2XMLKW.mjs.map
|
||||
1
node_modules/@mswjs/interceptors/lib/node/chunk-WA2XMLKW.mjs.map
generated
vendored
Normal file
1
node_modules/@mswjs/interceptors/lib/node/chunk-WA2XMLKW.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
node_modules/@mswjs/interceptors/lib/node/interceptors/ClientRequest/index.d.ts
generated
vendored
9
node_modules/@mswjs/interceptors/lib/node/interceptors/ClientRequest/index.d.ts
generated
vendored
@@ -47,6 +47,7 @@ declare class MockHttpSocket extends MockSocket {
|
||||
private onResponse;
|
||||
private responseListenersPromise?;
|
||||
private requestRawHeadersBuffer;
|
||||
private responseRawHeadersBuffer;
|
||||
private writeBuffer;
|
||||
private request?;
|
||||
private requestParser;
|
||||
@@ -86,6 +87,14 @@ declare class MockHttpSocket extends MockSocket {
|
||||
private onRequestStart;
|
||||
private onRequestBody;
|
||||
private onRequestEnd;
|
||||
/**
|
||||
* This callback might be called when the response is "slow":
|
||||
* - Response headers were fragmented across multiple TCP packages;
|
||||
* - Response headers were too large to be processed in a single run
|
||||
* (e.g. more than 30 response headers).
|
||||
* @note This is called before response start.
|
||||
*/
|
||||
private onResponseHeaders;
|
||||
private onResponseStart;
|
||||
private onResponseBody;
|
||||
private onResponseEnd;
|
||||
|
||||
4
node_modules/@mswjs/interceptors/lib/node/interceptors/ClientRequest/index.js
generated
vendored
4
node_modules/@mswjs/interceptors/lib/node/interceptors/ClientRequest/index.js
generated
vendored
@@ -1,11 +1,11 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
||||
|
||||
var _chunkF6CVST3Sjs = require('../../chunk-F6CVST3S.js');
|
||||
var _chunkATZKM2BZjs = require('../../chunk-ATZKM2BZ.js');
|
||||
require('../../chunk-4YBV77DG.js');
|
||||
require('../../chunk-C2JSMMHY.js');
|
||||
require('../../chunk-A7U44ARP.js');
|
||||
require('../../chunk-SMXZPJEA.js');
|
||||
|
||||
|
||||
exports.ClientRequestInterceptor = _chunkF6CVST3Sjs.ClientRequestInterceptor;
|
||||
exports.ClientRequestInterceptor = _chunkATZKM2BZjs.ClientRequestInterceptor;
|
||||
//# sourceMappingURL=index.js.map
|
||||
2
node_modules/@mswjs/interceptors/lib/node/interceptors/ClientRequest/index.mjs
generated
vendored
2
node_modules/@mswjs/interceptors/lib/node/interceptors/ClientRequest/index.mjs
generated
vendored
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
ClientRequestInterceptor
|
||||
} from "../../chunk-HGTNS5VM.mjs";
|
||||
} from "../../chunk-WA2XMLKW.mjs";
|
||||
import "../../chunk-TJDMZZXE.mjs";
|
||||
import "../../chunk-LGXJ3UUF.mjs";
|
||||
import "../../chunk-IHJSPMYM.mjs";
|
||||
|
||||
4
node_modules/@mswjs/interceptors/lib/node/presets/node.js
generated
vendored
4
node_modules/@mswjs/interceptors/lib/node/presets/node.js
generated
vendored
@@ -1,6 +1,6 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
||||
|
||||
var _chunkF6CVST3Sjs = require('../chunk-F6CVST3S.js');
|
||||
var _chunkATZKM2BZjs = require('../chunk-ATZKM2BZ.js');
|
||||
require('../chunk-4YBV77DG.js');
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ require('../chunk-SMXZPJEA.js');
|
||||
|
||||
// src/presets/node.ts
|
||||
var node_default = [
|
||||
new (0, _chunkF6CVST3Sjs.ClientRequestInterceptor)(),
|
||||
new (0, _chunkATZKM2BZjs.ClientRequestInterceptor)(),
|
||||
new (0, _chunk4WG2AM2Tjs.XMLHttpRequestInterceptor)(),
|
||||
new (0, _chunkYAIEISARjs.FetchInterceptor)()
|
||||
];
|
||||
|
||||
2
node_modules/@mswjs/interceptors/lib/node/presets/node.mjs
generated
vendored
2
node_modules/@mswjs/interceptors/lib/node/presets/node.mjs
generated
vendored
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
ClientRequestInterceptor
|
||||
} from "../chunk-HGTNS5VM.mjs";
|
||||
} from "../chunk-WA2XMLKW.mjs";
|
||||
import "../chunk-TJDMZZXE.mjs";
|
||||
import {
|
||||
XMLHttpRequestInterceptor
|
||||
|
||||
2
node_modules/@mswjs/interceptors/package.json
generated
vendored
2
node_modules/@mswjs/interceptors/package.json
generated
vendored
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@mswjs/interceptors",
|
||||
"description": "Low-level HTTP/HTTPS/XHR/fetch request interception library.",
|
||||
"version": "0.39.3",
|
||||
"version": "0.39.5",
|
||||
"main": "./lib/node/index.js",
|
||||
"module": "./lib/node/index.mjs",
|
||||
"types": "./lib/node/index.d.ts",
|
||||
|
||||
24
node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/MockHttpSocket.ts
generated
vendored
24
node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/MockHttpSocket.ts
generated
vendored
@@ -1,7 +1,7 @@
|
||||
import net from 'node:net'
|
||||
import {
|
||||
type HeadersCallback,
|
||||
HTTPParser,
|
||||
RequestHeadersCallback,
|
||||
type RequestHeadersCompleteCallback,
|
||||
type ResponseHeadersCompleteCallback,
|
||||
} from '_http_common'
|
||||
@@ -55,6 +55,7 @@ export class MockHttpSocket extends MockSocket {
|
||||
private responseListenersPromise?: Promise<void>
|
||||
|
||||
private requestRawHeadersBuffer: Array<string> = []
|
||||
private responseRawHeadersBuffer: Array<string> = []
|
||||
private writeBuffer: Array<NormalizedSocketWriteArgs> = []
|
||||
private request?: Request
|
||||
private requestParser: HTTPParser<0>
|
||||
@@ -125,6 +126,8 @@ export class MockHttpSocket extends MockSocket {
|
||||
// Response parser.
|
||||
this.responseParser = new HTTPParser()
|
||||
this.responseParser.initialize(HTTPParser.RESPONSE, {})
|
||||
this.responseParser[HTTPParser.kOnHeaders] =
|
||||
this.onResponseHeaders.bind(this)
|
||||
this.responseParser[HTTPParser.kOnHeadersComplete] =
|
||||
this.onResponseStart.bind(this)
|
||||
this.responseParser[HTTPParser.kOnBody] = this.onResponseBody.bind(this)
|
||||
@@ -482,7 +485,7 @@ export class MockHttpSocket extends MockSocket {
|
||||
* (e.g. more than 30 request headers).
|
||||
* @note This is called before request start.
|
||||
*/
|
||||
private onRequestHeaders: RequestHeadersCallback = (rawHeaders) => {
|
||||
private onRequestHeaders: HeadersCallback = (rawHeaders) => {
|
||||
this.requestRawHeadersBuffer.push(...rawHeaders)
|
||||
}
|
||||
|
||||
@@ -597,6 +600,17 @@ export class MockHttpSocket extends MockSocket {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This callback might be called when the response is "slow":
|
||||
* - Response headers were fragmented across multiple TCP packages;
|
||||
* - Response headers were too large to be processed in a single run
|
||||
* (e.g. more than 30 response headers).
|
||||
* @note This is called before response start.
|
||||
*/
|
||||
private onResponseHeaders: HeadersCallback = (rawHeaders) => {
|
||||
this.responseRawHeadersBuffer.push(...rawHeaders)
|
||||
}
|
||||
|
||||
private onResponseStart: ResponseHeadersCompleteCallback = (
|
||||
versionMajor,
|
||||
versionMinor,
|
||||
@@ -606,7 +620,11 @@ export class MockHttpSocket extends MockSocket {
|
||||
status,
|
||||
statusText
|
||||
) => {
|
||||
const headers = FetchResponse.parseRawHeaders(rawHeaders)
|
||||
const headers = FetchResponse.parseRawHeaders([
|
||||
...this.responseRawHeadersBuffer,
|
||||
...(rawHeaders || []),
|
||||
])
|
||||
this.responseRawHeadersBuffer.length = 0
|
||||
|
||||
const response = new FetchResponse(
|
||||
/**
|
||||
|
||||
4
node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/agents.ts
generated
vendored
4
node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/agents.ts
generated
vendored
@@ -75,12 +75,12 @@ export class MockHttpsAgent extends https.Agent {
|
||||
|
||||
public createConnection(options: any, callback: any): net.Socket {
|
||||
const createConnection =
|
||||
this.customAgent instanceof https.Agent
|
||||
this.customAgent instanceof http.Agent
|
||||
? this.customAgent.createConnection
|
||||
: super.createConnection
|
||||
|
||||
const createConnectionOptions =
|
||||
this.customAgent instanceof https.Agent
|
||||
this.customAgent instanceof http.Agent
|
||||
? {
|
||||
...options,
|
||||
...this.customAgent.options,
|
||||
|
||||
6
node_modules/@types/node/README.md
generated
vendored
6
node_modules/@types/node/README.md
generated
vendored
@@ -5,11 +5,11 @@
|
||||
This package contains type definitions for node (https://nodejs.org/).
|
||||
|
||||
# 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/v20.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Tue, 07 Nov 2023 20:08:00 GMT
|
||||
* Last updated: Sat, 19 Jul 2025 00:47:11 GMT
|
||||
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
||||
|
||||
# Credits
|
||||
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [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), [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), [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), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky).
|
||||
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [Alberto Schiabel](https://github.com/jkomyno), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [David Junger](https://github.com/touffy), [Mohsen Azimi](https://github.com/mohsen1), [Nikita Galkin](https://github.com/galkin), [Sebastian Silbermann](https://github.com/eps1lon), [Wilco Bakker](https://github.com/WilcoBakker), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky).
|
||||
|
||||
142
node_modules/@types/node/assert.d.ts
generated
vendored
142
node_modules/@types/node/assert.d.ts
generated
vendored
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* The `node:assert` module provides a set of assertion functions for verifying
|
||||
* invariants.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/assert.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/assert.js)
|
||||
*/
|
||||
declare module "assert" {
|
||||
/**
|
||||
@@ -12,7 +12,7 @@ declare module "assert" {
|
||||
function assert(value: unknown, message?: string | Error): asserts value;
|
||||
namespace assert {
|
||||
/**
|
||||
* Indicates the failure of an assertion. All errors thrown by the `node:assert`module will be instances of the `AssertionError` class.
|
||||
* Indicates the failure of an assertion. All errors thrown by the `node:assert` module will be instances of the `AssertionError` class.
|
||||
*/
|
||||
class AssertionError extends Error {
|
||||
/**
|
||||
@@ -45,7 +45,7 @@ declare module "assert" {
|
||||
/** The `operator` property on the error instance. */
|
||||
operator?: string | undefined;
|
||||
/** If provided, the generated stack trace omits frames before this function. */
|
||||
// tslint:disable-next-line:ban-types
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
stackStartFn?: Function | undefined;
|
||||
});
|
||||
}
|
||||
@@ -76,10 +76,12 @@ declare module "assert" {
|
||||
* @since v14.2.0, v12.19.0
|
||||
* @param [fn='A no-op function']
|
||||
* @param [exact=1]
|
||||
* @return that wraps `fn`.
|
||||
* @return A function that wraps `fn`.
|
||||
*/
|
||||
calls(exact?: number): () => void;
|
||||
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
|
||||
calls(fn: undefined, exact?: number): () => void;
|
||||
calls<Func extends (...args: any[]) => any>(fn: Func, exact?: number): Func;
|
||||
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func | (() => void);
|
||||
/**
|
||||
* Example:
|
||||
*
|
||||
@@ -96,8 +98,7 @@ declare module "assert" {
|
||||
* [{ thisArg: undefined, arguments: [1, 2, 3] }]);
|
||||
* ```
|
||||
* @since v18.8.0, v16.18.0
|
||||
* @param fn
|
||||
* @return An Array with all the calls to a tracked function.
|
||||
* @return An array with all the calls to a tracked function.
|
||||
*/
|
||||
getCalls(fn: Function): CallTrackerCall[];
|
||||
/**
|
||||
@@ -130,12 +131,11 @@ declare module "assert" {
|
||||
* // ]
|
||||
* ```
|
||||
* @since v14.2.0, v12.19.0
|
||||
* @return An Array of objects containing information about the wrapper functions returned by `calls`.
|
||||
* @return An array of objects containing information about the wrapper functions returned by {@link tracker.calls()}.
|
||||
*/
|
||||
report(): CallTrackerReportInformation[];
|
||||
/**
|
||||
* Reset calls of the call tracker.
|
||||
* If a tracked function is passed as an argument, the calls will be reset for it.
|
||||
* Reset calls of the call tracker. If a tracked function is passed as an argument, the calls will be reset for it.
|
||||
* If no arguments are passed, all tracked functions will be reset.
|
||||
*
|
||||
* ```js
|
||||
@@ -158,7 +158,7 @@ declare module "assert" {
|
||||
*/
|
||||
reset(fn?: Function): void;
|
||||
/**
|
||||
* Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that
|
||||
* Iterates through the list of functions passed to {@link tracker.calls()} and will throw an error for functions that
|
||||
* have not been called the expected number of times.
|
||||
*
|
||||
* ```js
|
||||
@@ -228,14 +228,14 @@ declare module "assert" {
|
||||
expected: unknown,
|
||||
message?: string | Error,
|
||||
operator?: string,
|
||||
// tslint:disable-next-line:ban-types
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
stackStartFn?: Function,
|
||||
): never;
|
||||
/**
|
||||
* Tests if `value` is truthy. It is equivalent to`assert.equal(!!value, true, message)`.
|
||||
* Tests if `value` is truthy. It is equivalent to `assert.equal(!!value, true, message)`.
|
||||
*
|
||||
* If `value` is not truthy, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is `undefined`, a default
|
||||
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
||||
* If `value` is not truthy, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is `undefined`, a default
|
||||
* error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
||||
* If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``.
|
||||
*
|
||||
* Be aware that in the `repl` the error message will be different to the one
|
||||
@@ -317,8 +317,8 @@ declare module "assert" {
|
||||
* // AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
|
||||
* ```
|
||||
*
|
||||
* If the values are not equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default
|
||||
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
||||
* If the values are not equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default
|
||||
* error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function equal(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
@@ -347,8 +347,8 @@ declare module "assert" {
|
||||
* // AssertionError: 1 != '1'
|
||||
* ```
|
||||
*
|
||||
* If the values are equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default error
|
||||
* message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
||||
* If the values are equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default error
|
||||
* message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
@@ -414,8 +414,8 @@ declare module "assert" {
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values are deeply equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a default
|
||||
* error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
||||
* If the values are deeply equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default
|
||||
* error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
@@ -452,8 +452,8 @@ declare module "assert" {
|
||||
* // TypeError: Inputs are not identical
|
||||
* ```
|
||||
*
|
||||
* If the values are not strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
|
||||
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
||||
* If the values are not strictly equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a
|
||||
* default error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
@@ -477,8 +477,8 @@ declare module "assert" {
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values are strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
|
||||
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
||||
* If the values are strictly equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a
|
||||
* default error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
@@ -519,7 +519,7 @@ declare module "assert" {
|
||||
* using an object, it is also possible to use a regular expression, when
|
||||
* validating against a string property. See below for examples.
|
||||
*
|
||||
* If specified, `message` will be appended to the message provided by the`AssertionError` if the `fn` call fails to throw or in case the error validation
|
||||
* If specified, `message` will be appended to the message provided by the `AssertionError` if the `fn` call fails to throw or in case the error validation
|
||||
* fails.
|
||||
*
|
||||
* Custom validation object/error instance:
|
||||
@@ -649,8 +649,8 @@ declare module "assert" {
|
||||
* ```
|
||||
*
|
||||
* `error` cannot be a string. If a string is provided as the second
|
||||
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Using the same
|
||||
* message as the thrown error message is going to result in an`ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
|
||||
* argument, then `error` is assumed to be omitted and the string will be used for `message` instead. This can lead to easy-to-miss mistakes. Using the same
|
||||
* message as the thrown error message is going to result in an `ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
|
||||
* a string as the second argument gets considered:
|
||||
*
|
||||
* ```js
|
||||
@@ -703,9 +703,9 @@ declare module "assert" {
|
||||
* adding a comment next to the specific code path that should not throw and keep
|
||||
* error messages as expressive as possible.
|
||||
*
|
||||
* When `assert.doesNotThrow()` is called, it will immediately call the `fn`function.
|
||||
* When `assert.doesNotThrow()` is called, it will immediately call the `fn` function.
|
||||
*
|
||||
* If an error is thrown and it is the same type as that specified by the `error`parameter, then an `AssertionError` is thrown. If the error is of a
|
||||
* If an error is thrown and it is the same type as that specified by the `error` parameter, then an `AssertionError` is thrown. If the error is of a
|
||||
* different type, or if the `error` parameter is undefined, the error is
|
||||
* propagated back to the caller.
|
||||
*
|
||||
@@ -741,7 +741,7 @@ declare module "assert" {
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* If an `AssertionError` is thrown and a value is provided for the `message`parameter, the value of `message` will be appended to the `AssertionError` message:
|
||||
* If an `AssertionError` is thrown and a value is provided for the `message` parameter, the value of `message` will be appended to the `AssertionError` message:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
@@ -762,7 +762,7 @@ declare module "assert" {
|
||||
/**
|
||||
* Throws `value` if `value` is not `undefined` or `null`. This is useful when
|
||||
* testing the `error` argument in callbacks. The stack trace contains all frames
|
||||
* from the error passed to `ifError()` including the potential new frames for`ifError()` itself.
|
||||
* from the error passed to `ifError()` including the potential new frames for `ifError()` itself.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
@@ -797,18 +797,18 @@ declare module "assert" {
|
||||
* calls the function and awaits the returned promise to complete. It will then
|
||||
* check that the promise is rejected.
|
||||
*
|
||||
* If `asyncFn` is a function and it throws an error synchronously,`assert.rejects()` will return a rejected `Promise` with that error. If the
|
||||
* function does not return a promise, `assert.rejects()` will return a rejected`Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases the error
|
||||
* handler is skipped.
|
||||
* If `asyncFn` is a function and it throws an error synchronously, `assert.rejects()` will return a rejected `Promise` with that error. If the
|
||||
* function does not return a promise, `assert.rejects()` will return a rejected `Promise` with an [ERR_INVALID_RETURN_VALUE](https://nodejs.org/docs/latest-v20.x/api/errors.html#err_invalid_return_value)
|
||||
* error. In both cases the error handler is skipped.
|
||||
*
|
||||
* Besides the async nature to await the completion behaves identically to {@link throws}.
|
||||
*
|
||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
|
||||
* an object where each property will be tested for, or an instance of error where
|
||||
* each property will be tested for including the non-enumerable `message` and`name` properties.
|
||||
* each property will be tested for including the non-enumerable `message` and `name` properties.
|
||||
*
|
||||
* If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject.
|
||||
* If specified, `message` will be the message provided by the `{@link AssertionError}` if the `asyncFn` fails to reject.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
@@ -850,10 +850,9 @@ declare module "assert" {
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* `error` cannot be a string. If a string is provided as the second
|
||||
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Please read the
|
||||
* example in {@link throws} carefully if using a string as the second
|
||||
* argument gets considered.
|
||||
* `error` cannot be a string. If a string is provided as the second argument, then `error` is assumed to
|
||||
* be omitted and the string will be used for `message` instead. This can lead to easy-to-miss mistakes. Please read the
|
||||
* example in {@link throws} carefully if using a string as the second argument gets considered.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
||||
@@ -867,9 +866,9 @@ declare module "assert" {
|
||||
* calls the function and awaits the returned promise to complete. It will then
|
||||
* check that the promise is not rejected.
|
||||
*
|
||||
* If `asyncFn` is a function and it throws an error synchronously,`assert.doesNotReject()` will return a rejected `Promise` with that error. If
|
||||
* If `asyncFn` is a function and it throws an error synchronously, `assert.doesNotReject()` will return a rejected `Promise` with that error. If
|
||||
* the function does not return a promise, `assert.doesNotReject()` will return a
|
||||
* rejected `Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases
|
||||
* rejected `Promise` with an [ERR_INVALID_RETURN_VALUE](https://nodejs.org/docs/latest-v20.x/api/errors.html#err_invalid_return_value) error. In both cases
|
||||
* the error handler is skipped.
|
||||
*
|
||||
* Using `assert.doesNotReject()` is actually not useful because there is little
|
||||
@@ -929,10 +928,10 @@ declare module "assert" {
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values do not match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
|
||||
* If the values do not match, or if the `string` argument is of another type than `string`, an `{@link AssertionError}` is thrown with a `message` property set equal
|
||||
* to the value of the `message` parameter. If the `message` parameter is
|
||||
* undefined, a default error message is assigned. If the `message` parameter is an
|
||||
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
||||
* instance of an [Error](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) then it will be thrown instead of the `{@link AssertionError}`.
|
||||
* @since v13.6.0, v12.16.0
|
||||
*/
|
||||
function match(value: string, regExp: RegExp, message?: string | Error): void;
|
||||
@@ -952,13 +951,60 @@ declare module "assert" {
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values do match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
|
||||
* If the values do match, or if the `string` argument is of another type than `string`, an `{@link AssertionError}` is thrown with a `message` property set equal
|
||||
* to the value of the `message` parameter. If the `message` parameter is
|
||||
* undefined, a default error message is assigned. If the `message` parameter is an
|
||||
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
||||
* instance of an [Error](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) then it will be thrown instead of the `{@link AssertionError}`.
|
||||
* @since v13.6.0, v12.16.0
|
||||
*/
|
||||
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
|
||||
/**
|
||||
* In strict assertion mode, non-strict methods behave like their corresponding strict methods. For example,
|
||||
* {@link deepEqual} will behave like {@link deepStrictEqual}.
|
||||
*
|
||||
* In strict assertion mode, error messages for objects display a diff. In legacy assertion mode, error
|
||||
* messages for objects display the objects, often truncated.
|
||||
*
|
||||
* To use strict assertion mode:
|
||||
*
|
||||
* ```js
|
||||
* import { strict as assert } from 'node:assert';COPY
|
||||
* import assert from 'node:assert/strict';
|
||||
* ```
|
||||
*
|
||||
* Example error diff:
|
||||
*
|
||||
* ```js
|
||||
* import { strict as assert } from 'node:assert';
|
||||
*
|
||||
* assert.deepEqual([[[1, 2, 3]], 4, 5], [[[1, 2, '3']], 4, 5]);
|
||||
* // AssertionError: Expected inputs to be strictly deep-equal:
|
||||
* // + actual - expected ... Lines skipped
|
||||
* //
|
||||
* // [
|
||||
* // [
|
||||
* // ...
|
||||
* // 2,
|
||||
* // + 3
|
||||
* // - '3'
|
||||
* // ],
|
||||
* // ...
|
||||
* // 5
|
||||
* // ]
|
||||
* ```
|
||||
*
|
||||
* To deactivate the colors, use the `NO_COLOR` or `NODE_DISABLE_COLORS` environment variables. This will also
|
||||
* deactivate the colors in the REPL. For more on color support in terminal environments, read the tty
|
||||
* `getColorDepth()` documentation.
|
||||
*
|
||||
* @since v15.0.0, v13.9.0, v12.16.2, v9.9.0
|
||||
*/
|
||||
namespace strict {
|
||||
type AssertionError = assert.AssertionError;
|
||||
type AssertPredicate = assert.AssertPredicate;
|
||||
type CallTrackerCall = assert.CallTrackerCall;
|
||||
type CallTrackerReportInformation = assert.CallTrackerReportInformation;
|
||||
}
|
||||
const strict:
|
||||
& Omit<
|
||||
typeof assert,
|
||||
@@ -971,6 +1017,7 @@ declare module "assert" {
|
||||
| "deepStrictEqual"
|
||||
| "ifError"
|
||||
| "strict"
|
||||
| "AssertionError"
|
||||
>
|
||||
& {
|
||||
(value: unknown, message?: string | Error): asserts value;
|
||||
@@ -986,6 +1033,7 @@ declare module "assert" {
|
||||
deepStrictEqual: typeof deepStrictEqual;
|
||||
ifError: typeof ifError;
|
||||
strict: typeof strict;
|
||||
AssertionError: typeof AssertionError;
|
||||
};
|
||||
}
|
||||
export = assert;
|
||||
|
||||
96
node_modules/@types/node/async_hooks.d.ts
generated
vendored
96
node_modules/@types/node/async_hooks.d.ts
generated
vendored
@@ -2,8 +2,8 @@
|
||||
* We strongly discourage the use of the `async_hooks` API.
|
||||
* Other APIs that can cover most of its use cases include:
|
||||
*
|
||||
* * `AsyncLocalStorage` tracks async context
|
||||
* * `process.getActiveResourcesInfo()` tracks active resources
|
||||
* * [`AsyncLocalStorage`](https://nodejs.org/docs/latest-v20.x/api/async_context.html#class-asynclocalstorage) tracks async context
|
||||
* * [`process.getActiveResourcesInfo()`](https://nodejs.org/docs/latest-v20.x/api/process.html#processgetactiveresourcesinfo) tracks active resources
|
||||
*
|
||||
* The `node:async_hooks` module provides an API to track asynchronous resources.
|
||||
* It can be accessed using:
|
||||
@@ -12,7 +12,7 @@
|
||||
* import async_hooks from 'node:async_hooks';
|
||||
* ```
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/async_hooks.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/async_hooks.js)
|
||||
*/
|
||||
declare module "async_hooks" {
|
||||
/**
|
||||
@@ -44,7 +44,7 @@ declare module "async_hooks" {
|
||||
* ```
|
||||
*
|
||||
* Promise contexts may not get precise `executionAsyncIds` by default.
|
||||
* See the section on `promise execution tracking`.
|
||||
* See the section on [promise execution tracking](https://nodejs.org/docs/latest-v20.x/api/async_hooks.html#promise-execution-tracking).
|
||||
* @since v8.1.0
|
||||
* @return The `asyncId` of the current execution context. Useful to track when something calls.
|
||||
*/
|
||||
@@ -117,17 +117,17 @@ declare module "async_hooks" {
|
||||
* ```
|
||||
*
|
||||
* Promise contexts may not get valid `triggerAsyncId`s by default. See
|
||||
* the section on `promise execution tracking`.
|
||||
* the section on [promise execution tracking](https://nodejs.org/docs/latest-v20.x/api/async_hooks.html#promise-execution-tracking).
|
||||
* @return The ID of the resource responsible for calling the callback that is currently being executed.
|
||||
*/
|
||||
function triggerAsyncId(): number;
|
||||
interface HookCallbacks {
|
||||
/**
|
||||
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
||||
* @param asyncId a unique ID for the async resource
|
||||
* @param type the type of the async resource
|
||||
* @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
|
||||
* @param resource reference to the resource representing the async operation, needs to be released during destroy
|
||||
* @param asyncId A unique ID for the async resource
|
||||
* @param type The type of the async resource
|
||||
* @param triggerAsyncId The unique ID of the async resource in whose execution context this async resource was created
|
||||
* @param resource Reference to the resource representing the async operation, needs to be released during destroy
|
||||
*/
|
||||
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
|
||||
/**
|
||||
@@ -137,7 +137,9 @@ declare module "async_hooks" {
|
||||
*/
|
||||
before?(asyncId: number): void;
|
||||
/**
|
||||
* Called immediately after the callback specified in before is completed.
|
||||
* Called immediately after the callback specified in `before` is completed.
|
||||
*
|
||||
* If an uncaught exception occurs during execution of the callback, then `after` will run after the `'uncaughtException'` event is emitted or a `domain`'s handler runs.
|
||||
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
||||
*/
|
||||
after?(asyncId: number): void;
|
||||
@@ -321,7 +323,7 @@ declare module "async_hooks" {
|
||||
/**
|
||||
* This class creates stores that stay coherent through asynchronous operations.
|
||||
*
|
||||
* While you can create your own implementation on top of the `node:async_hooks`module, `AsyncLocalStorage` should be preferred as it is a performant and memory
|
||||
* While you can create your own implementation on top of the `node: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.
|
||||
*
|
||||
@@ -407,12 +409,12 @@ declare module "async_hooks" {
|
||||
static snapshot(): <R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs) => R;
|
||||
/**
|
||||
* 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.enterWith()` is called again.
|
||||
*
|
||||
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
||||
* instance will be exited.
|
||||
*
|
||||
* Calling `asyncLocalStorage.disable()` is required before the`asyncLocalStorage` can be garbage collected. This does not apply to stores
|
||||
* Calling `asyncLocalStorage.disable()` is required before the `asyncLocalStorage` can be garbage collected. This does not apply to stores
|
||||
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
||||
* along with the corresponding async resources.
|
||||
*
|
||||
@@ -465,7 +467,7 @@ declare module "async_hooks" {
|
||||
/**
|
||||
* Runs a function synchronously outside of a context and returns its
|
||||
* return value. The store is not accessible within the callback function or
|
||||
* the asynchronous operations created within the callback. Any `getStore()`call done within the callback function will always return `undefined`.
|
||||
* the asynchronous operations created within the callback. Any `getStore()` call done within the callback function will always return `undefined`.
|
||||
*
|
||||
* The optional `args` are passed to the callback function.
|
||||
*
|
||||
@@ -511,7 +513,7 @@ declare module "async_hooks" {
|
||||
* 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
|
||||
* 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
|
||||
@@ -533,6 +535,70 @@ declare module "async_hooks" {
|
||||
*/
|
||||
enterWith(store: T): void;
|
||||
}
|
||||
/**
|
||||
* @since v17.2.0, v16.14.0
|
||||
* @return A map of provider types to the corresponding numeric id.
|
||||
* This map contains all the event types that might be emitted by the `async_hooks.init()` event.
|
||||
*/
|
||||
namespace asyncWrapProviders {
|
||||
const NONE: number;
|
||||
const DIRHANDLE: number;
|
||||
const DNSCHANNEL: number;
|
||||
const ELDHISTOGRAM: number;
|
||||
const FILEHANDLE: number;
|
||||
const FILEHANDLECLOSEREQ: number;
|
||||
const FIXEDSIZEBLOBCOPY: number;
|
||||
const FSEVENTWRAP: number;
|
||||
const FSREQCALLBACK: number;
|
||||
const FSREQPROMISE: number;
|
||||
const GETADDRINFOREQWRAP: number;
|
||||
const GETNAMEINFOREQWRAP: number;
|
||||
const HEAPSNAPSHOT: number;
|
||||
const HTTP2SESSION: number;
|
||||
const HTTP2STREAM: number;
|
||||
const HTTP2PING: number;
|
||||
const HTTP2SETTINGS: number;
|
||||
const HTTPINCOMINGMESSAGE: number;
|
||||
const HTTPCLIENTREQUEST: number;
|
||||
const JSSTREAM: number;
|
||||
const JSUDPWRAP: number;
|
||||
const MESSAGEPORT: number;
|
||||
const PIPECONNECTWRAP: number;
|
||||
const PIPESERVERWRAP: number;
|
||||
const PIPEWRAP: number;
|
||||
const PROCESSWRAP: number;
|
||||
const PROMISE: number;
|
||||
const QUERYWRAP: number;
|
||||
const SHUTDOWNWRAP: number;
|
||||
const SIGNALWRAP: number;
|
||||
const STATWATCHER: number;
|
||||
const STREAMPIPE: number;
|
||||
const TCPCONNECTWRAP: number;
|
||||
const TCPSERVERWRAP: number;
|
||||
const TCPWRAP: number;
|
||||
const TTYWRAP: number;
|
||||
const UDPSENDWRAP: number;
|
||||
const UDPWRAP: number;
|
||||
const SIGINTWATCHDOG: number;
|
||||
const WORKER: number;
|
||||
const WORKERHEAPSNAPSHOT: number;
|
||||
const WRITEWRAP: number;
|
||||
const ZLIB: number;
|
||||
const CHECKPRIMEREQUEST: number;
|
||||
const PBKDF2REQUEST: number;
|
||||
const KEYPAIRGENREQUEST: number;
|
||||
const KEYGENREQUEST: number;
|
||||
const KEYEXPORTREQUEST: number;
|
||||
const CIPHERREQUEST: number;
|
||||
const DERIVEBITSREQUEST: number;
|
||||
const HASHREQUEST: number;
|
||||
const RANDOMBYTESREQUEST: number;
|
||||
const RANDOMPRIMEREQUEST: number;
|
||||
const SCRYPTREQUEST: number;
|
||||
const SIGNREQUEST: number;
|
||||
const TLSWRAP: number;
|
||||
const VERIFYREQUEST: number;
|
||||
}
|
||||
}
|
||||
declare module "node:async_hooks" {
|
||||
export * from "async_hooks";
|
||||
|
||||
462
node_modules/@types/node/buffer.buffer.d.ts
generated
vendored
Normal file
462
node_modules/@types/node/buffer.buffer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,462 @@
|
||||
declare module "buffer" {
|
||||
type ImplicitArrayBuffer<T extends WithImplicitCoercion<ArrayBufferLike>> = T extends
|
||||
{ valueOf(): infer V extends ArrayBufferLike } ? V : T;
|
||||
global {
|
||||
interface BufferConstructor {
|
||||
// see buffer.d.ts for implementation shared with all TypeScript versions
|
||||
|
||||
/**
|
||||
* Allocates a new buffer containing the given {str}.
|
||||
*
|
||||
* @param str String to store in buffer.
|
||||
* @param encoding encoding to use, optional. Default is 'utf8'
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
|
||||
*/
|
||||
new(str: string, encoding?: BufferEncoding): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
|
||||
*/
|
||||
new(size: number): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
||||
*/
|
||||
new(array: ArrayLike<number>): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Produces a Buffer backed by the same allocated memory as
|
||||
* the given {ArrayBuffer}/{SharedArrayBuffer}.
|
||||
*
|
||||
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
|
||||
*/
|
||||
new<TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(arrayBuffer: TArrayBuffer): Buffer<TArrayBuffer>;
|
||||
/**
|
||||
* Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
|
||||
* Array entries outside that range will be truncated to fit into it.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
|
||||
* const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
|
||||
* ```
|
||||
*
|
||||
* If `array` is an `Array`-like object (that is, one with a `length` property of
|
||||
* type `number`), it is treated as if it is an array, unless it is a `Buffer` or
|
||||
* a `Uint8Array`. This means all other `TypedArray` variants get treated as an
|
||||
* `Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use
|
||||
* `Buffer.copyBytesFrom()`.
|
||||
*
|
||||
* A `TypeError` will be thrown if `array` is not an `Array` or another type
|
||||
* appropriate for `Buffer.from()` variants.
|
||||
*
|
||||
* `Buffer.from(array)` and `Buffer.from(string)` may also use the internal
|
||||
* `Buffer` pool like `Buffer.allocUnsafe()` does.
|
||||
* @since v5.10.0
|
||||
*/
|
||||
from(array: WithImplicitCoercion<ArrayLike<number>>): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* This creates a view of the `ArrayBuffer` without copying the underlying
|
||||
* memory. For example, when passed a reference to the `.buffer` property of a
|
||||
* `TypedArray` instance, the newly created `Buffer` will share the same
|
||||
* allocated memory as the `TypedArray`'s underlying `ArrayBuffer`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const arr = new Uint16Array(2);
|
||||
*
|
||||
* arr[0] = 5000;
|
||||
* arr[1] = 4000;
|
||||
*
|
||||
* // Shares memory with `arr`.
|
||||
* const buf = Buffer.from(arr.buffer);
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 88 13 a0 0f>
|
||||
*
|
||||
* // Changing the original Uint16Array changes the Buffer also.
|
||||
* arr[1] = 6000;
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 88 13 70 17>
|
||||
* ```
|
||||
*
|
||||
* The optional `byteOffset` and `length` arguments specify a memory range within
|
||||
* the `arrayBuffer` that will be shared by the `Buffer`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const ab = new ArrayBuffer(10);
|
||||
* const buf = Buffer.from(ab, 0, 2);
|
||||
*
|
||||
* console.log(buf.length);
|
||||
* // Prints: 2
|
||||
* ```
|
||||
*
|
||||
* A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer` or a
|
||||
* `SharedArrayBuffer` or another type appropriate for `Buffer.from()`
|
||||
* variants.
|
||||
*
|
||||
* It is important to remember that a backing `ArrayBuffer` can cover a range
|
||||
* of memory that extends beyond the bounds of a `TypedArray` view. A new
|
||||
* `Buffer` created using the `buffer` property of a `TypedArray` may extend
|
||||
* beyond the range of the `TypedArray`:
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const arrA = Uint8Array.from([0x63, 0x64, 0x65, 0x66]); // 4 elements
|
||||
* const arrB = new Uint8Array(arrA.buffer, 1, 2); // 2 elements
|
||||
* console.log(arrA.buffer === arrB.buffer); // true
|
||||
*
|
||||
* const buf = Buffer.from(arrB.buffer);
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 63 64 65 66>
|
||||
* ```
|
||||
* @since v5.10.0
|
||||
* @param arrayBuffer An `ArrayBuffer`, `SharedArrayBuffer`, for example the
|
||||
* `.buffer` property of a `TypedArray`.
|
||||
* @param byteOffset Index of first byte to expose. **Default:** `0`.
|
||||
* @param length Number of bytes to expose. **Default:**
|
||||
* `arrayBuffer.byteLength - byteOffset`.
|
||||
*/
|
||||
from<TArrayBuffer extends WithImplicitCoercion<ArrayBufferLike>>(
|
||||
arrayBuffer: TArrayBuffer,
|
||||
byteOffset?: number,
|
||||
length?: number,
|
||||
): Buffer<ImplicitArrayBuffer<TArrayBuffer>>;
|
||||
/**
|
||||
* Creates a new `Buffer` containing `string`. The `encoding` parameter identifies
|
||||
* the character encoding to be used when converting `string` into bytes.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf1 = Buffer.from('this is a tést');
|
||||
* const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
|
||||
*
|
||||
* console.log(buf1.toString());
|
||||
* // Prints: this is a tést
|
||||
* console.log(buf2.toString());
|
||||
* // Prints: this is a tést
|
||||
* console.log(buf1.toString('latin1'));
|
||||
* // Prints: this is a tést
|
||||
* ```
|
||||
*
|
||||
* A `TypeError` will be thrown if `string` is not a string or another type
|
||||
* appropriate for `Buffer.from()` variants.
|
||||
*
|
||||
* `Buffer.from(string)` may also use the internal `Buffer` pool like
|
||||
* `Buffer.allocUnsafe()` does.
|
||||
* @since v5.10.0
|
||||
* @param string A string to encode.
|
||||
* @param encoding The encoding of `string`. **Default:** `'utf8'`.
|
||||
*/
|
||||
from(string: WithImplicitCoercion<string>, encoding?: BufferEncoding): Buffer<ArrayBuffer>;
|
||||
from(arrayOrString: WithImplicitCoercion<ArrayLike<number> | string>): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Creates a new Buffer using the passed {data}
|
||||
* @param values to create a new Buffer
|
||||
*/
|
||||
of(...items: number[]): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
|
||||
*
|
||||
* If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
|
||||
*
|
||||
* If `totalLength` is not provided, it is calculated from the `Buffer` instances
|
||||
* in `list` by adding their lengths.
|
||||
*
|
||||
* If `totalLength` is provided, it is coerced to an unsigned integer. If the
|
||||
* combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
|
||||
* truncated to `totalLength`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Create a single `Buffer` from a list of three `Buffer` instances.
|
||||
*
|
||||
* const buf1 = Buffer.alloc(10);
|
||||
* const buf2 = Buffer.alloc(14);
|
||||
* const buf3 = Buffer.alloc(18);
|
||||
* const totalLength = buf1.length + buf2.length + buf3.length;
|
||||
*
|
||||
* console.log(totalLength);
|
||||
* // Prints: 42
|
||||
*
|
||||
* const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
|
||||
*
|
||||
* console.log(bufA);
|
||||
* // Prints: <Buffer 00 00 00 00 ...>
|
||||
* console.log(bufA.length);
|
||||
* // Prints: 42
|
||||
* ```
|
||||
*
|
||||
* `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
|
||||
* @since v0.7.11
|
||||
* @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
|
||||
* @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
|
||||
*/
|
||||
concat(list: readonly Uint8Array[], totalLength?: number): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Copies the underlying memory of `view` into a new `Buffer`.
|
||||
*
|
||||
* ```js
|
||||
* const u16 = new Uint16Array([0, 0xffff]);
|
||||
* const buf = Buffer.copyBytesFrom(u16, 1, 1);
|
||||
* u16[1] = 0;
|
||||
* console.log(buf.length); // 2
|
||||
* console.log(buf[0]); // 255
|
||||
* console.log(buf[1]); // 255
|
||||
* ```
|
||||
* @since v19.8.0
|
||||
* @param view The {TypedArray} to copy.
|
||||
* @param [offset=0] The starting offset within `view`.
|
||||
* @param [length=view.length - offset] The number of elements from `view` to copy.
|
||||
*/
|
||||
copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.alloc(5);
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 00 00 00 00 00>
|
||||
* ```
|
||||
*
|
||||
* If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
||||
*
|
||||
* If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.alloc(5, 'a');
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 61 61 61 61 61>
|
||||
* ```
|
||||
*
|
||||
* If both `fill` and `encoding` are specified, the allocated `Buffer` will be
|
||||
* initialized by calling `buf.fill(fill, encoding)`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
|
||||
* ```
|
||||
*
|
||||
* Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
|
||||
* contents will never contain sensitive data from previous allocations, including
|
||||
* data that might not have been allocated for `Buffer`s.
|
||||
*
|
||||
* A `TypeError` will be thrown if `size` is not a number.
|
||||
* @since v5.10.0
|
||||
* @param size The desired length of the new `Buffer`.
|
||||
* @param [fill=0] A value to pre-fill the new `Buffer` with.
|
||||
* @param [encoding='utf8'] If `fill` is a string, this is its encoding.
|
||||
*/
|
||||
alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
||||
*
|
||||
* The underlying memory for `Buffer` instances created in this way is _not_
|
||||
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.allocUnsafe(10);
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
|
||||
*
|
||||
* buf.fill(0);
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
|
||||
* ```
|
||||
*
|
||||
* A `TypeError` will be thrown if `size` is not a number.
|
||||
*
|
||||
* The `Buffer` module pre-allocates an internal `Buffer` instance of
|
||||
* size `Buffer.poolSize` that is used as a pool for the fast allocation of new `Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`,
|
||||
* and `Buffer.concat()` only when `size` is less than `Buffer.poolSize >>> 1` (floor of `Buffer.poolSize` divided by two).
|
||||
*
|
||||
* Use of this pre-allocated internal memory pool is a key difference between
|
||||
* calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
|
||||
* Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less
|
||||
* than or equal to half `Buffer.poolSize`. The
|
||||
* difference is subtle but can be important when an application requires the
|
||||
* additional performance that `Buffer.allocUnsafe()` provides.
|
||||
* @since v5.10.0
|
||||
* @param size The desired length of the new `Buffer`.
|
||||
*/
|
||||
allocUnsafe(size: number): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if
|
||||
* `size` is 0.
|
||||
*
|
||||
* The underlying memory for `Buffer` instances created in this way is _not_
|
||||
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
|
||||
* such `Buffer` instances with zeroes.
|
||||
*
|
||||
* When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
||||
* allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
|
||||
* allows applications to avoid the garbage collection overhead of creating many
|
||||
* individually allocated `Buffer` instances. This approach improves both
|
||||
* performance and memory usage by eliminating the need to track and clean up as
|
||||
* many individual `ArrayBuffer` objects.
|
||||
*
|
||||
* However, in the case where a developer may need to retain a small chunk of
|
||||
* memory from a pool for an indeterminate amount of time, it may be appropriate
|
||||
* to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
|
||||
* then copying out the relevant bits.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Need to keep around a few small chunks of memory.
|
||||
* const store = [];
|
||||
*
|
||||
* socket.on('readable', () => {
|
||||
* let data;
|
||||
* while (null !== (data = readable.read())) {
|
||||
* // Allocate for retained data.
|
||||
* const sb = Buffer.allocUnsafeSlow(10);
|
||||
*
|
||||
* // Copy the data into the new allocation.
|
||||
* data.copy(sb, 0, 0, 10);
|
||||
*
|
||||
* store.push(sb);
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* A `TypeError` will be thrown if `size` is not a number.
|
||||
* @since v5.12.0
|
||||
* @param size The desired length of the new `Buffer`.
|
||||
*/
|
||||
allocUnsafeSlow(size: number): Buffer<ArrayBuffer>;
|
||||
}
|
||||
interface Buffer<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> extends Uint8Array<TArrayBuffer> {
|
||||
// see buffer.d.ts for implementation shared with all TypeScript versions
|
||||
|
||||
/**
|
||||
* Returns a new `Buffer` that references the same memory as the original, but
|
||||
* offset and cropped by the `start` and `end` indices.
|
||||
*
|
||||
* This method is not compatible with the `Uint8Array.prototype.slice()`,
|
||||
* which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.from('buffer');
|
||||
*
|
||||
* const copiedBuf = Uint8Array.prototype.slice.call(buf);
|
||||
* copiedBuf[0]++;
|
||||
* console.log(copiedBuf.toString());
|
||||
* // Prints: cuffer
|
||||
*
|
||||
* console.log(buf.toString());
|
||||
* // Prints: buffer
|
||||
*
|
||||
* // With buf.slice(), the original buffer is modified.
|
||||
* const notReallyCopiedBuf = buf.slice();
|
||||
* notReallyCopiedBuf[0]++;
|
||||
* console.log(notReallyCopiedBuf.toString());
|
||||
* // Prints: cuffer
|
||||
* console.log(buf.toString());
|
||||
* // Also prints: cuffer (!)
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
* @deprecated Use `subarray` instead.
|
||||
* @param [start=0] Where the new `Buffer` will start.
|
||||
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
||||
*/
|
||||
slice(start?: number, end?: number): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Returns a new `Buffer` that references the same memory as the original, but
|
||||
* offset and cropped by the `start` and `end` indices.
|
||||
*
|
||||
* Specifying `end` greater than `buf.length` will return the same result as
|
||||
* that of `end` equal to `buf.length`.
|
||||
*
|
||||
* This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
|
||||
*
|
||||
* Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
|
||||
* // from the original `Buffer`.
|
||||
*
|
||||
* const buf1 = Buffer.allocUnsafe(26);
|
||||
*
|
||||
* for (let i = 0; i < 26; i++) {
|
||||
* // 97 is the decimal ASCII value for 'a'.
|
||||
* buf1[i] = i + 97;
|
||||
* }
|
||||
*
|
||||
* const buf2 = buf1.subarray(0, 3);
|
||||
*
|
||||
* console.log(buf2.toString('ascii', 0, buf2.length));
|
||||
* // Prints: abc
|
||||
*
|
||||
* buf1[0] = 33;
|
||||
*
|
||||
* console.log(buf2.toString('ascii', 0, buf2.length));
|
||||
* // Prints: !bc
|
||||
* ```
|
||||
*
|
||||
* Specifying negative indexes causes the slice to be generated relative to the
|
||||
* end of `buf` rather than the beginning.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.from('buffer');
|
||||
*
|
||||
* console.log(buf.subarray(-6, -1).toString());
|
||||
* // Prints: buffe
|
||||
* // (Equivalent to buf.subarray(0, 5).)
|
||||
*
|
||||
* console.log(buf.subarray(-6, -2).toString());
|
||||
* // Prints: buff
|
||||
* // (Equivalent to buf.subarray(0, 4).)
|
||||
*
|
||||
* console.log(buf.subarray(-5, -2).toString());
|
||||
* // Prints: uff
|
||||
* // (Equivalent to buf.subarray(1, 4).)
|
||||
* ```
|
||||
* @since v3.0.0
|
||||
* @param [start=0] Where the new `Buffer` will start.
|
||||
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
||||
*/
|
||||
subarray(start?: number, end?: number): Buffer<TArrayBuffer>;
|
||||
}
|
||||
type NonSharedBuffer = Buffer<ArrayBuffer>;
|
||||
type AllowSharedBuffer = Buffer<ArrayBufferLike>;
|
||||
}
|
||||
/** @deprecated Use `Buffer.allocUnsafeSlow()` instead. */
|
||||
var SlowBuffer: {
|
||||
/** @deprecated Use `Buffer.allocUnsafeSlow()` instead. */
|
||||
new(size: number): Buffer<ArrayBuffer>;
|
||||
prototype: Buffer;
|
||||
};
|
||||
}
|
||||
592
node_modules/@types/node/buffer.d.ts
generated
vendored
592
node_modules/@types/node/buffer.d.ts
generated
vendored
@@ -1,3 +1,8 @@
|
||||
// If lib.dom.d.ts or lib.webworker.d.ts is loaded, then use the global types.
|
||||
// Otherwise, use the types from node.
|
||||
type _Blob = typeof globalThis extends { onmessage: any; Blob: any } ? {} : import("buffer").Blob;
|
||||
type _File = typeof globalThis extends { onmessage: any; File: any } ? {} : import("buffer").File;
|
||||
|
||||
/**
|
||||
* `Buffer` objects are used to represent a fixed-length sequence of bytes. Many
|
||||
* Node.js APIs support `Buffer`s.
|
||||
@@ -41,7 +46,7 @@
|
||||
* // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].
|
||||
* const buf7 = Buffer.from('tést', 'latin1');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/buffer.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/buffer.js)
|
||||
*/
|
||||
declare module "buffer" {
|
||||
import { BinaryLike } from "node:crypto";
|
||||
@@ -64,7 +69,7 @@ declare module "buffer" {
|
||||
* @param input The input to validate.
|
||||
*/
|
||||
export function isAscii(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean;
|
||||
export const INSPECT_MAX_BYTES: number;
|
||||
export let INSPECT_MAX_BYTES: number;
|
||||
export const kMaxLength: number;
|
||||
export const kStringMaxLength: number;
|
||||
export const constants: {
|
||||
@@ -88,7 +93,7 @@ declare module "buffer" {
|
||||
* Throws if the `fromEnc` or `toEnc` specify invalid character encodings or if
|
||||
* conversion from `fromEnc` to `toEnc` is not permitted.
|
||||
*
|
||||
* Encodings supported by `buffer.transcode()` are: `'ascii'`, `'utf8'`,`'utf16le'`, `'ucs2'`, `'latin1'`, and `'binary'`.
|
||||
* Encodings supported by `buffer.transcode()` are: `'ascii'`, `'utf8'`, `'utf16le'`, `'ucs2'`, `'latin1'`, and `'binary'`.
|
||||
*
|
||||
* The transcoding process will use substitution characters if a given byte
|
||||
* sequence cannot be adequately represented in the target encoding. For instance:
|
||||
@@ -109,11 +114,6 @@ declare module "buffer" {
|
||||
* @param toEnc To target encoding.
|
||||
*/
|
||||
export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
|
||||
export const SlowBuffer: {
|
||||
/** @deprecated since v6.0.0, use `Buffer.allocUnsafeSlow()` */
|
||||
new(size: number): Buffer;
|
||||
prototype: Buffer;
|
||||
};
|
||||
/**
|
||||
* Resolves a `'blob:nodedata:...'` an associated `Blob` object registered using
|
||||
* a prior call to `URL.createObjectURL()`.
|
||||
@@ -122,15 +122,16 @@ declare module "buffer" {
|
||||
* @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
|
||||
*/
|
||||
export function resolveObjectURL(id: string): Blob | undefined;
|
||||
export { Buffer };
|
||||
export { type AllowSharedBuffer, Buffer, type NonSharedBuffer };
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface BlobOptions {
|
||||
/**
|
||||
* @default 'utf8'
|
||||
* One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts
|
||||
* will be converted to the platform native line-ending as specified by `import { EOL } from 'node:node:os'`.
|
||||
*/
|
||||
encoding?: BufferEncoding | undefined;
|
||||
endings?: "transparent" | "native";
|
||||
/**
|
||||
* The Blob content-type. The intent is for `type` to convey
|
||||
* the MIME media type of the data, however no validation of the type format
|
||||
@@ -162,13 +163,25 @@ declare module "buffer" {
|
||||
*
|
||||
* String sources are also copied into the `Blob`.
|
||||
*/
|
||||
constructor(sources: Array<BinaryLike | Blob>, options?: BlobOptions);
|
||||
constructor(sources: Array<ArrayBuffer | BinaryLike | Blob>, options?: BlobOptions);
|
||||
/**
|
||||
* Returns a promise that fulfills with an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) containing a copy of
|
||||
* the `Blob` data.
|
||||
* @since v15.7.0, v14.18.0
|
||||
*/
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
/**
|
||||
* The `blob.bytes()` method returns the byte of the `Blob` object as a `Promise<Uint8Array>`.
|
||||
*
|
||||
* ```js
|
||||
* const blob = new Blob(['hello']);
|
||||
* blob.bytes().then((bytes) => {
|
||||
* console.log(bytes); // Outputs: Uint8Array(5) [ 104, 101, 108, 108, 111 ]
|
||||
* });
|
||||
* ```
|
||||
* @since v20.16.0
|
||||
*/
|
||||
bytes(): Promise<Uint8Array>;
|
||||
/**
|
||||
* Creates and returns a new `Blob` containing a subset of this `Blob` objects
|
||||
* data. The original `Blob` is not altered.
|
||||
@@ -193,7 +206,7 @@ declare module "buffer" {
|
||||
export interface FileOptions {
|
||||
/**
|
||||
* One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts will be
|
||||
* converted to the platform native line-ending as specified by `require('node:os').EOL`.
|
||||
* converted to the platform native line-ending as specified by `import { EOL } from 'node:node:os'`.
|
||||
*/
|
||||
endings?: "native" | "transparent";
|
||||
/** The File content-type. */
|
||||
@@ -220,10 +233,10 @@ declare module "buffer" {
|
||||
}
|
||||
export import atob = globalThis.atob;
|
||||
export import btoa = globalThis.btoa;
|
||||
import { Blob as NodeBlob } from "buffer";
|
||||
// This conditional type will be the existing global Blob in a browser, or
|
||||
// the copy below in a Node environment.
|
||||
type __Blob = typeof globalThis extends { onmessage: any; Blob: any } ? {} : NodeBlob;
|
||||
export type WithImplicitCoercion<T> =
|
||||
| T
|
||||
| { valueOf(): T }
|
||||
| (T extends string ? { [Symbol.toPrimitive](hint: "string"): T } : never);
|
||||
global {
|
||||
namespace NodeJS {
|
||||
export { BufferEncoding };
|
||||
@@ -242,111 +255,15 @@ declare module "buffer" {
|
||||
| "latin1"
|
||||
| "binary"
|
||||
| "hex";
|
||||
type WithImplicitCoercion<T> =
|
||||
| T
|
||||
| {
|
||||
valueOf(): T;
|
||||
};
|
||||
/**
|
||||
* Raw data is stored in instances of the Buffer class.
|
||||
* A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
|
||||
* Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex'
|
||||
*/
|
||||
interface BufferConstructor {
|
||||
/**
|
||||
* Allocates a new buffer containing the given {str}.
|
||||
*
|
||||
* @param str String to store in buffer.
|
||||
* @param encoding encoding to use, optional. Default is 'utf8'
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
|
||||
*/
|
||||
new(str: string, encoding?: BufferEncoding): Buffer;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
|
||||
*/
|
||||
new(size: number): Buffer;
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
||||
*/
|
||||
new(array: Uint8Array): Buffer;
|
||||
/**
|
||||
* Produces a Buffer backed by the same allocated memory as
|
||||
* the given {ArrayBuffer}/{SharedArrayBuffer}.
|
||||
*
|
||||
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
|
||||
*/
|
||||
new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
||||
*/
|
||||
new(array: ReadonlyArray<any>): Buffer;
|
||||
/**
|
||||
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
||||
*
|
||||
* @param buffer The buffer to copy.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
|
||||
*/
|
||||
new(buffer: Buffer): Buffer;
|
||||
/**
|
||||
* Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
|
||||
* Array entries outside that range will be truncated to fit into it.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
|
||||
* const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
|
||||
* ```
|
||||
*
|
||||
* If `array` is an `Array`\-like object (that is, one with a `length` property of
|
||||
* type `number`), it is treated as if it is an array, unless it is a `Buffer` or
|
||||
* a `Uint8Array`. This means all other `TypedArray` variants get treated as an`Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use `Buffer.copyBytesFrom()`.
|
||||
*
|
||||
* A `TypeError` will be thrown if `array` is not an `Array` or another type
|
||||
* appropriate for `Buffer.from()` variants.
|
||||
*
|
||||
* `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does.
|
||||
* @since v5.10.0
|
||||
*/
|
||||
from(
|
||||
arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
|
||||
byteOffset?: number,
|
||||
length?: number,
|
||||
): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer using the passed {data}
|
||||
* @param data data to create a new Buffer
|
||||
*/
|
||||
from(data: Uint8Array | ReadonlyArray<number>): Buffer;
|
||||
from(data: WithImplicitCoercion<Uint8Array | ReadonlyArray<number> | string>): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer containing the given JavaScript string {str}.
|
||||
* If provided, the {encoding} parameter identifies the character encoding.
|
||||
* If not provided, {encoding} defaults to 'utf8'.
|
||||
*/
|
||||
from(
|
||||
str:
|
||||
| WithImplicitCoercion<string>
|
||||
| {
|
||||
[Symbol.toPrimitive](hint: "string"): string;
|
||||
},
|
||||
encoding?: BufferEncoding,
|
||||
): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer using the passed {data}
|
||||
* @param values to create a new Buffer
|
||||
*/
|
||||
of(...items: number[]): Buffer;
|
||||
// see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later
|
||||
// see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier
|
||||
|
||||
/**
|
||||
* Returns `true` if `obj` is a `Buffer`, `false` otherwise.
|
||||
*
|
||||
@@ -415,67 +332,11 @@ declare module "buffer" {
|
||||
* @return The number of bytes contained within `string`.
|
||||
*/
|
||||
byteLength(
|
||||
string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
|
||||
string: string | Buffer | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
|
||||
encoding?: BufferEncoding,
|
||||
): number;
|
||||
/**
|
||||
* Returns a new `Buffer` which is the result of concatenating all the `Buffer`instances in the `list` together.
|
||||
*
|
||||
* If the list has no items, or if the `totalLength` is 0, then a new zero-length`Buffer` is returned.
|
||||
*
|
||||
* If `totalLength` is not provided, it is calculated from the `Buffer` instances
|
||||
* in `list` by adding their lengths.
|
||||
*
|
||||
* If `totalLength` is provided, it is coerced to an unsigned integer. If the
|
||||
* combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
|
||||
* truncated to `totalLength`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Create a single `Buffer` from a list of three `Buffer` instances.
|
||||
*
|
||||
* const buf1 = Buffer.alloc(10);
|
||||
* const buf2 = Buffer.alloc(14);
|
||||
* const buf3 = Buffer.alloc(18);
|
||||
* const totalLength = buf1.length + buf2.length + buf3.length;
|
||||
*
|
||||
* console.log(totalLength);
|
||||
* // Prints: 42
|
||||
*
|
||||
* const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
|
||||
*
|
||||
* console.log(bufA);
|
||||
* // Prints: <Buffer 00 00 00 00 ...>
|
||||
* console.log(bufA.length);
|
||||
* // Prints: 42
|
||||
* ```
|
||||
*
|
||||
* `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
|
||||
* @since v0.7.11
|
||||
* @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
|
||||
* @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
|
||||
*/
|
||||
concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
|
||||
/**
|
||||
* Copies the underlying memory of `view` into a new `Buffer`.
|
||||
*
|
||||
* ```js
|
||||
* const u16 = new Uint16Array([0, 0xffff]);
|
||||
* const buf = Buffer.copyBytesFrom(u16, 1, 1);
|
||||
* u16[1] = 0;
|
||||
* console.log(buf.length); // 2
|
||||
* console.log(buf[0]); // 255
|
||||
* console.log(buf[1]); // 255
|
||||
* ```
|
||||
* @since v19.8.0
|
||||
* @param view The {TypedArray} to copy.
|
||||
* @param [offset=': 0'] The starting offset within `view`.
|
||||
* @param [length=view.length - offset] The number of elements from `view` to copy.
|
||||
*/
|
||||
copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer;
|
||||
/**
|
||||
* Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of`Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
|
||||
* Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of `Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
@@ -492,135 +353,6 @@ declare module "buffer" {
|
||||
* @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details.
|
||||
*/
|
||||
compare(buf1: Uint8Array, buf2: Uint8Array): -1 | 0 | 1;
|
||||
/**
|
||||
* Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.alloc(5);
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 00 00 00 00 00>
|
||||
* ```
|
||||
*
|
||||
* If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
||||
*
|
||||
* If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.alloc(5, 'a');
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 61 61 61 61 61>
|
||||
* ```
|
||||
*
|
||||
* If both `fill` and `encoding` are specified, the allocated `Buffer` will be
|
||||
* initialized by calling `buf.fill(fill, encoding)`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
|
||||
* ```
|
||||
*
|
||||
* Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
|
||||
* contents will never contain sensitive data from previous allocations, including
|
||||
* data that might not have been allocated for `Buffer`s.
|
||||
*
|
||||
* A `TypeError` will be thrown if `size` is not a number.
|
||||
* @since v5.10.0
|
||||
* @param size The desired length of the new `Buffer`.
|
||||
* @param [fill=0] A value to pre-fill the new `Buffer` with.
|
||||
* @param [encoding='utf8'] If `fill` is a string, this is its encoding.
|
||||
*/
|
||||
alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer;
|
||||
/**
|
||||
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
||||
*
|
||||
* The underlying memory for `Buffer` instances created in this way is _not_
|
||||
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.allocUnsafe(10);
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
|
||||
*
|
||||
* buf.fill(0);
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
|
||||
* ```
|
||||
*
|
||||
* A `TypeError` will be thrown if `size` is not a number.
|
||||
*
|
||||
* The `Buffer` module pre-allocates an internal `Buffer` instance of
|
||||
* size `Buffer.poolSize` that is used as a pool for the fast allocation of new`Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`,
|
||||
* and `Buffer.concat()` only when `size` is less than or equal to`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two).
|
||||
*
|
||||
* Use of this pre-allocated internal memory pool is a key difference between
|
||||
* calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
|
||||
* Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less
|
||||
* than or equal to half `Buffer.poolSize`. The
|
||||
* difference is subtle but can be important when an application requires the
|
||||
* additional performance that `Buffer.allocUnsafe()` provides.
|
||||
* @since v5.10.0
|
||||
* @param size The desired length of the new `Buffer`.
|
||||
*/
|
||||
allocUnsafe(size: number): Buffer;
|
||||
/**
|
||||
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if
|
||||
* `size` is 0.
|
||||
*
|
||||
* The underlying memory for `Buffer` instances created in this way is _not_
|
||||
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
|
||||
* such `Buffer` instances with zeroes.
|
||||
*
|
||||
* When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
||||
* allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
|
||||
* allows applications to avoid the garbage collection overhead of creating many
|
||||
* individually allocated `Buffer` instances. This approach improves both
|
||||
* performance and memory usage by eliminating the need to track and clean up as
|
||||
* many individual `ArrayBuffer` objects.
|
||||
*
|
||||
* However, in the case where a developer may need to retain a small chunk of
|
||||
* memory from a pool for an indeterminate amount of time, it may be appropriate
|
||||
* to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
|
||||
* then copying out the relevant bits.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Need to keep around a few small chunks of memory.
|
||||
* const store = [];
|
||||
*
|
||||
* socket.on('readable', () => {
|
||||
* let data;
|
||||
* while (null !== (data = readable.read())) {
|
||||
* // Allocate for retained data.
|
||||
* const sb = Buffer.allocUnsafeSlow(10);
|
||||
*
|
||||
* // Copy the data into the new allocation.
|
||||
* data.copy(sb, 0, 0, 10);
|
||||
*
|
||||
* store.push(sb);
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* A `TypeError` will be thrown if `size` is not a number.
|
||||
* @since v5.12.0
|
||||
* @param size The desired length of the new `Buffer`.
|
||||
*/
|
||||
allocUnsafeSlow(size: number): Buffer;
|
||||
/**
|
||||
* This is the size (in bytes) of pre-allocated internal `Buffer` instances used
|
||||
* for pooling. This value may be modified.
|
||||
@@ -628,7 +360,10 @@ declare module "buffer" {
|
||||
*/
|
||||
poolSize: number;
|
||||
}
|
||||
interface Buffer extends Uint8Array {
|
||||
interface Buffer {
|
||||
// see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later
|
||||
// see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier
|
||||
|
||||
/**
|
||||
* Writes `string` to `buf` at `offset` according to the character encoding in`encoding`. The `length` parameter is the number of bytes to write. If `buf` did
|
||||
* not contain enough space to fit the entire string, only part of `string` will be
|
||||
@@ -780,7 +515,7 @@ declare module "buffer" {
|
||||
* // (This result is equal to: [buf1, buf3, buf2].)
|
||||
* ```
|
||||
*
|
||||
* The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd`arguments can be used to limit the comparison to specific ranges within `target`and `buf` respectively.
|
||||
* The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd` arguments can be used to limit the comparison to specific ranges within `target` and `buf` respectively.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
@@ -796,7 +531,7 @@ declare module "buffer" {
|
||||
* // Prints: 1
|
||||
* ```
|
||||
*
|
||||
* `ERR_OUT_OF_RANGE` is thrown if `targetStart < 0`, `sourceStart < 0`,`targetEnd > target.byteLength`, or `sourceEnd > source.byteLength`.
|
||||
* `ERR_OUT_OF_RANGE` is thrown if `targetStart < 0`, `sourceStart < 0`, `targetEnd > target.byteLength`, or `sourceEnd > source.byteLength`.
|
||||
* @since v0.11.13
|
||||
* @param target A `Buffer` or {@link Uint8Array} with which to compare `buf`.
|
||||
* @param [targetStart=0] The offset within `target` at which to begin comparison.
|
||||
@@ -865,100 +600,6 @@ declare module "buffer" {
|
||||
* @return The number of bytes copied.
|
||||
*/
|
||||
copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
||||
/**
|
||||
* Returns a new `Buffer` that references the same memory as the original, but
|
||||
* offset and cropped by the `start` and `end` indices.
|
||||
*
|
||||
* This method is not compatible with the `Uint8Array.prototype.slice()`,
|
||||
* which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.from('buffer');
|
||||
*
|
||||
* const copiedBuf = Uint8Array.prototype.slice.call(buf);
|
||||
* copiedBuf[0]++;
|
||||
* console.log(copiedBuf.toString());
|
||||
* // Prints: cuffer
|
||||
*
|
||||
* console.log(buf.toString());
|
||||
* // Prints: buffer
|
||||
*
|
||||
* // With buf.slice(), the original buffer is modified.
|
||||
* const notReallyCopiedBuf = buf.slice();
|
||||
* notReallyCopiedBuf[0]++;
|
||||
* console.log(notReallyCopiedBuf.toString());
|
||||
* // Prints: cuffer
|
||||
* console.log(buf.toString());
|
||||
* // Also prints: cuffer (!)
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
* @deprecated Use `subarray` instead.
|
||||
* @param [start=0] Where the new `Buffer` will start.
|
||||
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
||||
*/
|
||||
slice(start?: number, end?: number): Buffer;
|
||||
/**
|
||||
* Returns a new `Buffer` that references the same memory as the original, but
|
||||
* offset and cropped by the `start` and `end` indices.
|
||||
*
|
||||
* Specifying `end` greater than `buf.length` will return the same result as
|
||||
* that of `end` equal to `buf.length`.
|
||||
*
|
||||
* This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
|
||||
*
|
||||
* Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
|
||||
* // from the original `Buffer`.
|
||||
*
|
||||
* const buf1 = Buffer.allocUnsafe(26);
|
||||
*
|
||||
* for (let i = 0; i < 26; i++) {
|
||||
* // 97 is the decimal ASCII value for 'a'.
|
||||
* buf1[i] = i + 97;
|
||||
* }
|
||||
*
|
||||
* const buf2 = buf1.subarray(0, 3);
|
||||
*
|
||||
* console.log(buf2.toString('ascii', 0, buf2.length));
|
||||
* // Prints: abc
|
||||
*
|
||||
* buf1[0] = 33;
|
||||
*
|
||||
* console.log(buf2.toString('ascii', 0, buf2.length));
|
||||
* // Prints: !bc
|
||||
* ```
|
||||
*
|
||||
* Specifying negative indexes causes the slice to be generated relative to the
|
||||
* end of `buf` rather than the beginning.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.from('buffer');
|
||||
*
|
||||
* console.log(buf.subarray(-6, -1).toString());
|
||||
* // Prints: buffe
|
||||
* // (Equivalent to buf.subarray(0, 5).)
|
||||
*
|
||||
* console.log(buf.subarray(-6, -2).toString());
|
||||
* // Prints: buff
|
||||
* // (Equivalent to buf.subarray(0, 4).)
|
||||
*
|
||||
* console.log(buf.subarray(-5, -2).toString());
|
||||
* // Prints: uff
|
||||
* // (Equivalent to buf.subarray(1, 4).)
|
||||
* ```
|
||||
* @since v3.0.0
|
||||
* @param [start=0] Where the new `Buffer` will start.
|
||||
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
||||
*/
|
||||
subarray(start?: number, end?: number): Buffer;
|
||||
/**
|
||||
* Writes `value` to `buf` at the specified `offset` as big-endian.
|
||||
*
|
||||
@@ -1214,7 +855,7 @@ declare module "buffer" {
|
||||
*/
|
||||
readBigInt64LE(offset?: number): bigint;
|
||||
/**
|
||||
* Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as an unsigned, little-endian integer supporting
|
||||
* Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as an unsigned, little-endian integer supporting
|
||||
* up to 48 bits of accuracy.
|
||||
*
|
||||
* This function is also available under the `readUintLE` alias.
|
||||
@@ -1238,7 +879,7 @@ declare module "buffer" {
|
||||
*/
|
||||
readUintLE(offset: number, byteLength: number): number;
|
||||
/**
|
||||
* Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as an unsigned big-endian integer supporting
|
||||
* Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as an unsigned big-endian integer supporting
|
||||
* up to 48 bits of accuracy.
|
||||
*
|
||||
* This function is also available under the `readUintBE` alias.
|
||||
@@ -1264,7 +905,7 @@ declare module "buffer" {
|
||||
*/
|
||||
readUintBE(offset: number, byteLength: number): number;
|
||||
/**
|
||||
* Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as a little-endian, two's complement signed value
|
||||
* Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as a little-endian, two's complement signed value
|
||||
* supporting up to 48 bits of accuracy.
|
||||
*
|
||||
* ```js
|
||||
@@ -1281,7 +922,7 @@ declare module "buffer" {
|
||||
*/
|
||||
readIntLE(offset: number, byteLength: number): number;
|
||||
/**
|
||||
* Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as a big-endian, two's complement signed value
|
||||
* Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as a big-endian, two's complement signed value
|
||||
* supporting up to 48 bits of accuracy.
|
||||
*
|
||||
* ```js
|
||||
@@ -1328,7 +969,7 @@ declare module "buffer" {
|
||||
*/
|
||||
readUint8(offset?: number): number;
|
||||
/**
|
||||
* Reads an unsigned, little-endian 16-bit integer from `buf` at the specified`offset`.
|
||||
* Reads an unsigned, little-endian 16-bit integer from `buf` at the specified `offset`.
|
||||
*
|
||||
* This function is also available under the `readUint16LE` alias.
|
||||
*
|
||||
@@ -1616,7 +1257,7 @@ declare module "buffer" {
|
||||
* @since v5.10.0
|
||||
* @return A reference to `buf`.
|
||||
*/
|
||||
swap16(): Buffer;
|
||||
swap16(): this;
|
||||
/**
|
||||
* Interprets `buf` as an array of unsigned 32-bit integers and swaps the
|
||||
* byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.
|
||||
@@ -1642,7 +1283,7 @@ declare module "buffer" {
|
||||
* @since v5.10.0
|
||||
* @return A reference to `buf`.
|
||||
*/
|
||||
swap32(): Buffer;
|
||||
swap32(): this;
|
||||
/**
|
||||
* Interprets `buf` as an array of 64-bit numbers and swaps byte order _in-place_.
|
||||
* Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.
|
||||
@@ -1668,7 +1309,7 @@ declare module "buffer" {
|
||||
* @since v6.3.0
|
||||
* @return A reference to `buf`.
|
||||
*/
|
||||
swap64(): Buffer;
|
||||
swap64(): this;
|
||||
/**
|
||||
* Writes `value` to `buf` at the specified `offset`. `value` must be a
|
||||
* valid unsigned 8-bit integer. Behavior is undefined when `value` is anything
|
||||
@@ -1701,7 +1342,7 @@ declare module "buffer" {
|
||||
*/
|
||||
writeUint8(value: number, offset?: number): number;
|
||||
/**
|
||||
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid unsigned 16-bit integer. Behavior is undefined when `value` is
|
||||
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid unsigned 16-bit integer. Behavior is undefined when `value` is
|
||||
* anything other than an unsigned 16-bit integer.
|
||||
*
|
||||
* This function is also available under the `writeUint16LE` alias.
|
||||
@@ -1729,7 +1370,7 @@ declare module "buffer" {
|
||||
*/
|
||||
writeUint16LE(value: number, offset?: number): number;
|
||||
/**
|
||||
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid unsigned 16-bit integer. Behavior is undefined when `value`is anything other than an
|
||||
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid unsigned 16-bit integer. Behavior is undefined when `value`is anything other than an
|
||||
* unsigned 16-bit integer.
|
||||
*
|
||||
* This function is also available under the `writeUint16BE` alias.
|
||||
@@ -1757,7 +1398,7 @@ declare module "buffer" {
|
||||
*/
|
||||
writeUint16BE(value: number, offset?: number): number;
|
||||
/**
|
||||
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid unsigned 32-bit integer. Behavior is undefined when `value` is
|
||||
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid unsigned 32-bit integer. Behavior is undefined when `value` is
|
||||
* anything other than an unsigned 32-bit integer.
|
||||
*
|
||||
* This function is also available under the `writeUint32LE` alias.
|
||||
@@ -1784,7 +1425,7 @@ declare module "buffer" {
|
||||
*/
|
||||
writeUint32LE(value: number, offset?: number): number;
|
||||
/**
|
||||
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid unsigned 32-bit integer. Behavior is undefined when `value`is anything other than an
|
||||
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid unsigned 32-bit integer. Behavior is undefined when `value`is anything other than an
|
||||
* unsigned 32-bit integer.
|
||||
*
|
||||
* This function is also available under the `writeUint32BE` alias.
|
||||
@@ -1835,7 +1476,7 @@ declare module "buffer" {
|
||||
*/
|
||||
writeInt8(value: number, offset?: number): number;
|
||||
/**
|
||||
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid signed 16-bit integer. Behavior is undefined when `value` is
|
||||
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid signed 16-bit integer. Behavior is undefined when `value` is
|
||||
* anything other than a signed 16-bit integer.
|
||||
*
|
||||
* The `value` is interpreted and written as a two's complement signed integer.
|
||||
@@ -1857,7 +1498,7 @@ declare module "buffer" {
|
||||
*/
|
||||
writeInt16LE(value: number, offset?: number): number;
|
||||
/**
|
||||
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid signed 16-bit integer. Behavior is undefined when `value` is
|
||||
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid signed 16-bit integer. Behavior is undefined when `value` is
|
||||
* anything other than a signed 16-bit integer.
|
||||
*
|
||||
* The `value` is interpreted and written as a two's complement signed integer.
|
||||
@@ -1879,7 +1520,7 @@ declare module "buffer" {
|
||||
*/
|
||||
writeInt16BE(value: number, offset?: number): number;
|
||||
/**
|
||||
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid signed 32-bit integer. Behavior is undefined when `value` is
|
||||
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid signed 32-bit integer. Behavior is undefined when `value` is
|
||||
* anything other than a signed 32-bit integer.
|
||||
*
|
||||
* The `value` is interpreted and written as a two's complement signed integer.
|
||||
@@ -1901,7 +1542,7 @@ declare module "buffer" {
|
||||
*/
|
||||
writeInt32LE(value: number, offset?: number): number;
|
||||
/**
|
||||
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid signed 32-bit integer. Behavior is undefined when `value` is
|
||||
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid signed 32-bit integer. Behavior is undefined when `value` is
|
||||
* anything other than a signed 32-bit integer.
|
||||
*
|
||||
* The `value` is interpreted and written as a two's complement signed integer.
|
||||
@@ -1963,7 +1604,7 @@ declare module "buffer" {
|
||||
*/
|
||||
writeFloatBE(value: number, offset?: number): number;
|
||||
/**
|
||||
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a JavaScript number. Behavior is undefined when `value` is anything
|
||||
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a JavaScript number. Behavior is undefined when `value` is anything
|
||||
* other than a JavaScript number.
|
||||
*
|
||||
* ```js
|
||||
@@ -1983,7 +1624,7 @@ declare module "buffer" {
|
||||
*/
|
||||
writeDoubleLE(value: number, offset?: number): number;
|
||||
/**
|
||||
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a JavaScript number. Behavior is undefined when `value` is anything
|
||||
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a JavaScript number. Behavior is undefined when `value` is anything
|
||||
* other than a JavaScript number.
|
||||
*
|
||||
* ```js
|
||||
@@ -2062,10 +1703,12 @@ declare module "buffer" {
|
||||
* @return A reference to `buf`.
|
||||
*/
|
||||
fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this;
|
||||
fill(value: string | Uint8Array | number, offset: number, encoding: BufferEncoding): this;
|
||||
fill(value: string | Uint8Array | number, encoding: BufferEncoding): this;
|
||||
/**
|
||||
* If `value` is:
|
||||
*
|
||||
* * a string, `value` is interpreted according to the character encoding in`encoding`.
|
||||
* * a string, `value` is interpreted according to the character encoding in `encoding`.
|
||||
* * a `Buffer` or [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), `value` will be used in its entirety.
|
||||
* To compare a partial `Buffer`, use `buf.subarray`.
|
||||
* * a number, `value` will be interpreted as an unsigned 8-bit integer
|
||||
@@ -2097,7 +1740,7 @@ declare module "buffer" {
|
||||
* // Prints: 6
|
||||
* ```
|
||||
*
|
||||
* If `value` is not a string, number, or `Buffer`, this method will throw a`TypeError`. If `value` is a number, it will be coerced to a valid byte value,
|
||||
* If `value` is not a string, number, or `Buffer`, this method will throw a `TypeError`. If `value` is a number, it will be coerced to a valid byte value,
|
||||
* an integer between 0 and 255.
|
||||
*
|
||||
* If `byteOffset` is not a number, it will be coerced to a number. If the result
|
||||
@@ -2131,6 +1774,7 @@ declare module "buffer" {
|
||||
* @return The index of the first occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
|
||||
*/
|
||||
indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
|
||||
indexOf(value: string | number | Uint8Array, encoding: BufferEncoding): number;
|
||||
/**
|
||||
* Identical to `buf.indexOf()`, except the last occurrence of `value` is found
|
||||
* rather than the first occurrence.
|
||||
@@ -2163,7 +1807,7 @@ declare module "buffer" {
|
||||
* // Prints: 4
|
||||
* ```
|
||||
*
|
||||
* If `value` is not a string, number, or `Buffer`, this method will throw a`TypeError`. If `value` is a number, it will be coerced to a valid byte value,
|
||||
* If `value` is not a string, number, or `Buffer`, this method will throw a `TypeError`. If `value` is a number, it will be coerced to a valid byte value,
|
||||
* an integer between 0 and 255.
|
||||
*
|
||||
* If `byteOffset` is not a number, it will be coerced to a number. Any arguments
|
||||
@@ -2199,31 +1843,7 @@ declare module "buffer" {
|
||||
* @return The index of the last occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
|
||||
*/
|
||||
lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
|
||||
/**
|
||||
* Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `[index, byte]` pairs from the contents
|
||||
* of `buf`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Log the entire contents of a `Buffer`.
|
||||
*
|
||||
* const buf = Buffer.from('buffer');
|
||||
*
|
||||
* for (const pair of buf.entries()) {
|
||||
* console.log(pair);
|
||||
* }
|
||||
* // Prints:
|
||||
* // [0, 98]
|
||||
* // [1, 117]
|
||||
* // [2, 102]
|
||||
* // [3, 102]
|
||||
* // [4, 101]
|
||||
* // [5, 114]
|
||||
* ```
|
||||
* @since v1.1.0
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
lastIndexOf(value: string | number | Uint8Array, encoding: BufferEncoding): number;
|
||||
/**
|
||||
* Equivalent to `buf.indexOf() !== -1`.
|
||||
*
|
||||
@@ -2254,62 +1874,7 @@ declare module "buffer" {
|
||||
* @return `true` if `value` was found in `buf`, `false` otherwise.
|
||||
*/
|
||||
includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean;
|
||||
/**
|
||||
* Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indices).
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.from('buffer');
|
||||
*
|
||||
* for (const key of buf.keys()) {
|
||||
* console.log(key);
|
||||
* }
|
||||
* // Prints:
|
||||
* // 0
|
||||
* // 1
|
||||
* // 2
|
||||
* // 3
|
||||
* // 4
|
||||
* // 5
|
||||
* ```
|
||||
* @since v1.1.0
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) for `buf` values (bytes). This function is
|
||||
* called automatically when a `Buffer` is used in a `for..of` statement.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.from('buffer');
|
||||
*
|
||||
* for (const value of buf.values()) {
|
||||
* console.log(value);
|
||||
* }
|
||||
* // Prints:
|
||||
* // 98
|
||||
* // 117
|
||||
* // 102
|
||||
* // 102
|
||||
* // 101
|
||||
* // 114
|
||||
*
|
||||
* for (const value of buf) {
|
||||
* console.log(value);
|
||||
* }
|
||||
* // Prints:
|
||||
* // 98
|
||||
* // 117
|
||||
* // 102
|
||||
* // 102
|
||||
* // 101
|
||||
* // 114
|
||||
* ```
|
||||
* @since v1.1.0
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
includes(value: string | number | Buffer, encoding: BufferEncoding): boolean;
|
||||
}
|
||||
var Buffer: BufferConstructor;
|
||||
/**
|
||||
@@ -2322,7 +1887,7 @@ declare module "buffer" {
|
||||
* **and should never be used in new code, because they use strings to represent**
|
||||
* **binary data and predate the introduction of typed arrays in JavaScript.**
|
||||
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
||||
* **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.**
|
||||
* **and binary data should be performed using `Buffer.from(str, 'base64')` and `buf.toString('base64')`.**
|
||||
* @since v15.13.0, v14.17.0
|
||||
* @legacy Use `Buffer.from(data, 'base64')` instead.
|
||||
* @param data The Base64-encoded input string.
|
||||
@@ -2338,23 +1903,28 @@ declare module "buffer" {
|
||||
* **and should never be used in new code, because they use strings to represent**
|
||||
* **binary data and predate the introduction of typed arrays in JavaScript.**
|
||||
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
||||
* **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.**
|
||||
* **and binary data should be performed using `Buffer.from(str, 'base64')` and `buf.toString('base64')`.**
|
||||
* @since v15.13.0, v14.17.0
|
||||
* @legacy Use `buf.toString('base64')` instead.
|
||||
* @param data An ASCII (Latin1) string.
|
||||
*/
|
||||
function btoa(data: string): string;
|
||||
interface Blob extends __Blob {}
|
||||
interface Blob extends _Blob {}
|
||||
/**
|
||||
* `Blob` class is a global reference for `require('node:buffer').Blob`
|
||||
* `Blob` class is a global reference for `import { Blob } from 'node:node:buffer'`
|
||||
* https://nodejs.org/api/buffer.html#class-blob
|
||||
* @since v18.0.0
|
||||
*/
|
||||
var Blob: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
Blob: infer T;
|
||||
} ? T
|
||||
: typeof NodeBlob;
|
||||
var Blob: typeof globalThis extends { onmessage: any; Blob: infer T } ? T
|
||||
: typeof import("buffer").Blob;
|
||||
interface File extends _File {}
|
||||
/**
|
||||
* `File` class is a global reference for `import { File } from 'node:node:buffer'`
|
||||
* https://nodejs.org/api/buffer.html#class-file
|
||||
* @since v20.0.0
|
||||
*/
|
||||
var File: typeof globalThis extends { onmessage: any; File: infer T } ? T
|
||||
: typeof import("buffer").File;
|
||||
}
|
||||
}
|
||||
declare module "node:buffer" {
|
||||
|
||||
196
node_modules/@types/node/child_process.d.ts
generated
vendored
196
node_modules/@types/node/child_process.d.ts
generated
vendored
@@ -4,7 +4,7 @@
|
||||
* is primarily provided by the {@link spawn} function:
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('node:child_process');
|
||||
* import { spawn } from 'node:child_process';
|
||||
* const ls = spawn('ls', ['-lh', '/usr']);
|
||||
*
|
||||
* ls.stdout.on('data', (data) => {
|
||||
@@ -25,7 +25,7 @@
|
||||
* limited (and platform-specific) capacity. If the subprocess writes to
|
||||
* stdout in excess of that limit without the output being captured, the
|
||||
* subprocess blocks waiting for the pipe buffer to accept more data. This is
|
||||
* identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }`option if the output will not be consumed.
|
||||
* identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }` option if the output will not be consumed.
|
||||
*
|
||||
* The command lookup is performed using the `options.env.PATH` environment
|
||||
* variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is
|
||||
@@ -38,7 +38,7 @@
|
||||
* lexicographically sorts the `env` keys and uses the first one that
|
||||
* case-insensitively matches. Only first (in lexicographic order) entry will be
|
||||
* passed to the subprocess. This might lead to issues on Windows when passing
|
||||
* objects to the `env` option that have multiple variants of the same key, such as`PATH` and `Path`.
|
||||
* objects to the `env` option that have multiple variants of the same key, such as `PATH` and `Path`.
|
||||
*
|
||||
* The {@link spawn} method spawns the child process asynchronously,
|
||||
* without blocking the Node.js event loop. The {@link spawnSync} function provides equivalent functionality in a synchronous manner that blocks
|
||||
@@ -63,16 +63,17 @@
|
||||
* For certain use cases, such as automating shell scripts, the `synchronous counterparts` may be more convenient. In many cases, however,
|
||||
* the synchronous methods can have significant impact on performance due to
|
||||
* stalling the event loop while spawned processes complete.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/child_process.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/child_process.js)
|
||||
*/
|
||||
declare module "child_process" {
|
||||
import { ObjectEncodingOptions } from "node:fs";
|
||||
import { Abortable, EventEmitter } from "node:events";
|
||||
import * as dgram from "node:dgram";
|
||||
import * as net from "node:net";
|
||||
import { Pipe, Readable, Stream, Writable } from "node:stream";
|
||||
import { URL } from "node:url";
|
||||
type Serializable = string | object | number | boolean | bigint;
|
||||
type SendHandle = net.Socket | net.Server;
|
||||
type SendHandle = net.Socket | net.Server | dgram.Socket | undefined;
|
||||
/**
|
||||
* Instances of the `ChildProcess` represent spawned child processes.
|
||||
*
|
||||
@@ -94,7 +95,7 @@ declare module "child_process" {
|
||||
* `subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will
|
||||
* refer to the same value.
|
||||
*
|
||||
* The `subprocess.stdin` property can be `null` or `undefined`if the child process could not be successfully spawned.
|
||||
* The `subprocess.stdin` property can be `null` or `undefined` if the child process could not be successfully spawned.
|
||||
* @since v0.1.90
|
||||
*/
|
||||
stdin: Writable | null;
|
||||
@@ -108,7 +109,7 @@ declare module "child_process" {
|
||||
* refer to the same value.
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('node:child_process');
|
||||
* import { spawn } from 'node:child_process';
|
||||
*
|
||||
* const subprocess = spawn('ls');
|
||||
*
|
||||
@@ -117,7 +118,7 @@ declare module "child_process" {
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* The `subprocess.stdout` property can be `null` or `undefined`if the child process could not be successfully spawned.
|
||||
* The `subprocess.stdout` property can be `null` or `undefined` if the child process could not be successfully spawned.
|
||||
* @since v0.1.90
|
||||
*/
|
||||
stdout: Readable | null;
|
||||
@@ -130,7 +131,7 @@ declare module "child_process" {
|
||||
* `subprocess.stderr` is an alias for `subprocess.stdio[2]`. Both properties will
|
||||
* refer to the same value.
|
||||
*
|
||||
* The `subprocess.stderr` property can be `null` or `undefined`if the child process could not be successfully spawned.
|
||||
* The `subprocess.stderr` property can be `null` or `undefined` if the child process could not be successfully spawned.
|
||||
* @since v0.1.90
|
||||
*/
|
||||
stderr: Readable | null;
|
||||
@@ -143,7 +144,7 @@ declare module "child_process" {
|
||||
/**
|
||||
* A sparse array of pipes to the child process, corresponding with positions in
|
||||
* the `stdio` option passed to {@link spawn} that have been set
|
||||
* to the value `'pipe'`. `subprocess.stdio[0]`, `subprocess.stdio[1]`, and`subprocess.stdio[2]` are also available as `subprocess.stdin`,`subprocess.stdout`, and `subprocess.stderr`,
|
||||
* to the value `'pipe'`. `subprocess.stdio[0]`, `subprocess.stdio[1]`, and `subprocess.stdio[2]` are also available as `subprocess.stdin`, `subprocess.stdout`, and `subprocess.stderr`,
|
||||
* respectively.
|
||||
*
|
||||
* In the following example, only the child's fd `1` (stdout) is configured as a
|
||||
@@ -151,9 +152,9 @@ declare module "child_process" {
|
||||
* in the array are `null`.
|
||||
*
|
||||
* ```js
|
||||
* const assert = require('node:assert');
|
||||
* const fs = require('node:fs');
|
||||
* const child_process = require('node:child_process');
|
||||
* import assert from 'node:assert';
|
||||
* import fs from 'node:fs';
|
||||
* import child_process from 'node:child_process';
|
||||
*
|
||||
* const subprocess = child_process.spawn('ls', {
|
||||
* stdio: [
|
||||
@@ -201,7 +202,7 @@ declare module "child_process" {
|
||||
* emitted.
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('node:child_process');
|
||||
* import { spawn } from 'node:child_process';
|
||||
* const grep = spawn('grep', ['ssh']);
|
||||
*
|
||||
* console.log(`Spawned child pid: ${grep.pid}`);
|
||||
@@ -212,7 +213,7 @@ declare module "child_process" {
|
||||
readonly pid?: number | undefined;
|
||||
/**
|
||||
* The `subprocess.connected` property indicates whether it is still possible to
|
||||
* send and receive messages from a child process. When `subprocess.connected` is`false`, it is no longer possible to send or receive messages.
|
||||
* send and receive messages from a child process. When `subprocess.connected` is `false`, it is no longer possible to send or receive messages.
|
||||
* @since v0.7.2
|
||||
*/
|
||||
readonly connected: boolean;
|
||||
@@ -248,7 +249,7 @@ declare module "child_process" {
|
||||
* returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise.
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('node:child_process');
|
||||
* import { spawn } from 'node:child_process';
|
||||
* const grep = spawn('grep', ['ssh']);
|
||||
*
|
||||
* grep.on('close', (code, signal) => {
|
||||
@@ -272,7 +273,7 @@ declare module "child_process" {
|
||||
* See [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for reference.
|
||||
*
|
||||
* On Windows, where POSIX signals do not exist, the `signal` argument will be
|
||||
* ignored, and the process will be killed forcefully and abruptly (similar to`'SIGKILL'`).
|
||||
* ignored, and the process will be killed forcefully and abruptly (similar to `'SIGKILL'`).
|
||||
* See `Signal Events` for more details.
|
||||
*
|
||||
* On Linux, child processes of child processes will not be terminated
|
||||
@@ -281,7 +282,7 @@ declare module "child_process" {
|
||||
*
|
||||
* ```js
|
||||
* 'use strict';
|
||||
* const { spawn } = require('node:child_process');
|
||||
* import { spawn } from 'node:child_process';
|
||||
*
|
||||
* const subprocess = spawn(
|
||||
* 'sh',
|
||||
@@ -319,7 +320,7 @@ declare module "child_process" {
|
||||
* For example, in the parent script:
|
||||
*
|
||||
* ```js
|
||||
* const cp = require('node:child_process');
|
||||
* import cp from 'node:child_process';
|
||||
* const n = cp.fork(`${__dirname}/sub.js`);
|
||||
*
|
||||
* n.on('message', (m) => {
|
||||
@@ -346,20 +347,20 @@ declare module "child_process" {
|
||||
*
|
||||
* There is a special case when sending a `{cmd: 'NODE_foo'}` message. Messages
|
||||
* containing a `NODE_` prefix in the `cmd` property are reserved for use within
|
||||
* Node.js core and will not be emitted in the child's `'message'` event. Rather, such messages are emitted using the`'internalMessage'` event and are consumed internally by Node.js.
|
||||
* Applications should avoid using such messages or listening for`'internalMessage'` events as it is subject to change without notice.
|
||||
* Node.js core and will not be emitted in the child's `'message'` event. Rather, such messages are emitted using the `'internalMessage'` event and are consumed internally by Node.js.
|
||||
* Applications should avoid using such messages or listening for `'internalMessage'` events as it is subject to change without notice.
|
||||
*
|
||||
* The optional `sendHandle` argument that may be passed to `subprocess.send()` is
|
||||
* for passing a TCP server or socket object to the child process. The child will
|
||||
* receive the object as the second argument passed to the callback function
|
||||
* registered on the `'message'` event. Any data that is received
|
||||
* and buffered in the socket will not be sent to the child.
|
||||
* registered on the `'message'` event. Any data that is received and buffered in
|
||||
* the socket will not be sent to the child. Sending IPC sockets is not supported on Windows.
|
||||
*
|
||||
* The optional `callback` is a function that is invoked after the message is
|
||||
* sent but before the child may have received it. The function is called with a
|
||||
* single argument: `null` on success, or an `Error` object on failure.
|
||||
*
|
||||
* If no `callback` function is provided and the message cannot be sent, an`'error'` event will be emitted by the `ChildProcess` object. This can
|
||||
* If no `callback` function is provided and the message cannot be sent, an `'error'` event will be emitted by the `ChildProcess` object. This can
|
||||
* happen, for instance, when the child process has already exited.
|
||||
*
|
||||
* `subprocess.send()` will return `false` if the channel has closed or when the
|
||||
@@ -373,10 +374,12 @@ declare module "child_process" {
|
||||
* a TCP server object to the child process as illustrated in the example below:
|
||||
*
|
||||
* ```js
|
||||
* const subprocess = require('node:child_process').fork('subprocess.js');
|
||||
* import child_process from 'node:child_process';
|
||||
* const subprocess = child_process.fork('subprocess.js');
|
||||
*
|
||||
* // Open up the server object and send the handle.
|
||||
* const server = require('node:net').createServer();
|
||||
* import net from 'node:net';
|
||||
* const server = net.createServer();
|
||||
* server.on('connection', (socket) => {
|
||||
* socket.end('handled by parent');
|
||||
* });
|
||||
@@ -400,8 +403,8 @@ declare module "child_process" {
|
||||
* Once the server is now shared between the parent and child, some connections
|
||||
* can be handled by the parent and some by the child.
|
||||
*
|
||||
* While the example above uses a server created using the `node:net` module,`node:dgram` module servers use exactly the same workflow with the exceptions of
|
||||
* listening on a `'message'` event instead of `'connection'` and using`server.bind()` instead of `server.listen()`. This is, however, only
|
||||
* While the example above uses a server created using the `node:net` module, `node:dgram` module servers use exactly the same workflow with the exceptions of
|
||||
* listening on a `'message'` event instead of `'connection'` and using `server.bind()` instead of `server.listen()`. This is, however, only
|
||||
* supported on Unix platforms.
|
||||
*
|
||||
* #### Example: sending a socket object
|
||||
@@ -411,13 +414,14 @@ declare module "child_process" {
|
||||
* handle connections with "normal" or "special" priority:
|
||||
*
|
||||
* ```js
|
||||
* const { fork } = require('node:child_process');
|
||||
* import { fork } from 'node:child_process';
|
||||
* const normal = fork('subprocess.js', ['normal']);
|
||||
* const special = fork('subprocess.js', ['special']);
|
||||
*
|
||||
* // Open up the server and send sockets to child. Use pauseOnConnect to prevent
|
||||
* // the sockets from being read before they are sent to the child process.
|
||||
* const server = require('node:net').createServer({ pauseOnConnect: true });
|
||||
* import net from 'node:net';
|
||||
* const server = net.createServer({ pauseOnConnect: true });
|
||||
* server.on('connection', (socket) => {
|
||||
*
|
||||
* // If this is special priority...
|
||||
@@ -454,6 +458,7 @@ declare module "child_process" {
|
||||
* as the connection may have been closed during the time it takes to send the
|
||||
* connection to the child.
|
||||
* @since v0.5.9
|
||||
* @param sendHandle `undefined`, or a [`net.Socket`](https://nodejs.org/docs/latest-v20.x/api/net.html#class-netsocket), [`net.Server`](https://nodejs.org/docs/latest-v20.x/api/net.html#class-netserver), or [`dgram.Socket`](https://nodejs.org/docs/latest-v20.x/api/dgram.html#class-dgramsocket) object.
|
||||
* @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: Serializable, callback?: (error: Error | null) => void): boolean;
|
||||
@@ -482,13 +487,13 @@ declare module "child_process" {
|
||||
disconnect(): void;
|
||||
/**
|
||||
* By default, the parent will wait for the detached child to exit. To prevent the
|
||||
* parent from waiting for a given `subprocess` to exit, use the`subprocess.unref()` method. Doing so will cause the parent's event loop to not
|
||||
* parent from waiting for a given `subprocess` to exit, use the `subprocess.unref()` method. Doing so will cause the parent's event loop to not
|
||||
* include the child in its reference count, allowing the parent to exit
|
||||
* independently of the child, unless there is an established IPC channel between
|
||||
* the child and the parent.
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('node:child_process');
|
||||
* import { spawn } from 'node:child_process';
|
||||
*
|
||||
* const subprocess = spawn(process.argv[0], ['child_program.js'], {
|
||||
* detached: true,
|
||||
@@ -506,7 +511,7 @@ declare module "child_process" {
|
||||
* to wait for the child to exit before exiting itself.
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('node:child_process');
|
||||
* import { spawn } from 'node:child_process';
|
||||
*
|
||||
* const subprocess = spawn(process.argv[0], ['child_program.js'], {
|
||||
* detached: true,
|
||||
@@ -678,7 +683,7 @@ declare module "child_process" {
|
||||
stdio: [Stdin, Stdout, Stderr];
|
||||
}
|
||||
/**
|
||||
* The `child_process.spawn()` method spawns a new process using the given`command`, with command-line arguments in `args`. If omitted, `args` defaults
|
||||
* The `child_process.spawn()` method spawns a new process using the given `command`, with command-line arguments in `args`. If omitted, `args` defaults
|
||||
* to an empty array.
|
||||
*
|
||||
* **If the `shell` option is enabled, do not pass unsanitized user input to this**
|
||||
@@ -709,7 +714,7 @@ declare module "child_process" {
|
||||
* exit code:
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('node:child_process');
|
||||
* import { spawn } from 'node:child_process';
|
||||
* const ls = spawn('ls', ['-lh', '/usr']);
|
||||
*
|
||||
* ls.stdout.on('data', (data) => {
|
||||
@@ -728,7 +733,7 @@ declare module "child_process" {
|
||||
* Example: A very elaborate way to run `ps ax | grep ssh`
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('node:child_process');
|
||||
* import { spawn } from 'node:child_process';
|
||||
* const ps = spawn('ps', ['ax']);
|
||||
* const grep = spawn('grep', ['ssh']);
|
||||
*
|
||||
@@ -765,7 +770,7 @@ declare module "child_process" {
|
||||
* Example of checking for failed `spawn`:
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('node:child_process');
|
||||
* import { spawn } from 'node:child_process';
|
||||
* const subprocess = spawn('bad_command');
|
||||
*
|
||||
* subprocess.on('error', (err) => {
|
||||
@@ -776,14 +781,14 @@ declare module "child_process" {
|
||||
* Certain platforms (macOS, Linux) will use the value of `argv[0]` for the process
|
||||
* title while others (Windows, SunOS) will use `command`.
|
||||
*
|
||||
* Node.js overwrites `argv[0]` with `process.execPath` on startup, so`process.argv[0]` in a Node.js child process will not match the `argv0`parameter passed to `spawn` from the parent. Retrieve
|
||||
* it with the`process.argv0` property instead.
|
||||
* Node.js overwrites `argv[0]` with `process.execPath` on startup, so `process.argv[0]` in a Node.js child process will not match the `argv0` parameter passed to `spawn` from the parent. Retrieve
|
||||
* it with the `process.argv0` property instead.
|
||||
*
|
||||
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
||||
* If the `signal` option is enabled, calling `.abort()` on the corresponding `AbortController` is similar to calling `.kill()` on the child process except
|
||||
* the error passed to the callback will be an `AbortError`:
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('node:child_process');
|
||||
* import { spawn } from 'node:child_process';
|
||||
* const controller = new AbortController();
|
||||
* const { signal } = controller;
|
||||
* const grep = spawn('grep', ['ssh'], { signal });
|
||||
@@ -833,50 +838,50 @@ declare module "child_process" {
|
||||
// overloads of spawn with 'args'
|
||||
function spawn(
|
||||
command: string,
|
||||
args?: ReadonlyArray<string>,
|
||||
args?: readonly string[],
|
||||
options?: SpawnOptionsWithoutStdio,
|
||||
): ChildProcessWithoutNullStreams;
|
||||
function spawn(
|
||||
command: string,
|
||||
args: ReadonlyArray<string>,
|
||||
args: readonly string[],
|
||||
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
|
||||
): ChildProcessByStdio<Writable, Readable, Readable>;
|
||||
function spawn(
|
||||
command: string,
|
||||
args: ReadonlyArray<string>,
|
||||
args: readonly string[],
|
||||
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
|
||||
): ChildProcessByStdio<Writable, Readable, null>;
|
||||
function spawn(
|
||||
command: string,
|
||||
args: ReadonlyArray<string>,
|
||||
args: readonly string[],
|
||||
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
|
||||
): ChildProcessByStdio<Writable, null, Readable>;
|
||||
function spawn(
|
||||
command: string,
|
||||
args: ReadonlyArray<string>,
|
||||
args: readonly string[],
|
||||
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
|
||||
): ChildProcessByStdio<null, Readable, Readable>;
|
||||
function spawn(
|
||||
command: string,
|
||||
args: ReadonlyArray<string>,
|
||||
args: readonly string[],
|
||||
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
|
||||
): ChildProcessByStdio<Writable, null, null>;
|
||||
function spawn(
|
||||
command: string,
|
||||
args: ReadonlyArray<string>,
|
||||
args: readonly string[],
|
||||
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
|
||||
): ChildProcessByStdio<null, Readable, null>;
|
||||
function spawn(
|
||||
command: string,
|
||||
args: ReadonlyArray<string>,
|
||||
args: readonly string[],
|
||||
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
|
||||
): ChildProcessByStdio<null, null, Readable>;
|
||||
function spawn(
|
||||
command: string,
|
||||
args: ReadonlyArray<string>,
|
||||
args: readonly string[],
|
||||
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
|
||||
): ChildProcessByStdio<null, null, null>;
|
||||
function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptions): ChildProcess;
|
||||
function spawn(command: string, args: readonly string[], options: SpawnOptions): ChildProcess;
|
||||
interface ExecOptions extends CommonOptions {
|
||||
shell?: string | undefined;
|
||||
signal?: AbortSignal | undefined;
|
||||
@@ -894,6 +899,8 @@ declare module "child_process" {
|
||||
killed?: boolean | undefined;
|
||||
code?: number | undefined;
|
||||
signal?: NodeJS.Signals | undefined;
|
||||
stdout?: string;
|
||||
stderr?: string;
|
||||
}
|
||||
/**
|
||||
* Spawns a shell then executes the `command` within that shell, buffering any
|
||||
@@ -902,7 +909,7 @@ declare module "child_process" {
|
||||
* need to be dealt with accordingly:
|
||||
*
|
||||
* ```js
|
||||
* const { exec } = require('node:child_process');
|
||||
* import { exec } from 'node:child_process';
|
||||
*
|
||||
* exec('"/path/to/test file/test.sh" arg1 arg2');
|
||||
* // Double quotes are used so that the space in the path is not interpreted as
|
||||
@@ -915,9 +922,9 @@ declare module "child_process" {
|
||||
* **Never pass unsanitized user input to this function. Any input containing shell**
|
||||
* **metacharacters may be used to trigger arbitrary command execution.**
|
||||
*
|
||||
* If a `callback` function is provided, it is called with the arguments`(error, stdout, stderr)`. On success, `error` will be `null`. On error,`error` will be an instance of `Error`. The
|
||||
* If a `callback` function is provided, it is called with the arguments `(error, stdout, stderr)`. On success, `error` will be `null`. On error, `error` will be an instance of `Error`. The
|
||||
* `error.code` property will be
|
||||
* the exit code of the process. By convention, any exit code other than `0`indicates an error. `error.signal` will be the signal that terminated the
|
||||
* the exit code of the process. By convention, any exit code other than `0` indicates an error. `error.signal` will be the signal that terminated the
|
||||
* process.
|
||||
*
|
||||
* The `stdout` and `stderr` arguments passed to the callback will contain the
|
||||
@@ -928,7 +935,7 @@ declare module "child_process" {
|
||||
* encoding, `Buffer` objects will be passed to the callback instead.
|
||||
*
|
||||
* ```js
|
||||
* const { exec } = require('node:child_process');
|
||||
* import { exec } from 'node:child_process';
|
||||
* exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
|
||||
* if (error) {
|
||||
* console.error(`exec error: ${error}`);
|
||||
@@ -947,14 +954,15 @@ declare module "child_process" {
|
||||
* the existing process and uses a shell to execute the command.
|
||||
*
|
||||
* If this method is invoked as its `util.promisify()` ed version, it returns
|
||||
* a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In
|
||||
* a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned `ChildProcess` instance is attached to the `Promise` as a `child` property. In
|
||||
* case of an error (including any error resulting in an exit code other than 0), a
|
||||
* rejected promise is returned, with the same `error` object given in the
|
||||
* callback, but with two additional properties `stdout` and `stderr`.
|
||||
*
|
||||
* ```js
|
||||
* const util = require('node:util');
|
||||
* const exec = util.promisify(require('node:child_process').exec);
|
||||
* import util from 'node:util';
|
||||
* import child_process from 'node:child_process';
|
||||
* const exec = util.promisify(child_process.exec);
|
||||
*
|
||||
* async function lsExample() {
|
||||
* const { stdout, stderr } = await exec('ls');
|
||||
@@ -964,11 +972,11 @@ declare module "child_process" {
|
||||
* lsExample();
|
||||
* ```
|
||||
*
|
||||
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
||||
* If the `signal` option is enabled, calling `.abort()` on the corresponding `AbortController` is similar to calling `.kill()` on the child process except
|
||||
* the error passed to the callback will be an `AbortError`:
|
||||
*
|
||||
* ```js
|
||||
* const { exec } = require('node:child_process');
|
||||
* import { exec } from 'node:child_process';
|
||||
* const controller = new AbortController();
|
||||
* const { signal } = controller;
|
||||
* const child = exec('grep ssh', { signal }, (error) => {
|
||||
@@ -1092,7 +1100,7 @@ declare module "child_process" {
|
||||
* supported.
|
||||
*
|
||||
* ```js
|
||||
* const { execFile } = require('node:child_process');
|
||||
* import { execFile } from 'node:child_process';
|
||||
* const child = execFile('node', ['--version'], (error, stdout, stderr) => {
|
||||
* if (error) {
|
||||
* throw error;
|
||||
@@ -1109,13 +1117,13 @@ declare module "child_process" {
|
||||
* encoding, `Buffer` objects will be passed to the callback instead.
|
||||
*
|
||||
* If this method is invoked as its `util.promisify()` ed version, it returns
|
||||
* a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In
|
||||
* a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned `ChildProcess` instance is attached to the `Promise` as a `child` property. In
|
||||
* case of an error (including any error resulting in an exit code other than 0), a
|
||||
* rejected promise is returned, with the same `error` object given in the
|
||||
* callback, but with two additional properties `stdout` and `stderr`.
|
||||
*
|
||||
* ```js
|
||||
* const util = require('node:util');
|
||||
* import util from 'node:util';
|
||||
* const execFile = util.promisify(require('node:child_process').execFile);
|
||||
* async function getVersion() {
|
||||
* const { stdout } = await execFile('node', ['--version']);
|
||||
@@ -1128,11 +1136,11 @@ declare module "child_process" {
|
||||
* **function. Any input containing shell metacharacters may be used to trigger**
|
||||
* **arbitrary command execution.**
|
||||
*
|
||||
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
||||
* If the `signal` option is enabled, calling `.abort()` on the corresponding `AbortController` is similar to calling `.kill()` on the child process except
|
||||
* the error passed to the callback will be an `AbortError`:
|
||||
*
|
||||
* ```js
|
||||
* const { execFile } = require('node:child_process');
|
||||
* import { execFile } from 'node:child_process';
|
||||
* const controller = new AbortController();
|
||||
* const { signal } = controller;
|
||||
* const child = execFile('node', ['--version'], { signal }, (error) => {
|
||||
@@ -1150,10 +1158,10 @@ declare module "child_process" {
|
||||
file: string,
|
||||
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
||||
): ChildProcess;
|
||||
function execFile(file: string, args?: ReadonlyArray<string> | null): ChildProcess;
|
||||
function execFile(file: string, args?: readonly string[] | null): ChildProcess;
|
||||
function execFile(
|
||||
file: string,
|
||||
args: ReadonlyArray<string> | undefined | null,
|
||||
args: readonly string[] | undefined | null,
|
||||
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
||||
): ChildProcess;
|
||||
// no `options` definitely means stdout/stderr are `string`.
|
||||
@@ -1163,7 +1171,7 @@ declare module "child_process" {
|
||||
): ChildProcess;
|
||||
function execFile(
|
||||
file: string,
|
||||
args: ReadonlyArray<string> | undefined | null,
|
||||
args: readonly string[] | undefined | null,
|
||||
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
): ChildProcess;
|
||||
// `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
|
||||
@@ -1174,7 +1182,7 @@ declare module "child_process" {
|
||||
): ChildProcess;
|
||||
function execFile(
|
||||
file: string,
|
||||
args: ReadonlyArray<string> | undefined | null,
|
||||
args: readonly string[] | undefined | null,
|
||||
options: ExecFileOptionsWithBufferEncoding,
|
||||
callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void,
|
||||
): ChildProcess;
|
||||
@@ -1186,7 +1194,7 @@ declare module "child_process" {
|
||||
): ChildProcess;
|
||||
function execFile(
|
||||
file: string,
|
||||
args: ReadonlyArray<string> | undefined | null,
|
||||
args: readonly string[] | undefined | null,
|
||||
options: ExecFileOptionsWithStringEncoding,
|
||||
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
): ChildProcess;
|
||||
@@ -1199,7 +1207,7 @@ declare module "child_process" {
|
||||
): ChildProcess;
|
||||
function execFile(
|
||||
file: string,
|
||||
args: ReadonlyArray<string> | undefined | null,
|
||||
args: readonly string[] | undefined | null,
|
||||
options: ExecFileOptionsWithOtherEncoding,
|
||||
callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
|
||||
): ChildProcess;
|
||||
@@ -1211,7 +1219,7 @@ declare module "child_process" {
|
||||
): ChildProcess;
|
||||
function execFile(
|
||||
file: string,
|
||||
args: ReadonlyArray<string> | undefined | null,
|
||||
args: readonly string[] | undefined | null,
|
||||
options: ExecFileOptions,
|
||||
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
): ChildProcess;
|
||||
@@ -1226,7 +1234,7 @@ declare module "child_process" {
|
||||
): ChildProcess;
|
||||
function execFile(
|
||||
file: string,
|
||||
args: ReadonlyArray<string> | undefined | null,
|
||||
args: readonly string[] | undefined | null,
|
||||
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
||||
callback:
|
||||
| ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void)
|
||||
@@ -1240,7 +1248,7 @@ declare module "child_process" {
|
||||
}>;
|
||||
function __promisify__(
|
||||
file: string,
|
||||
args: ReadonlyArray<string> | undefined | null,
|
||||
args: readonly string[] | undefined | null,
|
||||
): PromiseWithChild<{
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
@@ -1254,7 +1262,7 @@ declare module "child_process" {
|
||||
}>;
|
||||
function __promisify__(
|
||||
file: string,
|
||||
args: ReadonlyArray<string> | undefined | null,
|
||||
args: readonly string[] | undefined | null,
|
||||
options: ExecFileOptionsWithBufferEncoding,
|
||||
): PromiseWithChild<{
|
||||
stdout: Buffer;
|
||||
@@ -1269,7 +1277,7 @@ declare module "child_process" {
|
||||
}>;
|
||||
function __promisify__(
|
||||
file: string,
|
||||
args: ReadonlyArray<string> | undefined | null,
|
||||
args: readonly string[] | undefined | null,
|
||||
options: ExecFileOptionsWithStringEncoding,
|
||||
): PromiseWithChild<{
|
||||
stdout: string;
|
||||
@@ -1284,7 +1292,7 @@ declare module "child_process" {
|
||||
}>;
|
||||
function __promisify__(
|
||||
file: string,
|
||||
args: ReadonlyArray<string> | undefined | null,
|
||||
args: readonly string[] | undefined | null,
|
||||
options: ExecFileOptionsWithOtherEncoding,
|
||||
): PromiseWithChild<{
|
||||
stdout: string | Buffer;
|
||||
@@ -1299,7 +1307,7 @@ declare module "child_process" {
|
||||
}>;
|
||||
function __promisify__(
|
||||
file: string,
|
||||
args: ReadonlyArray<string> | undefined | null,
|
||||
args: readonly string[] | undefined | null,
|
||||
options: ExecFileOptions,
|
||||
): PromiseWithChild<{
|
||||
stdout: string;
|
||||
@@ -1314,7 +1322,7 @@ declare module "child_process" {
|
||||
}>;
|
||||
function __promisify__(
|
||||
file: string,
|
||||
args: ReadonlyArray<string> | undefined | null,
|
||||
args: readonly string[] | undefined | null,
|
||||
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
||||
): PromiseWithChild<{
|
||||
stdout: string | Buffer;
|
||||
@@ -1352,7 +1360,7 @@ declare module "child_process" {
|
||||
* required, spawning a large number of child Node.js processes is not
|
||||
* recommended.
|
||||
*
|
||||
* By default, `child_process.fork()` will spawn new Node.js instances using the `process.execPath` of the parent process. The `execPath` property in the`options` object allows for an alternative
|
||||
* By default, `child_process.fork()` will spawn new Node.js instances using the `process.execPath` of the parent process. The `execPath` property in the `options` object allows for an alternative
|
||||
* execution path to be used.
|
||||
*
|
||||
* Node.js processes launched with a custom `execPath` will communicate with the
|
||||
@@ -1362,9 +1370,9 @@ declare module "child_process" {
|
||||
* Unlike the [`fork(2)`](http://man7.org/linux/man-pages/man2/fork.2.html) POSIX system call, `child_process.fork()` does not clone the
|
||||
* current process.
|
||||
*
|
||||
* The `shell` option available in {@link spawn} is not supported by`child_process.fork()` and will be ignored if set.
|
||||
* The `shell` option available in {@link spawn} is not supported by `child_process.fork()` and will be ignored if set.
|
||||
*
|
||||
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
||||
* If the `signal` option is enabled, calling `.abort()` on the corresponding `AbortController` is similar to calling `.kill()` on the child process except
|
||||
* the error passed to the callback will be an `AbortError`:
|
||||
*
|
||||
* ```js
|
||||
@@ -1373,7 +1381,7 @@ declare module "child_process" {
|
||||
* console.log(`Hello from ${process.argv[2]}!`);
|
||||
* }, 1_000);
|
||||
* } else {
|
||||
* const { fork } = require('node:child_process');
|
||||
* import { fork } from 'node:child_process';
|
||||
* const controller = new AbortController();
|
||||
* const { signal } = controller;
|
||||
* const child = fork(__filename, ['child'], { signal });
|
||||
@@ -1387,8 +1395,8 @@ declare module "child_process" {
|
||||
* @param modulePath The module to run in the child.
|
||||
* @param args List of string arguments.
|
||||
*/
|
||||
function fork(modulePath: string, options?: ForkOptions): ChildProcess;
|
||||
function fork(modulePath: string, args?: ReadonlyArray<string>, options?: ForkOptions): ChildProcess;
|
||||
function fork(modulePath: string | URL, options?: ForkOptions): ChildProcess;
|
||||
function fork(modulePath: string | URL, args?: readonly string[], options?: ForkOptions): ChildProcess;
|
||||
interface SpawnSyncOptions extends CommonSpawnOptions {
|
||||
input?: string | NodeJS.ArrayBufferView | undefined;
|
||||
maxBuffer?: number | undefined;
|
||||
@@ -1428,20 +1436,20 @@ declare module "child_process" {
|
||||
function spawnSync(command: string, options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
|
||||
function spawnSync(command: string, options: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
|
||||
function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<string | Buffer>;
|
||||
function spawnSync(command: string, args: ReadonlyArray<string>): SpawnSyncReturns<Buffer>;
|
||||
function spawnSync(command: string, args: readonly string[]): SpawnSyncReturns<Buffer>;
|
||||
function spawnSync(
|
||||
command: string,
|
||||
args: ReadonlyArray<string>,
|
||||
args: readonly string[],
|
||||
options: SpawnSyncOptionsWithStringEncoding,
|
||||
): SpawnSyncReturns<string>;
|
||||
function spawnSync(
|
||||
command: string,
|
||||
args: ReadonlyArray<string>,
|
||||
args: readonly string[],
|
||||
options: SpawnSyncOptionsWithBufferEncoding,
|
||||
): SpawnSyncReturns<Buffer>;
|
||||
function spawnSync(
|
||||
command: string,
|
||||
args?: ReadonlyArray<string>,
|
||||
args?: readonly string[],
|
||||
options?: SpawnSyncOptions,
|
||||
): SpawnSyncReturns<string | Buffer>;
|
||||
interface CommonExecOptions extends CommonOptions {
|
||||
@@ -1473,7 +1481,7 @@ declare module "child_process" {
|
||||
* The `child_process.execSync()` method is generally identical to {@link exec} with the exception that the method will not return
|
||||
* until the child process has fully closed. When a timeout has been encountered
|
||||
* and `killSignal` is sent, the method won't return until the process has
|
||||
* completely exited. If the child process intercepts and handles the `SIGTERM`signal and doesn't exit, the parent process will wait until the child process
|
||||
* completely exited. If the child process intercepts and handles the `SIGTERM` signal and doesn't exit, the parent process will wait until the child process
|
||||
* has exited.
|
||||
*
|
||||
* If the process times out or has a non-zero exit code, this method will throw.
|
||||
@@ -1522,18 +1530,18 @@ declare module "child_process" {
|
||||
function execFileSync(file: string, options: ExecFileSyncOptionsWithStringEncoding): string;
|
||||
function execFileSync(file: string, options: ExecFileSyncOptionsWithBufferEncoding): Buffer;
|
||||
function execFileSync(file: string, options?: ExecFileSyncOptions): string | Buffer;
|
||||
function execFileSync(file: string, args: ReadonlyArray<string>): Buffer;
|
||||
function execFileSync(file: string, args: readonly string[]): Buffer;
|
||||
function execFileSync(
|
||||
file: string,
|
||||
args: ReadonlyArray<string>,
|
||||
args: readonly string[],
|
||||
options: ExecFileSyncOptionsWithStringEncoding,
|
||||
): string;
|
||||
function execFileSync(
|
||||
file: string,
|
||||
args: ReadonlyArray<string>,
|
||||
args: readonly string[],
|
||||
options: ExecFileSyncOptionsWithBufferEncoding,
|
||||
): Buffer;
|
||||
function execFileSync(file: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptions): string | Buffer;
|
||||
function execFileSync(file: string, args?: readonly string[], options?: ExecFileSyncOptions): string | Buffer;
|
||||
}
|
||||
declare module "node:child_process" {
|
||||
export * from "child_process";
|
||||
|
||||
188
node_modules/@types/node/cluster.d.ts
generated
vendored
188
node_modules/@types/node/cluster.d.ts
generated
vendored
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* Clusters of Node.js processes can be used to run multiple instances of Node.js
|
||||
* that can distribute workloads among their application threads. When process
|
||||
* isolation is not needed, use the `worker_threads` module instead, which
|
||||
* allows running multiple application threads within a single Node.js instance.
|
||||
* that can distribute workloads among their application threads. When process isolation
|
||||
* is not needed, use the [`worker_threads`](https://nodejs.org/docs/latest-v20.x/api/worker_threads.html)
|
||||
* module instead, which allows running multiple application threads within a single Node.js instance.
|
||||
*
|
||||
* The cluster module allows easy creation of child processes that all share
|
||||
* server ports.
|
||||
@@ -50,7 +50,7 @@
|
||||
* ```
|
||||
*
|
||||
* 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/v20.2.0/lib/cluster.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/cluster.js)
|
||||
*/
|
||||
declare module "cluster" {
|
||||
import * as child from "node:child_process";
|
||||
@@ -58,22 +58,74 @@ declare module "cluster" {
|
||||
import * as net from "node:net";
|
||||
type SerializationType = "json" | "advanced";
|
||||
export interface ClusterSettings {
|
||||
execArgv?: string[] | undefined; // default: process.execArgv
|
||||
/**
|
||||
* List of string arguments passed to the Node.js executable.
|
||||
* @default process.execArgv
|
||||
*/
|
||||
execArgv?: string[] | undefined;
|
||||
/**
|
||||
* File path to worker file.
|
||||
* @default process.argv[1]
|
||||
*/
|
||||
exec?: string | undefined;
|
||||
/**
|
||||
* String arguments passed to worker.
|
||||
* @default process.argv.slice(2)
|
||||
*/
|
||||
args?: string[] | undefined;
|
||||
/**
|
||||
* Whether or not to send output to parent's stdio.
|
||||
* @default false
|
||||
*/
|
||||
silent?: boolean | undefined;
|
||||
/**
|
||||
* Configures the stdio of forked processes. Because the cluster module relies on IPC to function, this configuration must
|
||||
* contain an `'ipc'` entry. When this option is provided, it overrides `silent`. See [`child_prcess.spawn()`](https://nodejs.org/docs/latest-v20.x/api/child_process.html#child_processspawncommand-args-options)'s
|
||||
* [`stdio`](https://nodejs.org/docs/latest-v20.x/api/child_process.html#optionsstdio).
|
||||
*/
|
||||
stdio?: any[] | undefined;
|
||||
/**
|
||||
* Sets the user identity of the process. (See [`setuid(2)`](https://man7.org/linux/man-pages/man2/setuid.2.html).)
|
||||
*/
|
||||
uid?: number | undefined;
|
||||
/**
|
||||
* Sets the group identity of the process. (See [`setgid(2)`](https://man7.org/linux/man-pages/man2/setgid.2.html).)
|
||||
*/
|
||||
gid?: number | undefined;
|
||||
/**
|
||||
* Sets inspector port of worker. This can be a number, or a function that takes no arguments and returns a number.
|
||||
* By default each worker gets its own port, incremented from the primary's `process.debugPort`.
|
||||
*/
|
||||
inspectPort?: number | (() => number) | undefined;
|
||||
/**
|
||||
* Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`.
|
||||
* See [Advanced serialization for `child_process`](https://nodejs.org/docs/latest-v20.x/api/child_process.html#advanced-serialization) for more details.
|
||||
* @default false
|
||||
*/
|
||||
serialization?: SerializationType | undefined;
|
||||
/**
|
||||
* Current working directory of the worker process.
|
||||
* @default undefined (inherits from parent process)
|
||||
*/
|
||||
cwd?: string | undefined;
|
||||
/**
|
||||
* Hide the forked processes console window that would normally be created on Windows systems.
|
||||
* @default false
|
||||
*/
|
||||
windowsHide?: boolean | undefined;
|
||||
}
|
||||
export interface Address {
|
||||
address: string;
|
||||
port: number;
|
||||
addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6"
|
||||
/**
|
||||
* The `addressType` is one of:
|
||||
*
|
||||
* * `4` (TCPv4)
|
||||
* * `6` (TCPv6)
|
||||
* * `-1` (Unix domain socket)
|
||||
* * `'udp4'` or `'udp6'` (UDPv4 or UDPv6)
|
||||
*/
|
||||
addressType: 4 | 6 | -1 | "udp4" | "udp6";
|
||||
}
|
||||
/**
|
||||
* A `Worker` object contains all public information and method about a worker.
|
||||
@@ -83,17 +135,17 @@ declare module "cluster" {
|
||||
*/
|
||||
export class Worker extends EventEmitter {
|
||||
/**
|
||||
* Each new worker is given its own unique id, this id is stored in the`id`.
|
||||
* 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`.
|
||||
* While a worker is alive, this is the key that indexes it in `cluster.workers`.
|
||||
* @since v0.8.0
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* All workers are created using `child_process.fork()`, the returned object
|
||||
* from this function is stored as `.process`. In a worker, the global `process`is stored.
|
||||
* All workers are created using [`child_process.fork()`](https://nodejs.org/docs/latest-v20.x/api/child_process.html#child_processforkmodulepath-args-options), the returned object
|
||||
* from this function is stored as `.process`. In a worker, the global `process` is stored.
|
||||
*
|
||||
* See: `Child Process module`.
|
||||
* See: [Child Process module](https://nodejs.org/docs/latest-v20.x/api/child_process.html#child_processforkmodulepath-args-options).
|
||||
*
|
||||
* Workers will call `process.exit(0)` if the `'disconnect'` event occurs
|
||||
* on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
|
||||
@@ -104,9 +156,9 @@ declare module "cluster" {
|
||||
/**
|
||||
* 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 the primary, this sends a message to a specific worker. It is identical to [`ChildProcess.send()`](https://nodejs.org/docs/latest-v20.x/api/child_process.html#subprocesssendmessage-sendhandle-options-callback).
|
||||
*
|
||||
* In a worker, this sends a message to the primary. It is identical to`process.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:
|
||||
*
|
||||
@@ -122,7 +174,7 @@ declare module "cluster" {
|
||||
* }
|
||||
* ```
|
||||
* @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:
|
||||
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles.
|
||||
*/
|
||||
send(message: child.Serializable, callback?: (error: Error | null) => void): boolean;
|
||||
send(
|
||||
@@ -138,7 +190,7 @@ declare module "cluster" {
|
||||
): boolean;
|
||||
/**
|
||||
* This function will kill the worker. In the primary worker, it does this by
|
||||
* disconnecting the `worker.process`, and once disconnected, killing with`signal`. In the worker, it does it by killing the process with `signal`.
|
||||
* disconnecting the `worker.process`, and once disconnected, killing with `signal`. In the worker, it does it by killing the process with `signal`.
|
||||
*
|
||||
* The `kill()` function kills the worker process without waiting for a graceful
|
||||
* disconnect, it has the same behavior as `worker.process.kill()`.
|
||||
@@ -146,7 +198,7 @@ declare module "cluster" {
|
||||
* This method is aliased as `worker.destroy()` for backwards compatibility.
|
||||
*
|
||||
* In a worker, `process.kill()` exists, but it is not this function;
|
||||
* it is `kill()`.
|
||||
* it is [`kill()`](https://nodejs.org/docs/latest-v20.x/api/process.html#processkillpid-signal).
|
||||
* @since v0.9.12
|
||||
* @param [signal='SIGTERM'] Name of the kill signal to send to the worker process.
|
||||
*/
|
||||
@@ -156,7 +208,7 @@ declare module "cluster" {
|
||||
* 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.
|
||||
* In the primary, an internal message is sent to the worker causing it to call `.disconnect()` on itself.
|
||||
*
|
||||
* Causes `.exitedAfterDisconnect` to be set.
|
||||
*
|
||||
@@ -179,6 +231,7 @@ declare module "cluster" {
|
||||
* the `'disconnect'` event has not been emitted after some time.
|
||||
*
|
||||
* ```js
|
||||
* import net from 'node:net';
|
||||
* if (cluster.isPrimary) {
|
||||
* const worker = cluster.fork();
|
||||
* let timeout;
|
||||
@@ -196,7 +249,6 @@ declare module "cluster" {
|
||||
* });
|
||||
*
|
||||
* } else if (cluster.isWorker) {
|
||||
* const net = require('node:net');
|
||||
* const server = net.createServer((socket) => {
|
||||
* // Connections never end
|
||||
* });
|
||||
@@ -213,7 +265,7 @@ declare module "cluster" {
|
||||
* @since v0.7.7
|
||||
* @return A reference to `worker`.
|
||||
*/
|
||||
disconnect(): void;
|
||||
disconnect(): this;
|
||||
/**
|
||||
* 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
|
||||
@@ -336,20 +388,114 @@ declare module "cluster" {
|
||||
}
|
||||
export interface Cluster extends EventEmitter {
|
||||
disconnect(callback?: () => void): void;
|
||||
/**
|
||||
* Spawn a new worker process.
|
||||
*
|
||||
* This can only be called from the primary process.
|
||||
* @param env Key/value pairs to add to worker process environment.
|
||||
* @since v0.6.0
|
||||
*/
|
||||
fork(env?: any): Worker;
|
||||
/** @deprecated since v16.0.0 - use isPrimary. */
|
||||
readonly isMaster: boolean;
|
||||
/**
|
||||
* True if the process is a primary. This is determined by the `process.env.NODE_UNIQUE_ID`. If `process.env.NODE_UNIQUE_ID`
|
||||
* is undefined, then `isPrimary` is `true`.
|
||||
* @since v16.0.0
|
||||
*/
|
||||
readonly isPrimary: boolean;
|
||||
/**
|
||||
* True if the process is not a primary (it is the negation of `cluster.isPrimary`).
|
||||
* @since v0.6.0
|
||||
*/
|
||||
readonly isWorker: boolean;
|
||||
/**
|
||||
* The scheduling policy, either `cluster.SCHED_RR` for round-robin or `cluster.SCHED_NONE` to leave it to the operating system. This is a
|
||||
* global setting and effectively frozen once either the first worker is spawned, or [`.setupPrimary()`](https://nodejs.org/docs/latest-v20.x/api/cluster.html#clustersetupprimarysettings)
|
||||
* is called, whichever comes first.
|
||||
*
|
||||
* `SCHED_RR` is the default on all operating systems except Windows. Windows will change to `SCHED_RR` once libuv is able to effectively distribute
|
||||
* IOCP handles without incurring a large performance hit.
|
||||
*
|
||||
* `cluster.schedulingPolicy` can also be set through the `NODE_CLUSTER_SCHED_POLICY` environment variable. Valid values are `'rr'` and `'none'`.
|
||||
* @since v0.11.2
|
||||
*/
|
||||
schedulingPolicy: number;
|
||||
/**
|
||||
* After calling [`.setupPrimary()`](https://nodejs.org/docs/latest-v20.x/api/cluster.html#clustersetupprimarysettings)
|
||||
* (or [`.fork()`](https://nodejs.org/docs/latest-v20.x/api/cluster.html#clusterforkenv)) this settings object will contain
|
||||
* the settings, including the default values.
|
||||
*
|
||||
* This object is not intended to be changed or set manually.
|
||||
* @since v0.7.1
|
||||
*/
|
||||
readonly settings: ClusterSettings;
|
||||
/** @deprecated since v16.0.0 - use setupPrimary. */
|
||||
/** @deprecated since v16.0.0 - use [`.setupPrimary()`](https://nodejs.org/docs/latest-v20.x/api/cluster.html#clustersetupprimarysettings) instead. */
|
||||
setupMaster(settings?: ClusterSettings): void;
|
||||
/**
|
||||
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings.
|
||||
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in `cluster.settings`.
|
||||
*
|
||||
* Any settings changes only affect future calls to [`.fork()`](https://nodejs.org/docs/latest-v20.x/api/cluster.html#clusterforkenv)
|
||||
* and have no effect on workers that are already running.
|
||||
*
|
||||
* The only attribute of a worker that cannot be set via `.setupPrimary()` is the `env` passed to
|
||||
* [`.fork()`](https://nodejs.org/docs/latest-v20.x/api/cluster.html#clusterforkenv).
|
||||
*
|
||||
* The defaults above apply to the first call only; the defaults for later calls are the current values at the time of
|
||||
* `cluster.setupPrimary()` is called.
|
||||
*
|
||||
* ```js
|
||||
* import cluster from 'node:cluster';
|
||||
*
|
||||
* cluster.setupPrimary({
|
||||
* exec: 'worker.js',
|
||||
* args: ['--use', 'https'],
|
||||
* silent: true,
|
||||
* });
|
||||
* cluster.fork(); // https worker
|
||||
* cluster.setupPrimary({
|
||||
* exec: 'worker.js',
|
||||
* args: ['--use', 'http'],
|
||||
* });
|
||||
* cluster.fork(); // http worker
|
||||
* ```
|
||||
*
|
||||
* This can only be called from the primary process.
|
||||
* @since v16.0.0
|
||||
*/
|
||||
setupPrimary(settings?: ClusterSettings): void;
|
||||
/**
|
||||
* A reference to the current worker object. Not available in the primary process.
|
||||
*
|
||||
* ```js
|
||||
* import cluster from 'node:cluster';
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* console.log('I am primary');
|
||||
* cluster.fork();
|
||||
* cluster.fork();
|
||||
* } else if (cluster.isWorker) {
|
||||
* console.log(`I am worker #${cluster.worker.id}`);
|
||||
* }
|
||||
* ```
|
||||
* @since v0.7.0
|
||||
*/
|
||||
readonly worker?: Worker | undefined;
|
||||
/**
|
||||
* A hash that stores the active worker objects, keyed by `id` field. This makes it easy to loop through all the workers. It is only available in the primary process.
|
||||
*
|
||||
* A worker is removed from `cluster.workers` after the worker has disconnected _and_ exited. The order between these two events cannot be determined in advance. However, it
|
||||
* is guaranteed that the removal from the `cluster.workers` list happens before the last `'disconnect'` or `'exit'` event is emitted.
|
||||
*
|
||||
* ```js
|
||||
* import cluster from 'node:cluster';
|
||||
*
|
||||
* for (const worker of Object.values(cluster.workers)) {
|
||||
* worker.send('big announcement to all workers');
|
||||
* }
|
||||
* ```
|
||||
* @since v0.7.0
|
||||
*/
|
||||
readonly workers?: NodeJS.Dict<Worker> | undefined;
|
||||
readonly SCHED_NONE: number;
|
||||
readonly SCHED_RR: number;
|
||||
|
||||
16
node_modules/@types/node/compatibility/disposable.d.ts
generated
vendored
Normal file
16
node_modules/@types/node/compatibility/disposable.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// Polyfills for the explicit resource management types added in TypeScript 5.2.
|
||||
// TODO: remove once this package no longer supports TS 5.1, and replace with a
|
||||
// <reference> to TypeScript's disposable library in index.d.ts.
|
||||
|
||||
interface SymbolConstructor {
|
||||
readonly dispose: unique symbol;
|
||||
readonly asyncDispose: unique symbol;
|
||||
}
|
||||
|
||||
interface Disposable {
|
||||
[Symbol.dispose](): void;
|
||||
}
|
||||
|
||||
interface AsyncDisposable {
|
||||
[Symbol.asyncDispose](): PromiseLike<void>;
|
||||
}
|
||||
9
node_modules/@types/node/compatibility/index.d.ts
generated
vendored
Normal file
9
node_modules/@types/node/compatibility/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// Declaration files in this directory contain types relating to TypeScript library features
|
||||
// that are not included in all TypeScript versions supported by DefinitelyTyped, but
|
||||
// which can be made backwards-compatible without needing `typesVersions`.
|
||||
// If adding declarations to this directory, please specify which versions of TypeScript require them,
|
||||
// so that they can be removed when no longer needed.
|
||||
|
||||
/// <reference path="disposable.d.ts" />
|
||||
/// <reference path="indexable.d.ts" />
|
||||
/// <reference path="iterators.d.ts" />
|
||||
20
node_modules/@types/node/compatibility/indexable.d.ts
generated
vendored
Normal file
20
node_modules/@types/node/compatibility/indexable.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Polyfill for ES2022's .at() method on string/array prototypes, added to TypeScript in 4.6.
|
||||
|
||||
interface RelativeIndexable<T> {
|
||||
at(index: number): T | undefined;
|
||||
}
|
||||
|
||||
interface String extends RelativeIndexable<string> {}
|
||||
interface Array<T> extends RelativeIndexable<T> {}
|
||||
interface ReadonlyArray<T> extends RelativeIndexable<T> {}
|
||||
interface Int8Array extends RelativeIndexable<number> {}
|
||||
interface Uint8Array extends RelativeIndexable<number> {}
|
||||
interface Uint8ClampedArray extends RelativeIndexable<number> {}
|
||||
interface Int16Array extends RelativeIndexable<number> {}
|
||||
interface Uint16Array extends RelativeIndexable<number> {}
|
||||
interface Int32Array extends RelativeIndexable<number> {}
|
||||
interface Uint32Array extends RelativeIndexable<number> {}
|
||||
interface Float32Array extends RelativeIndexable<number> {}
|
||||
interface Float64Array extends RelativeIndexable<number> {}
|
||||
interface BigInt64Array extends RelativeIndexable<bigint> {}
|
||||
interface BigUint64Array extends RelativeIndexable<bigint> {}
|
||||
21
node_modules/@types/node/compatibility/iterators.d.ts
generated
vendored
Normal file
21
node_modules/@types/node/compatibility/iterators.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// Backwards-compatible iterator interfaces, augmented with iterator helper methods by lib.esnext.iterator in TypeScript 5.6.
|
||||
// The IterableIterator interface does not contain these methods, which creates assignability issues in places where IteratorObjects
|
||||
// are expected (eg. DOM-compatible APIs) if lib.esnext.iterator is loaded.
|
||||
// Also ensures that iterators returned by the Node API, which inherit from Iterator.prototype, correctly expose the iterator helper methods
|
||||
// if lib.esnext.iterator is loaded.
|
||||
// TODO: remove once this package no longer supports TS 5.5, and replace NodeJS.BuiltinIteratorReturn with BuiltinIteratorReturn.
|
||||
|
||||
// Placeholders for TS <5.6
|
||||
interface IteratorObject<T, TReturn, TNext> {}
|
||||
interface AsyncIteratorObject<T, TReturn, TNext> {}
|
||||
|
||||
declare namespace NodeJS {
|
||||
// Populate iterator methods for TS <5.6
|
||||
interface Iterator<T, TReturn, TNext> extends globalThis.Iterator<T, TReturn, TNext> {}
|
||||
interface AsyncIterator<T, TReturn, TNext> extends globalThis.AsyncIterator<T, TReturn, TNext> {}
|
||||
|
||||
// Polyfill for TS 5.6's instrinsic BuiltinIteratorReturn type, required for DOM-compatible iterators
|
||||
type BuiltinIteratorReturn = ReturnType<any[][typeof Symbol.iterator]> extends
|
||||
globalThis.Iterator<any, infer TReturn> ? TReturn
|
||||
: any;
|
||||
}
|
||||
93
node_modules/@types/node/console.d.ts
generated
vendored
93
node_modules/@types/node/console.d.ts
generated
vendored
@@ -4,12 +4,13 @@
|
||||
*
|
||||
* 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('node:console')`.
|
||||
* * 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`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and
|
||||
* [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
|
||||
*
|
||||
* _**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
|
||||
* asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for
|
||||
* more information.
|
||||
*
|
||||
* Example using the global `console`:
|
||||
@@ -53,7 +54,7 @@
|
||||
* myConsole.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to err
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/console.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/console.js)
|
||||
*/
|
||||
declare module "console" {
|
||||
import console = require("node:console");
|
||||
@@ -68,7 +69,8 @@ declare module "node:console" {
|
||||
/**
|
||||
* `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()`.
|
||||
* starts with `"Assertion failed"`. If provided, `message` is formatted using
|
||||
* [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args).
|
||||
*
|
||||
* If `value` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), nothing happens.
|
||||
*
|
||||
@@ -91,7 +93,7 @@ declare module "node:console" {
|
||||
* 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
|
||||
* 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
|
||||
@@ -150,7 +152,7 @@ declare module "node:console" {
|
||||
*/
|
||||
debug(message?: any, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* Uses `util.inspect()` on `obj` and prints the resulting string to `stdout`.
|
||||
* Uses [`util.inspect()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilinspectobject-options) on `obj` and prints the resulting string to `stdout`.
|
||||
* This function bypasses any custom `inspect()` function defined on `obj`.
|
||||
* @since v0.1.101
|
||||
*/
|
||||
@@ -164,7 +166,8 @@ declare module "node:console" {
|
||||
/**
|
||||
* 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()`).
|
||||
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)
|
||||
* (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)).
|
||||
*
|
||||
* ```js
|
||||
* const code = 5;
|
||||
@@ -174,13 +177,15 @@ declare module "node:console" {
|
||||
* // 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.
|
||||
* If formatting elements (e.g. `%d`) are not found in the first string then
|
||||
* [`util.inspect()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilinspectobject-options) is called on each argument and the
|
||||
* resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)
|
||||
* for more information.
|
||||
* @since v0.1.100
|
||||
*/
|
||||
error(message?: any, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* Increases indentation of subsequent lines by spaces for `groupIndentation`length.
|
||||
* 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.
|
||||
@@ -193,7 +198,7 @@ declare module "node:console" {
|
||||
*/
|
||||
groupCollapsed(...label: any[]): void;
|
||||
/**
|
||||
* Decreases indentation of subsequent lines by spaces for `groupIndentation`length.
|
||||
* Decreases indentation of subsequent lines by spaces for `groupIndentation` length.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
groupEnd(): void;
|
||||
@@ -205,7 +210,8 @@ declare module "node:console" {
|
||||
/**
|
||||
* 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()`).
|
||||
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)
|
||||
* (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)).
|
||||
*
|
||||
* ```js
|
||||
* const count = 5;
|
||||
@@ -215,12 +221,12 @@ declare module "node:console" {
|
||||
* // Prints: count: 5, to stdout
|
||||
* ```
|
||||
*
|
||||
* See `util.format()` for more information.
|
||||
* See [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args) 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
|
||||
* 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
|
||||
@@ -250,7 +256,7 @@ declare module "node:console" {
|
||||
* @since v10.0.0
|
||||
* @param properties Alternate properties for constructing the table.
|
||||
*/
|
||||
table(tabularData: any, properties?: ReadonlyArray<string>): void;
|
||||
table(tabularData: any, properties?: readonly 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
|
||||
@@ -291,7 +297,8 @@ declare module "node:console" {
|
||||
*/
|
||||
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.
|
||||
* Prints to `stderr` the string `'Trace: '`, followed by the [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)
|
||||
* formatted message and stack trace to the current position in the code.
|
||||
*
|
||||
* ```js
|
||||
* console.trace('Show me');
|
||||
@@ -318,18 +325,32 @@ declare module "node:console" {
|
||||
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.
|
||||
* This method does not display anything unless used in the inspector. The `console.profile()`
|
||||
* method starts a JavaScript CPU profile with an optional label until {@link profileEnd}
|
||||
* is called. The profile is then added to the Profile panel of the inspector.
|
||||
*
|
||||
* ```js
|
||||
* console.profile('MyLabel');
|
||||
* // Some code
|
||||
* console.profileEnd('MyLabel');
|
||||
* // Adds the profile 'MyLabel' to the Profiles panel of the inspector.
|
||||
* ```
|
||||
* @since v8.0.0
|
||||
*/
|
||||
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.
|
||||
* 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. See {@link profile} for an example.
|
||||
*
|
||||
* If this method is called without a label, the most recently started profile is stopped.
|
||||
* @since v8.0.0
|
||||
*/
|
||||
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.
|
||||
* This method does not display anything unless used in the inspector. The `console.timeStamp()`
|
||||
* method adds an event with the label `'label'` to the Timeline panel of the inspector.
|
||||
* @since v8.0.0
|
||||
*/
|
||||
timeStamp(label?: string): void;
|
||||
}
|
||||
@@ -339,12 +360,13 @@ declare module "node:console" {
|
||||
*
|
||||
* 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')`.
|
||||
* * 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`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and
|
||||
* [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
|
||||
*
|
||||
* _**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
|
||||
* asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for
|
||||
* more information.
|
||||
*
|
||||
* Example using the global `console`:
|
||||
@@ -388,17 +410,32 @@ declare module "node:console" {
|
||||
* 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)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)
|
||||
*/
|
||||
namespace console {
|
||||
interface ConsoleConstructorOptions {
|
||||
stdout: NodeJS.WritableStream;
|
||||
stderr?: NodeJS.WritableStream | undefined;
|
||||
/**
|
||||
* Ignore errors when writing to the underlying streams.
|
||||
* @default true
|
||||
*/
|
||||
ignoreErrors?: boolean | undefined;
|
||||
/**
|
||||
* Set color support for this `Console` instance. Setting to true enables coloring while inspecting
|
||||
* values. Setting to `false` disables coloring while inspecting values. Setting to `'auto'` makes color
|
||||
* support depend on the value of the `isTTY` property and the value returned by `getColorDepth()` on the
|
||||
* respective stream. This option can not be used, if `inspectOptions.colors` is set as well.
|
||||
* @default auto
|
||||
*/
|
||||
colorMode?: boolean | "auto" | undefined;
|
||||
/**
|
||||
* Specifies options that are passed along to
|
||||
* [`util.inspect()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilinspectobject-options).
|
||||
*/
|
||||
inspectOptions?: InspectOptions | undefined;
|
||||
/**
|
||||
* Set group indentation
|
||||
* Set group indentation.
|
||||
* @default 2
|
||||
*/
|
||||
groupIndentation?: number | undefined;
|
||||
|
||||
26
node_modules/@types/node/constants.d.ts
generated
vendored
26
node_modules/@types/node/constants.d.ts
generated
vendored
@@ -1,16 +1,18 @@
|
||||
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
|
||||
/**
|
||||
* @deprecated The `node:constants` module is deprecated. When requiring access to constants
|
||||
* relevant to specific Node.js builtin modules, developers should instead refer
|
||||
* to the `constants` property exposed by the relevant module. For instance,
|
||||
* `require('node:fs').constants` and `require('node:os').constants`.
|
||||
*/
|
||||
declare module "constants" {
|
||||
import { constants as osConstants, SignalConstants } from "node:os";
|
||||
import { constants as cryptoConstants } from "node:crypto";
|
||||
import { constants as fsConstants } from "node:fs";
|
||||
|
||||
const exp:
|
||||
& typeof osConstants.errno
|
||||
& typeof osConstants.priority
|
||||
& SignalConstants
|
||||
& typeof cryptoConstants
|
||||
& typeof fsConstants;
|
||||
export = exp;
|
||||
const constants:
|
||||
& typeof import("node:os").constants.dlopen
|
||||
& typeof import("node:os").constants.errno
|
||||
& typeof import("node:os").constants.priority
|
||||
& typeof import("node:os").constants.signals
|
||||
& typeof import("node:fs").constants
|
||||
& typeof import("node:crypto").constants;
|
||||
export = constants;
|
||||
}
|
||||
|
||||
declare module "node:constants" {
|
||||
|
||||
288
node_modules/@types/node/crypto.d.ts
generated
vendored
288
node_modules/@types/node/crypto.d.ts
generated
vendored
@@ -14,7 +14,7 @@
|
||||
* // Prints:
|
||||
* // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/crypto.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/crypto.js)
|
||||
*/
|
||||
declare module "crypto" {
|
||||
import * as stream from "node:stream";
|
||||
@@ -27,7 +27,7 @@ declare module "crypto" {
|
||||
* should not use this element anymore.
|
||||
*
|
||||
* The `node:crypto` module provides the `Certificate` class for working with SPKAC
|
||||
* data. The most common usage is handling output generated by the HTML5`<keygen>` element. Node.js uses [OpenSSL's SPKAC
|
||||
* data. The most common usage is handling output generated by the HTML5 `<keygen>` element. Node.js uses [OpenSSL's SPKAC
|
||||
* implementation](https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html) internally.
|
||||
* @since v0.11.8
|
||||
*/
|
||||
@@ -100,11 +100,13 @@ declare module "crypto" {
|
||||
const OPENSSL_VERSION_NUMBER: number;
|
||||
/** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */
|
||||
const SSL_OP_ALL: number;
|
||||
/** Instructs OpenSSL to allow a non-[EC]DHE-based key exchange mode for TLS v1.3 */
|
||||
const SSL_OP_ALLOW_NO_DHE_KEX: number;
|
||||
/** Allows legacy insecure renegotiation between OpenSSL and unpatched clients or servers. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */
|
||||
const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
|
||||
/** Attempts to use the server's preferences instead of the client's when selecting a cipher. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */
|
||||
const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
|
||||
/** Instructs OpenSSL to use Cisco's "speshul" version of DTLS_BAD_VER. */
|
||||
/** Instructs OpenSSL to use Cisco's version identifier of DTLS_BAD_VER. */
|
||||
const SSL_OP_CISCO_ANYCONNECT: number;
|
||||
/** Instructs OpenSSL to turn on cookie exchange. */
|
||||
const SSL_OP_COOKIE_EXCHANGE: number;
|
||||
@@ -116,15 +118,29 @@ declare module "crypto" {
|
||||
const SSL_OP_LEGACY_SERVER_CONNECT: number;
|
||||
/** Instructs OpenSSL to disable support for SSL/TLS compression. */
|
||||
const SSL_OP_NO_COMPRESSION: number;
|
||||
/** Instructs OpenSSL to disable encrypt-then-MAC. */
|
||||
const SSL_OP_NO_ENCRYPT_THEN_MAC: number;
|
||||
const SSL_OP_NO_QUERY_MTU: number;
|
||||
/** Instructs OpenSSL to disable renegotiation. */
|
||||
const SSL_OP_NO_RENEGOTIATION: number;
|
||||
/** Instructs OpenSSL to always start a new session when performing renegotiation. */
|
||||
const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
|
||||
/** Instructs OpenSSL to turn off SSL v2 */
|
||||
const SSL_OP_NO_SSLv2: number;
|
||||
/** Instructs OpenSSL to turn off SSL v3 */
|
||||
const SSL_OP_NO_SSLv3: number;
|
||||
/** Instructs OpenSSL to disable use of RFC4507bis tickets. */
|
||||
const SSL_OP_NO_TICKET: number;
|
||||
/** Instructs OpenSSL to turn off TLS v1 */
|
||||
const SSL_OP_NO_TLSv1: number;
|
||||
/** Instructs OpenSSL to turn off TLS v1.1 */
|
||||
const SSL_OP_NO_TLSv1_1: number;
|
||||
/** Instructs OpenSSL to turn off TLS v1.2 */
|
||||
const SSL_OP_NO_TLSv1_2: number;
|
||||
/** Instructs OpenSSL to turn off TLS v1.3 */
|
||||
const SSL_OP_NO_TLSv1_3: number;
|
||||
/** Instructs OpenSSL server to prioritize ChaCha20-Poly1305 when the client does. This option has no effect if `SSL_OP_CIPHER_SERVER_PREFERENCE` is not enabled. */
|
||||
const SSL_OP_PRIORITIZE_CHACHA: number;
|
||||
/** Instructs OpenSSL to disable version rollback attack detection. */
|
||||
const SSL_OP_TLS_ROLLBACK_BUG: number;
|
||||
const ENGINE_METHOD_RSA: number;
|
||||
@@ -363,7 +379,7 @@ declare module "crypto" {
|
||||
* @since v13.1.0
|
||||
* @param options `stream.transform` options
|
||||
*/
|
||||
copy(options?: stream.TransformOptions): Hash;
|
||||
copy(options?: HashOptions): Hash;
|
||||
/**
|
||||
* Updates the hash content with the given `data`, the encoding of which
|
||||
* is given in `inputEncoding`.
|
||||
@@ -454,6 +470,7 @@ declare module "crypto" {
|
||||
* // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
|
||||
* ```
|
||||
* @since v0.1.94
|
||||
* @deprecated Since v20.13.0 Calling `Hmac` class directly with `Hmac()` or `new Hmac()` is deprecated due to being internals, not intended for public use. Please use the {@link createHmac} method to create Hmac instances.
|
||||
*/
|
||||
class Hmac extends stream.Transform {
|
||||
private constructor();
|
||||
@@ -592,11 +609,6 @@ declare module "crypto" {
|
||||
* @since v11.6.0
|
||||
*/
|
||||
asymmetricKeyType?: KeyType | undefined;
|
||||
/**
|
||||
* For asymmetric keys, this property represents the size of the embedded key in
|
||||
* bytes. This property is `undefined` for symmetric keys.
|
||||
*/
|
||||
asymmetricKeySize?: number | undefined;
|
||||
/**
|
||||
* This property exists only on asymmetric keys. Depending on the type of the key,
|
||||
* this object contains information about the key. None of the information obtained
|
||||
@@ -637,6 +649,13 @@ declare module "crypto" {
|
||||
export(options: KeyExportOptions<"pem">): string | Buffer;
|
||||
export(options?: KeyExportOptions<"der">): Buffer;
|
||||
export(options?: JwkKeyExportOptions): JsonWebKey;
|
||||
/**
|
||||
* Returns `true` or `false` depending on whether the keys have exactly the same
|
||||
* type, value, and parameters. This method is not [constant time](https://en.wikipedia.org/wiki/Timing_attack).
|
||||
* @since v17.7.0, v16.15.0
|
||||
* @param otherKeyObject A `KeyObject` with which to compare `keyObject`.
|
||||
*/
|
||||
equals(otherKeyObject: KeyObject): boolean;
|
||||
/**
|
||||
* For secret keys, this property represents the size of the key in bytes. This
|
||||
* property is `undefined` for asymmetric keys.
|
||||
@@ -650,9 +669,10 @@ declare module "crypto" {
|
||||
*/
|
||||
type: KeyObjectType;
|
||||
}
|
||||
type CipherCCMTypes = "aes-128-ccm" | "aes-192-ccm" | "aes-256-ccm" | "chacha20-poly1305";
|
||||
type CipherCCMTypes = "aes-128-ccm" | "aes-192-ccm" | "aes-256-ccm";
|
||||
type CipherGCMTypes = "aes-128-gcm" | "aes-192-gcm" | "aes-256-gcm";
|
||||
type CipherOCBTypes = "aes-128-ocb" | "aes-192-ocb" | "aes-256-ocb";
|
||||
type CipherChaCha20Poly1305Types = "chacha20-poly1305";
|
||||
type BinaryLike = string | NodeJS.ArrayBufferView;
|
||||
type CipherKey = BinaryLike | KeyObject;
|
||||
interface CipherCCMOptions extends stream.TransformOptions {
|
||||
@@ -664,8 +684,12 @@ declare module "crypto" {
|
||||
interface CipherOCBOptions extends stream.TransformOptions {
|
||||
authTagLength: number;
|
||||
}
|
||||
interface CipherChaCha20Poly1305Options extends stream.TransformOptions {
|
||||
/** @default 16 */
|
||||
authTagLength?: number | undefined;
|
||||
}
|
||||
/**
|
||||
* Creates and returns a `Cipher` object that uses the given `algorithm` and`password`.
|
||||
* Creates and returns a `Cipher` object that uses the given `algorithm` and `password`.
|
||||
*
|
||||
* The `options` argument controls stream behavior and is optional except when a
|
||||
* cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the
|
||||
@@ -705,6 +729,14 @@ declare module "crypto" {
|
||||
/** @deprecated since v10.0.0 use `createCipheriv()` */
|
||||
function createCipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): CipherGCM;
|
||||
/** @deprecated since v10.0.0 use `createCipheriv()` */
|
||||
function createCipher(algorithm: CipherOCBTypes, password: BinaryLike, options: CipherOCBOptions): CipherOCB;
|
||||
/** @deprecated since v10.0.0 use `createCipheriv()` */
|
||||
function createCipher(
|
||||
algorithm: CipherChaCha20Poly1305Types,
|
||||
password: BinaryLike,
|
||||
options?: CipherChaCha20Poly1305Options,
|
||||
): CipherChaCha20Poly1305;
|
||||
/** @deprecated since v10.0.0 use `createCipheriv()` */
|
||||
function createCipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Cipher;
|
||||
/**
|
||||
* Creates and returns a `Cipher` object, with the given `algorithm`, `key` and
|
||||
@@ -754,6 +786,12 @@ declare module "crypto" {
|
||||
iv: BinaryLike,
|
||||
options?: CipherGCMOptions,
|
||||
): CipherGCM;
|
||||
function createCipheriv(
|
||||
algorithm: CipherChaCha20Poly1305Types,
|
||||
key: CipherKey,
|
||||
iv: BinaryLike,
|
||||
options?: CipherChaCha20Poly1305Options,
|
||||
): CipherChaCha20Poly1305;
|
||||
function createCipheriv(
|
||||
algorithm: string,
|
||||
key: CipherKey,
|
||||
@@ -883,8 +921,8 @@ declare module "crypto" {
|
||||
private constructor();
|
||||
/**
|
||||
* Updates the cipher with `data`. If the `inputEncoding` argument is given,
|
||||
* the `data`argument is a string using the specified encoding. If the `inputEncoding`argument is not given, `data` must be a `Buffer`, `TypedArray`, or`DataView`. If `data` is a `Buffer`,
|
||||
* `TypedArray`, or `DataView`, then`inputEncoding` is ignored.
|
||||
* the `data`argument is a string using the specified encoding. If the `inputEncoding`argument is not given, `data` must be a `Buffer`, `TypedArray`, or `DataView`. If `data` is a `Buffer`,
|
||||
* `TypedArray`, or `DataView`, then `inputEncoding` is ignored.
|
||||
*
|
||||
* The `outputEncoding` specifies the output format of the enciphered
|
||||
* data. If the `outputEncoding`is specified, a string using the specified encoding is returned. If no`outputEncoding` is provided, a `Buffer` is returned.
|
||||
@@ -953,11 +991,20 @@ declare module "crypto" {
|
||||
): this;
|
||||
getAuthTag(): Buffer;
|
||||
}
|
||||
interface CipherChaCha20Poly1305 extends Cipher {
|
||||
setAAD(
|
||||
buffer: NodeJS.ArrayBufferView,
|
||||
options: {
|
||||
plaintextLength: number;
|
||||
},
|
||||
): this;
|
||||
getAuthTag(): Buffer;
|
||||
}
|
||||
/**
|
||||
* Creates and returns a `Decipher` object that uses the given `algorithm` and`password` (key).
|
||||
* Creates and returns a `Decipher` object that uses the given `algorithm` and `password` (key).
|
||||
*
|
||||
* The `options` argument controls stream behavior and is optional except when a
|
||||
* cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the
|
||||
* cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the `authTagLength` option is required and specifies the length of the
|
||||
* authentication tag in bytes, see `CCM mode`.
|
||||
* For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
|
||||
*
|
||||
@@ -983,13 +1030,21 @@ declare module "crypto" {
|
||||
/** @deprecated since v10.0.0 use `createDecipheriv()` */
|
||||
function createDecipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): DecipherGCM;
|
||||
/** @deprecated since v10.0.0 use `createDecipheriv()` */
|
||||
function createDecipher(algorithm: CipherOCBTypes, password: BinaryLike, options: CipherOCBOptions): DecipherOCB;
|
||||
/** @deprecated since v10.0.0 use `createDecipheriv()` */
|
||||
function createDecipher(
|
||||
algorithm: CipherChaCha20Poly1305Types,
|
||||
password: BinaryLike,
|
||||
options?: CipherChaCha20Poly1305Options,
|
||||
): DecipherChaCha20Poly1305;
|
||||
/** @deprecated since v10.0.0 use `createDecipheriv()` */
|
||||
function createDecipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Decipher;
|
||||
/**
|
||||
* Creates and returns a `Decipher` object that uses the given `algorithm`, `key`and initialization vector (`iv`).
|
||||
* Creates and returns a `Decipher` object that uses the given `algorithm`, `key` and initialization vector (`iv`).
|
||||
*
|
||||
* The `options` argument controls stream behavior and is optional except when a
|
||||
* cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the
|
||||
* authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to restrict accepted authentication tags
|
||||
* cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the `authTagLength` option is required and specifies the length of the
|
||||
* authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength` option is not required but can be used to restrict accepted authentication tags
|
||||
* to those with the specified length.
|
||||
* For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
|
||||
*
|
||||
@@ -1031,6 +1086,12 @@ declare module "crypto" {
|
||||
iv: BinaryLike,
|
||||
options?: CipherGCMOptions,
|
||||
): DecipherGCM;
|
||||
function createDecipheriv(
|
||||
algorithm: CipherChaCha20Poly1305Types,
|
||||
key: CipherKey,
|
||||
iv: BinaryLike,
|
||||
options?: CipherChaCha20Poly1305Options,
|
||||
): DecipherChaCha20Poly1305;
|
||||
function createDecipheriv(
|
||||
algorithm: string,
|
||||
key: CipherKey,
|
||||
@@ -1149,11 +1210,11 @@ declare module "crypto" {
|
||||
private constructor();
|
||||
/**
|
||||
* Updates the decipher with `data`. If the `inputEncoding` argument is given,
|
||||
* the `data`argument is a string using the specified encoding. If the `inputEncoding`argument is not given, `data` must be a `Buffer`. If `data` is a `Buffer` then `inputEncoding` is
|
||||
* the `data` argument is a string using the specified encoding. If the `inputEncoding` argument is not given, `data` must be a `Buffer`. If `data` is a `Buffer` then `inputEncoding` is
|
||||
* ignored.
|
||||
*
|
||||
* The `outputEncoding` specifies the output format of the enciphered
|
||||
* data. If the `outputEncoding`is specified, a string using the specified encoding is returned. If no`outputEncoding` is provided, a `Buffer` is returned.
|
||||
* data. If the `outputEncoding` is specified, a string using the specified encoding is returned. If no `outputEncoding` is provided, a `Buffer` is returned.
|
||||
*
|
||||
* The `decipher.update()` method can be called multiple times with new data until `decipher.final()` is called. Calling `decipher.update()` after `decipher.final()` will result in an error
|
||||
* being thrown.
|
||||
@@ -1176,7 +1237,7 @@ declare module "crypto" {
|
||||
final(): Buffer;
|
||||
final(outputEncoding: BufferEncoding): string;
|
||||
/**
|
||||
* When data has been encrypted without standard block padding, calling`decipher.setAutoPadding(false)` will disable automatic padding to prevent `decipher.final()` from checking for and
|
||||
* When data has been encrypted without standard block padding, calling `decipher.setAutoPadding(false)` will disable automatic padding to prevent `decipher.final()` from checking for and
|
||||
* removing padding.
|
||||
*
|
||||
* Turning auto padding off will only work if the input data's length is a
|
||||
@@ -1216,6 +1277,15 @@ declare module "crypto" {
|
||||
},
|
||||
): this;
|
||||
}
|
||||
interface DecipherChaCha20Poly1305 extends Decipher {
|
||||
setAuthTag(buffer: NodeJS.ArrayBufferView): this;
|
||||
setAAD(
|
||||
buffer: NodeJS.ArrayBufferView,
|
||||
options: {
|
||||
plaintextLength: number;
|
||||
},
|
||||
): this;
|
||||
}
|
||||
interface PrivateKeyInput {
|
||||
key: string | Buffer;
|
||||
format?: KeyFormat | undefined;
|
||||
@@ -1230,7 +1300,7 @@ declare module "crypto" {
|
||||
encoding?: string | undefined;
|
||||
}
|
||||
/**
|
||||
* Asynchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`.
|
||||
* Asynchronously generates a new random secret key of the given `length`. The `type` will determine which validations will be performed on the `length`.
|
||||
*
|
||||
* ```js
|
||||
* const {
|
||||
@@ -1256,7 +1326,7 @@ declare module "crypto" {
|
||||
callback: (err: Error | null, key: KeyObject) => void,
|
||||
): void;
|
||||
/**
|
||||
* Synchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`.
|
||||
* Synchronously generates a new random secret key of the given `length`. The `type` will determine which validations will be performed on the `length`.
|
||||
*
|
||||
* ```js
|
||||
* const {
|
||||
@@ -1284,7 +1354,7 @@ declare module "crypto" {
|
||||
}
|
||||
/**
|
||||
* Creates and returns a new key object containing a private key. If `key` is a
|
||||
* string or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key`must be an object with the properties described above.
|
||||
* string or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key` must be an object with the properties described above.
|
||||
*
|
||||
* If the private key is encrypted, a `passphrase` must be specified. The length
|
||||
* of the passphrase is limited to 1024 bytes.
|
||||
@@ -1293,7 +1363,7 @@ declare module "crypto" {
|
||||
function createPrivateKey(key: PrivateKeyInput | string | Buffer | JsonWebKeyInput): KeyObject;
|
||||
/**
|
||||
* Creates and returns a new key object containing a public key. If `key` is a
|
||||
* string or `Buffer`, `format` is assumed to be `'pem'`; if `key` is a `KeyObject`with type `'private'`, the public key is derived from the given private key;
|
||||
* string or `Buffer`, `format` is assumed to be `'pem'`; if `key` is a `KeyObject` with type `'private'`, the public key is derived from the given private key;
|
||||
* otherwise, `key` must be an object with the properties described above.
|
||||
*
|
||||
* If the format is `'pem'`, the `'key'` may also be an X.509 certificate.
|
||||
@@ -1301,7 +1371,7 @@ declare module "crypto" {
|
||||
* Because public keys can be derived from private keys, a private key may be
|
||||
* passed instead of a public key. In that case, this function behaves as if {@link createPrivateKey} had been called, except that the type of the
|
||||
* returned `KeyObject` will be `'public'` and that the private key cannot be
|
||||
* extracted from the returned `KeyObject`. Similarly, if a `KeyObject` with type`'private'` is given, a new `KeyObject` with type `'public'` will be returned
|
||||
* extracted from the returned `KeyObject`. Similarly, if a `KeyObject` with type `'private'` is given, a new `KeyObject` with type `'public'` will be returned
|
||||
* and it will be impossible to extract the private key from the returned object.
|
||||
* @since v11.6.0
|
||||
*/
|
||||
@@ -1340,6 +1410,7 @@ declare module "crypto" {
|
||||
interface SignKeyObjectInput extends SigningOptions {
|
||||
key: KeyObject;
|
||||
}
|
||||
interface SignJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
|
||||
interface VerifyPublicKeyInput extends PublicKeyInput, SigningOptions {}
|
||||
interface VerifyKeyObjectInput extends SigningOptions {
|
||||
key: KeyObject;
|
||||
@@ -1426,7 +1497,7 @@ declare module "crypto" {
|
||||
/**
|
||||
* Calculates the signature on all the data passed through using either `sign.update()` or `sign.write()`.
|
||||
*
|
||||
* If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an
|
||||
* If `privateKey` is not a `KeyObject`, this function behaves as if `privateKey` had been passed to {@link createPrivateKey}. If it is an
|
||||
* object, the following additional properties can be passed:
|
||||
*
|
||||
* If `outputEncoding` is provided a string is returned; otherwise a `Buffer` is returned.
|
||||
@@ -1435,16 +1506,16 @@ declare module "crypto" {
|
||||
* called. Multiple calls to `sign.sign()` will result in an error being thrown.
|
||||
* @since v0.1.92
|
||||
*/
|
||||
sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput): Buffer;
|
||||
sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput): Buffer;
|
||||
sign(
|
||||
privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
|
||||
privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
|
||||
outputFormat: BinaryToTextEncoding,
|
||||
): string;
|
||||
}
|
||||
/**
|
||||
* Creates and returns a `Verify` object that uses the given algorithm.
|
||||
* Use {@link getHashes} to obtain an array of names of the available
|
||||
* signing algorithms. Optional `options` argument controls the`stream.Writable` behavior.
|
||||
* signing algorithms. Optional `options` argument controls the `stream.Writable` behavior.
|
||||
*
|
||||
* In some cases, a `Verify` instance can be created using the name of a signature
|
||||
* algorithm, such as `'RSA-SHA256'`, instead of a digest algorithm. This will use
|
||||
@@ -1464,7 +1535,7 @@ declare module "crypto" {
|
||||
* * Using the `verify.update()` and `verify.verify()` methods to verify
|
||||
* the signature.
|
||||
*
|
||||
* The {@link createVerify} method is used to create `Verify` instances.`Verify` objects are not to be created directly using the `new` keyword.
|
||||
* The {@link createVerify} method is used to create `Verify` instances. `Verify` objects are not to be created directly using the `new` keyword.
|
||||
*
|
||||
* See `Sign` for examples.
|
||||
* @since v0.1.92
|
||||
@@ -1475,7 +1546,7 @@ declare module "crypto" {
|
||||
* Updates the `Verify` content with the given `data`, the encoding of which
|
||||
* is given in `inputEncoding`.
|
||||
* If `inputEncoding` is not provided, and the `data` is a string, an
|
||||
* encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored.
|
||||
* encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or `DataView`, then `inputEncoding` is ignored.
|
||||
*
|
||||
* This can be called many times with new data as it is streamed.
|
||||
* @since v0.1.92
|
||||
@@ -1486,13 +1557,13 @@ declare module "crypto" {
|
||||
/**
|
||||
* Verifies the provided data using the given `object` and `signature`.
|
||||
*
|
||||
* If `object` is not a `KeyObject`, this function behaves as if`object` had been passed to {@link createPublicKey}. If it is an
|
||||
* If `object` is not a `KeyObject`, this function behaves as if `object` had been passed to {@link createPublicKey}. If it is an
|
||||
* object, the following additional properties can be passed:
|
||||
*
|
||||
* The `signature` argument is the previously calculated signature for the data, in
|
||||
* the `signatureEncoding`.
|
||||
* If a `signatureEncoding` is specified, the `signature` is expected to be a
|
||||
* string; otherwise `signature` is expected to be a `Buffer`,`TypedArray`, or `DataView`.
|
||||
* string; otherwise `signature` is expected to be a `Buffer`, `TypedArray`, or `DataView`.
|
||||
*
|
||||
* The `verify` object can not be used again after `verify.verify()` has been
|
||||
* called. Multiple calls to `verify.verify()` will result in an error being
|
||||
@@ -1516,7 +1587,7 @@ declare module "crypto" {
|
||||
* Creates a `DiffieHellman` key exchange object using the supplied `prime` and an
|
||||
* optional specific `generator`.
|
||||
*
|
||||
* The `generator` argument can be a number, string, or `Buffer`. If`generator` is not specified, the value `2` is used.
|
||||
* The `generator` argument can be a number, string, or `Buffer`. If `generator` is not specified, the value `2` is used.
|
||||
*
|
||||
* If `primeEncoding` is specified, `prime` is expected to be a string; otherwise
|
||||
* a `Buffer`, `TypedArray`, or `DataView` is expected.
|
||||
@@ -1602,7 +1673,7 @@ declare module "crypto" {
|
||||
* key is interpreted using the specified `inputEncoding`, and secret is
|
||||
* encoded using specified `outputEncoding`.
|
||||
* If the `inputEncoding` is not
|
||||
* provided, `otherPublicKey` is expected to be a `Buffer`,`TypedArray`, or `DataView`.
|
||||
* provided, `otherPublicKey` is expected to be a `Buffer`, `TypedArray`, or `DataView`.
|
||||
*
|
||||
* If `outputEncoding` is given a string is returned; otherwise, a `Buffer` is returned.
|
||||
* @since v0.5.0
|
||||
@@ -1658,7 +1729,7 @@ declare module "crypto" {
|
||||
getPrivateKey(): Buffer;
|
||||
getPrivateKey(encoding: BinaryToTextEncoding): string;
|
||||
/**
|
||||
* Sets the Diffie-Hellman public key. If the `encoding` argument is provided,`publicKey` is expected
|
||||
* Sets the Diffie-Hellman public key. If the `encoding` argument is provided, `publicKey` is expected
|
||||
* to be a string. If no `encoding` is provided, `publicKey` is expected
|
||||
* to be a `Buffer`, `TypedArray`, or `DataView`.
|
||||
* @since v0.5.0
|
||||
@@ -1761,10 +1832,10 @@ declare module "crypto" {
|
||||
/**
|
||||
* Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2)
|
||||
* implementation. A selected HMAC digest algorithm specified by `digest` is
|
||||
* applied to derive a key of the requested byte length (`keylen`) from the`password`, `salt` and `iterations`.
|
||||
* applied to derive a key of the requested byte length (`keylen`) from the `password`, `salt` and `iterations`.
|
||||
*
|
||||
* The supplied `callback` function is called with two arguments: `err` and`derivedKey`. If an error occurs while deriving the key, `err` will be set;
|
||||
* otherwise `err` will be `null`. By default, the successfully generated`derivedKey` will be passed to the callback as a `Buffer`. An error will be
|
||||
* The supplied `callback` function is called with two arguments: `err` and `derivedKey`. If an error occurs while deriving the key, `err` will be set;
|
||||
* otherwise `err` will be `null`. By default, the successfully generated `derivedKey` will be passed to the callback as a `Buffer`. An error will be
|
||||
* thrown if any of the input arguments specify invalid values or types.
|
||||
*
|
||||
* The `iterations` argument must be a number set as high as possible. The
|
||||
@@ -1804,7 +1875,7 @@ declare module "crypto" {
|
||||
/**
|
||||
* Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2)
|
||||
* implementation. A selected HMAC digest algorithm specified by `digest` is
|
||||
* applied to derive a key of the requested byte length (`keylen`) from the`password`, `salt` and `iterations`.
|
||||
* applied to derive a key of the requested byte length (`keylen`) from the `password`, `salt` and `iterations`.
|
||||
*
|
||||
* If an error occurs an `Error` will be thrown, otherwise the derived key will be
|
||||
* returned as a `Buffer`.
|
||||
@@ -1843,7 +1914,7 @@ declare module "crypto" {
|
||||
*
|
||||
* If a `callback` function is provided, the bytes are generated asynchronously
|
||||
* and the `callback` function is invoked with two arguments: `err` and `buf`.
|
||||
* If an error occurs, `err` will be an `Error` object; otherwise it is `null`. The`buf` argument is a `Buffer` containing the generated bytes.
|
||||
* If an error occurs, `err` will be an `Error` object; otherwise it is `null`. The `buf` argument is a `Buffer` containing the generated bytes.
|
||||
*
|
||||
* ```js
|
||||
* // Asynchronous
|
||||
@@ -1897,7 +1968,7 @@ declare module "crypto" {
|
||||
* Return a random integer `n` such that `min <= n < max`. This
|
||||
* implementation avoids [modulo bias](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modulo_bias).
|
||||
*
|
||||
* The range (`max - min`) must be less than 248. `min` and `max` must
|
||||
* The range (`max - min`) must be less than 2**48. `min` and `max` must
|
||||
* be [safe integers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
|
||||
*
|
||||
* If the `callback` function is not provided, the random integer is
|
||||
@@ -2014,7 +2085,7 @@ declare module "crypto" {
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Any `ArrayBuffer`, `TypedArray`, or `DataView` instance may be passed as`buffer`.
|
||||
* Any `ArrayBuffer`, `TypedArray`, or `DataView` instance may be passed as `buffer`.
|
||||
*
|
||||
* While this includes instances of `Float32Array` and `Float64Array`, this
|
||||
* function should not be used to generate random floating-point numbers. The
|
||||
@@ -2094,7 +2165,7 @@ declare module "crypto" {
|
||||
*
|
||||
* When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`.
|
||||
*
|
||||
* The `callback` function is called with two arguments: `err` and `derivedKey`.`err` is an exception object when key derivation fails, otherwise `err` is`null`. `derivedKey` is passed to the
|
||||
* The `callback` function is called with two arguments: `err` and `derivedKey`. `err` is an exception object when key derivation fails, otherwise `err` is `null`. `derivedKey` is passed to the
|
||||
* callback as a `Buffer`.
|
||||
*
|
||||
* An exception is thrown when any of the input arguments specify invalid values
|
||||
@@ -2180,8 +2251,8 @@ declare module "crypto" {
|
||||
* Encrypts the content of `buffer` with `key` and returns a new `Buffer` with encrypted content. The returned data can be decrypted using
|
||||
* the corresponding private key, for example using {@link privateDecrypt}.
|
||||
*
|
||||
* If `key` is not a `KeyObject`, this function behaves as if`key` had been passed to {@link createPublicKey}. If it is an
|
||||
* object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_OAEP_PADDING`.
|
||||
* If `key` is not a `KeyObject`, this function behaves as if `key` had been passed to {@link createPublicKey}. If it is an
|
||||
* object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_OAEP_PADDING`.
|
||||
*
|
||||
* Because RSA public keys can be derived from private keys, a private key may
|
||||
* be passed instead of a public key.
|
||||
@@ -2192,8 +2263,8 @@ declare module "crypto" {
|
||||
* Decrypts `buffer` with `key`.`buffer` was previously encrypted using
|
||||
* the corresponding private key, for example using {@link privateEncrypt}.
|
||||
*
|
||||
* If `key` is not a `KeyObject`, this function behaves as if`key` had been passed to {@link createPublicKey}. If it is an
|
||||
* object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_PADDING`.
|
||||
* If `key` is not a `KeyObject`, this function behaves as if `key` had been passed to {@link createPublicKey}. If it is an
|
||||
* object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_PADDING`.
|
||||
*
|
||||
* Because RSA public keys can be derived from private keys, a private key may
|
||||
* be passed instead of a public key.
|
||||
@@ -2204,8 +2275,8 @@ declare module "crypto" {
|
||||
* Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using
|
||||
* the corresponding public key, for example using {@link publicEncrypt}.
|
||||
*
|
||||
* If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an
|
||||
* object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_OAEP_PADDING`.
|
||||
* If `privateKey` is not a `KeyObject`, this function behaves as if `privateKey` had been passed to {@link createPrivateKey}. If it is an
|
||||
* object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_OAEP_PADDING`.
|
||||
* @since v0.11.14
|
||||
*/
|
||||
function privateDecrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
|
||||
@@ -2213,8 +2284,8 @@ declare module "crypto" {
|
||||
* Encrypts `buffer` with `privateKey`. The returned data can be decrypted using
|
||||
* the corresponding public key, for example using {@link publicDecrypt}.
|
||||
*
|
||||
* If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an
|
||||
* object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_PADDING`.
|
||||
* If `privateKey` is not a `KeyObject`, this function behaves as if `privateKey` had been passed to {@link createPrivateKey}. If it is an
|
||||
* object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_PADDING`.
|
||||
* @since v1.1.0
|
||||
*/
|
||||
function privateEncrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
|
||||
@@ -2309,9 +2380,9 @@ declare module "crypto" {
|
||||
* On recent OpenSSL releases, `openssl ecparam -list_curves` will also display
|
||||
* the name and description of each available elliptic curve.
|
||||
*
|
||||
* If `format` is not specified the point will be returned in `'uncompressed'`format.
|
||||
* If `format` is not specified the point will be returned in `'uncompressed'` format.
|
||||
*
|
||||
* If the `inputEncoding` is not provided, `key` is expected to be a `Buffer`,`TypedArray`, or `DataView`.
|
||||
* If the `inputEncoding` is not provided, `key` is expected to be a `Buffer`, `TypedArray`, or `DataView`.
|
||||
*
|
||||
* Example (uncompressing a key):
|
||||
*
|
||||
@@ -2352,7 +2423,7 @@ declare module "crypto" {
|
||||
* the public key in the specified `format` and `encoding`. This key should be
|
||||
* transferred to the other party.
|
||||
*
|
||||
* The `format` argument specifies point encoding and can be `'compressed'` or`'uncompressed'`. If `format` is not specified, the point will be returned in`'uncompressed'` format.
|
||||
* The `format` argument specifies point encoding and can be `'compressed'` or `'uncompressed'`. If `format` is not specified, the point will be returned in`'uncompressed'` format.
|
||||
*
|
||||
* If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.
|
||||
* @since v0.11.14
|
||||
@@ -2367,11 +2438,11 @@ declare module "crypto" {
|
||||
* key is interpreted using specified `inputEncoding`, and the returned secret
|
||||
* is encoded using the specified `outputEncoding`.
|
||||
* If the `inputEncoding` is not
|
||||
* provided, `otherPublicKey` is expected to be a `Buffer`, `TypedArray`, or`DataView`.
|
||||
* provided, `otherPublicKey` is expected to be a `Buffer`, `TypedArray`, or `DataView`.
|
||||
*
|
||||
* If `outputEncoding` is given a string will be returned; otherwise a `Buffer` is returned.
|
||||
*
|
||||
* `ecdh.computeSecret` will throw an`ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY` error when `otherPublicKey`lies outside of the elliptic curve. Since `otherPublicKey` is
|
||||
* `ecdh.computeSecret` will throw an`ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY` error when `otherPublicKey` lies outside of the elliptic curve. Since `otherPublicKey` is
|
||||
* usually supplied from a remote user over an insecure network,
|
||||
* be sure to handle this exception accordingly.
|
||||
* @since v0.11.14
|
||||
@@ -2396,7 +2467,7 @@ declare module "crypto" {
|
||||
getPrivateKey(): Buffer;
|
||||
getPrivateKey(encoding: BinaryToTextEncoding): string;
|
||||
/**
|
||||
* The `format` argument specifies point encoding and can be `'compressed'` or`'uncompressed'`. If `format` is not specified the point will be returned in`'uncompressed'` format.
|
||||
* The `format` argument specifies point encoding and can be `'compressed'` or `'uncompressed'`. If `format` is not specified the point will be returned in`'uncompressed'` format.
|
||||
*
|
||||
* If `encoding` is specified, a string is returned; otherwise a `Buffer` is
|
||||
* returned.
|
||||
@@ -2410,7 +2481,7 @@ declare module "crypto" {
|
||||
/**
|
||||
* Sets the EC Diffie-Hellman private key.
|
||||
* If `encoding` is provided, `privateKey` is expected
|
||||
* to be a string; otherwise `privateKey` is expected to be a `Buffer`,`TypedArray`, or `DataView`.
|
||||
* to be a string; otherwise `privateKey` is expected to be a `Buffer`, `TypedArray`, or `DataView`.
|
||||
*
|
||||
* If `privateKey` is not valid for the curve specified when the `ECDH` object was
|
||||
* created, an error is thrown. Upon setting the private key, the associated
|
||||
@@ -2430,7 +2501,7 @@ declare module "crypto" {
|
||||
*/
|
||||
function createECDH(curveName: string): ECDH;
|
||||
/**
|
||||
* This function compares the underlying bytes that represent the given`ArrayBuffer`, `TypedArray`, or `DataView` instances using a constant-time
|
||||
* This function compares the underlying bytes that represent the given `ArrayBuffer`, `TypedArray`, or `DataView` instances using a constant-time
|
||||
* algorithm.
|
||||
*
|
||||
* This function does not leak timing information that
|
||||
@@ -2445,8 +2516,8 @@ declare module "crypto" {
|
||||
* entry, such as `Uint16Array`, the result will be computed using the platform
|
||||
* byte order.
|
||||
*
|
||||
* **When both of the inputs are `Float32Array`s or`Float64Array`s, this function might return unexpected results due to IEEE 754**
|
||||
* **encoding of floating-point numbers. In particular, neither `x === y` nor`Object.is(x, y)` implies that the byte representations of two floating-point**
|
||||
* **When both of the inputs are `Float32Array`s or `Float64Array`s, this function might return unexpected results due to IEEE 754**
|
||||
* **encoding of floating-point numbers. In particular, neither `x === y` nor `Object.is(x, y)` implies that the byte representations of two floating-point**
|
||||
* **numbers `x` and `y` are equal.**
|
||||
*
|
||||
* Use of `crypto.timingSafeEqual` does not guarantee that the _surrounding_ code
|
||||
@@ -2475,6 +2546,10 @@ declare module "crypto" {
|
||||
* Name of the curve to use
|
||||
*/
|
||||
namedCurve: string;
|
||||
/**
|
||||
* Must be `'named'` or `'explicit'`. Default: `'named'`.
|
||||
*/
|
||||
paramEncoding?: "explicit" | "named" | undefined;
|
||||
}
|
||||
interface RSAKeyPairKeyObjectOptions {
|
||||
/**
|
||||
@@ -2585,11 +2660,7 @@ declare module "crypto" {
|
||||
type: "pkcs8";
|
||||
};
|
||||
}
|
||||
interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
||||
/**
|
||||
* Name of the curve to use.
|
||||
*/
|
||||
namedCurve: string;
|
||||
interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> extends ECKeyPairKeyObjectOptions {
|
||||
publicKeyEncoding: {
|
||||
type: "pkcs1" | "spki";
|
||||
format: PubF;
|
||||
@@ -2823,7 +2894,7 @@ declare module "crypto" {
|
||||
* behaves as if `keyObject.export()` had been called on its result. Otherwise,
|
||||
* the respective part of the key is returned as a `KeyObject`.
|
||||
*
|
||||
* It is recommended to encode public keys as `'spki'` and private keys as`'pkcs8'` with encryption for long-term storage:
|
||||
* It is recommended to encode public keys as `'spki'` and private keys as `'pkcs8'` with encryption for long-term storage:
|
||||
*
|
||||
* ```js
|
||||
* const {
|
||||
@@ -2847,7 +2918,7 @@ declare module "crypto" {
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* On completion, `callback` will be called with `err` set to `undefined` and`publicKey` / `privateKey` representing the generated key pair.
|
||||
* On completion, `callback` will be called with `err` set to `undefined` and `publicKey` / `privateKey` representing the generated key pair.
|
||||
*
|
||||
* If this method is invoked as its `util.promisify()` ed version, it returns
|
||||
* a `Promise` for an `Object` with `publicKey` and `privateKey` properties.
|
||||
@@ -3312,16 +3383,16 @@ declare module "crypto" {
|
||||
function sign(
|
||||
algorithm: string | null | undefined,
|
||||
data: NodeJS.ArrayBufferView,
|
||||
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
|
||||
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
|
||||
): Buffer;
|
||||
function sign(
|
||||
algorithm: string | null | undefined,
|
||||
data: NodeJS.ArrayBufferView,
|
||||
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
|
||||
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
|
||||
callback: (error: Error | null, data: Buffer) => void,
|
||||
): void;
|
||||
/**
|
||||
* Verifies the given signature for `data` using the given key and algorithm. If`algorithm` is `null` or `undefined`, then the algorithm is dependent upon the
|
||||
* Verifies the given signature for `data` using the given key and algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is dependent upon the
|
||||
* key type (especially Ed25519 and Ed448).
|
||||
*
|
||||
* If `key` is not a `KeyObject`, this function behaves as if `key` had been
|
||||
@@ -3351,10 +3422,45 @@ declare module "crypto" {
|
||||
): void;
|
||||
/**
|
||||
* Computes the Diffie-Hellman secret based on a `privateKey` and a `publicKey`.
|
||||
* Both keys must have the same `asymmetricKeyType`, which must be one of `'dh'`(for Diffie-Hellman), `'ec'` (for ECDH), `'x448'`, or `'x25519'` (for ECDH-ES).
|
||||
* Both keys must have the same `asymmetricKeyType`, which must be one of `'dh'` (for Diffie-Hellman), `'ec'` (for ECDH), `'x448'`, or `'x25519'` (for ECDH-ES).
|
||||
* @since v13.9.0, v12.17.0
|
||||
*/
|
||||
function diffieHellman(options: { privateKey: KeyObject; publicKey: KeyObject }): Buffer;
|
||||
/**
|
||||
* A utility for creating one-shot hash digests of data. It can be faster than the object-based `crypto.createHash()` when hashing a smaller amount of data
|
||||
* (<= 5MB) that's readily available. If the data can be big or if it is streamed, it's still recommended to use `crypto.createHash()` instead. The `algorithm`
|
||||
* is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc. On recent releases
|
||||
* of OpenSSL, `openssl list -digest-algorithms` will display the available digest algorithms.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* import crypto from 'node:crypto';
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Hashing a string and return the result as a hex-encoded string.
|
||||
* const string = 'Node.js';
|
||||
* // 10b3493287f831e81a438811a1ffba01f8cec4b7
|
||||
* console.log(crypto.hash('sha1', string));
|
||||
*
|
||||
* // Encode a base64-encoded string into a Buffer, hash it and return
|
||||
* // the result as a buffer.
|
||||
* const base64 = 'Tm9kZS5qcw==';
|
||||
* // <Buffer 10 b3 49 32 87 f8 31 e8 1a 43 88 11 a1 ff ba 01 f8 ce c4 b7>
|
||||
* console.log(crypto.hash('sha1', Buffer.from(base64, 'base64'), 'buffer'));
|
||||
* ```
|
||||
* @since v21.7.0, v20.12.0
|
||||
* @param data When `data` is a string, it will be encoded as UTF-8 before being hashed. If a different input encoding is desired for a string input, user
|
||||
* could encode the string into a `TypedArray` using either `TextEncoder` or `Buffer.from()` and passing the encoded `TypedArray` into this API instead.
|
||||
* @param [outputEncoding='hex'] [Encoding](https://nodejs.org/docs/latest-v20.x/api/buffer.html#buffers-and-character-encodings) used to encode the returned digest.
|
||||
*/
|
||||
function hash(algorithm: string, data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
|
||||
function hash(algorithm: string, data: BinaryLike, outputEncoding: "buffer"): Buffer;
|
||||
function hash(
|
||||
algorithm: string,
|
||||
data: BinaryLike,
|
||||
outputEncoding?: BinaryToTextEncoding | "buffer",
|
||||
): string | Buffer;
|
||||
type CipherMode = "cbc" | "ccm" | "cfb" | "ctr" | "ecb" | "gcm" | "ocb" | "ofb" | "stream" | "wrap" | "xts";
|
||||
interface CipherInfoOptions {
|
||||
/**
|
||||
@@ -3407,9 +3513,9 @@ declare module "crypto" {
|
||||
*/
|
||||
function getCipherInfo(nameOrNid: string | number, options?: CipherInfoOptions): CipherInfo | undefined;
|
||||
/**
|
||||
* HKDF is a simple key derivation function defined in RFC 5869\. The given `ikm`,`salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.
|
||||
* HKDF is a simple key derivation function defined in RFC 5869\. The given `ikm`, `salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.
|
||||
*
|
||||
* The supplied `callback` function is called with two arguments: `err` and`derivedKey`. If an errors occurs while deriving the key, `err` will be set;
|
||||
* The supplied `callback` function is called with two arguments: `err` and `derivedKey`. If an errors occurs while deriving the key, `err` will be set;
|
||||
* otherwise `err` will be `null`. The successfully generated `derivedKey` will
|
||||
* be passed to the callback as an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). An error will be thrown if any
|
||||
* of the input arguments specify invalid values or types.
|
||||
@@ -3443,7 +3549,7 @@ declare module "crypto" {
|
||||
): void;
|
||||
/**
|
||||
* Provides a synchronous HKDF key derivation function as defined in RFC 5869\. The
|
||||
* given `ikm`, `salt` and `info` are used with the `digest` to derive a key of`keylen` bytes.
|
||||
* given `ikm`, `salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.
|
||||
*
|
||||
* The successfully generated `derivedKey` will be returned as an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer).
|
||||
*
|
||||
@@ -3772,7 +3878,7 @@ declare module "crypto" {
|
||||
/**
|
||||
* Generates a pseudorandom prime of `size` bits.
|
||||
*
|
||||
* If `options.safe` is `true`, the prime will be a safe prime -- that is,`(prime - 1) / 2` will also be a prime.
|
||||
* If `options.safe` is `true`, the prime will be a safe prime -- that is, `(prime - 1) / 2` will also be a prime.
|
||||
*
|
||||
* The `options.add` and `options.rem` parameters can be used to enforce additional
|
||||
* requirements, e.g., for Diffie-Hellman:
|
||||
@@ -3788,7 +3894,7 @@ declare module "crypto" {
|
||||
* * `options.rem` is ignored if `options.add` is not given.
|
||||
*
|
||||
* Both `options.add` and `options.rem` must be encoded as big-endian sequences
|
||||
* if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or`DataView`.
|
||||
* if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or `DataView`.
|
||||
*
|
||||
* By default, the prime is encoded as a big-endian sequence of octets
|
||||
* in an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). If the `bigint` option is `true`, then a
|
||||
@@ -3815,7 +3921,7 @@ declare module "crypto" {
|
||||
/**
|
||||
* Generates a pseudorandom prime of `size` bits.
|
||||
*
|
||||
* If `options.safe` is `true`, the prime will be a safe prime -- that is,`(prime - 1) / 2` will also be a prime.
|
||||
* If `options.safe` is `true`, the prime will be a safe prime -- that is, `(prime - 1) / 2` will also be a prime.
|
||||
*
|
||||
* The `options.add` and `options.rem` parameters can be used to enforce additional
|
||||
* requirements, e.g., for Diffie-Hellman:
|
||||
@@ -3831,7 +3937,7 @@ declare module "crypto" {
|
||||
* * `options.rem` is ignored if `options.add` is not given.
|
||||
*
|
||||
* Both `options.add` and `options.rem` must be encoded as big-endian sequences
|
||||
* if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or`DataView`.
|
||||
* if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or `DataView`.
|
||||
*
|
||||
* By default, the prime is encoded as a big-endian sequence of octets
|
||||
* in an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). If the `bigint` option is `true`, then a
|
||||
@@ -3877,7 +3983,7 @@ declare module "crypto" {
|
||||
*
|
||||
* `engine` could be either an id or a path to the engine's shared library.
|
||||
*
|
||||
* The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags`is a bit field taking one of or a mix of the following flags (defined in`crypto.constants`):
|
||||
* The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags` is a bit field taking one of or a mix of the following flags (defined in `crypto.constants`):
|
||||
*
|
||||
* * `crypto.constants.ENGINE_METHOD_RSA`
|
||||
* * `crypto.constants.ENGINE_METHOD_DSA`
|
||||
@@ -4047,7 +4153,7 @@ declare module "crypto" {
|
||||
saltLength: number;
|
||||
}
|
||||
/**
|
||||
* Calling `require('node:crypto').webcrypto` returns an instance of the `Crypto` class.
|
||||
* Importing the `webcrypto` object (`import { webcrypto } from 'node:crypto'`) gives an instance of the `Crypto` class.
|
||||
* `Crypto` is a singleton that provides access to the remainder of the crypto API.
|
||||
* @since v15.0.0
|
||||
*/
|
||||
@@ -4208,7 +4314,7 @@ declare module "crypto" {
|
||||
| HkdfParams
|
||||
| Pbkdf2Params,
|
||||
extractable: boolean,
|
||||
keyUsages: ReadonlyArray<KeyUsage>,
|
||||
keyUsages: readonly KeyUsage[],
|
||||
): Promise<CryptoKey>;
|
||||
/**
|
||||
* Using the method identified by `algorithm`, `subtle.digest()` attempts to generate a digest of `data`.
|
||||
@@ -4288,12 +4394,12 @@ declare module "crypto" {
|
||||
generateKey(
|
||||
algorithm: RsaHashedKeyGenParams | EcKeyGenParams,
|
||||
extractable: boolean,
|
||||
keyUsages: ReadonlyArray<KeyUsage>,
|
||||
keyUsages: readonly KeyUsage[],
|
||||
): Promise<CryptoKeyPair>;
|
||||
generateKey(
|
||||
algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params,
|
||||
extractable: boolean,
|
||||
keyUsages: ReadonlyArray<KeyUsage>,
|
||||
keyUsages: readonly KeyUsage[],
|
||||
): Promise<CryptoKey>;
|
||||
generateKey(
|
||||
algorithm: AlgorithmIdentifier,
|
||||
@@ -4320,7 +4426,7 @@ declare module "crypto" {
|
||||
| HmacImportParams
|
||||
| AesKeyAlgorithm,
|
||||
extractable: boolean,
|
||||
keyUsages: ReadonlyArray<KeyUsage>,
|
||||
keyUsages: readonly KeyUsage[],
|
||||
): Promise<CryptoKey>;
|
||||
importKey(
|
||||
format: Exclude<KeyFormat, "jwk">,
|
||||
@@ -4450,6 +4556,14 @@ declare module "crypto" {
|
||||
): Promise<ArrayBuffer>;
|
||||
}
|
||||
}
|
||||
|
||||
global {
|
||||
var crypto: typeof globalThis extends {
|
||||
crypto: infer T;
|
||||
onmessage: any;
|
||||
} ? T
|
||||
: webcrypto.Crypto;
|
||||
}
|
||||
}
|
||||
declare module "node:crypto" {
|
||||
export * from "crypto";
|
||||
|
||||
52
node_modules/@types/node/dgram.d.ts
generated
vendored
52
node_modules/@types/node/dgram.d.ts
generated
vendored
@@ -23,7 +23,7 @@
|
||||
* server.bind(41234);
|
||||
* // Prints: server listening 0.0.0.0:41234
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dgram.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/dgram.js)
|
||||
*/
|
||||
declare module "dgram" {
|
||||
import { AddressInfo } from "node:net";
|
||||
@@ -66,7 +66,7 @@ declare module "dgram" {
|
||||
* (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:
|
||||
* 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();
|
||||
@@ -93,7 +93,7 @@ declare module "dgram" {
|
||||
*/
|
||||
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
|
||||
* 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.
|
||||
@@ -122,7 +122,7 @@ declare module "dgram" {
|
||||
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.
|
||||
* 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
|
||||
@@ -133,10 +133,10 @@ declare module "dgram" {
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
@@ -206,7 +206,7 @@ declare module "dgram" {
|
||||
*/
|
||||
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
|
||||
* 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.
|
||||
*
|
||||
@@ -227,6 +227,16 @@ declare module "dgram" {
|
||||
* @return the `SO_SNDBUF` socket send buffer size in bytes.
|
||||
*/
|
||||
getSendBufferSize(): number;
|
||||
/**
|
||||
* @since v18.8.0, v16.19.0
|
||||
* @return Number of bytes queued for sending.
|
||||
*/
|
||||
getSendQueueSize(): number;
|
||||
/**
|
||||
* @since v18.8.0, v16.19.0
|
||||
* @return Number of send requests currently in the queue awaiting to be processed.
|
||||
*/
|
||||
getSendQueueCount(): 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
|
||||
@@ -259,14 +269,14 @@ declare module "dgram" {
|
||||
* 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
|
||||
* 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 nullish, `'127.0.0.1'` (for `udp4` sockets) or `'::1'`(for `udp6` sockets) will be used by default.
|
||||
* provided or otherwise nullish, `'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
|
||||
@@ -277,7 +287,7 @@ declare module "dgram" {
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
@@ -319,7 +329,7 @@ declare module "dgram" {
|
||||
* 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`:
|
||||
* Example of sending a UDP packet using a socket connected to a port on `localhost`:
|
||||
*
|
||||
* ```js
|
||||
* import dgram from 'node:dgram';
|
||||
@@ -342,22 +352,22 @@ declare module "dgram" {
|
||||
* @param callback Called when the message has been sent.
|
||||
*/
|
||||
send(
|
||||
msg: string | Uint8Array | ReadonlyArray<any>,
|
||||
msg: string | NodeJS.ArrayBufferView | readonly any[],
|
||||
port?: number,
|
||||
address?: string,
|
||||
callback?: (error: Error | null, bytes: number) => void,
|
||||
): void;
|
||||
send(
|
||||
msg: string | Uint8Array | ReadonlyArray<any>,
|
||||
msg: string | NodeJS.ArrayBufferView | readonly any[],
|
||||
port?: number,
|
||||
callback?: (error: Error | null, bytes: number) => void,
|
||||
): void;
|
||||
send(
|
||||
msg: string | Uint8Array | ReadonlyArray<any>,
|
||||
msg: string | NodeJS.ArrayBufferView | readonly any[],
|
||||
callback?: (error: Error | null, bytes: number) => void,
|
||||
): void;
|
||||
send(
|
||||
msg: string | Uint8Array,
|
||||
msg: string | NodeJS.ArrayBufferView,
|
||||
offset: number,
|
||||
length: number,
|
||||
port?: number,
|
||||
@@ -365,14 +375,14 @@ declare module "dgram" {
|
||||
callback?: (error: Error | null, bytes: number) => void,
|
||||
): void;
|
||||
send(
|
||||
msg: string | Uint8Array,
|
||||
msg: string | NodeJS.ArrayBufferView,
|
||||
offset: number,
|
||||
length: number,
|
||||
port?: number,
|
||||
callback?: (error: Error | null, bytes: number) => void,
|
||||
): void;
|
||||
send(
|
||||
msg: string | Uint8Array,
|
||||
msg: string | NodeJS.ArrayBufferView,
|
||||
offset: number,
|
||||
length: number,
|
||||
callback?: (error: Error | null, bytes: number) => void,
|
||||
@@ -501,7 +511,7 @@ declare module "dgram" {
|
||||
* process active, allowing the process to exit even if the socket is still
|
||||
* listening.
|
||||
*
|
||||
* Calling `socket.unref()` multiple times will have no addition effect.
|
||||
* Calling `socket.unref()` multiple times will have no additional effect.
|
||||
*
|
||||
* The `socket.unref()` method returns a reference to the socket so calls can be
|
||||
* chained.
|
||||
@@ -509,10 +519,10 @@ declare module "dgram" {
|
||||
*/
|
||||
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
|
||||
* 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.
|
||||
* 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.
|
||||
@@ -520,7 +530,7 @@ declare module "dgram" {
|
||||
*/
|
||||
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
|
||||
* 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.
|
||||
|
||||
391
node_modules/@types/node/diagnostics_channel.d.ts
generated
vendored
391
node_modules/@types/node/diagnostics_channel.d.ts
generated
vendored
@@ -20,9 +20,10 @@
|
||||
* should generally include the module name to avoid collisions with data from
|
||||
* other modules.
|
||||
* @since v15.1.0, v14.17.0
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/diagnostics_channel.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/diagnostics_channel.js)
|
||||
*/
|
||||
declare module "diagnostics_channel" {
|
||||
import { AsyncLocalStorage } from "node:async_hooks";
|
||||
/**
|
||||
* 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.
|
||||
@@ -95,6 +96,36 @@ declare module "diagnostics_channel" {
|
||||
* @return `true` if the handler was found, `false` otherwise.
|
||||
*/
|
||||
function unsubscribe(name: string | symbol, onMessage: ChannelListener): boolean;
|
||||
/**
|
||||
* Creates a `TracingChannel` wrapper for the given `TracingChannel Channels`. If a name is given, the corresponding tracing
|
||||
* channels will be created in the form of `tracing:${name}:${eventType}` where `eventType` corresponds to the types of `TracingChannel Channels`.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channelsByName = diagnostics_channel.tracingChannel('my-channel');
|
||||
*
|
||||
* // or...
|
||||
*
|
||||
* const channelsByCollection = diagnostics_channel.tracingChannel({
|
||||
* start: diagnostics_channel.channel('tracing:my-channel:start'),
|
||||
* end: diagnostics_channel.channel('tracing:my-channel:end'),
|
||||
* asyncStart: diagnostics_channel.channel('tracing:my-channel:asyncStart'),
|
||||
* asyncEnd: diagnostics_channel.channel('tracing:my-channel:asyncEnd'),
|
||||
* error: diagnostics_channel.channel('tracing:my-channel:error'),
|
||||
* });
|
||||
* ```
|
||||
* @since v19.9.0
|
||||
* @experimental
|
||||
* @param nameOrChannels Channel name or object containing all the `TracingChannel Channels`
|
||||
* @return Collection of channels to trace with
|
||||
*/
|
||||
function tracingChannel<
|
||||
StoreType = unknown,
|
||||
ContextType extends object = StoreType extends object ? StoreType : object,
|
||||
>(
|
||||
nameOrChannels: string | TracingChannelCollection<StoreType, ContextType>,
|
||||
): TracingChannel<StoreType, ContextType>;
|
||||
/**
|
||||
* The class `Channel` represents an individual named channel within the data
|
||||
* pipeline. It is used to track subscribers and to publish messages when there
|
||||
@@ -104,7 +135,7 @@ declare module "diagnostics_channel" {
|
||||
* with `new Channel(name)` is not supported.
|
||||
* @since v15.1.0, v14.17.0
|
||||
*/
|
||||
class Channel {
|
||||
class Channel<StoreType = unknown, ContextType = StoreType> {
|
||||
readonly name: string | symbol;
|
||||
/**
|
||||
* Check if there are active subscribers to this channel. This is helpful if
|
||||
@@ -184,6 +215,362 @@ declare module "diagnostics_channel" {
|
||||
* @return `true` if the handler was found, `false` otherwise.
|
||||
*/
|
||||
unsubscribe(onMessage: ChannelListener): void;
|
||||
/**
|
||||
* When `channel.runStores(context, ...)` is called, the given context data
|
||||
* will be applied to any store bound to the channel. If the store has already been
|
||||
* bound the previous `transform` function will be replaced with the new one.
|
||||
* The `transform` function may be omitted to set the given context data as the
|
||||
* context directly.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
* import { AsyncLocalStorage } from 'node:async_hooks';
|
||||
*
|
||||
* const store = new AsyncLocalStorage();
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
*
|
||||
* channel.bindStore(store, (data) => {
|
||||
* return { data };
|
||||
* });
|
||||
* ```
|
||||
* @since v19.9.0
|
||||
* @experimental
|
||||
* @param store The store to which to bind the context data
|
||||
* @param transform Transform context data before setting the store context
|
||||
*/
|
||||
bindStore(store: AsyncLocalStorage<StoreType>, transform?: (context: ContextType) => StoreType): void;
|
||||
/**
|
||||
* Remove a message handler previously registered to this channel with `channel.bindStore(store)`.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
* import { AsyncLocalStorage } from 'node:async_hooks';
|
||||
*
|
||||
* const store = new AsyncLocalStorage();
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
*
|
||||
* channel.bindStore(store);
|
||||
* channel.unbindStore(store);
|
||||
* ```
|
||||
* @since v19.9.0
|
||||
* @experimental
|
||||
* @param store The store to unbind from the channel.
|
||||
* @return `true` if the store was found, `false` otherwise.
|
||||
*/
|
||||
unbindStore(store: AsyncLocalStorage<StoreType>): boolean;
|
||||
/**
|
||||
* Applies the given data to any AsyncLocalStorage instances bound to the channel
|
||||
* for the duration of the given function, then publishes to the channel within
|
||||
* the scope of that data is applied to the stores.
|
||||
*
|
||||
* If a transform function was given to `channel.bindStore(store)` it will be
|
||||
* applied to transform the message data before it becomes the context value for
|
||||
* the store. The prior storage context is accessible from within the transform
|
||||
* function in cases where context linking is required.
|
||||
*
|
||||
* The context applied to the store should be accessible in any async code which
|
||||
* continues from execution which began during the given function, however
|
||||
* there are some situations in which `context loss` may occur.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
* import { AsyncLocalStorage } from 'node:async_hooks';
|
||||
*
|
||||
* const store = new AsyncLocalStorage();
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
*
|
||||
* channel.bindStore(store, (message) => {
|
||||
* const parent = store.getStore();
|
||||
* return new Span(message, parent);
|
||||
* });
|
||||
* channel.runStores({ some: 'message' }, () => {
|
||||
* store.getStore(); // Span({ some: 'message' })
|
||||
* });
|
||||
* ```
|
||||
* @since v19.9.0
|
||||
* @experimental
|
||||
* @param context Message to send to subscribers and bind to stores
|
||||
* @param fn Handler to run within the entered storage context
|
||||
* @param thisArg The receiver to be used for the function call.
|
||||
* @param args Optional arguments to pass to the function.
|
||||
*/
|
||||
runStores<ThisArg = any, Args extends any[] = any[], Result = any>(
|
||||
context: ContextType,
|
||||
fn: (this: ThisArg, ...args: Args) => Result,
|
||||
thisArg?: ThisArg,
|
||||
...args: Args
|
||||
): Result;
|
||||
}
|
||||
interface TracingChannelSubscribers<ContextType extends object> {
|
||||
start: (message: ContextType) => void;
|
||||
end: (
|
||||
message: ContextType & {
|
||||
error?: unknown;
|
||||
result?: unknown;
|
||||
},
|
||||
) => void;
|
||||
asyncStart: (
|
||||
message: ContextType & {
|
||||
error?: unknown;
|
||||
result?: unknown;
|
||||
},
|
||||
) => void;
|
||||
asyncEnd: (
|
||||
message: ContextType & {
|
||||
error?: unknown;
|
||||
result?: unknown;
|
||||
},
|
||||
) => void;
|
||||
error: (
|
||||
message: ContextType & {
|
||||
error: unknown;
|
||||
},
|
||||
) => void;
|
||||
}
|
||||
interface TracingChannelCollection<StoreType = unknown, ContextType = StoreType> {
|
||||
start: Channel<StoreType, ContextType>;
|
||||
end: Channel<StoreType, ContextType>;
|
||||
asyncStart: Channel<StoreType, ContextType>;
|
||||
asyncEnd: Channel<StoreType, ContextType>;
|
||||
error: Channel<StoreType, ContextType>;
|
||||
}
|
||||
/**
|
||||
* The class `TracingChannel` is a collection of `TracingChannel Channels` which
|
||||
* together express a single traceable action. It is used to formalize and
|
||||
* simplify the process of producing events for tracing application flow. {@link tracingChannel} is used to construct a `TracingChannel`. As with `Channel` it is recommended to create and reuse a
|
||||
* single `TracingChannel` at the top-level of the file rather than creating them
|
||||
* dynamically.
|
||||
* @since v19.9.0
|
||||
* @experimental
|
||||
*/
|
||||
class TracingChannel<StoreType = unknown, ContextType extends object = {}> implements TracingChannelCollection {
|
||||
start: Channel<StoreType, ContextType>;
|
||||
end: Channel<StoreType, ContextType>;
|
||||
asyncStart: Channel<StoreType, ContextType>;
|
||||
asyncEnd: Channel<StoreType, ContextType>;
|
||||
error: Channel<StoreType, ContextType>;
|
||||
/**
|
||||
* Helper to subscribe a collection of functions to the corresponding channels.
|
||||
* This is the same as calling `channel.subscribe(onMessage)` on each channel
|
||||
* individually.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channels = diagnostics_channel.tracingChannel('my-channel');
|
||||
*
|
||||
* channels.subscribe({
|
||||
* start(message) {
|
||||
* // Handle start message
|
||||
* },
|
||||
* end(message) {
|
||||
* // Handle end message
|
||||
* },
|
||||
* asyncStart(message) {
|
||||
* // Handle asyncStart message
|
||||
* },
|
||||
* asyncEnd(message) {
|
||||
* // Handle asyncEnd message
|
||||
* },
|
||||
* error(message) {
|
||||
* // Handle error message
|
||||
* },
|
||||
* });
|
||||
* ```
|
||||
* @since v19.9.0
|
||||
* @experimental
|
||||
* @param subscribers Set of `TracingChannel Channels` subscribers
|
||||
*/
|
||||
subscribe(subscribers: TracingChannelSubscribers<ContextType>): void;
|
||||
/**
|
||||
* Helper to unsubscribe a collection of functions from the corresponding channels.
|
||||
* This is the same as calling `channel.unsubscribe(onMessage)` on each channel
|
||||
* individually.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channels = diagnostics_channel.tracingChannel('my-channel');
|
||||
*
|
||||
* channels.unsubscribe({
|
||||
* start(message) {
|
||||
* // Handle start message
|
||||
* },
|
||||
* end(message) {
|
||||
* // Handle end message
|
||||
* },
|
||||
* asyncStart(message) {
|
||||
* // Handle asyncStart message
|
||||
* },
|
||||
* asyncEnd(message) {
|
||||
* // Handle asyncEnd message
|
||||
* },
|
||||
* error(message) {
|
||||
* // Handle error message
|
||||
* },
|
||||
* });
|
||||
* ```
|
||||
* @since v19.9.0
|
||||
* @experimental
|
||||
* @param subscribers Set of `TracingChannel Channels` subscribers
|
||||
* @return `true` if all handlers were successfully unsubscribed, and `false` otherwise.
|
||||
*/
|
||||
unsubscribe(subscribers: TracingChannelSubscribers<ContextType>): void;
|
||||
/**
|
||||
* Trace a synchronous function call. This will always produce a `start event` and `end event` around the execution and may produce an `error event` if the given function throws an error.
|
||||
* This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all
|
||||
* events should have any bound stores set to match this trace context.
|
||||
*
|
||||
* To ensure only correct trace graphs are formed, events will only be published if subscribers are present prior to starting the trace. Subscriptions
|
||||
* which are added after the trace begins will not receive future events from that trace, only future traces will be seen.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channels = diagnostics_channel.tracingChannel('my-channel');
|
||||
*
|
||||
* channels.traceSync(() => {
|
||||
* // Do something
|
||||
* }, {
|
||||
* some: 'thing',
|
||||
* });
|
||||
* ```
|
||||
* @since v19.9.0
|
||||
* @experimental
|
||||
* @param fn Function to wrap a trace around
|
||||
* @param context Shared object to correlate events through
|
||||
* @param thisArg The receiver to be used for the function call
|
||||
* @param args Optional arguments to pass to the function
|
||||
* @return The return value of the given function
|
||||
*/
|
||||
traceSync<ThisArg = any, Args extends any[] = any[], Result = any>(
|
||||
fn: (this: ThisArg, ...args: Args) => Result,
|
||||
context?: ContextType,
|
||||
thisArg?: ThisArg,
|
||||
...args: Args
|
||||
): Result;
|
||||
/**
|
||||
* Trace a promise-returning function call. This will always produce a `start event` and `end event` around the synchronous portion of the
|
||||
* function execution, and will produce an `asyncStart event` and `asyncEnd event` when a promise continuation is reached. It may also
|
||||
* produce an `error event` if the given function throws an error or the
|
||||
* returned promise rejects. This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all
|
||||
* events should have any bound stores set to match this trace context.
|
||||
*
|
||||
* To ensure only correct trace graphs are formed, events will only be published if subscribers are present prior to starting the trace. Subscriptions
|
||||
* which are added after the trace begins will not receive future events from that trace, only future traces will be seen.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channels = diagnostics_channel.tracingChannel('my-channel');
|
||||
*
|
||||
* channels.tracePromise(async () => {
|
||||
* // Do something
|
||||
* }, {
|
||||
* some: 'thing',
|
||||
* });
|
||||
* ```
|
||||
* @since v19.9.0
|
||||
* @experimental
|
||||
* @param fn Promise-returning function to wrap a trace around
|
||||
* @param context Shared object to correlate trace events through
|
||||
* @param thisArg The receiver to be used for the function call
|
||||
* @param args Optional arguments to pass to the function
|
||||
* @return Chained from promise returned by the given function
|
||||
*/
|
||||
tracePromise<ThisArg = any, Args extends any[] = any[], Result = any>(
|
||||
fn: (this: ThisArg, ...args: Args) => Promise<Result>,
|
||||
context?: ContextType,
|
||||
thisArg?: ThisArg,
|
||||
...args: Args
|
||||
): Promise<Result>;
|
||||
/**
|
||||
* Trace a callback-receiving function call. This will always produce a `start event` and `end event` around the synchronous portion of the
|
||||
* function execution, and will produce a `asyncStart event` and `asyncEnd event` around the callback execution. It may also produce an `error event` if the given function throws an error or
|
||||
* the returned
|
||||
* promise rejects. This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all
|
||||
* events should have any bound stores set to match this trace context.
|
||||
*
|
||||
* The `position` will be -1 by default to indicate the final argument should
|
||||
* be used as the callback.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channels = diagnostics_channel.tracingChannel('my-channel');
|
||||
*
|
||||
* channels.traceCallback((arg1, callback) => {
|
||||
* // Do something
|
||||
* callback(null, 'result');
|
||||
* }, 1, {
|
||||
* some: 'thing',
|
||||
* }, thisArg, arg1, callback);
|
||||
* ```
|
||||
*
|
||||
* The callback will also be run with `channel.runStores(context, ...)` which
|
||||
* enables context loss recovery in some cases.
|
||||
*
|
||||
* To ensure only correct trace graphs are formed, events will only be published if subscribers are present prior to starting the trace. Subscriptions
|
||||
* which are added after the trace begins will not receive future events from that trace, only future traces will be seen.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
* import { AsyncLocalStorage } from 'node:async_hooks';
|
||||
*
|
||||
* const channels = diagnostics_channel.tracingChannel('my-channel');
|
||||
* const myStore = new AsyncLocalStorage();
|
||||
*
|
||||
* // The start channel sets the initial store data to something
|
||||
* // and stores that store data value on the trace context object
|
||||
* channels.start.bindStore(myStore, (data) => {
|
||||
* const span = new Span(data);
|
||||
* data.span = span;
|
||||
* return span;
|
||||
* });
|
||||
*
|
||||
* // Then asyncStart can restore from that data it stored previously
|
||||
* channels.asyncStart.bindStore(myStore, (data) => {
|
||||
* return data.span;
|
||||
* });
|
||||
* ```
|
||||
* @since v19.9.0
|
||||
* @experimental
|
||||
* @param fn callback using function to wrap a trace around
|
||||
* @param position Zero-indexed argument position of expected callback
|
||||
* @param context Shared object to correlate trace events through
|
||||
* @param thisArg The receiver to be used for the function call
|
||||
* @param args Optional arguments to pass to the function
|
||||
* @return The return value of the given function
|
||||
*/
|
||||
traceCallback<ThisArg = any, Args extends any[] = any[], Result = any>(
|
||||
fn: (this: ThisArg, ...args: Args) => Result,
|
||||
position?: number,
|
||||
context?: ContextType,
|
||||
thisArg?: ThisArg,
|
||||
...args: Args
|
||||
): Result;
|
||||
/**
|
||||
* `true` if any of the individual channels has a subscriber, `false` if not.
|
||||
*
|
||||
* This is a helper method available on a {@link TracingChannel} instance to check
|
||||
* if any of the [TracingChannel Channels](https://nodejs.org/api/diagnostics_channel.html#tracingchannel-channels) have subscribers.
|
||||
* A `true` is returned if any of them have at least one subscriber, a `false` is returned otherwise.
|
||||
*
|
||||
* ```js
|
||||
* const diagnostics_channel = require('node:diagnostics_channel');
|
||||
*
|
||||
* const channels = diagnostics_channel.tracingChannel('my-channel');
|
||||
*
|
||||
* if (channels.hasSubscribers) {
|
||||
* // Do something
|
||||
* }
|
||||
* ```
|
||||
* @since v22.0.0, v20.13.0
|
||||
*/
|
||||
readonly hasSubscribers: boolean;
|
||||
}
|
||||
}
|
||||
declare module "node:diagnostics_channel" {
|
||||
|
||||
252
node_modules/@types/node/dns.d.ts
generated
vendored
252
node_modules/@types/node/dns.d.ts
generated
vendored
@@ -9,7 +9,7 @@
|
||||
* system do, use {@link lookup}.
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('node:dns');
|
||||
* import dns from 'node:dns';
|
||||
*
|
||||
* dns.lookup('example.org', (err, address, family) => {
|
||||
* console.log('address: %j family: IPv%s', address, family);
|
||||
@@ -23,7 +23,7 @@
|
||||
* DNS queries, bypassing other name-resolution facilities.
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('node:dns');
|
||||
* import dns from 'node:dns';
|
||||
*
|
||||
* dns.resolve4('archive.org', (err, addresses) => {
|
||||
* if (err) throw err;
|
||||
@@ -41,13 +41,21 @@
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* See the `Implementation considerations section` for more information.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dns.js)
|
||||
* See the [Implementation considerations section](https://nodejs.org/docs/latest-v20.x/api/dns.html#implementation-considerations) for more information.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/dns.js)
|
||||
*/
|
||||
declare module "dns" {
|
||||
import * as dnsPromises from "node:dns/promises";
|
||||
// Supported getaddrinfo flags.
|
||||
/**
|
||||
* Limits returned address types to the types of non-loopback addresses configured on the system. For example, IPv4 addresses are
|
||||
* only returned if the current system has at least one IPv4 address configured.
|
||||
*/
|
||||
export const ADDRCONFIG: number;
|
||||
/**
|
||||
* If the IPv6 family was specified, but no IPv6 addresses were found, then return IPv4 mapped IPv6 addresses. It is not supported
|
||||
* on some operating systems (e.g. FreeBSD 10.1).
|
||||
*/
|
||||
export const V4MAPPED: number;
|
||||
/**
|
||||
* If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
|
||||
@@ -55,11 +63,37 @@ declare module "dns" {
|
||||
*/
|
||||
export const ALL: number;
|
||||
export interface LookupOptions {
|
||||
family?: number | undefined;
|
||||
/**
|
||||
* The record family. Must be `4`, `6`, or `0`. For backward compatibility reasons, `'IPv4'` and `'IPv6'` are interpreted
|
||||
* as `4` and `6` respectively. The value 0 indicates that either an IPv4 or IPv6 address is returned. If the value `0` is used
|
||||
* with `{ all: true } (see below)`, both IPv4 and IPv6 addresses are returned.
|
||||
* @default 0
|
||||
*/
|
||||
family?: number | "IPv4" | "IPv6" | undefined;
|
||||
/**
|
||||
* One or more [supported `getaddrinfo`](https://nodejs.org/docs/latest-v20.x/api/dns.html#supported-getaddrinfo-flags) flags. Multiple flags may be
|
||||
* passed by bitwise `OR`ing their values.
|
||||
*/
|
||||
hints?: number | undefined;
|
||||
/**
|
||||
* When `true`, the callback returns all resolved addresses in an array. Otherwise, returns a single address.
|
||||
* @default false
|
||||
*/
|
||||
all?: boolean | undefined;
|
||||
/**
|
||||
* @default true
|
||||
* When `verbatim`, the resolved addresses are return unsorted. When `ipv4first`, the resolved addresses are sorted
|
||||
* by placing IPv4 addresses before IPv6 addresses. When `ipv6first`, the resolved addresses are sorted by placing IPv6
|
||||
* addresses before IPv4 addresses. Default value is configurable using
|
||||
* {@link setDefaultResultOrder} or [`--dns-result-order`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--dns-result-orderorder).
|
||||
* @default `verbatim` (addresses are not reordered)
|
||||
*/
|
||||
order?: "ipv4first" | "ipv6first" | "verbatim" | undefined;
|
||||
/**
|
||||
* When `true`, the callback receives IPv4 and IPv6 addresses in the order the DNS resolver returned them. When `false`, IPv4
|
||||
* addresses are placed before IPv6 addresses. This option will be deprecated in favor of `order`. When both are specified,
|
||||
* `order` has higher precedence. New code should only use `order`. Default value is configurable using {@link setDefaultResultOrder}
|
||||
* or [`--dns-result-order`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--dns-result-orderorder).
|
||||
* @default true (addresses are not reordered)
|
||||
*/
|
||||
verbatim?: boolean | undefined;
|
||||
}
|
||||
@@ -70,7 +104,14 @@ declare module "dns" {
|
||||
all: true;
|
||||
}
|
||||
export interface LookupAddress {
|
||||
/**
|
||||
* A string representation of an IPv4 or IPv6 address.
|
||||
*/
|
||||
address: string;
|
||||
/**
|
||||
* `4` or `6`, denoting the family of `address`, or `0` if the address is not an IPv4 or IPv6 address. `0` is a likely indicator of a
|
||||
* bug in the name resolution service used by the operating system.
|
||||
*/
|
||||
family: number;
|
||||
}
|
||||
/**
|
||||
@@ -79,7 +120,7 @@ declare module "dns" {
|
||||
* integer, then it must be `4` or `6` – if `options` is `0` or not provided, then
|
||||
* IPv4 and IPv6 addresses are both returned if found.
|
||||
*
|
||||
* With the `all` option set to `true`, the arguments for `callback` change to`(err, addresses)`, with `addresses` being an array of objects with the
|
||||
* With the `all` option set to `true`, the arguments for `callback` change to `(err, addresses)`, with `addresses` being an array of objects with the
|
||||
* properties `address` and `family`.
|
||||
*
|
||||
* On error, `err` is an `Error` object, where `err.code` is the error code.
|
||||
@@ -91,12 +132,13 @@ declare module "dns" {
|
||||
* 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()`.
|
||||
* time to consult the [Implementation considerations section](https://nodejs.org/docs/latest-v20.x/api/dns.html#implementation-considerations)
|
||||
* before using `dns.lookup()`.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('node:dns');
|
||||
* import dns from 'node:dns';
|
||||
* const options = {
|
||||
* family: 6,
|
||||
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
||||
@@ -112,7 +154,8 @@ declare module "dns" {
|
||||
* // 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.
|
||||
* If this method is invoked as its [util.promisify()](https://nodejs.org/docs/latest-v20.x/api/util.html#utilpromisifyoriginal) 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(
|
||||
@@ -149,19 +192,21 @@ declare module "dns" {
|
||||
* 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.
|
||||
* 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.
|
||||
* On an error, `err` is an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object,
|
||||
* where `err.code` is the error code.
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('node:dns');
|
||||
* import dns from 'node: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.
|
||||
* If this method is invoked as its [util.promisify()](https://nodejs.org/docs/latest-v20.x/api/util.html#utilpromisifyoriginal) ed
|
||||
* version, it returns a `Promise` for an `Object` with `hostname` and `service` properties.
|
||||
* @since v0.11.14
|
||||
*/
|
||||
export function lookupService(
|
||||
@@ -204,6 +249,9 @@ declare module "dns" {
|
||||
contactemail?: string | undefined;
|
||||
contactphone?: string | undefined;
|
||||
}
|
||||
export interface AnyCaaRecord extends CaaRecord {
|
||||
type: "CAA";
|
||||
}
|
||||
export interface MxRecord {
|
||||
priority: number;
|
||||
exchange: string;
|
||||
@@ -262,6 +310,7 @@ declare module "dns" {
|
||||
export type AnyRecord =
|
||||
| AnyARecord
|
||||
| AnyAaaaRecord
|
||||
| AnyCaaRecord
|
||||
| AnyCnameRecord
|
||||
| AnyMxRecord
|
||||
| AnyNaptrRecord
|
||||
@@ -272,12 +321,13 @@ declare module "dns" {
|
||||
| AnyTxtRecord;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
|
||||
* of the resource records. The `callback` function has arguments`(err, records)`. When successful, `records` will be an array of resource
|
||||
* of the resource records. The `callback` function has arguments `(err, records)`. When successful, `records` will be an array of resource
|
||||
* records. The type and structure of individual results varies based on `rrtype`:
|
||||
*
|
||||
* <omitted>
|
||||
*
|
||||
* On error, `err` is an `Error` object, where `err.code` is one of the `DNS error codes`.
|
||||
* On error, `err` is an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object,
|
||||
* where `err.code` is one of the `DNS error codes`.
|
||||
* @since v0.1.27
|
||||
* @param hostname Host name to resolve.
|
||||
* @param [rrtype='A'] Resource record type.
|
||||
@@ -288,12 +338,7 @@ declare module "dns" {
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "A",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "AAAA",
|
||||
rrtype: "A" | "AAAA" | "CNAME" | "NS" | "PTR",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
@@ -303,8 +348,8 @@ declare module "dns" {
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "CNAME",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
rrtype: "CAA",
|
||||
callback: (err: NodeJS.ErrnoException | null, address: CaaRecord[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
@@ -316,16 +361,6 @@ declare module "dns" {
|
||||
rrtype: "NAPTR",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "NS",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "PTR",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "SOA",
|
||||
@@ -346,12 +381,21 @@ declare module "dns" {
|
||||
rrtype: string,
|
||||
callback: (
|
||||
err: NodeJS.ErrnoException | null,
|
||||
addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[],
|
||||
addresses:
|
||||
| string[]
|
||||
| CaaRecord[]
|
||||
| MxRecord[]
|
||||
| NaptrRecord[]
|
||||
| SoaRecord
|
||||
| SrvRecord[]
|
||||
| string[][]
|
||||
| AnyRecord[],
|
||||
) => void,
|
||||
): void;
|
||||
export namespace resolve {
|
||||
function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
|
||||
function __promisify__(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
||||
@@ -360,10 +404,19 @@ declare module "dns" {
|
||||
function __promisify__(
|
||||
hostname: string,
|
||||
rrtype: string,
|
||||
): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
||||
): Promise<
|
||||
| string[]
|
||||
| CaaRecord[]
|
||||
| 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
|
||||
* Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the `hostname`. The `addresses` argument passed to the `callback` function
|
||||
* will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
||||
* @since v0.1.16
|
||||
* @param hostname Host name to resolve.
|
||||
@@ -388,7 +441,7 @@ declare module "dns" {
|
||||
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
||||
* Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the `hostname`. The `addresses` argument passed to the `callback` function
|
||||
* will contain an array of IPv6 addresses.
|
||||
* @since v0.1.16
|
||||
* @param hostname Host name to resolve.
|
||||
@@ -413,8 +466,8 @@ declare module "dns" {
|
||||
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
|
||||
* will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`).
|
||||
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The `addresses` argument passed to the `callback` function
|
||||
* will contain an array of canonical name records available for the `hostname` (e.g. `['bar.example.com']`).
|
||||
* @since v0.3.2
|
||||
*/
|
||||
export function resolveCname(
|
||||
@@ -425,7 +478,7 @@ declare module "dns" {
|
||||
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
|
||||
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. The `addresses` argument passed to the `callback` function
|
||||
* will contain an array of certification authority authorization records
|
||||
* available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`).
|
||||
* @since v15.0.0, v14.17.0
|
||||
@@ -438,8 +491,8 @@ declare module "dns" {
|
||||
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'}, ...]`).
|
||||
* 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(
|
||||
@@ -450,7 +503,7 @@ declare module "dns" {
|
||||
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
|
||||
* Uses the DNS protocol to resolve regular expression-based records (`NAPTR` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of
|
||||
* objects with the following properties:
|
||||
*
|
||||
* * `flags`
|
||||
@@ -480,8 +533,8 @@ declare module "dns" {
|
||||
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
|
||||
* contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`).
|
||||
* Uses the DNS protocol to resolve name server records (`NS` records) for the `hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* contain an array of name server records available for `hostname` (e.g. `['ns1.example.com', 'ns2.example.com']`).
|
||||
* @since v0.1.90
|
||||
*/
|
||||
export function resolveNs(
|
||||
@@ -492,7 +545,7 @@ declare module "dns" {
|
||||
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
|
||||
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the `hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* be an array of strings containing the reply records.
|
||||
* @since v6.0.0
|
||||
*/
|
||||
@@ -537,7 +590,7 @@ declare module "dns" {
|
||||
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
|
||||
* Uses the DNS protocol to resolve service records (`SRV` records) for the `hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* be an array of objects with the following properties:
|
||||
*
|
||||
* * `priority`
|
||||
@@ -563,7 +616,7 @@ declare module "dns" {
|
||||
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
|
||||
* Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. The `records` argument passed to the `callback` function is a
|
||||
* two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
||||
* one record. Depending on the use case, these could be either joined together or
|
||||
* treated separately.
|
||||
@@ -603,8 +656,8 @@ declare module "dns" {
|
||||
* 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).
|
||||
* 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,
|
||||
@@ -617,8 +670,8 @@ declare module "dns" {
|
||||
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
||||
* array of host names.
|
||||
*
|
||||
* On error, `err` is an `Error` object, where `err.code` is
|
||||
* one of the `DNS error codes`.
|
||||
* On error, `err` is an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code` is
|
||||
* one of the [DNS error codes](https://nodejs.org/docs/latest-v20.x/api/dns.html#error-codes).
|
||||
* @since v0.1.16
|
||||
*/
|
||||
export function reverse(
|
||||
@@ -626,13 +679,15 @@ declare module "dns" {
|
||||
callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void,
|
||||
): void;
|
||||
/**
|
||||
* Get the default value for `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be:
|
||||
* Get the default value for `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromiseslookuphostname-options).
|
||||
* The value could be:
|
||||
*
|
||||
* * `ipv4first`: for `verbatim` defaulting to `false`.
|
||||
* * `verbatim`: for `verbatim` defaulting to `true`.
|
||||
* @since v20.1.0
|
||||
* * `ipv4first`: for `order` defaulting to `ipv4first`.
|
||||
* * `ipv6first`: for `order` defaulting to `ipv6first`.
|
||||
* * `verbatim`: for `order` defaulting to `verbatim`.
|
||||
* @since v18.17.0
|
||||
*/
|
||||
export function getDefaultResultOrder(): "ipv4first" | "verbatim";
|
||||
export function getDefaultResultOrder(): "ipv4first" | "ipv6first" | "verbatim";
|
||||
/**
|
||||
* 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
|
||||
@@ -652,16 +707,16 @@ declare module "dns" {
|
||||
* 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}).
|
||||
* 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
|
||||
* 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
|
||||
* @param servers array of [RFC 5952](https://datatracker.ietf.org/doc/html/rfc5952#section-6) formatted addresses
|
||||
*/
|
||||
export function setServers(servers: ReadonlyArray<string>): void;
|
||||
export function setServers(servers: readonly 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
|
||||
@@ -679,46 +734,53 @@ declare module "dns" {
|
||||
*/
|
||||
export function getServers(): string[];
|
||||
/**
|
||||
* Set the default value of `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be:
|
||||
* Set the default value of `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromiseslookuphostname-options).
|
||||
* The value could be:
|
||||
*
|
||||
* * `ipv4first`: sets default `verbatim` `false`.
|
||||
* * `verbatim`: sets default `verbatim` `true`.
|
||||
* * `ipv4first`: sets default `order` to `ipv4first`.
|
||||
* * `ipv6first`: sets default `order` to `ipv6first`.
|
||||
* * `verbatim`: sets default `order` to `verbatim`.
|
||||
*
|
||||
* The default is `verbatim` and {@link setDefaultResultOrder} have higher
|
||||
* priority than `--dns-result-order`. When using `worker threads`,{@link setDefaultResultOrder} from the main thread won't affect the default
|
||||
* dns orders in workers.
|
||||
* priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--dns-result-orderorder). When using
|
||||
* [worker threads](https://nodejs.org/docs/latest-v20.x/api/worker_threads.html), {@link setDefaultResultOrder} from the main
|
||||
* thread won't affect the default dns orders in workers.
|
||||
* @since v16.4.0, v14.18.0
|
||||
* @param order must be `'ipv4first'` or `'verbatim'`.
|
||||
* @param order must be `'ipv4first'`, `'ipv6first'` or `'verbatim'`.
|
||||
*/
|
||||
export function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
|
||||
export function setDefaultResultOrder(order: "ipv4first" | "ipv6first" | "verbatim"): void;
|
||||
// Error codes
|
||||
export const NODATA: string;
|
||||
export const FORMERR: string;
|
||||
export const SERVFAIL: string;
|
||||
export const NOTFOUND: string;
|
||||
export const NOTIMP: string;
|
||||
export const REFUSED: string;
|
||||
export const BADQUERY: string;
|
||||
export const BADNAME: string;
|
||||
export const BADFAMILY: string;
|
||||
export const BADRESP: string;
|
||||
export const CONNREFUSED: string;
|
||||
export const TIMEOUT: string;
|
||||
export const EOF: string;
|
||||
export const FILE: string;
|
||||
export const NOMEM: string;
|
||||
export const DESTRUCTION: string;
|
||||
export const BADSTR: string;
|
||||
export const BADFLAGS: string;
|
||||
export const NONAME: string;
|
||||
export const BADHINTS: string;
|
||||
export const NOTINITIALIZED: string;
|
||||
export const LOADIPHLPAPI: string;
|
||||
export const ADDRGETNETWORKPARAMS: string;
|
||||
export const CANCELLED: string;
|
||||
export const NODATA: "ENODATA";
|
||||
export const FORMERR: "EFORMERR";
|
||||
export const SERVFAIL: "ESERVFAIL";
|
||||
export const NOTFOUND: "ENOTFOUND";
|
||||
export const NOTIMP: "ENOTIMP";
|
||||
export const REFUSED: "EREFUSED";
|
||||
export const BADQUERY: "EBADQUERY";
|
||||
export const BADNAME: "EBADNAME";
|
||||
export const BADFAMILY: "EBADFAMILY";
|
||||
export const BADRESP: "EBADRESP";
|
||||
export const CONNREFUSED: "ECONNREFUSED";
|
||||
export const TIMEOUT: "ETIMEOUT";
|
||||
export const EOF: "EOF";
|
||||
export const FILE: "EFILE";
|
||||
export const NOMEM: "ENOMEM";
|
||||
export const DESTRUCTION: "EDESTRUCTION";
|
||||
export const BADSTR: "EBADSTR";
|
||||
export const BADFLAGS: "EBADFLAGS";
|
||||
export const NONAME: "ENONAME";
|
||||
export const BADHINTS: "EBADHINTS";
|
||||
export const NOTINITIALIZED: "ENOTINITIALIZED";
|
||||
export const LOADIPHLPAPI: "ELOADIPHLPAPI";
|
||||
export const ADDRGETNETWORKPARAMS: "EADDRGETNETWORKPARAMS";
|
||||
export const CANCELLED: "ECANCELLED";
|
||||
export interface ResolverOptions {
|
||||
/**
|
||||
* Query timeout in milliseconds, or `-1` to use the default timeout.
|
||||
*/
|
||||
timeout?: number | undefined;
|
||||
/**
|
||||
* The number of tries the resolver will try contacting each name server before giving up.
|
||||
* @default 4
|
||||
*/
|
||||
tries?: number;
|
||||
@@ -727,11 +789,11 @@ declare module "dns" {
|
||||
* An independent resolver for DNS requests.
|
||||
*
|
||||
* Creating a new resolver uses the default server settings. Setting
|
||||
* the servers used for a resolver using `resolver.setServers()` does not affect
|
||||
* the servers used for a resolver using [`resolver.setServers()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnssetserversservers) does not affect
|
||||
* other resolvers:
|
||||
*
|
||||
* ```js
|
||||
* const { Resolver } = require('node:dns');
|
||||
* import { Resolver } from 'node:dns';
|
||||
* const resolver = new Resolver();
|
||||
* resolver.setServers(['4.4.4.4']);
|
||||
*
|
||||
|
||||
146
node_modules/@types/node/dns/promises.d.ts
generated
vendored
146
node_modules/@types/node/dns/promises.d.ts
generated
vendored
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* 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('node:dns').promises` or `require('node:dns/promises')`.
|
||||
* via `import { promises } from 'node:dns'` or `import dnsPromises from 'node:dns/promises'`.
|
||||
* @since v10.6.0
|
||||
*/
|
||||
declare module "dns/promises" {
|
||||
@@ -43,24 +43,24 @@ declare module "dns/promises" {
|
||||
* 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`.
|
||||
* 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.
|
||||
* On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-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
|
||||
* [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromiseslookuphostname-options) 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
|
||||
* take some time to consult the [Implementation considerations section](https://nodejs.org/docs/latest-v20.x/api/dns.html#implementation-considerations) before
|
||||
* using `dnsPromises.lookup()`.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('node:dns');
|
||||
* import dns from 'node:dns';
|
||||
* const dnsPromises = dns.promises;
|
||||
* const options = {
|
||||
* family: 6,
|
||||
@@ -91,13 +91,13 @@ declare module "dns/promises" {
|
||||
* 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.
|
||||
* 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.
|
||||
* On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code` is the error code.
|
||||
*
|
||||
* ```js
|
||||
* const dnsPromises = require('node:dns').promises;
|
||||
* dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
|
||||
* import dns from 'node:dns';
|
||||
* dns.promises.lookupService('127.0.0.1', 22).then((result) => {
|
||||
* console.log(result.hostname, result.service);
|
||||
* // Prints: localhost ssh
|
||||
* });
|
||||
@@ -119,30 +119,33 @@ declare module "dns/promises" {
|
||||
*
|
||||
* <omitted>
|
||||
*
|
||||
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`.
|
||||
* On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code`
|
||||
* is one of the [DNS error codes](https://nodejs.org/docs/latest-v20.x/api/dns.html#error-codes).
|
||||
* @since v10.6.0
|
||||
* @param hostname Host name to resolve.
|
||||
* @param [rrtype='A'] 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: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): 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[]>;
|
||||
function resolve(hostname: string, rrtype: string): Promise<
|
||||
| string[]
|
||||
| CaaRecord[]
|
||||
| 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
|
||||
* 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.
|
||||
@@ -151,7 +154,7 @@ declare module "dns/promises" {
|
||||
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
|
||||
* 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.
|
||||
@@ -191,7 +194,7 @@ declare module "dns/promises" {
|
||||
/**
|
||||
* 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'}]`).
|
||||
* 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, v14.17.0
|
||||
*/
|
||||
function resolveCaa(hostname: string): Promise<CaaRecord[]>;
|
||||
@@ -203,13 +206,13 @@ declare module "dns/promises" {
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
* 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`
|
||||
@@ -233,13 +236,13 @@ declare module "dns/promises" {
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
* 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
|
||||
*/
|
||||
@@ -272,7 +275,7 @@ declare module "dns/promises" {
|
||||
*/
|
||||
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
|
||||
* 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`
|
||||
@@ -292,7 +295,7 @@ declare module "dns/promises" {
|
||||
*/
|
||||
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
|
||||
* 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.
|
||||
@@ -303,10 +306,20 @@ declare module "dns/promises" {
|
||||
* 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`.
|
||||
* On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code`
|
||||
* is one of the [DNS error codes](https://nodejs.org/docs/latest-v20.x/api/dns.html#error-codes).
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function reverse(ip: string): Promise<string[]>;
|
||||
/**
|
||||
* Get the default value for `verbatim` in {@link lookup} and [dnsPromises.lookup()](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromiseslookuphostname-options).
|
||||
* The value could be:
|
||||
*
|
||||
* * `ipv4first`: for `verbatim` defaulting to `false`.
|
||||
* * `verbatim`: for `verbatim` defaulting to `true`.
|
||||
* @since v20.1.0
|
||||
*/
|
||||
function getDefaultResultOrder(): "ipv4first" | "verbatim";
|
||||
/**
|
||||
* 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
|
||||
@@ -327,35 +340,64 @@ declare module "dns/promises" {
|
||||
* 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
|
||||
* 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;
|
||||
function setServers(servers: readonly string[]): void;
|
||||
/**
|
||||
* Set the default value of `verbatim` in `dns.lookup()` and `dnsPromises.lookup()`. The value could be:
|
||||
* Set the default value of `order` in `dns.lookup()` and `{@link lookup}`. The value could be:
|
||||
*
|
||||
* * `ipv4first`: sets default `verbatim` `false`.
|
||||
* * `verbatim`: sets default `verbatim` `true`.
|
||||
* * `ipv4first`: sets default `order` to `ipv4first`.
|
||||
* * `ipv6first`: sets default `order` to `ipv6first`.
|
||||
* * `verbatim`: sets default `order` to `verbatim`.
|
||||
*
|
||||
* The default is `verbatim` and `dnsPromises.setDefaultResultOrder()` have
|
||||
* higher priority than `--dns-result-order`. When using `worker threads`,`dnsPromises.setDefaultResultOrder()` from the main thread won't affect the
|
||||
* default dns orders in workers.
|
||||
* The default is `verbatim` and [dnsPromises.setDefaultResultOrder()](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetdefaultresultorderorder)
|
||||
* have higher priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--dns-result-orderorder).
|
||||
* When using [worker threads](https://nodejs.org/docs/latest-v20.x/api/worker_threads.html), [`dnsPromises.setDefaultResultOrder()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetdefaultresultorderorder)
|
||||
* from the main thread won't affect the default dns orders in workers.
|
||||
* @since v16.4.0, v14.18.0
|
||||
* @param order must be `'ipv4first'` or `'verbatim'`.
|
||||
* @param order must be `'ipv4first'`, `'ipv6first'` or `'verbatim'`.
|
||||
*/
|
||||
function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
|
||||
function setDefaultResultOrder(order: "ipv4first" | "ipv6first" | "verbatim"): void;
|
||||
// Error codes
|
||||
const NODATA: "ENODATA";
|
||||
const FORMERR: "EFORMERR";
|
||||
const SERVFAIL: "ESERVFAIL";
|
||||
const NOTFOUND: "ENOTFOUND";
|
||||
const NOTIMP: "ENOTIMP";
|
||||
const REFUSED: "EREFUSED";
|
||||
const BADQUERY: "EBADQUERY";
|
||||
const BADNAME: "EBADNAME";
|
||||
const BADFAMILY: "EBADFAMILY";
|
||||
const BADRESP: "EBADRESP";
|
||||
const CONNREFUSED: "ECONNREFUSED";
|
||||
const TIMEOUT: "ETIMEOUT";
|
||||
const EOF: "EOF";
|
||||
const FILE: "EFILE";
|
||||
const NOMEM: "ENOMEM";
|
||||
const DESTRUCTION: "EDESTRUCTION";
|
||||
const BADSTR: "EBADSTR";
|
||||
const BADFLAGS: "EBADFLAGS";
|
||||
const NONAME: "ENONAME";
|
||||
const BADHINTS: "EBADHINTS";
|
||||
const NOTINITIALIZED: "ENOTINITIALIZED";
|
||||
const LOADIPHLPAPI: "ELOADIPHLPAPI";
|
||||
const ADDRGETNETWORKPARAMS: "EADDRGETNETWORKPARAMS";
|
||||
const CANCELLED: "ECANCELLED";
|
||||
|
||||
/**
|
||||
* An independent resolver for DNS requests.
|
||||
*
|
||||
* Creating a new resolver uses the default server settings. Setting
|
||||
* the servers used for a resolver using `resolver.setServers()` does not affect
|
||||
* the servers used for a resolver using [`resolver.setServers()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetserversservers) does not affect
|
||||
* other resolvers:
|
||||
*
|
||||
* ```js
|
||||
* const { Resolver } = require('node:dns').promises;
|
||||
* import dns from 'node:dns';
|
||||
* const { Resolver } = dns.promises;
|
||||
* const resolver = new Resolver();
|
||||
* resolver.setServers(['4.4.4.4']);
|
||||
*
|
||||
@@ -392,6 +434,11 @@ declare module "dns/promises" {
|
||||
*/
|
||||
class Resolver {
|
||||
constructor(options?: ResolverOptions);
|
||||
/**
|
||||
* Cancel all outstanding DNS queries made by this resolver. The corresponding
|
||||
* callbacks will be called with an error with code `ECANCELLED`.
|
||||
* @since v8.3.0
|
||||
*/
|
||||
cancel(): void;
|
||||
getServers: typeof getServers;
|
||||
resolve: typeof resolve;
|
||||
@@ -408,6 +455,21 @@ declare module "dns/promises" {
|
||||
resolveSrv: typeof resolveSrv;
|
||||
resolveTxt: typeof resolveTxt;
|
||||
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, v14.17.0
|
||||
* @param [ipv4='0.0.0.0'] A string representation of an IPv4 address.
|
||||
* @param [ipv6='::0'] A string representation of an IPv6 address.
|
||||
*/
|
||||
setLocalAddress(ipv4?: string, ipv6?: string): void;
|
||||
setServers: typeof setServers;
|
||||
}
|
||||
|
||||
145
node_modules/@types/node/dom-events.d.ts
generated
vendored
145
node_modules/@types/node/dom-events.d.ts
generated
vendored
@@ -1,77 +1,50 @@
|
||||
export {}; // Don't export anything!
|
||||
// Make this a module
|
||||
export {};
|
||||
|
||||
//// DOM-like Events
|
||||
// NB: The Event / EventTarget / EventListener implementations below were copied
|
||||
// from lib.dom.d.ts, then edited to reflect Node's documentation at
|
||||
// https://nodejs.org/api/events.html#class-eventtarget.
|
||||
// Please read that link to understand important implementation differences.
|
||||
// Conditional type aliases, which are later merged into the global scope.
|
||||
// Will either be empty if the relevant web library is already present, or the @types/node definition otherwise.
|
||||
|
||||
// This conditional type will be the existing global Event in a browser, or
|
||||
// the copy below in a Node environment.
|
||||
type __Event = typeof globalThis extends { onmessage: any; Event: any } ? {}
|
||||
: {
|
||||
/** This is not used in Node.js and is provided purely for completeness. */
|
||||
readonly bubbles: boolean;
|
||||
/** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */
|
||||
cancelBubble: () => void;
|
||||
/** True if the event was created with the cancelable option */
|
||||
readonly cancelable: boolean;
|
||||
/** This is not used in Node.js and is provided purely for completeness. */
|
||||
readonly composed: boolean;
|
||||
/** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */
|
||||
composedPath(): [EventTarget?];
|
||||
/** Alias for event.target. */
|
||||
readonly currentTarget: EventTarget | null;
|
||||
/** Is true if cancelable is true and event.preventDefault() has been called. */
|
||||
readonly defaultPrevented: boolean;
|
||||
/** This is not used in Node.js and is provided purely for completeness. */
|
||||
readonly eventPhase: 0 | 2;
|
||||
/** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */
|
||||
readonly isTrusted: boolean;
|
||||
/** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */
|
||||
preventDefault(): void;
|
||||
/** This is not used in Node.js and is provided purely for completeness. */
|
||||
returnValue: boolean;
|
||||
/** Alias for event.target. */
|
||||
readonly srcElement: EventTarget | null;
|
||||
/** Stops the invocation of event listeners after the current one completes. */
|
||||
stopImmediatePropagation(): void;
|
||||
/** This is not used in Node.js and is provided purely for completeness. */
|
||||
stopPropagation(): void;
|
||||
/** The `EventTarget` dispatching the event */
|
||||
readonly target: EventTarget | null;
|
||||
/** The millisecond timestamp when the Event object was created. */
|
||||
readonly timeStamp: number;
|
||||
/** Returns the type of event, e.g. "click", "hashchange", or "submit". */
|
||||
readonly type: string;
|
||||
};
|
||||
type __Event = typeof globalThis extends { onmessage: any } ? {} : Event;
|
||||
interface Event {
|
||||
readonly bubbles: boolean;
|
||||
cancelBubble: boolean;
|
||||
readonly cancelable: boolean;
|
||||
readonly composed: boolean;
|
||||
composedPath(): [EventTarget?];
|
||||
readonly currentTarget: EventTarget | null;
|
||||
readonly defaultPrevented: boolean;
|
||||
readonly eventPhase: 0 | 2;
|
||||
initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
|
||||
readonly isTrusted: boolean;
|
||||
preventDefault(): void;
|
||||
readonly returnValue: boolean;
|
||||
readonly srcElement: EventTarget | null;
|
||||
stopImmediatePropagation(): void;
|
||||
stopPropagation(): void;
|
||||
readonly target: EventTarget | null;
|
||||
readonly timeStamp: number;
|
||||
readonly type: string;
|
||||
}
|
||||
|
||||
// See comment above explaining conditional type
|
||||
type __EventTarget = typeof globalThis extends { onmessage: any; EventTarget: any } ? {}
|
||||
: {
|
||||
/**
|
||||
* Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value.
|
||||
*
|
||||
* If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched.
|
||||
*
|
||||
* The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification.
|
||||
* Specifically, the `capture` option is used as part of the key when registering a `listener`.
|
||||
* Any individual `listener` may be added once with `capture = false`, and once with `capture = true`.
|
||||
*/
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: EventListener | EventListenerObject,
|
||||
options?: AddEventListenerOptions | boolean,
|
||||
): void;
|
||||
/** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */
|
||||
dispatchEvent(event: Event): boolean;
|
||||
/** Removes the event listener in target's event listener list with the same type, callback, and options. */
|
||||
removeEventListener(
|
||||
type: string,
|
||||
listener: EventListener | EventListenerObject,
|
||||
options?: EventListenerOptions | boolean,
|
||||
): void;
|
||||
};
|
||||
type __CustomEvent<T = any> = typeof globalThis extends { onmessage: any } ? {} : CustomEvent<T>;
|
||||
interface CustomEvent<T = any> extends Event {
|
||||
readonly detail: T;
|
||||
}
|
||||
|
||||
type __EventTarget = typeof globalThis extends { onmessage: any } ? {} : EventTarget;
|
||||
interface EventTarget {
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: EventListener | EventListenerObject,
|
||||
options?: AddEventListenerOptions | boolean,
|
||||
): void;
|
||||
dispatchEvent(event: Event): boolean;
|
||||
removeEventListener(
|
||||
type: string,
|
||||
listener: EventListener | EventListenerObject,
|
||||
options?: EventListenerOptions | boolean,
|
||||
): void;
|
||||
}
|
||||
|
||||
interface EventInit {
|
||||
bubbles?: boolean;
|
||||
@@ -79,16 +52,18 @@ interface EventInit {
|
||||
composed?: boolean;
|
||||
}
|
||||
|
||||
interface CustomEventInit<T = any> extends EventInit {
|
||||
detail?: T;
|
||||
}
|
||||
|
||||
interface EventListenerOptions {
|
||||
/** Not directly used by Node.js. Added for API completeness. Default: `false`. */
|
||||
capture?: boolean;
|
||||
}
|
||||
|
||||
interface AddEventListenerOptions extends EventListenerOptions {
|
||||
/** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */
|
||||
once?: boolean;
|
||||
/** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */
|
||||
passive?: boolean;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
|
||||
interface EventListener {
|
||||
@@ -99,24 +74,26 @@ interface EventListenerObject {
|
||||
handleEvent(object: Event): void;
|
||||
}
|
||||
|
||||
import {} from "events"; // Make this an ambient declaration
|
||||
// Merge conditional interfaces into global scope, and conditionally declare global constructors.
|
||||
declare global {
|
||||
/** An event which takes place in the DOM. */
|
||||
interface Event extends __Event {}
|
||||
var Event: typeof globalThis extends { onmessage: any; Event: infer T } ? T
|
||||
: {
|
||||
prototype: __Event;
|
||||
new(type: string, eventInitDict?: EventInit): __Event;
|
||||
prototype: Event;
|
||||
new(type: string, eventInitDict?: EventInit): Event;
|
||||
};
|
||||
|
||||
interface CustomEvent<T = any> extends __CustomEvent<T> {}
|
||||
var CustomEvent: typeof globalThis extends { onmessage: any; CustomEvent: infer T } ? T
|
||||
: {
|
||||
prototype: CustomEvent;
|
||||
new<T>(type: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>;
|
||||
};
|
||||
|
||||
/**
|
||||
* EventTarget is a DOM interface implemented by objects that can
|
||||
* receive events and may have listeners for them.
|
||||
*/
|
||||
interface EventTarget extends __EventTarget {}
|
||||
var EventTarget: typeof globalThis extends { onmessage: any; EventTarget: infer T } ? T
|
||||
: {
|
||||
prototype: __EventTarget;
|
||||
new(): __EventTarget;
|
||||
prototype: EventTarget;
|
||||
new(): EventTarget;
|
||||
};
|
||||
}
|
||||
|
||||
12
node_modules/@types/node/domain.d.ts
generated
vendored
12
node_modules/@types/node/domain.d.ts
generated
vendored
@@ -9,10 +9,10 @@
|
||||
* 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
|
||||
* 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/v20.2.0/lib/domain.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/domain.js)
|
||||
*/
|
||||
declare module "domain" {
|
||||
import EventEmitter = require("node:events");
|
||||
@@ -29,7 +29,7 @@ declare module "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
|
||||
* 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
|
||||
@@ -47,7 +47,7 @@ declare module "domain" {
|
||||
* 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.
|
||||
* 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
|
||||
@@ -63,8 +63,8 @@ declare module "domain" {
|
||||
* This is the most basic way to use a domain.
|
||||
*
|
||||
* ```js
|
||||
* const domain = require('node:domain');
|
||||
* const fs = require('node:fs');
|
||||
* import domain from 'node:domain';
|
||||
* import fs from 'node:fs';
|
||||
* const d = domain.create();
|
||||
* d.on('error', (er) => {
|
||||
* console.error('Caught error!', er);
|
||||
|
||||
243
node_modules/@types/node/events.d.ts
generated
vendored
243
node_modules/@types/node/events.d.ts
generated
vendored
@@ -32,7 +32,7 @@
|
||||
* });
|
||||
* myEmitter.emit('event');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/events.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/events.js)
|
||||
*/
|
||||
declare module "events" {
|
||||
import { AsyncResource, AsyncResourceOptions } from "node:async_hooks";
|
||||
@@ -75,24 +75,48 @@ declare module "events" {
|
||||
*/
|
||||
captureRejections?: boolean | undefined;
|
||||
}
|
||||
// Any EventTarget with a Node-style `once` function
|
||||
interface _NodeEventTarget {
|
||||
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
// Any EventTarget with a DOM-style `addEventListener`
|
||||
interface _DOMEventTarget {
|
||||
addEventListener(
|
||||
eventName: string,
|
||||
listener: (...args: any[]) => void,
|
||||
opts?: {
|
||||
once: boolean;
|
||||
},
|
||||
): any;
|
||||
}
|
||||
interface StaticEventEmitterOptions {
|
||||
/**
|
||||
* Can be used to cancel awaiting events.
|
||||
*/
|
||||
signal?: AbortSignal | undefined;
|
||||
}
|
||||
interface EventEmitter extends NodeJS.EventEmitter {}
|
||||
interface StaticEventEmitterIteratorOptions extends StaticEventEmitterOptions {
|
||||
/**
|
||||
* Names of events that will end the iteration.
|
||||
*/
|
||||
close?: string[] | undefined;
|
||||
/**
|
||||
* The high watermark. The emitter is paused every time the size of events being buffered is higher than it.
|
||||
* Supported only on emitters implementing `pause()` and `resume()` methods.
|
||||
* @default Number.MAX_SAFE_INTEGER
|
||||
*/
|
||||
highWaterMark?: number | undefined;
|
||||
/**
|
||||
* The low watermark. The emitter is resumed every time the size of events being buffered is lower than it.
|
||||
* Supported only on emitters implementing `pause()` and `resume()` methods.
|
||||
* @default 1
|
||||
*/
|
||||
lowWaterMark?: number | undefined;
|
||||
}
|
||||
interface EventEmitter<T extends EventMap<T> = DefaultEventMap> extends NodeJS.EventEmitter<T> {}
|
||||
type EventMap<T> = Record<keyof T, any[]> | DefaultEventMap;
|
||||
type DefaultEventMap = [never];
|
||||
type AnyRest = [...args: any[]];
|
||||
type Args<K, T> = T extends DefaultEventMap ? AnyRest : (
|
||||
K extends keyof T ? T[K] : never
|
||||
);
|
||||
type Key<K, T> = T extends DefaultEventMap ? string | symbol : K | keyof T;
|
||||
type Key2<K, T> = T extends DefaultEventMap ? string | symbol : K & keyof T;
|
||||
type Listener<K, T, F> = T extends DefaultEventMap ? F : (
|
||||
K extends keyof T ? (
|
||||
T[K] extends unknown[] ? (...args: T[K]) => void : never
|
||||
)
|
||||
: never
|
||||
);
|
||||
type Listener1<K, T> = Listener<K, T, (...args: any[]) => void>;
|
||||
type Listener2<K, T> = Listener<K, T, Function>;
|
||||
|
||||
/**
|
||||
* The `EventEmitter` class is defined and exposed by the `node:events` module:
|
||||
*
|
||||
@@ -106,10 +130,10 @@ declare module "events" {
|
||||
* It supports the following option:
|
||||
* @since v0.1.26
|
||||
*/
|
||||
class EventEmitter {
|
||||
class EventEmitter<T extends EventMap<T> = DefaultEventMap> {
|
||||
constructor(options?: EventEmitterOptions);
|
||||
|
||||
[EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void;
|
||||
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: Key<K, T>, ...args: Args<K, T>): void;
|
||||
|
||||
/**
|
||||
* Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
|
||||
@@ -145,7 +169,7 @@ declare module "events" {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* The special handling of the `'error'` event is only used when `events.once()`is used to wait for another event. If `events.once()` is used to wait for the
|
||||
* The special handling of the `'error'` event is only used when `events.once()` is used to wait for another event. If `events.once()` is used to wait for the
|
||||
* '`error'` event itself, then it is treated as any other kind of event without
|
||||
* special handling:
|
||||
*
|
||||
@@ -191,11 +215,11 @@ declare module "events" {
|
||||
* @since v11.13.0, v10.16.0
|
||||
*/
|
||||
static once(
|
||||
emitter: _NodeEventTarget,
|
||||
emitter: NodeJS.EventEmitter,
|
||||
eventName: string | symbol,
|
||||
options?: StaticEventEmitterOptions,
|
||||
): Promise<any[]>;
|
||||
static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||
static once(emitter: EventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||
/**
|
||||
* ```js
|
||||
* import { on, EventEmitter } from 'node:events';
|
||||
@@ -251,17 +275,43 @@ declare module "events" {
|
||||
*
|
||||
* process.nextTick(() => ac.abort());
|
||||
* ```
|
||||
*
|
||||
* Use the `close` option to specify an array of event names that will end the iteration:
|
||||
*
|
||||
* ```js
|
||||
* import { on, EventEmitter } from 'node:events';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* const ee = new EventEmitter();
|
||||
*
|
||||
* // Emit later on
|
||||
* process.nextTick(() => {
|
||||
* ee.emit('foo', 'bar');
|
||||
* ee.emit('foo', 42);
|
||||
* ee.emit('close');
|
||||
* });
|
||||
*
|
||||
* for await (const event of on(ee, 'foo', { close: ['close'] })) {
|
||||
* console.log(event); // prints ['bar'] [42]
|
||||
* }
|
||||
* // the loop will exit after 'close' is emitted
|
||||
* console.log('done'); // prints 'done'
|
||||
* ```
|
||||
* @since v13.6.0, v12.16.0
|
||||
* @param eventName The name of the event being listened for
|
||||
* @return that iterates `eventName` events emitted by the `emitter`
|
||||
* @return An `AsyncIterator` that iterates `eventName` events emitted by the `emitter`
|
||||
*/
|
||||
static on(
|
||||
emitter: NodeJS.EventEmitter,
|
||||
eventName: string | symbol,
|
||||
options?: StaticEventEmitterIteratorOptions,
|
||||
): NodeJS.AsyncIterator<any[]>;
|
||||
static on(
|
||||
emitter: EventTarget,
|
||||
eventName: string,
|
||||
options?: StaticEventEmitterOptions,
|
||||
): AsyncIterableIterator<any>;
|
||||
options?: StaticEventEmitterIteratorOptions,
|
||||
): NodeJS.AsyncIterator<any[]>;
|
||||
/**
|
||||
* A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
|
||||
* A class method that returns the number of listeners for the given `eventName` registered on the given `emitter`.
|
||||
*
|
||||
* ```js
|
||||
* import { EventEmitter, listenerCount } from 'node:events';
|
||||
@@ -305,7 +355,7 @@ declare module "events" {
|
||||
* ```
|
||||
* @since v15.2.0, v14.17.0
|
||||
*/
|
||||
static getEventListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
||||
static getEventListeners(emitter: EventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
||||
/**
|
||||
* Returns the currently set max amount of listeners.
|
||||
*
|
||||
@@ -334,7 +384,7 @@ declare module "events" {
|
||||
* ```
|
||||
* @since v19.9.0
|
||||
*/
|
||||
static getMaxListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter): number;
|
||||
static getMaxListeners(emitter: EventTarget | NodeJS.EventEmitter): number;
|
||||
/**
|
||||
* ```js
|
||||
* import { setMaxListeners, EventEmitter } from 'node:events';
|
||||
@@ -346,10 +396,10 @@ declare module "events" {
|
||||
* ```
|
||||
* @since v15.4.0
|
||||
* @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
|
||||
* @param eventsTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
|
||||
* @param eventTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
|
||||
* objects.
|
||||
*/
|
||||
static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void;
|
||||
static setMaxListeners(n?: number, ...eventTargets: Array<EventTarget | NodeJS.EventEmitter>): void;
|
||||
/**
|
||||
* Listens once to the `abort` event on the provided `signal`.
|
||||
*
|
||||
@@ -386,9 +436,9 @@ declare module "events" {
|
||||
*/
|
||||
static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable;
|
||||
/**
|
||||
* This symbol shall be used to install a listener for only monitoring `'error'`events. Listeners installed using this symbol are called before the regular`'error'` listeners are called.
|
||||
* This symbol shall be used to install a listener for only monitoring `'error'` events. Listeners installed using this symbol are called before the regular `'error'` listeners are called.
|
||||
*
|
||||
* Installing a listener using this symbol does not change the behavior once an`'error'` event is emitted. Therefore, the process will still crash if no
|
||||
* Installing a listener using this symbol does not change the behavior once an `'error'` event is emitted. Therefore, the process will still crash if no
|
||||
* regular `'error'` listener is installed.
|
||||
* @since v13.6.0, v12.17.0
|
||||
*/
|
||||
@@ -411,16 +461,18 @@ declare module "events" {
|
||||
* By default, a maximum of `10` listeners can be registered for any single
|
||||
* event. This limit can be changed for individual `EventEmitter` instances
|
||||
* using the `emitter.setMaxListeners(n)` method. To change the default
|
||||
* for _all_`EventEmitter` instances, the `events.defaultMaxListeners`property can be used. If this value is not a positive number, a `RangeError`is thrown.
|
||||
* for _all_`EventEmitter` instances, the `events.defaultMaxListeners` property
|
||||
* can be used. If this value is not a positive number, a `RangeError` is thrown.
|
||||
*
|
||||
* Take caution when setting the `events.defaultMaxListeners` because the
|
||||
* change affects _all_`EventEmitter` instances, including those created before
|
||||
* change affects _all_ `EventEmitter` instances, including those created before
|
||||
* the change is made. However, calling `emitter.setMaxListeners(n)` still has
|
||||
* precedence over `events.defaultMaxListeners`.
|
||||
*
|
||||
* This is not a hard limit. The `EventEmitter` instance will allow
|
||||
* more listeners to be added but will output a trace warning to stderr indicating
|
||||
* that a "possible EventEmitter memory leak" has been detected. For any single`EventEmitter`, the `emitter.getMaxListeners()` and `emitter.setMaxListeners()`methods can be used to
|
||||
* that a "possible EventEmitter memory leak" has been detected. For any single
|
||||
* `EventEmitter`, the `emitter.getMaxListeners()` and `emitter.setMaxListeners()` methods can be used to
|
||||
* temporarily avoid this warning:
|
||||
*
|
||||
* ```js
|
||||
@@ -470,13 +522,41 @@ declare module "events" {
|
||||
}
|
||||
|
||||
/**
|
||||
* Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that require
|
||||
* manual async tracking. Specifically, all events emitted by instances of
|
||||
* `EventEmitterAsyncResource` will run within its async context.
|
||||
* Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that
|
||||
* require manual async tracking. Specifically, all events emitted by instances
|
||||
* of `events.EventEmitterAsyncResource` will run within its `async context`.
|
||||
*
|
||||
* The EventEmitterAsyncResource class has the same methods and takes the
|
||||
* same options as EventEmitter and AsyncResource themselves.
|
||||
* @throws if `options.name` is not provided when instantiated directly.
|
||||
* ```js
|
||||
* import { EventEmitterAsyncResource, EventEmitter } from 'node:events';
|
||||
* import { notStrictEqual, strictEqual } from 'node:assert';
|
||||
* import { executionAsyncId, triggerAsyncId } from 'node:async_hooks';
|
||||
*
|
||||
* // Async tracking tooling will identify this as 'Q'.
|
||||
* const ee1 = new EventEmitterAsyncResource({ name: 'Q' });
|
||||
*
|
||||
* // 'foo' listeners will run in the EventEmitters async context.
|
||||
* ee1.on('foo', () => {
|
||||
* strictEqual(executionAsyncId(), ee1.asyncId);
|
||||
* strictEqual(triggerAsyncId(), ee1.triggerAsyncId);
|
||||
* });
|
||||
*
|
||||
* const ee2 = new EventEmitter();
|
||||
*
|
||||
* // 'foo' listeners on ordinary EventEmitters that do not track async
|
||||
* // context, however, run in the same async context as the emit().
|
||||
* ee2.on('foo', () => {
|
||||
* notStrictEqual(executionAsyncId(), ee2.asyncId);
|
||||
* notStrictEqual(triggerAsyncId(), ee2.triggerAsyncId);
|
||||
* });
|
||||
*
|
||||
* Promise.resolve().then(() => {
|
||||
* ee1.emit('foo');
|
||||
* ee2.emit('foo');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* The `EventEmitterAsyncResource` class has the same methods and takes the
|
||||
* same options as `EventEmitter` and `AsyncResource` themselves.
|
||||
* @since v17.4.0, v16.14.0
|
||||
*/
|
||||
export class EventEmitterAsyncResource extends EventEmitter {
|
||||
@@ -485,34 +565,41 @@ declare module "events" {
|
||||
*/
|
||||
constructor(options?: EventEmitterAsyncResourceOptions);
|
||||
/**
|
||||
* Call all destroy hooks. This should only ever be called once. An
|
||||
* error will be thrown if it is called more than once. This must be
|
||||
* manually called. If the resource is left to be collected by the GC then
|
||||
* the destroy hooks will never be called.
|
||||
* Call all `destroy` hooks. This should only ever be called once. An error will
|
||||
* be thrown if it is called more than once. This **must** be manually called. If
|
||||
* the resource is left to be collected by the GC then the `destroy` hooks will
|
||||
* never be called.
|
||||
*/
|
||||
emitDestroy(): void;
|
||||
/** The unique asyncId assigned to the resource. */
|
||||
/**
|
||||
* The unique `asyncId` assigned to the resource.
|
||||
*/
|
||||
readonly asyncId: number;
|
||||
/** The same triggerAsyncId that is passed to the AsyncResource constructor. */
|
||||
/**
|
||||
* The same triggerAsyncId that is passed to the AsyncResource constructor.
|
||||
*/
|
||||
readonly triggerAsyncId: number;
|
||||
/** The underlying AsyncResource */
|
||||
/**
|
||||
* The returned `AsyncResource` object has an additional `eventEmitter` property
|
||||
* that provides a reference to this `EventEmitterAsyncResource`.
|
||||
*/
|
||||
readonly asyncResource: EventEmitterReferencingAsyncResource;
|
||||
}
|
||||
}
|
||||
global {
|
||||
namespace NodeJS {
|
||||
interface EventEmitter {
|
||||
[EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void;
|
||||
interface EventEmitter<T extends EventMap<T> = DefaultEventMap> {
|
||||
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: Key<K, T>, ...args: Args<K, T>): void;
|
||||
/**
|
||||
* Alias for `emitter.on(eventName, listener)`.
|
||||
* @since v0.1.26
|
||||
*/
|
||||
addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
addListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): 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.
|
||||
* 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) => {
|
||||
@@ -522,7 +609,7 @@ declare module "events" {
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
@@ -539,9 +626,9 @@ declare module "events" {
|
||||
* @param eventName The name of the event.
|
||||
* @param listener The callback function
|
||||
*/
|
||||
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
on<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
||||
/**
|
||||
* Adds a **one-time**`listener` function for the event named `eventName`. The
|
||||
* 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
|
||||
@@ -552,7 +639,7 @@ declare module "events" {
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
@@ -569,9 +656,9 @@ declare module "events" {
|
||||
* @param eventName The name of the event.
|
||||
* @param listener The callback function
|
||||
*/
|
||||
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
once<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
||||
/**
|
||||
* Removes the specified `listener` from the listener array for the event named`eventName`.
|
||||
* Removes the specified `listener` from the listener array for the event named `eventName`.
|
||||
*
|
||||
* ```js
|
||||
* const callback = (stream) => {
|
||||
@@ -588,7 +675,7 @@ declare module "events" {
|
||||
* 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
|
||||
* 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
|
||||
@@ -631,7 +718,7 @@ declare module "events" {
|
||||
*
|
||||
* 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:
|
||||
* recently added instance. In the example the `once('ping')` listener is removed:
|
||||
*
|
||||
* ```js
|
||||
* import { EventEmitter } from 'node:events';
|
||||
@@ -652,12 +739,12 @@ declare module "events" {
|
||||
* 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;
|
||||
removeListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
||||
/**
|
||||
* Alias for `emitter.removeListener()`.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
off(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
off<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
||||
/**
|
||||
* Removes all listeners, or those of the specified `eventName`.
|
||||
*
|
||||
@@ -668,12 +755,12 @@ declare module "events" {
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
* @since v0.1.26
|
||||
*/
|
||||
removeAllListeners(event?: string | symbol): this;
|
||||
removeAllListeners(eventName?: Key<unknown, T>): 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.
|
||||
* 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
|
||||
@@ -681,7 +768,7 @@ declare module "events" {
|
||||
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}.
|
||||
* set by `emitter.setMaxListeners(n)` or defaults to {@link EventEmitter.defaultMaxListeners}.
|
||||
* @since v1.0.0
|
||||
*/
|
||||
getMaxListeners(): number;
|
||||
@@ -697,7 +784,7 @@ declare module "events" {
|
||||
* ```
|
||||
* @since v0.1.26
|
||||
*/
|
||||
listeners(eventName: string | symbol): Function[];
|
||||
listeners<K>(eventName: Key<K, T>): Array<Listener2<K, T>>;
|
||||
/**
|
||||
* Returns a copy of the array of listeners for the event named `eventName`,
|
||||
* including any wrappers (such as those created by `.once()`).
|
||||
@@ -728,9 +815,9 @@ declare module "events" {
|
||||
* ```
|
||||
* @since v9.4.0
|
||||
*/
|
||||
rawListeners(eventName: string | symbol): Function[];
|
||||
rawListeners<K>(eventName: Key<K, T>): Array<Listener2<K, T>>;
|
||||
/**
|
||||
* Synchronously calls each of the listeners registered for the event named`eventName`, in the order they were registered, passing the supplied arguments
|
||||
* 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.
|
||||
@@ -769,7 +856,7 @@ declare module "events" {
|
||||
* ```
|
||||
* @since v0.1.26
|
||||
*/
|
||||
emit(eventName: string | symbol, ...args: any[]): boolean;
|
||||
emit<K>(eventName: Key<K, T>, ...args: Args<K, T>): boolean;
|
||||
/**
|
||||
* Returns the number of listeners listening for the event named `eventName`.
|
||||
* If `listener` is provided, it will return how many times the listener is found
|
||||
@@ -778,12 +865,12 @@ declare module "events" {
|
||||
* @param eventName The name of the event being listened for
|
||||
* @param listener The event handler function
|
||||
*/
|
||||
listenerCount(eventName: string | symbol, listener?: Function): number;
|
||||
listenerCount<K>(eventName: Key<K, T>, listener?: Listener2<K, T>): 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.
|
||||
* 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) => {
|
||||
@@ -796,7 +883,7 @@ declare module "events" {
|
||||
* @param eventName The name of the event.
|
||||
* @param listener The callback function
|
||||
*/
|
||||
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
prependListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): 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.
|
||||
@@ -812,7 +899,7 @@ declare module "events" {
|
||||
* @param eventName The name of the event.
|
||||
* @param listener The callback function
|
||||
*/
|
||||
prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
||||
/**
|
||||
* Returns an array listing the events for which the emitter has registered
|
||||
* listeners. The values in the array are strings or `Symbol`s.
|
||||
@@ -832,7 +919,7 @@ declare module "events" {
|
||||
* ```
|
||||
* @since v6.0.0
|
||||
*/
|
||||
eventNames(): Array<string | symbol>;
|
||||
eventNames(): Array<(string | symbol) & Key2<unknown, T>>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
409
node_modules/@types/node/fs.d.ts
generated
vendored
409
node_modules/@types/node/fs.d.ts
generated
vendored
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* All file system operations have synchronous, callback, and promise-based
|
||||
* forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/fs.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/fs.js)
|
||||
*/
|
||||
declare module "fs" {
|
||||
import * as stream from "node:stream";
|
||||
@@ -77,7 +77,7 @@ declare module "fs" {
|
||||
* their synchronous counterparts are of this type.
|
||||
* If `bigint` in the `options` passed to those methods is true, the numeric values
|
||||
* will be `bigint` instead of `number`, and the object will contain additional
|
||||
* nanosecond-precision properties suffixed with `Ns`.
|
||||
* nanosecond-precision properties suffixed with `Ns`. `Stat` objects are not to be created directly using the `new` keyword.
|
||||
*
|
||||
* ```console
|
||||
* Stats {
|
||||
@@ -196,7 +196,7 @@ declare module "fs" {
|
||||
* the `withFileTypes` option set to `true`, the resulting array is filled with `fs.Dirent` objects, rather than strings or `Buffer` s.
|
||||
* @since v10.10.0
|
||||
*/
|
||||
export class Dirent {
|
||||
export class Dirent<Name extends string | Buffer = string> {
|
||||
/**
|
||||
* Returns `true` if the `fs.Dirent` object describes a regular file.
|
||||
* @since v10.10.0
|
||||
@@ -239,10 +239,16 @@ declare module "fs" {
|
||||
* value is determined by the `options.encoding` passed to {@link readdir} or {@link readdirSync}.
|
||||
* @since v10.10.0
|
||||
*/
|
||||
name: string;
|
||||
name: Name;
|
||||
/**
|
||||
* The base path that this `fs.Dirent` object refers to.
|
||||
* @since v20.12.0
|
||||
*/
|
||||
parentPath: string;
|
||||
/**
|
||||
* Alias for `dirent.parentPath`.
|
||||
* @since v20.1.0
|
||||
* @deprecated Since v20.12.0
|
||||
*/
|
||||
path: string;
|
||||
}
|
||||
@@ -276,12 +282,12 @@ declare module "fs" {
|
||||
/**
|
||||
* Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
|
||||
*/
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<Dirent>;
|
||||
[Symbol.asyncIterator](): NodeJS.AsyncIterator<Dirent>;
|
||||
/**
|
||||
* Asynchronously close the directory's underlying resource handle.
|
||||
* Subsequent reads will result in errors.
|
||||
*
|
||||
* A promise is returned that will be resolved after the resource has been
|
||||
* A promise is returned that will be fulfilled after the resource has been
|
||||
* closed.
|
||||
* @since v12.12.0
|
||||
*/
|
||||
@@ -296,7 +302,7 @@ declare module "fs" {
|
||||
/**
|
||||
* Asynchronously read the next directory entry via [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) as an `fs.Dirent`.
|
||||
*
|
||||
* A promise is returned that will be resolved with an `fs.Dirent`, or `null`if there are no more directory entries to read.
|
||||
* A promise is returned that will be fulfilled with an `fs.Dirent`, or `null` if there are no more directory entries to read.
|
||||
*
|
||||
* Directory entries returned by this function are in no particular order as
|
||||
* provided by the operating system's underlying directory mechanisms.
|
||||
@@ -354,31 +360,51 @@ declare module "fs" {
|
||||
* @since v0.5.8
|
||||
*/
|
||||
close(): void;
|
||||
/**
|
||||
* When called, requests that the Node.js event loop _not_ exit so long as the `fs.FSWatcher` is active. Calling `watcher.ref()` multiple times will have
|
||||
* no effect.
|
||||
*
|
||||
* By default, all `fs.FSWatcher` objects are "ref'ed", making it normally
|
||||
* unnecessary to call `watcher.ref()` unless `watcher.unref()` had been
|
||||
* called previously.
|
||||
* @since v14.3.0, v12.20.0
|
||||
*/
|
||||
ref(): this;
|
||||
/**
|
||||
* When called, the active `fs.FSWatcher` object will not require the Node.js
|
||||
* event loop to remain active. If there is no other activity keeping the
|
||||
* event loop running, the process may exit before the `fs.FSWatcher` object's
|
||||
* callback is invoked. Calling `watcher.unref()` multiple times will have
|
||||
* no effect.
|
||||
* @since v14.3.0, v12.20.0
|
||||
*/
|
||||
unref(): this;
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. change
|
||||
* 2. error
|
||||
* 2. close
|
||||
* 3. error
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
|
||||
addListener(event: "error", listener: (error: Error) => void): this;
|
||||
addListener(event: "close", listener: () => void): this;
|
||||
addListener(event: "error", listener: (error: Error) => void): this;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
|
||||
on(event: "error", listener: (error: Error) => void): this;
|
||||
on(event: "close", listener: () => void): this;
|
||||
on(event: "error", listener: (error: Error) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
|
||||
once(event: "error", listener: (error: Error) => void): this;
|
||||
once(event: "close", listener: () => void): this;
|
||||
once(event: "error", listener: (error: Error) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
|
||||
prependListener(event: "error", listener: (error: Error) => void): this;
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
prependListener(event: "error", listener: (error: Error) => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
|
||||
prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
||||
}
|
||||
/**
|
||||
* Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function.
|
||||
@@ -410,57 +436,47 @@ declare module "fs" {
|
||||
* 2. close
|
||||
* 3. ready
|
||||
*/
|
||||
addListener(event: "close", listener: () => void): this;
|
||||
addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
addListener(event: "end", listener: () => void): this;
|
||||
addListener(event: "error", listener: (err: Error) => void): this;
|
||||
addListener(event: "open", listener: (fd: number) => void): this;
|
||||
addListener(event: "pause", listener: () => void): this;
|
||||
addListener(event: "readable", listener: () => void): this;
|
||||
addListener(event: "ready", listener: () => void): this;
|
||||
addListener(event: "resume", listener: () => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
on(event: "close", listener: () => void): this;
|
||||
on(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
on(event: "end", listener: () => void): this;
|
||||
on(event: "error", listener: (err: Error) => void): this;
|
||||
on(event: "open", listener: (fd: number) => void): this;
|
||||
on(event: "pause", listener: () => void): this;
|
||||
on(event: "readable", listener: () => void): this;
|
||||
on(event: "ready", listener: () => void): this;
|
||||
on(event: "resume", listener: () => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
once(event: "close", listener: () => void): this;
|
||||
once(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
once(event: "end", listener: () => void): this;
|
||||
once(event: "error", listener: (err: Error) => void): this;
|
||||
once(event: "open", listener: (fd: number) => void): this;
|
||||
once(event: "pause", listener: () => void): this;
|
||||
once(event: "readable", listener: () => void): this;
|
||||
once(event: "ready", listener: () => void): this;
|
||||
once(event: "resume", listener: () => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
prependListener(event: "end", listener: () => void): this;
|
||||
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependListener(event: "open", listener: (fd: number) => void): this;
|
||||
prependListener(event: "pause", listener: () => void): this;
|
||||
prependListener(event: "readable", listener: () => void): this;
|
||||
prependListener(event: "ready", listener: () => void): this;
|
||||
prependListener(event: "resume", listener: () => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
||||
prependOnceListener(event: "end", listener: () => void): this;
|
||||
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: "open", listener: (fd: number) => void): this;
|
||||
prependOnceListener(event: "pause", listener: () => void): this;
|
||||
prependOnceListener(event: "readable", listener: () => void): this;
|
||||
prependOnceListener(event: "ready", listener: () => void): this;
|
||||
prependOnceListener(event: "resume", listener: () => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
addListener<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
|
||||
on<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
|
||||
once<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
|
||||
prependListener<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
|
||||
prependOnceListener<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Keys are events of the ReadStream and the values are the functions that are called when the event is emitted.
|
||||
*/
|
||||
type ReadStreamEvents = {
|
||||
close: () => void;
|
||||
data: (chunk: Buffer | string) => void;
|
||||
end: () => void;
|
||||
error: (err: Error) => void;
|
||||
open: (fd: number) => void;
|
||||
pause: () => void;
|
||||
readable: () => void;
|
||||
ready: () => void;
|
||||
resume: () => void;
|
||||
} & CustomEvents;
|
||||
|
||||
/**
|
||||
* string & {} allows to allow any kind of strings for the event
|
||||
* but still allows to have auto completion for the normal events.
|
||||
*/
|
||||
type CustomEvents = { [Key in string & {} | symbol]: (...args: any[]) => void };
|
||||
|
||||
/**
|
||||
* The Keys are events of the WriteStream and the values are the functions that are called when the event is emitted.
|
||||
*/
|
||||
type WriteStreamEvents = {
|
||||
close: () => void;
|
||||
drain: () => void;
|
||||
error: (err: Error) => void;
|
||||
finish: () => void;
|
||||
open: (fd: number) => void;
|
||||
pipe: (src: stream.Readable) => void;
|
||||
ready: () => void;
|
||||
unpipe: (src: stream.Readable) => void;
|
||||
} & CustomEvents;
|
||||
/**
|
||||
* * Extends `stream.Writable`
|
||||
*
|
||||
@@ -499,51 +515,11 @@ declare module "fs" {
|
||||
* 2. close
|
||||
* 3. ready
|
||||
*/
|
||||
addListener(event: "close", listener: () => void): this;
|
||||
addListener(event: "drain", listener: () => void): this;
|
||||
addListener(event: "error", listener: (err: Error) => void): this;
|
||||
addListener(event: "finish", listener: () => void): this;
|
||||
addListener(event: "open", listener: (fd: number) => void): this;
|
||||
addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
addListener(event: "ready", listener: () => void): this;
|
||||
addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
on(event: "close", listener: () => void): this;
|
||||
on(event: "drain", listener: () => void): this;
|
||||
on(event: "error", listener: (err: Error) => void): this;
|
||||
on(event: "finish", listener: () => void): this;
|
||||
on(event: "open", listener: (fd: number) => void): this;
|
||||
on(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
on(event: "ready", listener: () => void): this;
|
||||
on(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
once(event: "close", listener: () => void): this;
|
||||
once(event: "drain", listener: () => void): this;
|
||||
once(event: "error", listener: (err: Error) => void): this;
|
||||
once(event: "finish", listener: () => void): this;
|
||||
once(event: "open", listener: (fd: number) => void): this;
|
||||
once(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
once(event: "ready", listener: () => void): this;
|
||||
once(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
prependListener(event: "drain", listener: () => void): this;
|
||||
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependListener(event: "finish", listener: () => void): this;
|
||||
prependListener(event: "open", listener: (fd: number) => void): this;
|
||||
prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
prependListener(event: "ready", listener: () => void): this;
|
||||
prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
prependOnceListener(event: "drain", listener: () => void): this;
|
||||
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: "finish", listener: () => void): this;
|
||||
prependOnceListener(event: "open", listener: (fd: number) => void): this;
|
||||
prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
||||
prependOnceListener(event: "ready", listener: () => void): this;
|
||||
prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
addListener<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;
|
||||
on<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;
|
||||
once<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;
|
||||
prependListener<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;
|
||||
prependOnceListener<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;
|
||||
}
|
||||
/**
|
||||
* Asynchronously rename file at `oldPath` to the pathname provided
|
||||
@@ -603,7 +579,7 @@ declare module "fs" {
|
||||
* @since v0.8.6
|
||||
* @param [len=0]
|
||||
*/
|
||||
export function truncate(path: PathLike, len: number | undefined | null, callback: NoParamCallback): void;
|
||||
export function truncate(path: PathLike, len: number | undefined, callback: NoParamCallback): void;
|
||||
/**
|
||||
* Asynchronous truncate(2) - Truncate a file to a specified length.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
@@ -615,7 +591,7 @@ declare module "fs" {
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param len If not specified, defaults to `0`.
|
||||
*/
|
||||
function __promisify__(path: PathLike, len?: number | null): Promise<void>;
|
||||
function __promisify__(path: PathLike, len?: number): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Truncates the file. Returns `undefined`. A file descriptor can also be
|
||||
@@ -626,7 +602,7 @@ declare module "fs" {
|
||||
* @since v0.8.6
|
||||
* @param [len=0]
|
||||
*/
|
||||
export function truncateSync(path: PathLike, len?: number | null): void;
|
||||
export function truncateSync(path: PathLike, len?: number): void;
|
||||
/**
|
||||
* Truncates the file descriptor. No arguments other than a possible exception are
|
||||
* given to the completion callback.
|
||||
@@ -670,7 +646,7 @@ declare module "fs" {
|
||||
* @since v0.8.6
|
||||
* @param [len=0]
|
||||
*/
|
||||
export function ftruncate(fd: number, len: number | undefined | null, callback: NoParamCallback): void;
|
||||
export function ftruncate(fd: number, len: number | undefined, callback: NoParamCallback): void;
|
||||
/**
|
||||
* Asynchronous ftruncate(2) - Truncate a file to a specified length.
|
||||
* @param fd A file descriptor.
|
||||
@@ -682,7 +658,7 @@ declare module "fs" {
|
||||
* @param fd A file descriptor.
|
||||
* @param len If not specified, defaults to `0`.
|
||||
*/
|
||||
function __promisify__(fd: number, len?: number | null): Promise<void>;
|
||||
function __promisify__(fd: number, len?: number): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Truncates the file descriptor. Returns `undefined`.
|
||||
@@ -692,7 +668,7 @@ declare module "fs" {
|
||||
* @since v0.8.6
|
||||
* @param [len=0]
|
||||
*/
|
||||
export function ftruncateSync(fd: number, len?: number | null): void;
|
||||
export function ftruncateSync(fd: number, len?: number): void;
|
||||
/**
|
||||
* Asynchronously changes owner and group of a file. No arguments other than a
|
||||
* possible exception are given to the completion callback.
|
||||
@@ -1419,7 +1395,7 @@ declare module "fs" {
|
||||
* 2. The maximum number of symbolic links is platform-independent and generally
|
||||
* (much) higher than what the native [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html) implementation supports.
|
||||
*
|
||||
* The `callback` gets two arguments `(err, resolvedPath)`. May use `process.cwd`to resolve relative paths.
|
||||
* The `callback` gets two arguments `(err, resolvedPath)`. May use `process.cwd` to resolve relative paths.
|
||||
*
|
||||
* Only paths that can be converted to UTF8 strings are supported.
|
||||
*
|
||||
@@ -1663,7 +1639,7 @@ declare module "fs" {
|
||||
retryDelay?: number | undefined;
|
||||
}
|
||||
/**
|
||||
* Asynchronously removes files and directories (modeled on the standard POSIX `rm`utility). No arguments other than a possible exception are given to the
|
||||
* Asynchronously removes files and directories (modeled on the standard POSIX `rm` utility). No arguments other than a possible exception are given to the
|
||||
* completion callback.
|
||||
* @since v14.14.0
|
||||
*/
|
||||
@@ -1676,7 +1652,7 @@ declare module "fs" {
|
||||
function __promisify__(path: PathLike, options?: RmOptions): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Synchronously removes files and directories (modeled on the standard POSIX `rm`utility). Returns `undefined`.
|
||||
* Synchronously removes files and directories (modeled on the standard POSIX `rm` utility). Returns `undefined`.
|
||||
* @since v14.14.0
|
||||
*/
|
||||
export function rmSync(path: PathLike, options?: RmOptions): void;
|
||||
@@ -1701,7 +1677,7 @@ declare module "fs" {
|
||||
* created (for instance, if it was previously created).
|
||||
*
|
||||
* 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`fs.mkdir()` when `path` is a directory that
|
||||
* and sticky bits), or an object with a `mode` property and a `recursive` property indicating whether parent directories should be created. Calling `fs.mkdir()` when `path` is a directory that
|
||||
* exists results in an error only
|
||||
* when `recursive` is false. If `recursive` is false and the directory exists,
|
||||
* an `EEXIST` error occurs.
|
||||
@@ -1809,7 +1785,7 @@ declare module "fs" {
|
||||
): Promise<string | undefined>;
|
||||
}
|
||||
/**
|
||||
* Synchronously creates a directory. Returns `undefined`, or if `recursive` is`true`, the first directory path created.
|
||||
* Synchronously creates a directory. Returns `undefined`, or if `recursive` is `true`, the first directory path created.
|
||||
* This is the synchronous version of {@link mkdir}.
|
||||
*
|
||||
* See the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details.
|
||||
@@ -1846,7 +1822,7 @@ declare module "fs" {
|
||||
/**
|
||||
* Creates a unique temporary directory.
|
||||
*
|
||||
* Generates six random characters to be appended behind a required`prefix` to create a unique temporary directory. Due to platform
|
||||
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory. 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.
|
||||
@@ -1872,7 +1848,7 @@ declare module "fs" {
|
||||
* The `fs.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('node:path').sep`).
|
||||
* (`import { sep } from 'node:node:path'`).
|
||||
*
|
||||
* ```js
|
||||
* import { tmpdir } from 'node:os';
|
||||
@@ -1983,7 +1959,7 @@ declare module "fs" {
|
||||
*/
|
||||
export function mkdtempSync(prefix: string, options?: EncodingOption): string | Buffer;
|
||||
/**
|
||||
* Reads the contents of a directory. The callback gets two arguments `(err, files)`where `files` is an array of the names of the files in the directory excluding`'.'` and `'..'`.
|
||||
* Reads the contents of a directory. The callback gets two arguments `(err, files)` where `files` is an array of the names of the files in the directory excluding `'.'` and `'..'`.
|
||||
*
|
||||
* See the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details.
|
||||
*
|
||||
@@ -2062,6 +2038,20 @@ declare module "fs" {
|
||||
},
|
||||
callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void,
|
||||
): void;
|
||||
/**
|
||||
* 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 Must include `withFileTypes: true` and `encoding: 'buffer'`.
|
||||
*/
|
||||
export function readdir(
|
||||
path: PathLike,
|
||||
options: {
|
||||
encoding: "buffer";
|
||||
withFileTypes: true;
|
||||
recursive?: boolean | undefined;
|
||||
},
|
||||
callback: (err: NodeJS.ErrnoException | null, files: Dirent<Buffer>[]) => void,
|
||||
): void;
|
||||
export namespace readdir {
|
||||
/**
|
||||
* Asynchronous readdir(3) - read a directory.
|
||||
@@ -2121,6 +2111,19 @@ declare module "fs" {
|
||||
recursive?: boolean | undefined;
|
||||
},
|
||||
): Promise<Dirent[]>;
|
||||
/**
|
||||
* 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 Must include `withFileTypes: true` and `encoding: 'buffer'`.
|
||||
*/
|
||||
function __promisify__(
|
||||
path: PathLike,
|
||||
options: {
|
||||
encoding: "buffer";
|
||||
withFileTypes: true;
|
||||
recursive?: boolean | undefined;
|
||||
},
|
||||
): Promise<Dirent<Buffer>[]>;
|
||||
}
|
||||
/**
|
||||
* Reads the contents of the directory.
|
||||
@@ -2188,6 +2191,19 @@ declare module "fs" {
|
||||
recursive?: boolean | undefined;
|
||||
},
|
||||
): Dirent[];
|
||||
/**
|
||||
* Synchronous 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 Must include `withFileTypes: true` and `encoding: 'buffer'`.
|
||||
*/
|
||||
export function readdirSync(
|
||||
path: PathLike,
|
||||
options: {
|
||||
encoding: "buffer";
|
||||
withFileTypes: true;
|
||||
recursive?: boolean | undefined;
|
||||
},
|
||||
): Dirent<Buffer>[];
|
||||
/**
|
||||
* Closes the file descriptor. No arguments other than a possible exception are
|
||||
* given to the completion callback.
|
||||
@@ -2277,8 +2293,8 @@ declare module "fs" {
|
||||
*
|
||||
* The `atime` and `mtime` arguments follow these rules:
|
||||
*
|
||||
* * Values can be either numbers representing Unix epoch time in seconds,`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.
|
||||
* * Values can be either numbers representing Unix epoch time in seconds, `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 v0.4.2
|
||||
*/
|
||||
export function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
|
||||
@@ -2341,6 +2357,20 @@ declare module "fs" {
|
||||
* @since v0.1.96
|
||||
*/
|
||||
export function fsyncSync(fd: number): void;
|
||||
export interface WriteOptions {
|
||||
/**
|
||||
* @default 0
|
||||
*/
|
||||
offset?: number | undefined;
|
||||
/**
|
||||
* @default `buffer.byteLength - offset`
|
||||
*/
|
||||
length?: number | undefined;
|
||||
/**
|
||||
* @default null
|
||||
*/
|
||||
position?: number | undefined | null;
|
||||
}
|
||||
/**
|
||||
* Write `buffer` to the file specified by `fd`.
|
||||
*
|
||||
@@ -2351,7 +2381,7 @@ declare module "fs" {
|
||||
* should be written. If `typeof position !== 'number'`, the data will be written
|
||||
* at the current position. See [`pwrite(2)`](http://man7.org/linux/man-pages/man2/pwrite.2.html).
|
||||
*
|
||||
* The callback will be given three arguments `(err, bytesWritten, buffer)` where`bytesWritten` specifies how many _bytes_ were written from `buffer`.
|
||||
* The callback will be given three arguments `(err, bytesWritten, buffer)` where `bytesWritten` specifies how many _bytes_ were written from `buffer`.
|
||||
*
|
||||
* If this method is invoked as its `util.promisify()` ed version, it returns
|
||||
* a promise for an `Object` with `bytesWritten` and `buffer` properties.
|
||||
@@ -2409,6 +2439,20 @@ declare module "fs" {
|
||||
buffer: TBuffer,
|
||||
callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void,
|
||||
): void;
|
||||
/**
|
||||
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
|
||||
* @param fd A file descriptor.
|
||||
* @param options An object with the following properties:
|
||||
* * `offset` The part of the buffer to be written. If not supplied, defaults to `0`.
|
||||
* * `length` The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
|
||||
* * `position` The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
||||
*/
|
||||
export function write<TBuffer extends NodeJS.ArrayBufferView>(
|
||||
fd: number,
|
||||
buffer: TBuffer,
|
||||
options: WriteOptions,
|
||||
callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void,
|
||||
): void;
|
||||
/**
|
||||
* Asynchronously writes `string` to the file referenced by the supplied file descriptor.
|
||||
* @param fd A file descriptor.
|
||||
@@ -2463,6 +2507,22 @@ declare module "fs" {
|
||||
bytesWritten: number;
|
||||
buffer: TBuffer;
|
||||
}>;
|
||||
/**
|
||||
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
|
||||
* @param fd A file descriptor.
|
||||
* @param options An object with the following properties:
|
||||
* * `offset` The part of the buffer to be written. If not supplied, defaults to `0`.
|
||||
* * `length` The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
|
||||
* * `position` The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
||||
*/
|
||||
function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
|
||||
fd: number,
|
||||
buffer?: TBuffer,
|
||||
options?: WriteOptions,
|
||||
): Promise<{
|
||||
bytesWritten: number;
|
||||
buffer: TBuffer;
|
||||
}>;
|
||||
/**
|
||||
* Asynchronously writes `string` to the file referenced by the supplied file descriptor.
|
||||
* @param fd A file descriptor.
|
||||
@@ -2566,6 +2626,17 @@ declare module "fs" {
|
||||
options: ReadAsyncOptions<TBuffer>,
|
||||
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
|
||||
): void;
|
||||
export function read<TBuffer extends NodeJS.ArrayBufferView>(
|
||||
fd: number,
|
||||
buffer: TBuffer,
|
||||
options: ReadSyncOptions,
|
||||
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
|
||||
): void;
|
||||
export function read<TBuffer extends NodeJS.ArrayBufferView>(
|
||||
fd: number,
|
||||
buffer: TBuffer,
|
||||
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
|
||||
): void;
|
||||
export function read(
|
||||
fd: number,
|
||||
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void,
|
||||
@@ -2695,7 +2766,7 @@ declare module "fs" {
|
||||
} & Abortable)
|
||||
| undefined
|
||||
| null,
|
||||
callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void,
|
||||
callback: (err: NodeJS.ErrnoException | null, data: NonSharedBuffer) => void,
|
||||
): void;
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file.
|
||||
@@ -2730,7 +2801,7 @@ declare module "fs" {
|
||||
| BufferEncoding
|
||||
| undefined
|
||||
| null,
|
||||
callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void,
|
||||
callback: (err: NodeJS.ErrnoException | null, data: string | NonSharedBuffer) => void,
|
||||
): void;
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file.
|
||||
@@ -2739,7 +2810,7 @@ declare module "fs" {
|
||||
*/
|
||||
export function readFile(
|
||||
path: PathOrFileDescriptor,
|
||||
callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void,
|
||||
callback: (err: NodeJS.ErrnoException | null, data: NonSharedBuffer) => void,
|
||||
): void;
|
||||
export namespace readFile {
|
||||
/**
|
||||
@@ -2755,7 +2826,7 @@ declare module "fs" {
|
||||
encoding?: null | undefined;
|
||||
flag?: string | undefined;
|
||||
} | null,
|
||||
): Promise<Buffer>;
|
||||
): Promise<NonSharedBuffer>;
|
||||
/**
|
||||
* 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.
|
||||
@@ -2789,7 +2860,7 @@ declare module "fs" {
|
||||
})
|
||||
| BufferEncoding
|
||||
| null,
|
||||
): Promise<string | Buffer>;
|
||||
): Promise<string | NonSharedBuffer>;
|
||||
}
|
||||
/**
|
||||
* Returns the contents of the `path`.
|
||||
@@ -2800,7 +2871,7 @@ declare module "fs" {
|
||||
* If the `encoding` option is specified then this function returns a
|
||||
* string. Otherwise it returns a buffer.
|
||||
*
|
||||
* Similar to {@link readFile}, when the path is a directory, the behavior of`fs.readFileSync()` is platform-specific.
|
||||
* Similar to {@link readFile}, when the path is a directory, the behavior of `fs.readFileSync()` is platform-specific.
|
||||
*
|
||||
* ```js
|
||||
* import { readFileSync } from 'node:fs';
|
||||
@@ -2821,7 +2892,7 @@ declare module "fs" {
|
||||
encoding?: null | undefined;
|
||||
flag?: string | undefined;
|
||||
} | null,
|
||||
): Buffer;
|
||||
): NonSharedBuffer;
|
||||
/**
|
||||
* Synchronously 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.
|
||||
@@ -2853,7 +2924,7 @@ declare module "fs" {
|
||||
})
|
||||
| BufferEncoding
|
||||
| null,
|
||||
): string | Buffer;
|
||||
): string | NonSharedBuffer;
|
||||
export type WriteFileOptions =
|
||||
| (
|
||||
& ObjectEncodingOptions
|
||||
@@ -2861,6 +2932,7 @@ declare module "fs" {
|
||||
& {
|
||||
mode?: Mode | undefined;
|
||||
flag?: string | undefined;
|
||||
flush?: boolean | undefined;
|
||||
}
|
||||
)
|
||||
| BufferEncoding
|
||||
@@ -2869,7 +2941,7 @@ declare module "fs" {
|
||||
* When `file` is a filename, asynchronously writes data to the file, replacing the
|
||||
* file if it already exists. `data` can be a string or a buffer.
|
||||
*
|
||||
* When `file` is a file descriptor, the behavior is similar to calling`fs.write()` directly (which is recommended). See the notes below on using
|
||||
* When `file` is a file descriptor, the behavior is similar to calling `fs.write()` directly (which is recommended). See the notes below on using
|
||||
* a file descriptor.
|
||||
*
|
||||
* The `encoding` option is ignored if `data` is a buffer.
|
||||
@@ -3118,7 +3190,7 @@ declare module "fs" {
|
||||
* Watch for changes on `filename`. The callback `listener` will be called each
|
||||
* time the file is accessed.
|
||||
*
|
||||
* The `options` argument may be omitted. If provided, it should be an object. The`options` object may contain a boolean named `persistent` that indicates
|
||||
* The `options` argument may be omitted. If provided, it should be an object. The `options` object may contain a boolean named `persistent` that indicates
|
||||
* whether the process should continue to run as long as files are being watched.
|
||||
* The `options` object may specify an `interval` property indicating how often the
|
||||
* target should be polled in milliseconds.
|
||||
@@ -3147,7 +3219,7 @@ declare module "fs" {
|
||||
* again, with the latest stat objects. This is a change in functionality since
|
||||
* v0.10.
|
||||
*
|
||||
* Using {@link watch} is more efficient than `fs.watchFile` and`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and`fs.unwatchFile` when possible.
|
||||
* Using {@link watch} is more efficient than `fs.watchFile` and `fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and `fs.unwatchFile` when possible.
|
||||
*
|
||||
* When a file being watched by `fs.watchFile()` disappears and reappears,
|
||||
* then the contents of `previous` in the second callback event (the file's
|
||||
@@ -3169,7 +3241,7 @@ declare module "fs" {
|
||||
* Watch for changes on `filename`. The callback `listener` will be called each
|
||||
* time the file is accessed.
|
||||
*
|
||||
* The `options` argument may be omitted. If provided, it should be an object. The`options` object may contain a boolean named `persistent` that indicates
|
||||
* The `options` argument may be omitted. If provided, it should be an object. The `options` object may contain a boolean named `persistent` that indicates
|
||||
* whether the process should continue to run as long as files are being watched.
|
||||
* The `options` object may specify an `interval` property indicating how often the
|
||||
* target should be polled in milliseconds.
|
||||
@@ -3198,7 +3270,7 @@ declare module "fs" {
|
||||
* again, with the latest stat objects. This is a change in functionality since
|
||||
* v0.10.
|
||||
*
|
||||
* Using {@link watch} is more efficient than `fs.watchFile` and`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and`fs.unwatchFile` when possible.
|
||||
* Using {@link watch} is more efficient than `fs.watchFile` and `fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and `fs.unwatchFile` when possible.
|
||||
*
|
||||
* When a file being watched by `fs.watchFile()` disappears and reappears,
|
||||
* then the contents of `previous` in the second callback event (the file's
|
||||
@@ -3242,7 +3314,7 @@ declare module "fs" {
|
||||
* Calling `fs.unwatchFile()` with a filename that is not being watched is a
|
||||
* no-op, not an error.
|
||||
*
|
||||
* Using {@link watch} is more efficient than `fs.watchFile()` and`fs.unwatchFile()`. `fs.watch()` should be used instead of `fs.watchFile()`and `fs.unwatchFile()` when possible.
|
||||
* Using {@link watch} is more efficient than `fs.watchFile()` and `fs.unwatchFile()`. `fs.watch()` should be used instead of `fs.watchFile()` and `fs.unwatchFile()` when possible.
|
||||
* @since v0.1.31
|
||||
* @param listener Optional, a listener previously attached using `fs.watchFile()`
|
||||
*/
|
||||
@@ -3270,7 +3342,7 @@ declare module "fs" {
|
||||
* On most platforms, `'rename'` is emitted whenever a filename appears or
|
||||
* disappears in the directory.
|
||||
*
|
||||
* The listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but it is not the same thing as the `'change'` value of`eventType`.
|
||||
* The listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but it is not the same thing as the `'change'` value of `eventType`.
|
||||
*
|
||||
* If a `signal` is passed, aborting the corresponding AbortController will close
|
||||
* the returned `fs.FSWatcher`.
|
||||
@@ -3330,11 +3402,11 @@ declare module "fs" {
|
||||
* ```
|
||||
*
|
||||
* **The parameters for this callback are not consistent with other Node.js**
|
||||
* **callbacks.** Normally, the first parameter to a Node.js callback is an `err`parameter, optionally followed by other parameters. The `fs.exists()` callback
|
||||
* **callbacks.** Normally, the first parameter to a Node.js callback is an `err` parameter, optionally followed by other parameters. The `fs.exists()` callback
|
||||
* has only one boolean parameter. This is one reason `fs.access()` is recommended
|
||||
* instead of `fs.exists()`.
|
||||
*
|
||||
* Using `fs.exists()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended. Doing
|
||||
* Using `fs.exists()` to check for the existence of a file before calling `fs.open()`, `fs.readFile()`, or `fs.writeFile()` 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 does not exist.
|
||||
@@ -3461,7 +3533,7 @@ declare module "fs" {
|
||||
* For detailed information, see the documentation of the asynchronous version of
|
||||
* this API: {@link exists}.
|
||||
*
|
||||
* `fs.exists()` is deprecated, but `fs.existsSync()` is not. The `callback`parameter to `fs.exists()` accepts parameters that are inconsistent with other
|
||||
* `fs.exists()` is deprecated, but `fs.existsSync()` is not. The `callback` parameter to `fs.exists()` accepts parameters that are inconsistent with other
|
||||
* Node.js callbacks. `fs.existsSync()` does not use a callback.
|
||||
*
|
||||
* ```js
|
||||
@@ -3590,13 +3662,13 @@ declare module "fs" {
|
||||
/**
|
||||
* 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. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK`
|
||||
* checks to be performed. `mode` should be either the value `fs.constants.F_OK` or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`, `fs.constants.W_OK`, and `fs.constants.X_OK`
|
||||
* (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
|
||||
* possible values of `mode`.
|
||||
*
|
||||
* The final argument, `callback`, is a callback function that is invoked with
|
||||
* a possible error argument. If any of the accessibility checks fail, the error
|
||||
* argument will be an `Error` object. The following examples check if`package.json` exists, and if it is readable or writable.
|
||||
* argument will be an `Error` object. The following examples check if `package.json` exists, and if it is readable or writable.
|
||||
*
|
||||
* ```js
|
||||
* import { access, constants } from 'node:fs';
|
||||
@@ -3624,7 +3696,7 @@ declare module "fs" {
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Do not use `fs.access()` to check for the accessibility of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()`. Doing
|
||||
* Do not use `fs.access()` to check for the accessibility of a file before calling `fs.open()`, `fs.readFile()`, or `fs.writeFile()`. 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.
|
||||
@@ -3764,7 +3836,7 @@ declare module "fs" {
|
||||
/**
|
||||
* Synchronously 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. `mode` should be either the value`fs.constants.F_OK` or a mask consisting of the bitwise OR of any of`fs.constants.R_OK`, `fs.constants.W_OK`, and
|
||||
* accessibility checks to be performed. `mode` should be either the value `fs.constants.F_OK` or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`, `fs.constants.W_OK`, and
|
||||
* `fs.constants.X_OK` (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
|
||||
* possible values of `mode`.
|
||||
*
|
||||
@@ -3813,6 +3885,7 @@ declare module "fs" {
|
||||
}
|
||||
interface WriteStreamOptions extends StreamOptions {
|
||||
fs?: CreateWriteStreamFSImplementation | null | undefined;
|
||||
flush?: boolean | undefined;
|
||||
}
|
||||
/**
|
||||
* Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream
|
||||
@@ -3837,8 +3910,8 @@ declare module "fs" {
|
||||
* By default, the stream will emit a `'close'` event after it has been
|
||||
* destroyed. Set the `emitClose` option to `false` to change this behavior.
|
||||
*
|
||||
* By providing the `fs` option, it is possible to override the corresponding `fs`implementations for `open`, `read`, and `close`. When providing the `fs` option,
|
||||
* an override for `read` is required. If no `fd` is provided, an override for`open` is also required. If `autoClose` is `true`, an override for `close` is
|
||||
* By providing the `fs` option, it is possible to override the corresponding `fs` implementations for `open`, `read`, and `close`. When providing the `fs` option,
|
||||
* an override for `read` is required. If no `fd` is provided, an override for `open` is also required. If `autoClose` is `true`, an override for `close` is
|
||||
* also required.
|
||||
*
|
||||
* ```js
|
||||
@@ -3886,7 +3959,7 @@ declare module "fs" {
|
||||
* replacing it may require the `flags` option to be set to `r+` rather than the
|
||||
* default `w`. The `encoding` can be any one of those accepted by `Buffer`.
|
||||
*
|
||||
* If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
|
||||
* If `autoClose` is set to true (default behavior) on `'error'` or `'finish'` the file descriptor will be closed automatically. If `autoClose` is false,
|
||||
* then the file descriptor won't be closed, even if there's an error.
|
||||
* It is the application's responsibility to close it and make sure there's no
|
||||
* file descriptor leak.
|
||||
@@ -3894,12 +3967,12 @@ declare module "fs" {
|
||||
* By default, the stream will emit a `'close'` event after it has been
|
||||
* destroyed. Set the `emitClose` option to `false` to change this behavior.
|
||||
*
|
||||
* By providing the `fs` option it is possible to override the corresponding `fs`implementations for `open`, `write`, `writev`, and `close`. Overriding `write()`without `writev()` can reduce
|
||||
* By providing the `fs` option it is possible to override the corresponding `fs` implementations for `open`, `write`, `writev`, and `close`. Overriding `write()` without `writev()` can reduce
|
||||
* performance as some optimizations (`_writev()`)
|
||||
* will be disabled. When providing the `fs` option, overrides for at least one of`write` and `writev` are required. If no `fd` option is supplied, an override
|
||||
* for `open` is also required. If `autoClose` is `true`, an override for `close`is also required.
|
||||
* will be disabled. When providing the `fs` option, overrides for at least one of `write` and `writev` are required. If no `fd` option is supplied, an override
|
||||
* for `open` is also required. If `autoClose` is `true`, an override for `close` is also required.
|
||||
*
|
||||
* Like `fs.ReadStream`, if `fd` is specified, `fs.WriteStream` will ignore the`path` argument and will use the specified file descriptor. This means that no`'open'` event will be
|
||||
* Like `fs.ReadStream`, if `fd` is specified, `fs.WriteStream` will ignore the `path` argument and will use the specified file descriptor. This means that no `'open'` event will be
|
||||
* emitted. `fd` should be blocking; non-blocking `fd`s
|
||||
* should be passed to `net.Socket`.
|
||||
*
|
||||
@@ -4008,15 +4081,15 @@ declare module "fs" {
|
||||
*/
|
||||
export function copyFileSync(src: PathLike, dest: PathLike, mode?: number): void;
|
||||
/**
|
||||
* Write an array of `ArrayBufferView`s to the file specified by `fd` using`writev()`.
|
||||
* Write an array of `ArrayBufferView`s to the file specified by `fd` using `writev()`.
|
||||
*
|
||||
* `position` is the offset from the beginning of the file where this data
|
||||
* should be written. If `typeof position !== 'number'`, the data will be written
|
||||
* at the current position.
|
||||
*
|
||||
* The callback will be given three arguments: `err`, `bytesWritten`, and`buffers`. `bytesWritten` is how many bytes were written from `buffers`.
|
||||
* The callback will be given three arguments: `err`, `bytesWritten`, and `buffers`. `bytesWritten` is how many bytes were written from `buffers`.
|
||||
*
|
||||
* If this method is `util.promisify()` ed, it returns a promise for an`Object` with `bytesWritten` and `buffers` properties.
|
||||
* If this method is `util.promisify()` ed, it returns a promise for an `Object` with `bytesWritten` and `buffers` properties.
|
||||
*
|
||||
* It is unsafe to use `fs.writev()` multiple times on the same file without
|
||||
* waiting for the callback. For this scenario, use {@link createWriteStream}.
|
||||
@@ -4029,13 +4102,13 @@ declare module "fs" {
|
||||
*/
|
||||
export function writev(
|
||||
fd: number,
|
||||
buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
|
||||
buffers: readonly NodeJS.ArrayBufferView[],
|
||||
cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void,
|
||||
): void;
|
||||
export function writev(
|
||||
fd: number,
|
||||
buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
|
||||
position: number,
|
||||
buffers: readonly NodeJS.ArrayBufferView[],
|
||||
position: number | null,
|
||||
cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void,
|
||||
): void;
|
||||
export interface WriteVResult {
|
||||
@@ -4045,7 +4118,7 @@ declare module "fs" {
|
||||
export namespace writev {
|
||||
function __promisify__(
|
||||
fd: number,
|
||||
buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
|
||||
buffers: readonly NodeJS.ArrayBufferView[],
|
||||
position?: number,
|
||||
): Promise<WriteVResult>;
|
||||
}
|
||||
@@ -4056,7 +4129,7 @@ declare module "fs" {
|
||||
* @param [position='null']
|
||||
* @return The number of bytes written.
|
||||
*/
|
||||
export function writevSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
|
||||
export function writevSync(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number): number;
|
||||
/**
|
||||
* Read from a file specified by `fd` and write to an array of `ArrayBufferView`s
|
||||
* using `readv()`.
|
||||
@@ -4065,7 +4138,7 @@ declare module "fs" {
|
||||
* should be read. If `typeof position !== 'number'`, the data will be read
|
||||
* from the current position.
|
||||
*
|
||||
* The callback will be given three arguments: `err`, `bytesRead`, and`buffers`. `bytesRead` is how many bytes were read from the file.
|
||||
* The callback will be given three arguments: `err`, `bytesRead`, and `buffers`. `bytesRead` is how many bytes were read from the file.
|
||||
*
|
||||
* If this method is invoked as its `util.promisify()` ed version, it returns
|
||||
* a promise for an `Object` with `bytesRead` and `buffers` properties.
|
||||
@@ -4074,13 +4147,13 @@ declare module "fs" {
|
||||
*/
|
||||
export function readv(
|
||||
fd: number,
|
||||
buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
|
||||
buffers: readonly NodeJS.ArrayBufferView[],
|
||||
cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void,
|
||||
): void;
|
||||
export function readv(
|
||||
fd: number,
|
||||
buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
|
||||
position: number,
|
||||
buffers: readonly NodeJS.ArrayBufferView[],
|
||||
position: number | null,
|
||||
cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void,
|
||||
): void;
|
||||
export interface ReadVResult {
|
||||
@@ -4090,7 +4163,7 @@ declare module "fs" {
|
||||
export namespace readv {
|
||||
function __promisify__(
|
||||
fd: number,
|
||||
buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
|
||||
buffers: readonly NodeJS.ArrayBufferView[],
|
||||
position?: number,
|
||||
): Promise<ReadVResult>;
|
||||
}
|
||||
@@ -4101,7 +4174,7 @@ declare module "fs" {
|
||||
* @param [position='null']
|
||||
* @return The number of bytes read.
|
||||
*/
|
||||
export function readvSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
|
||||
export function readvSync(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number): number;
|
||||
|
||||
export interface OpenAsBlobOptions {
|
||||
/**
|
||||
|
||||
104
node_modules/@types/node/fs/promises.d.ts
generated
vendored
104
node_modules/@types/node/fs/promises.d.ts
generated
vendored
@@ -82,6 +82,7 @@ declare module "fs/promises" {
|
||||
emitClose?: boolean | undefined;
|
||||
start?: number | undefined;
|
||||
highWaterMark?: number | undefined;
|
||||
flush?: boolean | undefined;
|
||||
}
|
||||
interface ReadableWebStreamOptions {
|
||||
/**
|
||||
@@ -107,7 +108,10 @@ declare module "fs/promises" {
|
||||
*/
|
||||
appendFile(
|
||||
data: string | Uint8Array,
|
||||
options?: (ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding | null,
|
||||
options?:
|
||||
| (ObjectEncodingOptions & Abortable)
|
||||
| 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).
|
||||
@@ -185,7 +189,7 @@ declare module "fs/promises" {
|
||||
* replacing it may require the `flags` `open` option to be set to `r+` rather than
|
||||
* the default `r`. The `encoding` can be any one of those accepted by `Buffer`.
|
||||
*
|
||||
* If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
|
||||
* If `autoClose` is set to true (default behavior) on `'error'` or `'finish'` the file descriptor will be closed automatically. If `autoClose` is false,
|
||||
* then the file descriptor won't be closed, even if there's an error.
|
||||
* It is the application's responsibility to close it and make sure there's no
|
||||
* file descriptor leak.
|
||||
@@ -264,7 +268,7 @@ declare module "fs/promises" {
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
@@ -272,36 +276,26 @@ declare module "fs/promises" {
|
||||
* data will be a string.
|
||||
*/
|
||||
readFile(
|
||||
options?: {
|
||||
encoding?: null | undefined;
|
||||
flag?: OpenMode | undefined;
|
||||
} | null,
|
||||
options?:
|
||||
| ({ encoding?: null | undefined } & Abortable)
|
||||
| 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;
|
||||
}
|
||||
| ({ encoding: BufferEncoding } & Abortable)
|
||||
| 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;
|
||||
})
|
||||
| (ObjectEncodingOptions & Abortable)
|
||||
| BufferEncoding
|
||||
| null,
|
||||
): Promise<string | Buffer>;
|
||||
@@ -366,22 +360,22 @@ declare module "fs/promises" {
|
||||
*/
|
||||
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.
|
||||
* Change the file system timestamps of the object referenced by the `FileHandle` then fulfills the promise with no arguments upon success.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
utimes(atime: TimeLike, mtime: TimeLike): Promise<void>;
|
||||
/**
|
||||
* Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an
|
||||
* Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an
|
||||
* [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an
|
||||
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
|
||||
* The promise is resolved with no arguments upon success.
|
||||
* The promise is fulfilled 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).
|
||||
* without waiting for the promise to be fulfilled (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
|
||||
@@ -390,15 +384,18 @@ declare module "fs/promises" {
|
||||
*/
|
||||
writeFile(
|
||||
data: string | Uint8Array,
|
||||
options?: (ObjectEncodingOptions & FlagAndOpenMode & Abortable) | BufferEncoding | null,
|
||||
options?:
|
||||
| (ObjectEncodingOptions & Abortable)
|
||||
| BufferEncoding
|
||||
| null,
|
||||
): Promise<void>;
|
||||
/**
|
||||
* Write `buffer` to the file.
|
||||
*
|
||||
* The promise is resolved with an object containing two properties:
|
||||
* The promise is fulfilled 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
|
||||
* without waiting for the promise to be fulfilled (or rejected). For this
|
||||
* scenario, use `filehandle.createWriteStream()`.
|
||||
*
|
||||
* On Linux, positional writes do not work when the file is opened in append mode.
|
||||
@@ -430,10 +427,10 @@ declare module "fs/promises" {
|
||||
/**
|
||||
* 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:
|
||||
* The promise is fulfilled 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).
|
||||
* for the promise to be fulfilled (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
|
||||
@@ -442,14 +439,14 @@ declare module "fs/promises" {
|
||||
* @param [position='null'] 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>;
|
||||
writev(buffers: readonly 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='null'] 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>;
|
||||
readv(buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise<ReadVResult>;
|
||||
/**
|
||||
* Closes the file handle after waiting for any pending operation on the handle to
|
||||
* complete.
|
||||
@@ -478,11 +475,11 @@ declare module "fs/promises" {
|
||||
/**
|
||||
* 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. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK`
|
||||
* checks to be performed. `mode` should be either the value `fs.constants.F_OK` or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`, `fs.constants.W_OK`, and `fs.constants.X_OK`
|
||||
* (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
|
||||
* possible values of `mode`.
|
||||
*
|
||||
* If the accessibility check is successful, the promise is resolved with no
|
||||
* If the accessibility check is successful, the promise is fulfilled 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.
|
||||
@@ -563,7 +560,7 @@ declare module "fs/promises" {
|
||||
*/
|
||||
function rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
|
||||
/**
|
||||
* Truncates (shortens or extends the length) of the content at `path` to `len`bytes.
|
||||
* Truncates (shortens or extends the length) of the content at `path` to `len` bytes.
|
||||
* @since v10.0.0
|
||||
* @param [len=0]
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
@@ -573,7 +570,7 @@ declare module "fs/promises" {
|
||||
* 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.
|
||||
* 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
|
||||
@@ -590,7 +587,7 @@ declare module "fs/promises" {
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
@@ -645,7 +642,7 @@ declare module "fs/promises" {
|
||||
* 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.
|
||||
* If `options.withFileTypes` is set to `true`, the returned array will contain `fs.Dirent` objects.
|
||||
*
|
||||
* ```js
|
||||
* import { readdir } from 'node:fs/promises';
|
||||
@@ -713,9 +710,22 @@ declare module "fs/promises" {
|
||||
recursive?: boolean | undefined;
|
||||
},
|
||||
): Promise<Dirent[]>;
|
||||
/**
|
||||
* Asynchronous readdir(3) - read a directory.
|
||||
* @param path A path to a directory. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param options Must include `withFileTypes: true` and `encoding: 'buffer'`.
|
||||
*/
|
||||
function readdir(
|
||||
path: PathLike,
|
||||
options: {
|
||||
encoding: "buffer";
|
||||
withFileTypes: true;
|
||||
recursive?: boolean | undefined;
|
||||
},
|
||||
): Promise<Dirent<Buffer>[]>;
|
||||
/**
|
||||
* 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.
|
||||
* fulfilled 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
|
||||
@@ -740,7 +750,7 @@ declare module "fs/promises" {
|
||||
/**
|
||||
* Creates a symbolic link.
|
||||
*
|
||||
* The `type` argument is only used on Windows platforms and can be one of `'dir'`,`'file'`, or `'junction'`. If the `type` argument is not a string, Node.js will
|
||||
* The `type` argument is only used on Windows platforms and can be one of `'dir'`, `'file'`, or `'junction'`. If the `type` argument is not a string, Node.js will
|
||||
* autodetect `target` type and use `'file'` or `'dir'`. If the `target` does not
|
||||
* exist, `'file'` will be used. Windows junction points require the destination
|
||||
* path to be absolute. When using `'junction'`, the `target` argument will
|
||||
@@ -860,13 +870,13 @@ declare module "fs/promises" {
|
||||
*
|
||||
* * 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.
|
||||
* * 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: TimeLike, mtime: TimeLike): Promise<void>;
|
||||
/**
|
||||
* Determines the actual location of `path` using the same semantics as the`fs.realpath.native()` function.
|
||||
* 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.
|
||||
*
|
||||
@@ -920,9 +930,9 @@ declare module "fs/promises" {
|
||||
* ```
|
||||
*
|
||||
* 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
|
||||
* 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('node:path').sep`).
|
||||
* (`import { sep } from 'node:node:path'`).
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with a string containing the file system path of the newly created temporary directory.
|
||||
*/
|
||||
@@ -940,7 +950,7 @@ declare module "fs/promises" {
|
||||
*/
|
||||
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, an
|
||||
* Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an
|
||||
* [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an
|
||||
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
|
||||
*
|
||||
@@ -1001,6 +1011,12 @@ declare module "fs/promises" {
|
||||
| (ObjectEncodingOptions & {
|
||||
mode?: Mode | undefined;
|
||||
flag?: OpenMode | undefined;
|
||||
/**
|
||||
* If all data is successfully written to the file, and `flush`
|
||||
* is `true`, `filehandle.sync()` is used to flush the data.
|
||||
* @default false
|
||||
*/
|
||||
flush?: boolean | undefined;
|
||||
} & Abortable)
|
||||
| BufferEncoding
|
||||
| null,
|
||||
@@ -1022,7 +1038,7 @@ declare module "fs/promises" {
|
||||
function appendFile(
|
||||
path: PathLike | FileHandle,
|
||||
data: string | Uint8Array,
|
||||
options?: (ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding | null,
|
||||
options?: (ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined }) | BufferEncoding | null,
|
||||
): Promise<void>;
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file.
|
||||
@@ -1158,7 +1174,7 @@ declare module "fs/promises" {
|
||||
* Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
|
||||
*
|
||||
* ```js
|
||||
* const { watch } = require('node:fs/promises');
|
||||
* import { watch } from 'node:fs/promises';
|
||||
*
|
||||
* const ac = new AbortController();
|
||||
* const { signal } = ac;
|
||||
|
||||
682
node_modules/@types/node/globals.d.ts
generated
vendored
682
node_modules/@types/node/globals.d.ts
generated
vendored
@@ -1,381 +1,335 @@
|
||||
// Declare "static" methods in Error
|
||||
interface ErrorConstructor {
|
||||
/** Create .stack property on a target object */
|
||||
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
||||
export {}; // Make this a module
|
||||
|
||||
/**
|
||||
* Optional override for formatting stack traces
|
||||
*
|
||||
* @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
||||
*/
|
||||
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
||||
// #region Fetch and friends
|
||||
// Conditional type aliases, used at the end of this file.
|
||||
// Will either be empty if lib-dom is included, or the undici version otherwise.
|
||||
type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request;
|
||||
type _Response = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Response;
|
||||
type _FormData = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").FormData;
|
||||
type _Headers = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Headers;
|
||||
type _MessageEvent = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").MessageEvent;
|
||||
type _RequestInit = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("undici-types").RequestInit;
|
||||
type _ResponseInit = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("undici-types").ResponseInit;
|
||||
type _EventSource = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").EventSource;
|
||||
// #endregion Fetch and friends
|
||||
|
||||
stackTraceLimit: number;
|
||||
// #region DOMException
|
||||
type _DOMException = typeof globalThis extends { onmessage: any } ? {} : NodeDOMException;
|
||||
interface NodeDOMException extends Error {
|
||||
readonly code: number;
|
||||
readonly message: string;
|
||||
readonly name: string;
|
||||
readonly INDEX_SIZE_ERR: 1;
|
||||
readonly DOMSTRING_SIZE_ERR: 2;
|
||||
readonly HIERARCHY_REQUEST_ERR: 3;
|
||||
readonly WRONG_DOCUMENT_ERR: 4;
|
||||
readonly INVALID_CHARACTER_ERR: 5;
|
||||
readonly NO_DATA_ALLOWED_ERR: 6;
|
||||
readonly NO_MODIFICATION_ALLOWED_ERR: 7;
|
||||
readonly NOT_FOUND_ERR: 8;
|
||||
readonly NOT_SUPPORTED_ERR: 9;
|
||||
readonly INUSE_ATTRIBUTE_ERR: 10;
|
||||
readonly INVALID_STATE_ERR: 11;
|
||||
readonly SYNTAX_ERR: 12;
|
||||
readonly INVALID_MODIFICATION_ERR: 13;
|
||||
readonly NAMESPACE_ERR: 14;
|
||||
readonly INVALID_ACCESS_ERR: 15;
|
||||
readonly VALIDATION_ERR: 16;
|
||||
readonly TYPE_MISMATCH_ERR: 17;
|
||||
readonly SECURITY_ERR: 18;
|
||||
readonly NETWORK_ERR: 19;
|
||||
readonly ABORT_ERR: 20;
|
||||
readonly URL_MISMATCH_ERR: 21;
|
||||
readonly QUOTA_EXCEEDED_ERR: 22;
|
||||
readonly TIMEOUT_ERR: 23;
|
||||
readonly INVALID_NODE_TYPE_ERR: 24;
|
||||
readonly DATA_CLONE_ERR: 25;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------*
|
||||
* *
|
||||
* GLOBAL *
|
||||
* *
|
||||
------------------------------------------------*/
|
||||
|
||||
// For backwards compability
|
||||
interface NodeRequire extends NodeJS.Require {}
|
||||
interface RequireResolve extends NodeJS.RequireResolve {}
|
||||
interface NodeModule extends NodeJS.Module {}
|
||||
|
||||
declare var process: NodeJS.Process;
|
||||
declare var console: Console;
|
||||
|
||||
declare var __filename: string;
|
||||
declare var __dirname: string;
|
||||
|
||||
declare var require: NodeRequire;
|
||||
declare var module: NodeModule;
|
||||
|
||||
// Same as module.exports
|
||||
declare var exports: any;
|
||||
|
||||
/**
|
||||
* Only available if `--expose-gc` is passed to the process.
|
||||
*/
|
||||
declare var gc: undefined | (() => void);
|
||||
|
||||
// #region borrowed
|
||||
// from https://github.com/microsoft/TypeScript/blob/38da7c600c83e7b31193a62495239a0fe478cb67/lib/lib.webworker.d.ts#L633 until moved to separate lib
|
||||
/** A controller object that allows you to abort one or more DOM requests as and when desired. */
|
||||
interface AbortController {
|
||||
/**
|
||||
* Returns the AbortSignal object associated with this object.
|
||||
*/
|
||||
|
||||
readonly signal: AbortSignal;
|
||||
/**
|
||||
* Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted.
|
||||
*/
|
||||
abort(reason?: any): void;
|
||||
interface NodeDOMExceptionConstructor {
|
||||
prototype: DOMException;
|
||||
new(message?: string, nameOrOptions?: string | { name?: string; cause?: unknown }): DOMException;
|
||||
readonly INDEX_SIZE_ERR: 1;
|
||||
readonly DOMSTRING_SIZE_ERR: 2;
|
||||
readonly HIERARCHY_REQUEST_ERR: 3;
|
||||
readonly WRONG_DOCUMENT_ERR: 4;
|
||||
readonly INVALID_CHARACTER_ERR: 5;
|
||||
readonly NO_DATA_ALLOWED_ERR: 6;
|
||||
readonly NO_MODIFICATION_ALLOWED_ERR: 7;
|
||||
readonly NOT_FOUND_ERR: 8;
|
||||
readonly NOT_SUPPORTED_ERR: 9;
|
||||
readonly INUSE_ATTRIBUTE_ERR: 10;
|
||||
readonly INVALID_STATE_ERR: 11;
|
||||
readonly SYNTAX_ERR: 12;
|
||||
readonly INVALID_MODIFICATION_ERR: 13;
|
||||
readonly NAMESPACE_ERR: 14;
|
||||
readonly INVALID_ACCESS_ERR: 15;
|
||||
readonly VALIDATION_ERR: 16;
|
||||
readonly TYPE_MISMATCH_ERR: 17;
|
||||
readonly SECURITY_ERR: 18;
|
||||
readonly NETWORK_ERR: 19;
|
||||
readonly ABORT_ERR: 20;
|
||||
readonly URL_MISMATCH_ERR: 21;
|
||||
readonly QUOTA_EXCEEDED_ERR: 22;
|
||||
readonly TIMEOUT_ERR: 23;
|
||||
readonly INVALID_NODE_TYPE_ERR: 24;
|
||||
readonly DATA_CLONE_ERR: 25;
|
||||
}
|
||||
// #endregion DOMException
|
||||
|
||||
/** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */
|
||||
interface AbortSignal extends EventTarget {
|
||||
/**
|
||||
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
|
||||
*/
|
||||
readonly aborted: boolean;
|
||||
readonly reason: any;
|
||||
onabort: null | ((this: AbortSignal, event: Event) => any);
|
||||
throwIfAborted(): void;
|
||||
}
|
||||
declare global {
|
||||
var global: typeof globalThis;
|
||||
|
||||
declare var AbortController: typeof globalThis extends { onmessage: any; AbortController: infer T } ? T
|
||||
: {
|
||||
prototype: AbortController;
|
||||
new(): AbortController;
|
||||
};
|
||||
var process: NodeJS.Process;
|
||||
var console: Console;
|
||||
|
||||
declare var AbortSignal: typeof globalThis extends { onmessage: any; AbortSignal: infer T } ? T
|
||||
: {
|
||||
prototype: AbortSignal;
|
||||
new(): AbortSignal;
|
||||
abort(reason?: any): AbortSignal;
|
||||
timeout(milliseconds: number): AbortSignal;
|
||||
};
|
||||
// #endregion borrowed
|
||||
|
||||
// #region Disposable
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that is used to release resources held by an object. Called by the semantics of the `using` statement.
|
||||
*/
|
||||
readonly dispose: unique symbol;
|
||||
|
||||
/**
|
||||
* A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement.
|
||||
*/
|
||||
readonly asyncDispose: unique symbol;
|
||||
}
|
||||
|
||||
interface Disposable {
|
||||
[Symbol.dispose](): void;
|
||||
}
|
||||
|
||||
interface AsyncDisposable {
|
||||
[Symbol.asyncDispose](): PromiseLike<void>;
|
||||
}
|
||||
// #endregion Disposable
|
||||
|
||||
// #region ArrayLike.at()
|
||||
interface RelativeIndexable<T> {
|
||||
/**
|
||||
* Takes an integer value and returns the item at that index,
|
||||
* allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the array.
|
||||
*/
|
||||
at(index: number): T | undefined;
|
||||
}
|
||||
interface String extends RelativeIndexable<string> {}
|
||||
interface Array<T> extends RelativeIndexable<T> {}
|
||||
interface ReadonlyArray<T> extends RelativeIndexable<T> {}
|
||||
interface Int8Array extends RelativeIndexable<number> {}
|
||||
interface Uint8Array extends RelativeIndexable<number> {}
|
||||
interface Uint8ClampedArray extends RelativeIndexable<number> {}
|
||||
interface Int16Array extends RelativeIndexable<number> {}
|
||||
interface Uint16Array extends RelativeIndexable<number> {}
|
||||
interface Int32Array extends RelativeIndexable<number> {}
|
||||
interface Uint32Array extends RelativeIndexable<number> {}
|
||||
interface Float32Array extends RelativeIndexable<number> {}
|
||||
interface Float64Array extends RelativeIndexable<number> {}
|
||||
interface BigInt64Array extends RelativeIndexable<bigint> {}
|
||||
interface BigUint64Array extends RelativeIndexable<bigint> {}
|
||||
// #endregion ArrayLike.at() end
|
||||
|
||||
/**
|
||||
* @since v17.0.0
|
||||
*
|
||||
* Creates a deep clone of an object.
|
||||
*/
|
||||
declare function structuredClone<T>(
|
||||
value: T,
|
||||
transfer?: { transfer: ReadonlyArray<import("worker_threads").TransferListItem> },
|
||||
): T;
|
||||
|
||||
/*----------------------------------------------*
|
||||
* *
|
||||
* GLOBAL INTERFACES *
|
||||
* *
|
||||
*-----------------------------------------------*/
|
||||
declare namespace NodeJS {
|
||||
interface CallSite {
|
||||
interface ErrorConstructor {
|
||||
/**
|
||||
* Value of "this"
|
||||
*/
|
||||
getThis(): unknown;
|
||||
|
||||
/**
|
||||
* Type of "this" as a string.
|
||||
* This is the name of the function stored in the constructor field of
|
||||
* "this", if available. Otherwise the object's [[Class]] internal
|
||||
* property.
|
||||
*/
|
||||
getTypeName(): string | null;
|
||||
|
||||
/**
|
||||
* Current function
|
||||
*/
|
||||
getFunction(): Function | undefined;
|
||||
|
||||
/**
|
||||
* Name of the current function, typically its name property.
|
||||
* If a name property is not available an attempt will be made to try
|
||||
* to infer a name from the function's context.
|
||||
*/
|
||||
getFunctionName(): string | null;
|
||||
|
||||
/**
|
||||
* Name of the property [of "this" or one of its prototypes] that holds
|
||||
* the current function
|
||||
*/
|
||||
getMethodName(): string | null;
|
||||
|
||||
/**
|
||||
* Name of the script [if this function was defined in a script]
|
||||
*/
|
||||
getFileName(): string | undefined;
|
||||
|
||||
/**
|
||||
* Current line number [if this function was defined in a script]
|
||||
*/
|
||||
getLineNumber(): number | null;
|
||||
|
||||
/**
|
||||
* Current column number [if this function was defined in a script]
|
||||
*/
|
||||
getColumnNumber(): number | null;
|
||||
|
||||
/**
|
||||
* A call site object representing the location where eval was called
|
||||
* [if this function was created using a call to eval]
|
||||
*/
|
||||
getEvalOrigin(): string | undefined;
|
||||
|
||||
/**
|
||||
* Is this a toplevel invocation, that is, is "this" the global object?
|
||||
*/
|
||||
isToplevel(): boolean;
|
||||
|
||||
/**
|
||||
* Does this call take place in code defined by a call to eval?
|
||||
*/
|
||||
isEval(): boolean;
|
||||
|
||||
/**
|
||||
* Is this call in native V8 code?
|
||||
*/
|
||||
isNative(): boolean;
|
||||
|
||||
/**
|
||||
* Is this a constructor call?
|
||||
*/
|
||||
isConstructor(): boolean;
|
||||
}
|
||||
|
||||
interface ErrnoException extends Error {
|
||||
errno?: number | undefined;
|
||||
code?: string | undefined;
|
||||
path?: string | undefined;
|
||||
syscall?: string | undefined;
|
||||
}
|
||||
|
||||
interface ReadableStream extends EventEmitter {
|
||||
readable: boolean;
|
||||
read(size?: number): string | Buffer;
|
||||
setEncoding(encoding: BufferEncoding): this;
|
||||
pause(): this;
|
||||
resume(): this;
|
||||
isPaused(): boolean;
|
||||
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean | undefined }): T;
|
||||
unpipe(destination?: WritableStream): this;
|
||||
unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
|
||||
wrap(oldStream: ReadableStream): this;
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
|
||||
}
|
||||
|
||||
interface WritableStream extends EventEmitter {
|
||||
writable: boolean;
|
||||
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
|
||||
write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
|
||||
end(cb?: () => void): this;
|
||||
end(data: string | Uint8Array, cb?: () => void): this;
|
||||
end(str: string, encoding?: BufferEncoding, cb?: () => void): this;
|
||||
}
|
||||
|
||||
interface ReadWriteStream extends ReadableStream, WritableStream {}
|
||||
|
||||
interface RefCounted {
|
||||
ref(): this;
|
||||
unref(): this;
|
||||
}
|
||||
|
||||
type TypedArray =
|
||||
| Uint8Array
|
||||
| Uint8ClampedArray
|
||||
| Uint16Array
|
||||
| Uint32Array
|
||||
| Int8Array
|
||||
| Int16Array
|
||||
| Int32Array
|
||||
| BigUint64Array
|
||||
| BigInt64Array
|
||||
| Float32Array
|
||||
| Float64Array;
|
||||
type ArrayBufferView = TypedArray | DataView;
|
||||
|
||||
interface Require {
|
||||
(id: string): any;
|
||||
resolve: RequireResolve;
|
||||
cache: Dict<NodeModule>;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
extensions: RequireExtensions;
|
||||
main: Module | undefined;
|
||||
}
|
||||
|
||||
interface RequireResolve {
|
||||
(id: string, options?: { paths?: string[] | undefined }): string;
|
||||
paths(request: string): string[] | null;
|
||||
}
|
||||
|
||||
interface RequireExtensions extends Dict<(m: Module, filename: string) => any> {
|
||||
".js": (m: Module, filename: string) => any;
|
||||
".json": (m: Module, filename: string) => any;
|
||||
".node": (m: Module, filename: string) => any;
|
||||
}
|
||||
interface Module {
|
||||
/**
|
||||
* `true` if the module is running during the Node.js preload
|
||||
*/
|
||||
isPreloading: boolean;
|
||||
exports: any;
|
||||
require: Require;
|
||||
id: string;
|
||||
filename: string;
|
||||
loaded: boolean;
|
||||
/** @deprecated since v14.6.0 Please use `require.main` and `module.children` instead. */
|
||||
parent: Module | null | undefined;
|
||||
children: Module[];
|
||||
/**
|
||||
* @since v11.14.0
|
||||
* Creates a `.stack` property on `targetObject`, which when accessed returns
|
||||
* a string representing the location in the code at which
|
||||
* `Error.captureStackTrace()` was called.
|
||||
*
|
||||
* The directory name of the module. This is usually the same as the path.dirname() of the module.id.
|
||||
* ```js
|
||||
* const myObject = {};
|
||||
* Error.captureStackTrace(myObject);
|
||||
* myObject.stack; // Similar to `new Error().stack`
|
||||
* ```
|
||||
*
|
||||
* The first line of the trace will be prefixed with
|
||||
* `${myObject.name}: ${myObject.message}`.
|
||||
*
|
||||
* The optional `constructorOpt` argument accepts a function. If given, all frames
|
||||
* above `constructorOpt`, including `constructorOpt`, will be omitted from the
|
||||
* generated stack trace.
|
||||
*
|
||||
* The `constructorOpt` argument is useful for hiding implementation
|
||||
* details of error generation from the user. For instance:
|
||||
*
|
||||
* ```js
|
||||
* function a() {
|
||||
* b();
|
||||
* }
|
||||
*
|
||||
* function b() {
|
||||
* c();
|
||||
* }
|
||||
*
|
||||
* function c() {
|
||||
* // Create an error without stack trace to avoid calculating the stack trace twice.
|
||||
* const { stackTraceLimit } = Error;
|
||||
* Error.stackTraceLimit = 0;
|
||||
* const error = new Error();
|
||||
* Error.stackTraceLimit = stackTraceLimit;
|
||||
*
|
||||
* // Capture the stack trace above function b
|
||||
* Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
|
||||
* throw error;
|
||||
* }
|
||||
*
|
||||
* a();
|
||||
* ```
|
||||
*/
|
||||
path: string;
|
||||
paths: string[];
|
||||
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
||||
/**
|
||||
* @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
||||
*/
|
||||
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
||||
/**
|
||||
* The `Error.stackTraceLimit` property specifies the number of stack frames
|
||||
* collected by a stack trace (whether generated by `new Error().stack` or
|
||||
* `Error.captureStackTrace(obj)`).
|
||||
*
|
||||
* The default value is `10` but may be set to any valid JavaScript number. Changes
|
||||
* will affect any stack trace captured _after_ the value has been changed.
|
||||
*
|
||||
* If set to a non-number value, or set to a negative number, stack traces will
|
||||
* not capture any frames.
|
||||
*/
|
||||
stackTraceLimit: number;
|
||||
}
|
||||
|
||||
interface Dict<T> {
|
||||
[key: string]: T | undefined;
|
||||
/**
|
||||
* Enable this API with the `--expose-gc` CLI flag.
|
||||
*/
|
||||
var gc: NodeJS.GCFunction | undefined;
|
||||
|
||||
namespace NodeJS {
|
||||
interface CallSite {
|
||||
getColumnNumber(): number | null;
|
||||
getEnclosingColumnNumber(): number | null;
|
||||
getEnclosingLineNumber(): number | null;
|
||||
getEvalOrigin(): string | undefined;
|
||||
getFileName(): string | null;
|
||||
getFunction(): Function | undefined;
|
||||
getFunctionName(): string | null;
|
||||
getLineNumber(): number | null;
|
||||
getMethodName(): string | null;
|
||||
getPosition(): number;
|
||||
getPromiseIndex(): number | null;
|
||||
getScriptHash(): string;
|
||||
getScriptNameOrSourceURL(): string | null;
|
||||
getThis(): unknown;
|
||||
getTypeName(): string | null;
|
||||
isAsync(): boolean;
|
||||
isConstructor(): boolean;
|
||||
isEval(): boolean;
|
||||
isNative(): boolean;
|
||||
isPromiseAll(): boolean;
|
||||
isToplevel(): boolean;
|
||||
}
|
||||
|
||||
interface ErrnoException extends Error {
|
||||
errno?: number | undefined;
|
||||
code?: string | undefined;
|
||||
path?: string | undefined;
|
||||
syscall?: string | undefined;
|
||||
}
|
||||
|
||||
interface ReadableStream extends EventEmitter {
|
||||
readable: boolean;
|
||||
read(size?: number): string | Buffer;
|
||||
setEncoding(encoding: BufferEncoding): this;
|
||||
pause(): this;
|
||||
resume(): this;
|
||||
isPaused(): boolean;
|
||||
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean | undefined }): T;
|
||||
unpipe(destination?: WritableStream): this;
|
||||
unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
|
||||
wrap(oldStream: ReadableStream): this;
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
|
||||
}
|
||||
|
||||
interface WritableStream extends EventEmitter {
|
||||
writable: boolean;
|
||||
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
|
||||
write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
|
||||
end(cb?: () => void): this;
|
||||
end(data: string | Uint8Array, cb?: () => void): this;
|
||||
end(str: string, encoding?: BufferEncoding, cb?: () => void): this;
|
||||
}
|
||||
|
||||
interface ReadWriteStream extends ReadableStream, WritableStream {}
|
||||
|
||||
interface RefCounted {
|
||||
ref(): this;
|
||||
unref(): this;
|
||||
}
|
||||
|
||||
interface Dict<T> {
|
||||
[key: string]: T | undefined;
|
||||
}
|
||||
|
||||
interface ReadOnlyDict<T> {
|
||||
readonly [key: string]: T | undefined;
|
||||
}
|
||||
|
||||
interface GCFunction {
|
||||
(minor?: boolean): void;
|
||||
(options: NodeJS.GCOptions & { execution: "async" }): Promise<void>;
|
||||
(options: NodeJS.GCOptions): void;
|
||||
}
|
||||
|
||||
interface GCOptions {
|
||||
execution?: "sync" | "async" | undefined;
|
||||
flavor?: "regular" | "last-resort" | undefined;
|
||||
type?: "major-snapshot" | "major" | "minor" | undefined;
|
||||
filename?: string | undefined;
|
||||
}
|
||||
|
||||
/** An iterable iterator returned by the Node.js API. */
|
||||
// Default TReturn/TNext in v20 is `any`, for compatibility with the previously-used IterableIterator.
|
||||
interface Iterator<T, TReturn = any, TNext = any> extends IteratorObject<T, TReturn, TNext> {
|
||||
[Symbol.iterator](): NodeJS.Iterator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
/** An async iterable iterator returned by the Node.js API. */
|
||||
// Default TReturn/TNext in v20 is `any`, for compatibility with the previously-used AsyncIterableIterator.
|
||||
interface AsyncIterator<T, TReturn = any, TNext = any> extends AsyncIteratorObject<T, TReturn, TNext> {
|
||||
[Symbol.asyncIterator](): NodeJS.AsyncIterator<T, TReturn, TNext>;
|
||||
}
|
||||
}
|
||||
|
||||
interface ReadOnlyDict<T> {
|
||||
readonly [key: string]: T | undefined;
|
||||
}
|
||||
// Global DOM types
|
||||
|
||||
namespace fetch {
|
||||
type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request;
|
||||
type _Response = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Response;
|
||||
type _FormData = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").FormData;
|
||||
type _Headers = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Headers;
|
||||
type _RequestInit = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("undici-types").RequestInit;
|
||||
type Request = globalThis.Request;
|
||||
type Response = globalThis.Response;
|
||||
type Headers = globalThis.Headers;
|
||||
type FormData = globalThis.FormData;
|
||||
type RequestInit = globalThis.RequestInit;
|
||||
type RequestInfo = import("undici-types").RequestInfo;
|
||||
type HeadersInit = import("undici-types").HeadersInit;
|
||||
type BodyInit = import("undici-types").BodyInit;
|
||||
type RequestRedirect = import("undici-types").RequestRedirect;
|
||||
type RequestCredentials = import("undici-types").RequestCredentials;
|
||||
type RequestMode = import("undici-types").RequestMode;
|
||||
type ReferrerPolicy = import("undici-types").ReferrerPolicy;
|
||||
type Dispatcher = import("undici-types").Dispatcher;
|
||||
type RequestDuplex = import("undici-types").RequestDuplex;
|
||||
interface DOMException extends _DOMException {}
|
||||
var DOMException: typeof globalThis extends { onmessage: any; DOMException: infer T } ? T
|
||||
: NodeDOMExceptionConstructor;
|
||||
|
||||
// #region AbortController
|
||||
interface AbortController {
|
||||
readonly signal: AbortSignal;
|
||||
abort(reason?: any): void;
|
||||
}
|
||||
var AbortController: typeof globalThis extends { onmessage: any; AbortController: infer T } ? T
|
||||
: {
|
||||
prototype: AbortController;
|
||||
new(): AbortController;
|
||||
};
|
||||
|
||||
interface AbortSignal extends EventTarget {
|
||||
readonly aborted: boolean;
|
||||
onabort: ((this: AbortSignal, ev: Event) => any) | null;
|
||||
readonly reason: any;
|
||||
throwIfAborted(): void;
|
||||
}
|
||||
var AbortSignal: typeof globalThis extends { onmessage: any; AbortSignal: infer T } ? T
|
||||
: {
|
||||
prototype: AbortSignal;
|
||||
new(): AbortSignal;
|
||||
abort(reason?: any): AbortSignal;
|
||||
any(signals: AbortSignal[]): AbortSignal;
|
||||
timeout(milliseconds: number): AbortSignal;
|
||||
};
|
||||
// #endregion AbortController
|
||||
|
||||
// #region fetch
|
||||
interface RequestInit extends _RequestInit {}
|
||||
|
||||
function fetch(
|
||||
input: string | URL | globalThis.Request,
|
||||
init?: RequestInit,
|
||||
): Promise<Response>;
|
||||
|
||||
interface Request extends _Request {}
|
||||
var Request: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
Request: infer T;
|
||||
} ? T
|
||||
: typeof import("undici-types").Request;
|
||||
|
||||
interface ResponseInit extends _ResponseInit {}
|
||||
|
||||
interface Response extends _Response {}
|
||||
var Response: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
Response: infer T;
|
||||
} ? T
|
||||
: typeof import("undici-types").Response;
|
||||
|
||||
interface FormData extends _FormData {}
|
||||
var FormData: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
FormData: infer T;
|
||||
} ? T
|
||||
: typeof import("undici-types").FormData;
|
||||
|
||||
interface Headers extends _Headers {}
|
||||
var Headers: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
Headers: infer T;
|
||||
} ? T
|
||||
: typeof import("undici-types").Headers;
|
||||
|
||||
interface MessageEvent extends _MessageEvent {}
|
||||
var MessageEvent: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
MessageEvent: infer T;
|
||||
} ? T
|
||||
: typeof import("undici-types").MessageEvent;
|
||||
|
||||
interface EventSource extends _EventSource {}
|
||||
var EventSource: typeof globalThis extends { onmessage: any; EventSource: infer T } ? T
|
||||
: typeof import("undici-types").EventSource;
|
||||
// #endregion fetch
|
||||
}
|
||||
|
||||
interface RequestInit extends NodeJS.fetch._RequestInit {}
|
||||
|
||||
declare function fetch(
|
||||
input: NodeJS.fetch.RequestInfo,
|
||||
init?: RequestInit,
|
||||
): Promise<Response>;
|
||||
|
||||
interface Request extends NodeJS.fetch._Request {}
|
||||
declare var Request: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
Request: infer T;
|
||||
} ? T
|
||||
: typeof import("undici-types").Request;
|
||||
|
||||
interface Response extends NodeJS.fetch._Response {}
|
||||
declare var Response: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
Response: infer T;
|
||||
} ? T
|
||||
: typeof import("undici-types").Response;
|
||||
|
||||
interface FormData extends NodeJS.fetch._FormData {}
|
||||
declare var FormData: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
FormData: infer T;
|
||||
} ? T
|
||||
: typeof import("undici-types").FormData;
|
||||
|
||||
interface Headers extends NodeJS.fetch._Headers {}
|
||||
declare var Headers: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
Headers: infer T;
|
||||
} ? T
|
||||
: typeof import("undici-types").Headers;
|
||||
|
||||
1
node_modules/@types/node/globals.global.d.ts
generated
vendored
1
node_modules/@types/node/globals.global.d.ts
generated
vendored
@@ -1 +0,0 @@
|
||||
declare var global: typeof globalThis;
|
||||
21
node_modules/@types/node/globals.typedarray.d.ts
generated
vendored
Normal file
21
node_modules/@types/node/globals.typedarray.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export {}; // Make this a module
|
||||
|
||||
declare global {
|
||||
namespace NodeJS {
|
||||
type TypedArray<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> =
|
||||
| Uint8Array<TArrayBuffer>
|
||||
| Uint8ClampedArray<TArrayBuffer>
|
||||
| Uint16Array<TArrayBuffer>
|
||||
| Uint32Array<TArrayBuffer>
|
||||
| Int8Array<TArrayBuffer>
|
||||
| Int16Array<TArrayBuffer>
|
||||
| Int32Array<TArrayBuffer>
|
||||
| BigUint64Array<TArrayBuffer>
|
||||
| BigInt64Array<TArrayBuffer>
|
||||
| Float32Array<TArrayBuffer>
|
||||
| Float64Array<TArrayBuffer>;
|
||||
type ArrayBufferView<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> =
|
||||
| TypedArray<TArrayBuffer>
|
||||
| DataView<TArrayBuffer>;
|
||||
}
|
||||
}
|
||||
279
node_modules/@types/node/http.d.ts
generated
vendored
279
node_modules/@types/node/http.d.ts
generated
vendored
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* To use the HTTP server and client one must `require('node:http')`.
|
||||
* To use the HTTP server and client one must import the `node:http` module.
|
||||
*
|
||||
* The HTTP interfaces in Node.js are designed to support many features
|
||||
* of the protocol which have been traditionally difficult to use.
|
||||
@@ -9,12 +9,12 @@
|
||||
*
|
||||
* HTTP message headers are represented by an object like this:
|
||||
*
|
||||
* ```js
|
||||
* { 'content-length': '123',
|
||||
* 'content-type': 'text/plain',
|
||||
* 'connection': 'keep-alive',
|
||||
* 'host': 'example.com',
|
||||
* 'accept': '*' }
|
||||
* ```json
|
||||
* { "content-length": "123",
|
||||
* "content-type": "text/plain",
|
||||
* "connection": "keep-alive",
|
||||
* "host": "example.com",
|
||||
* "accept": "*" }
|
||||
* ```
|
||||
*
|
||||
* Keys are lowercased. Values are not modified.
|
||||
@@ -26,8 +26,8 @@
|
||||
*
|
||||
* See `message.headers` for details on how duplicate headers are handled.
|
||||
*
|
||||
* The raw headers as they were received are retained in the `rawHeaders`property, which is an array of `[key, value, key2, value2, ...]`. For
|
||||
* example, the previous message header object might have a `rawHeaders`list like the following:
|
||||
* The raw headers as they were received are retained in the `rawHeaders` property, which is an array of `[key, value, key2, value2, ...]`. For
|
||||
* example, the previous message header object might have a `rawHeaders` list like the following:
|
||||
*
|
||||
* ```js
|
||||
* [ 'ConTent-Length', '123456',
|
||||
@@ -37,7 +37,7 @@
|
||||
* 'Host', 'example.com',
|
||||
* 'accepT', '*' ]
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/http.js)
|
||||
*/
|
||||
declare module "http" {
|
||||
import * as stream from "node:stream";
|
||||
@@ -48,6 +48,7 @@ declare module "http" {
|
||||
// incoming headers will never contain number
|
||||
interface IncomingHttpHeaders extends NodeJS.Dict<string | string[]> {
|
||||
accept?: string | undefined;
|
||||
"accept-encoding"?: string | undefined;
|
||||
"accept-language"?: string | undefined;
|
||||
"accept-patch"?: string | undefined;
|
||||
"accept-ranges"?: string | undefined;
|
||||
@@ -94,6 +95,10 @@ declare module "http" {
|
||||
range?: string | undefined;
|
||||
referer?: string | undefined;
|
||||
"retry-after"?: string | undefined;
|
||||
"sec-fetch-site"?: string | undefined;
|
||||
"sec-fetch-mode"?: string | undefined;
|
||||
"sec-fetch-user"?: string | undefined;
|
||||
"sec-fetch-dest"?: string | undefined;
|
||||
"sec-websocket-accept"?: string | undefined;
|
||||
"sec-websocket-extensions"?: string | undefined;
|
||||
"sec-websocket-key"?: string | undefined;
|
||||
@@ -161,7 +166,7 @@ declare module "http" {
|
||||
location?: string | undefined;
|
||||
"max-forwards"?: string | undefined;
|
||||
origin?: string | undefined;
|
||||
prgama?: string | string[] | undefined;
|
||||
pragma?: string | string[] | undefined;
|
||||
"proxy-authenticate"?: string | string[] | undefined;
|
||||
"proxy-authorization"?: string | undefined;
|
||||
"public-key-pins"?: string | undefined;
|
||||
@@ -198,13 +203,15 @@ declare module "http" {
|
||||
_defaultAgent?: Agent | undefined;
|
||||
agent?: Agent | boolean | undefined;
|
||||
auth?: string | null | undefined;
|
||||
// https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278
|
||||
createConnection?:
|
||||
| ((options: ClientRequestArgs, oncreate: (err: Error, socket: Socket) => void) => Socket)
|
||||
| ((
|
||||
options: ClientRequestArgs,
|
||||
oncreate: (err: Error | null, socket: stream.Duplex) => void,
|
||||
) => stream.Duplex | null | undefined)
|
||||
| undefined;
|
||||
defaultPort?: number | string | undefined;
|
||||
family?: number | undefined;
|
||||
headers?: OutgoingHttpHeaders | undefined;
|
||||
headers?: OutgoingHttpHeaders | readonly string[] | undefined;
|
||||
hints?: LookupOptions["hints"];
|
||||
host?: string | null | undefined;
|
||||
hostname?: string | null | undefined;
|
||||
@@ -229,7 +236,7 @@ declare module "http" {
|
||||
}
|
||||
interface ServerOptions<
|
||||
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
||||
Response extends typeof ServerResponse = typeof ServerResponse,
|
||||
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
|
||||
> {
|
||||
/**
|
||||
* Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`.
|
||||
@@ -265,6 +272,13 @@ declare module "http" {
|
||||
* @default 30000
|
||||
*/
|
||||
connectionsCheckingInterval?: number | undefined;
|
||||
/**
|
||||
* Sets the timeout value in milliseconds for receiving the complete HTTP headers from the client.
|
||||
* See {@link Server.headersTimeout} for more information.
|
||||
* @default 60000
|
||||
* @since 18.0.0
|
||||
*/
|
||||
headersTimeout?: number | undefined;
|
||||
/**
|
||||
* Optionally overrides all `socket`s' `readableHighWaterMark` and `writableHighWaterMark`.
|
||||
* This affects `highWaterMark` property of both `IncomingMessage` and `ServerResponse`.
|
||||
@@ -280,9 +294,8 @@ declare module "http" {
|
||||
*/
|
||||
insecureHTTPParser?: boolean | undefined;
|
||||
/**
|
||||
* Optionally overrides the value of
|
||||
* `--max-http-header-size` for requests received by this server, i.e.
|
||||
* the maximum length of request headers in bytes.
|
||||
* Optionally overrides the value of `--max-http-header-size` for requests received by
|
||||
* this server, i.e. the maximum length of request headers in bytes.
|
||||
* @default 16384
|
||||
* @since v13.3.0
|
||||
*/
|
||||
@@ -293,6 +306,13 @@ declare module "http" {
|
||||
* @since v16.5.0
|
||||
*/
|
||||
noDelay?: boolean | undefined;
|
||||
/**
|
||||
* If set to `true`, it forces the server to respond with a 400 (Bad Request) status code
|
||||
* to any HTTP/1.1 request message that lacks a Host header (as mandated by the specification).
|
||||
* @default true
|
||||
* @since 20.0.0
|
||||
*/
|
||||
requireHostHeader?: boolean | undefined;
|
||||
/**
|
||||
* If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
|
||||
* similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`.
|
||||
@@ -311,17 +331,23 @@ declare module "http" {
|
||||
* If the header's value is an array, the items will be joined using `; `.
|
||||
*/
|
||||
uniqueHeaders?: Array<string | string[]> | undefined;
|
||||
/**
|
||||
* If set to `true`, an error is thrown when writing to an HTTP response which does not have a body.
|
||||
* @default false
|
||||
* @since v18.17.0, v20.2.0
|
||||
*/
|
||||
rejectNonStandardBodyWrites?: boolean | undefined;
|
||||
}
|
||||
type RequestListener<
|
||||
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
||||
Response extends typeof ServerResponse = typeof ServerResponse,
|
||||
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
|
||||
> = (req: InstanceType<Request>, res: InstanceType<Response> & { req: InstanceType<Request> }) => void;
|
||||
/**
|
||||
* @since v0.1.17
|
||||
*/
|
||||
class Server<
|
||||
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
||||
Response extends typeof ServerResponse = typeof ServerResponse,
|
||||
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
|
||||
> extends NetServer {
|
||||
constructor(requestListener?: RequestListener<Request, Response>);
|
||||
constructor(options: ServerOptions<Request, Response>, requestListener?: RequestListener<Request, Response>);
|
||||
@@ -339,8 +365,8 @@ declare module "http" {
|
||||
* @since v0.9.12
|
||||
* @param [msecs=0 (no timeout)]
|
||||
*/
|
||||
setTimeout(msecs?: number, callback?: () => void): this;
|
||||
setTimeout(callback: () => void): this;
|
||||
setTimeout(msecs?: number, callback?: (socket: Socket) => void): this;
|
||||
setTimeout(callback: (socket: Socket) => void): this;
|
||||
/**
|
||||
* Limits maximum incoming headers count. If set to 0, no limit will be applied.
|
||||
* @since v0.7.0
|
||||
@@ -386,7 +412,7 @@ declare module "http" {
|
||||
* The number of milliseconds of inactivity a server needs to wait for additional
|
||||
* incoming data, after it has finished writing the last response, before a socket
|
||||
* will be destroyed. If the server receives new data before the keep-alive
|
||||
* timeout has fired, it will reset the regular inactivity timeout, i.e.,`server.timeout`.
|
||||
* timeout has fired, it will reset the regular inactivity timeout, i.e., `server.timeout`.
|
||||
*
|
||||
* A value of `0` will disable the keep-alive timeout behavior on incoming
|
||||
* connections.
|
||||
@@ -573,7 +599,7 @@ declare module "http" {
|
||||
readonly socket: Socket | null;
|
||||
constructor();
|
||||
/**
|
||||
* Once a socket is associated with the message and is connected,`socket.setTimeout()` will be called with `msecs` as the first parameter.
|
||||
* Once a socket is associated with the message and is connected, `socket.setTimeout()` will be called with `msecs` as the first parameter.
|
||||
* @since v0.9.12
|
||||
* @param callback Optional function to be called when a timeout occurs. Same as binding to the `timeout` event.
|
||||
*/
|
||||
@@ -586,14 +612,50 @@ declare module "http" {
|
||||
* @param name Header name
|
||||
* @param value Header value
|
||||
*/
|
||||
setHeader(name: string, value: number | string | ReadonlyArray<string>): this;
|
||||
setHeader(name: string, value: number | string | readonly string[]): this;
|
||||
/**
|
||||
* Append a single header value for the header object.
|
||||
* Sets multiple header values for implicit headers. headers must be an instance of
|
||||
* `Headers` or `Map`, if a header already exists in the to-be-sent headers, its
|
||||
* value will be replaced.
|
||||
*
|
||||
* If the value is an array, this is equivalent of calling this method multiple
|
||||
* ```js
|
||||
* const headers = new Headers({ foo: 'bar' });
|
||||
* outgoingMessage.setHeaders(headers);
|
||||
* ```
|
||||
*
|
||||
* or
|
||||
*
|
||||
* ```js
|
||||
* const headers = new Map([['foo', 'bar']]);
|
||||
* outgoingMessage.setHeaders(headers);
|
||||
* ```
|
||||
*
|
||||
* When headers have been set with `outgoingMessage.setHeaders()`, they will be
|
||||
* merged with any headers passed to `response.writeHead()`, with the headers passed
|
||||
* to `response.writeHead()` given precedence.
|
||||
*
|
||||
* ```js
|
||||
* // Returns content-type = text/plain
|
||||
* const server = http.createServer((req, res) => {
|
||||
* const headers = new Headers({ 'Content-Type': 'text/html' });
|
||||
* res.setHeaders(headers);
|
||||
* res.writeHead(200, { 'Content-Type': 'text/plain' });
|
||||
* res.end('ok');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @since v19.6.0, v18.15.0
|
||||
* @param name Header name
|
||||
* @param value Header value
|
||||
*/
|
||||
setHeaders(headers: Headers | Map<string, number | string | readonly string[]>): this;
|
||||
/**
|
||||
* Append a single header value to the header object.
|
||||
*
|
||||
* If the value is an array, this is equivalent to calling this method multiple
|
||||
* times.
|
||||
*
|
||||
* If there were no previous value for the header, this is equivalent of calling `outgoingMessage.setHeader(name, value)`.
|
||||
* If there were no previous values for the header, this is equivalent to calling `outgoingMessage.setHeader(name, value)`.
|
||||
*
|
||||
* Depending of the value of `options.uniqueHeaders` when the client request or the
|
||||
* server were created, this will end up in the header being sent multiple times or
|
||||
@@ -602,7 +664,7 @@ declare module "http" {
|
||||
* @param name Header name
|
||||
* @param value Header value
|
||||
*/
|
||||
appendHeader(name: string, value: string | ReadonlyArray<string>): this;
|
||||
appendHeader(name: string, value: string | readonly string[]): this;
|
||||
/**
|
||||
* Gets the value of the HTTP header with the given name. If that header is not
|
||||
* set, the returned value will be `undefined`.
|
||||
@@ -689,7 +751,7 @@ declare module "http" {
|
||||
* packet.
|
||||
*
|
||||
* It is usually desired (it saves a TCP round-trip), but not when the first
|
||||
* data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the message.
|
||||
* data is not sent until possibly much later. `outgoingMessage.flushHeaders()` bypasses the optimization and kickstarts the message.
|
||||
* @since v1.6.0
|
||||
*/
|
||||
flushHeaders(): void;
|
||||
@@ -730,7 +792,7 @@ declare module "http" {
|
||||
*/
|
||||
statusMessage: string;
|
||||
/**
|
||||
* If set to `true`, Node.js will check whether the `Content-Length`header value and the size of the body, in bytes, are equal.
|
||||
* If set to `true`, Node.js will check whether the `Content-Length` header value and the size of the body, in bytes, are equal.
|
||||
* Mismatching the `Content-Length` header value will result
|
||||
* in an `Error` being thrown, identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`.
|
||||
* @since v18.10.0, v16.18.0
|
||||
@@ -741,7 +803,7 @@ declare module "http" {
|
||||
detachSocket(socket: Socket): void;
|
||||
/**
|
||||
* Sends an HTTP/1.1 100 Continue message to the client, indicating that
|
||||
* the request body should be sent. See the `'checkContinue'` event on`Server`.
|
||||
* the request body should be sent. See the `'checkContinue'` event on `Server`.
|
||||
* @since v0.3.0
|
||||
*/
|
||||
writeContinue(callback?: () => void): void;
|
||||
@@ -847,7 +909,7 @@ declare module "http" {
|
||||
* the request body should be sent.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
writeProcessing(): void;
|
||||
writeProcessing(callback?: () => void): void;
|
||||
}
|
||||
interface InformationEvent {
|
||||
statusCode: number;
|
||||
@@ -861,10 +923,10 @@ declare module "http" {
|
||||
/**
|
||||
* This object is created internally and returned from {@link request}. It
|
||||
* represents an _in-progress_ request whose header has already been queued. The
|
||||
* header is still mutable using the `setHeader(name, value)`,`getHeader(name)`, `removeHeader(name)` API. The actual header will
|
||||
* header is still mutable using the `setHeader(name, value)`, `getHeader(name)`, `removeHeader(name)` API. The actual header will
|
||||
* be sent along with the first data chunk or when calling `request.end()`.
|
||||
*
|
||||
* To get the response, add a listener for `'response'` to the request object.`'response'` will be emitted from the request object when the response
|
||||
* To get the response, add a listener for `'response'` to the request object. `'response'` will be emitted from the request object when the response
|
||||
* headers have been received. The `'response'` event is executed with one
|
||||
* argument which is an instance of {@link IncomingMessage}.
|
||||
*
|
||||
@@ -880,10 +942,10 @@ declare module "http" {
|
||||
* the data is read it will consume memory that can eventually lead to a
|
||||
* 'process out of memory' error.
|
||||
*
|
||||
* For backward compatibility, `res` will only emit `'error'` if there is an`'error'` listener registered.
|
||||
* For backward compatibility, `res` will only emit `'error'` if there is an `'error'` listener registered.
|
||||
*
|
||||
* Set `Content-Length` header to limit the response body size.
|
||||
* If `response.strictContentLength` is set to `true`, mismatching the`Content-Length` header value will result in an `Error` being thrown,
|
||||
* If `response.strictContentLength` is set to `true`, mismatching the `Content-Length` header value will result in an `Error` being thrown,
|
||||
* identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`.
|
||||
*
|
||||
* `Content-Length` value should be in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes.
|
||||
@@ -894,7 +956,7 @@ declare module "http" {
|
||||
* The `request.aborted` property will be `true` if the request has
|
||||
* been aborted.
|
||||
* @since v0.11.14
|
||||
* @deprecated Since v17.0.0,v16.12.0 - Check `destroyed` instead.
|
||||
* @deprecated Since v17.0.0, v16.12.0 - Check `destroyed` instead.
|
||||
*/
|
||||
aborted: boolean;
|
||||
/**
|
||||
@@ -1126,7 +1188,7 @@ declare module "http" {
|
||||
* access response
|
||||
* status, headers, and data.
|
||||
*
|
||||
* Different from its `socket` value which is a subclass of `stream.Duplex`, the`IncomingMessage` itself extends `stream.Readable` and is created separately to
|
||||
* Different from its `socket` value which is a subclass of `stream.Duplex`, the `IncomingMessage` itself extends `stream.Readable` and is created separately to
|
||||
* parse and emit the incoming HTTP headers and payload, as the underlying socket
|
||||
* may be reused multiple times in case of keep-alive.
|
||||
* @since v0.1.17
|
||||
@@ -1145,7 +1207,7 @@ declare module "http" {
|
||||
* client response, the HTTP version of the connected-to server.
|
||||
* Probably either `'1.1'` or `'1.0'`.
|
||||
*
|
||||
* Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second.
|
||||
* Also `message.httpVersionMajor` is the first integer and `message.httpVersionMinor` is the second.
|
||||
* @since v0.1.1
|
||||
*/
|
||||
httpVersion: string;
|
||||
@@ -1210,8 +1272,8 @@ declare module "http" {
|
||||
* Duplicates in raw headers are handled in the following ways, depending on the
|
||||
* header name:
|
||||
*
|
||||
* * Duplicates of `age`, `authorization`, `content-length`, `content-type`,`etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`,`last-modified`, `location`,
|
||||
* `max-forwards`, `proxy-authorization`, `referer`,`retry-after`, `server`, or `user-agent` are discarded.
|
||||
* * Duplicates of `age`, `authorization`, `content-length`, `content-type`, `etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,
|
||||
* `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`, or `user-agent` are discarded.
|
||||
* To allow duplicate values of the headers listed above to be joined,
|
||||
* use the option `joinDuplicateHeaders` in {@link request} and {@link createServer}. See RFC 9110 Section 5.3 for more
|
||||
* information.
|
||||
@@ -1305,29 +1367,32 @@ declare module "http" {
|
||||
* To parse the URL into its parts:
|
||||
*
|
||||
* ```js
|
||||
* new URL(request.url, `http://${request.headers.host}`);
|
||||
* new URL(`http://${process.env.HOST ?? 'localhost'}${request.url}`);
|
||||
* ```
|
||||
*
|
||||
* When `request.url` is `'/status?name=ryan'` and `request.headers.host` is`'localhost:3000'`:
|
||||
* When `request.url` is `'/status?name=ryan'` and `process.env.HOST` is undefined:
|
||||
*
|
||||
* ```console
|
||||
* $ node
|
||||
* > new URL(request.url, `http://${request.headers.host}`)
|
||||
* > new URL(`http://${process.env.HOST ?? 'localhost'}${request.url}`);
|
||||
* URL {
|
||||
* href: 'http://localhost:3000/status?name=ryan',
|
||||
* origin: 'http://localhost:3000',
|
||||
* href: 'http://localhost/status?name=ryan',
|
||||
* origin: 'http://localhost',
|
||||
* protocol: 'http:',
|
||||
* username: '',
|
||||
* password: '',
|
||||
* host: 'localhost:3000',
|
||||
* host: 'localhost',
|
||||
* hostname: 'localhost',
|
||||
* port: '3000',
|
||||
* port: '',
|
||||
* pathname: '/status',
|
||||
* search: '?name=ryan',
|
||||
* searchParams: URLSearchParams { 'name' => 'ryan' },
|
||||
* hash: ''
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Ensure that you set `process.env.HOST` to the server's host name, or consider replacing this part entirely. If using `req.headers.host`, ensure proper
|
||||
* validation is used, as clients may specify a custom `Host` header.
|
||||
* @since v0.1.90
|
||||
*/
|
||||
url?: string | undefined;
|
||||
@@ -1346,7 +1411,7 @@ declare module "http" {
|
||||
*/
|
||||
statusMessage?: string | undefined;
|
||||
/**
|
||||
* Calls `destroy()` on the socket that received the `IncomingMessage`. If `error`is provided, an `'error'` event is emitted on the socket and `error` is passed
|
||||
* Calls `destroy()` on the socket that received the `IncomingMessage`. If `error` is provided, an `'error'` event is emitted on the socket and `error` is passed
|
||||
* as an argument to any listeners on the event.
|
||||
* @since v0.3.0
|
||||
*/
|
||||
@@ -1390,7 +1455,7 @@ declare module "http" {
|
||||
* for a given host and port, reusing a single socket connection for each
|
||||
* until the queue is empty, at which time the socket is either destroyed
|
||||
* or put into a pool where it is kept to be used again for requests to the
|
||||
* same host and port. Whether it is destroyed or pooled depends on the`keepAlive` `option`.
|
||||
* same host and port. Whether it is destroyed or pooled depends on the `keepAlive` `option`.
|
||||
*
|
||||
* Pooled connections have TCP Keep-Alive enabled for them, but servers may
|
||||
* still close idle connections, in which case they will be removed from the
|
||||
@@ -1421,7 +1486,7 @@ declare module "http" {
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* An agent may also be used for an individual request. By providing`{agent: false}` as an option to the `http.get()` or `http.request()`functions, a one-time use `Agent` with default options
|
||||
* An agent may also be used for an individual request. By providing `{agent: false}` as an option to the `http.get()` or `http.request()` functions, a one-time use `Agent` with default options
|
||||
* will be used
|
||||
* for the client connection.
|
||||
*
|
||||
@@ -1437,6 +1502,17 @@ declare module "http" {
|
||||
* // Do stuff with response
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* `options` in [`socket.connect()`](https://nodejs.org/docs/latest-v20.x/api/net.html#socketconnectoptions-connectlistener) are also supported.
|
||||
*
|
||||
* To configure any of them, a custom {@link Agent} instance must be created.
|
||||
*
|
||||
* ```js
|
||||
* import http from 'node:http';
|
||||
* const keepAliveAgent = new http.Agent({ keepAlive: true });
|
||||
* options.agent = keepAliveAgent;
|
||||
* http.request(options, onResponseCallback)
|
||||
* ```
|
||||
* @since v0.3.4
|
||||
*/
|
||||
class Agent extends EventEmitter {
|
||||
@@ -1492,6 +1568,68 @@ declare module "http" {
|
||||
* @since v0.11.4
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Produces a socket/stream to be used for HTTP requests.
|
||||
*
|
||||
* By default, this function is the same as `net.createConnection()`. However,
|
||||
* custom agents may override this method in case greater flexibility is desired.
|
||||
*
|
||||
* A socket/stream can be supplied in one of two ways: by returning the
|
||||
* socket/stream from this function, or by passing the socket/stream to `callback`.
|
||||
*
|
||||
* This method is guaranteed to return an instance of the `net.Socket` class,
|
||||
* a subclass of `stream.Duplex`, unless the user specifies a socket
|
||||
* type other than `net.Socket`.
|
||||
*
|
||||
* `callback` has a signature of `(err, stream)`.
|
||||
* @since v0.11.4
|
||||
* @param options Options containing connection details. Check `createConnection` for the format of the options
|
||||
* @param callback Callback function that receives the created socket
|
||||
*/
|
||||
createConnection(
|
||||
options: ClientRequestArgs,
|
||||
callback?: (err: Error | null, stream: stream.Duplex) => void,
|
||||
): stream.Duplex;
|
||||
/**
|
||||
* Called when `socket` is detached from a request and could be persisted by the`Agent`. Default behavior is to:
|
||||
*
|
||||
* ```js
|
||||
* socket.setKeepAlive(true, this.keepAliveMsecs);
|
||||
* socket.unref();
|
||||
* return true;
|
||||
* ```
|
||||
*
|
||||
* This method can be overridden by a particular `Agent` subclass. If this
|
||||
* method returns a falsy value, the socket will be destroyed instead of persisting
|
||||
* it for use with the next request.
|
||||
*
|
||||
* The `socket` argument can be an instance of `net.Socket`, a subclass of `stream.Duplex`.
|
||||
* @since v8.1.0
|
||||
*/
|
||||
keepSocketAlive(socket: stream.Duplex): void;
|
||||
/**
|
||||
* Called when `socket` is attached to `request` after being persisted because of
|
||||
* the keep-alive options. Default behavior is to:
|
||||
*
|
||||
* ```js
|
||||
* socket.ref();
|
||||
* ```
|
||||
*
|
||||
* This method can be overridden by a particular `Agent` subclass.
|
||||
*
|
||||
* The `socket` argument can be an instance of `net.Socket`, a subclass of `stream.Duplex`.
|
||||
* @since v8.1.0
|
||||
*/
|
||||
reuseSocket(socket: stream.Duplex, request: ClientRequest): void;
|
||||
/**
|
||||
* Get a unique name for a set of request options, to determine whether a
|
||||
* connection can be reused. For an HTTP agent, this returns`host:port:localAddress` or `host:port:localAddress:family`. For an HTTPS agent,
|
||||
* the name includes the CA, cert, ciphers, and other HTTPS/TLS-specific options
|
||||
* that determine socket reusability.
|
||||
* @since v0.11.4
|
||||
* @param options A set of options providing information for name generation
|
||||
*/
|
||||
getName(options?: ClientRequestArgs): string;
|
||||
}
|
||||
const METHODS: string[];
|
||||
const STATUS_CODES: {
|
||||
@@ -1538,11 +1676,11 @@ declare module "http" {
|
||||
*/
|
||||
function createServer<
|
||||
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
||||
Response extends typeof ServerResponse = typeof ServerResponse,
|
||||
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
|
||||
>(requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
|
||||
function createServer<
|
||||
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
||||
Response extends typeof ServerResponse = typeof ServerResponse,
|
||||
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
|
||||
>(
|
||||
options: ServerOptions<Request, Response>,
|
||||
requestListener?: RequestListener<Request, Response>,
|
||||
@@ -1559,7 +1697,7 @@ declare module "http" {
|
||||
* `url` can be a string or a `URL` object. If `url` 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.
|
||||
*
|
||||
* If both `url` and `options` are specified, the objects are merged, with the`options` properties taking precedence.
|
||||
* If both `url` and `options` are specified, the objects are merged, with the `options` properties taking precedence.
|
||||
*
|
||||
* The optional `callback` parameter will be added as a one-time listener for
|
||||
* the `'response'` event.
|
||||
@@ -1659,7 +1797,7 @@ declare module "http" {
|
||||
* the following events will be emitted in the following order:
|
||||
*
|
||||
* * `'socket'`
|
||||
* * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
|
||||
* * `'error'` with an error with message `'Error: socket hang up'` and code `'ECONNRESET'`
|
||||
* * `'close'`
|
||||
*
|
||||
* In the case of a premature connection close after the response is received,
|
||||
@@ -1670,15 +1808,15 @@ declare module "http" {
|
||||
* * `'data'` any number of times, on the `res` object
|
||||
* * (connection closed here)
|
||||
* * `'aborted'` on the `res` object
|
||||
* * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`
|
||||
* * `'close'`
|
||||
* * `'error'` on the `res` object with an error with message `'Error: aborted'` and code `'ECONNRESET'`
|
||||
* * `'close'` on the `res` object
|
||||
*
|
||||
* If `req.destroy()` is called before a socket is assigned, the following
|
||||
* events will be emitted in the following order:
|
||||
*
|
||||
* * (`req.destroy()` called here)
|
||||
* * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called
|
||||
* * `'error'` with an error with message `'Error: socket hang up'` and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
|
||||
* * `'close'`
|
||||
*
|
||||
* If `req.destroy()` is called before the connection succeeds, the following
|
||||
@@ -1686,7 +1824,7 @@ declare module "http" {
|
||||
*
|
||||
* * `'socket'`
|
||||
* * (`req.destroy()` called here)
|
||||
* * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called
|
||||
* * `'error'` with an error with message `'Error: socket hang up'` and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
|
||||
* * `'close'`
|
||||
*
|
||||
* If `req.destroy()` is called after the response is received, the following
|
||||
@@ -1697,8 +1835,8 @@ declare module "http" {
|
||||
* * `'data'` any number of times, on the `res` object
|
||||
* * (`req.destroy()` called here)
|
||||
* * `'aborted'` on the `res` object
|
||||
* * `'error'` on the `res` object with an error with message `'Error: aborted'`and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
|
||||
* * `'close'`
|
||||
* * `'error'` on the `res` object with an error with message `'Error: aborted'` and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
|
||||
* * `'close'` on the `res` object
|
||||
*
|
||||
* If `req.abort()` is called before a socket is assigned, the following
|
||||
@@ -1714,7 +1852,7 @@ declare module "http" {
|
||||
* * `'socket'`
|
||||
* * (`req.abort()` called here)
|
||||
* * `'abort'`
|
||||
* * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
|
||||
* * `'error'` with an error with message `'Error: socket hang up'` and code `'ECONNRESET'`
|
||||
* * `'close'`
|
||||
*
|
||||
* If `req.abort()` is called after the response is received, the following
|
||||
@@ -1726,16 +1864,16 @@ declare module "http" {
|
||||
* * (`req.abort()` called here)
|
||||
* * `'abort'`
|
||||
* * `'aborted'` on the `res` object
|
||||
* * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`.
|
||||
* * `'error'` on the `res` object with an error with message `'Error: aborted'` and code `'ECONNRESET'`.
|
||||
* * `'close'`
|
||||
* * `'close'` on the `res` object
|
||||
*
|
||||
* Setting the `timeout` option or using the `setTimeout()` function will
|
||||
* not abort the request or do anything besides add a `'timeout'` event.
|
||||
*
|
||||
* Passing an `AbortSignal` and then calling `abort()` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the
|
||||
* Passing an `AbortSignal` and then calling `abort()` on the corresponding `AbortController` will behave the same way as calling `.destroy()` on the
|
||||
* request. Specifically, the `'error'` event will be emitted with an error with
|
||||
* the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'`and the `cause`, if one was provided.
|
||||
* the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'` and the `cause`, if one was provided.
|
||||
* @since v0.3.6
|
||||
*/
|
||||
function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
|
||||
@@ -1746,7 +1884,7 @@ declare module "http" {
|
||||
): ClientRequest;
|
||||
/**
|
||||
* Since most requests are GET requests without bodies, Node.js provides this
|
||||
* convenience method. The only difference between this method and {@link request} is that it sets the method to GET by default and calls `req.end()`automatically. The callback must take care to
|
||||
* convenience method. The only difference between this method and {@link request} is that it sets the method to GET by default and calls `req.end()` automatically. The callback must take care to
|
||||
* consume the response
|
||||
* data for reasons stated in {@link ClientRequest} section.
|
||||
*
|
||||
@@ -1807,14 +1945,13 @@ declare module "http" {
|
||||
function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
|
||||
function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
|
||||
/**
|
||||
* Performs the low-level validations on the provided `name` that are done when`res.setHeader(name, value)` is called.
|
||||
* Performs the low-level validations on the provided `name` that are done when `res.setHeader(name, value)` is called.
|
||||
*
|
||||
* Passing illegal value as `name` will result in a `TypeError` being thrown,
|
||||
* identified by `code: 'ERR_INVALID_HTTP_TOKEN'`.
|
||||
*
|
||||
* It is not necessary to use this method before passing headers to an HTTP request
|
||||
* or response. The HTTP module will automatically validate such headers.
|
||||
* Examples:
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
@@ -1834,7 +1971,7 @@ declare module "http" {
|
||||
*/
|
||||
function validateHeaderName(name: string): void;
|
||||
/**
|
||||
* Performs the low-level validations on the provided `value` that are done when`res.setHeader(name, value)` is called.
|
||||
* Performs the low-level validations on the provided `value` that are done when `res.setHeader(name, value)` is called.
|
||||
*
|
||||
* Passing illegal value as `value` will result in a `TypeError` being thrown.
|
||||
*
|
||||
@@ -1876,6 +2013,12 @@ declare module "http" {
|
||||
* @param [max=1000]
|
||||
*/
|
||||
function setMaxIdleHTTPParsers(max: number): void;
|
||||
/**
|
||||
* Global instance of `Agent` which is used as the default for all HTTP client
|
||||
* requests. Diverges from a default `Agent` configuration by having `keepAlive`
|
||||
* enabled and a `timeout` of 5 seconds.
|
||||
* @since v0.5.9
|
||||
*/
|
||||
let globalAgent: Agent;
|
||||
/**
|
||||
* Read-only property specifying the maximum allowed size of HTTP headers in bytes.
|
||||
|
||||
546
node_modules/@types/node/http2.d.ts
generated
vendored
546
node_modules/@types/node/http2.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
46
node_modules/@types/node/https.d.ts
generated
vendored
46
node_modules/@types/node/https.d.ts
generated
vendored
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a
|
||||
* separate module.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/https.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/https.js)
|
||||
*/
|
||||
declare module "https" {
|
||||
import { Duplex } from "node:stream";
|
||||
@@ -10,7 +10,7 @@ declare module "https" {
|
||||
import { URL } from "node:url";
|
||||
type ServerOptions<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
|
||||
> = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
|
||||
type RequestOptions =
|
||||
& http.RequestOptions
|
||||
@@ -34,7 +34,7 @@ declare module "https" {
|
||||
}
|
||||
interface Server<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
|
||||
> extends http.Server<Request, Response> {}
|
||||
/**
|
||||
* See `http.Server` for more information.
|
||||
@@ -42,7 +42,7 @@ declare module "https" {
|
||||
*/
|
||||
class Server<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
|
||||
> extends tls.Server {
|
||||
constructor(requestListener?: http.RequestListener<Request, Response>);
|
||||
constructor(
|
||||
@@ -119,25 +119,19 @@ declare module "https" {
|
||||
emit(
|
||||
event: "checkContinue",
|
||||
req: InstanceType<Request>,
|
||||
res: InstanceType<Response> & {
|
||||
req: InstanceType<Request>;
|
||||
},
|
||||
res: InstanceType<Response>,
|
||||
): boolean;
|
||||
emit(
|
||||
event: "checkExpectation",
|
||||
req: InstanceType<Request>,
|
||||
res: InstanceType<Response> & {
|
||||
req: InstanceType<Request>;
|
||||
},
|
||||
res: InstanceType<Response>,
|
||||
): boolean;
|
||||
emit(event: "clientError", err: Error, socket: Duplex): boolean;
|
||||
emit(event: "connect", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
|
||||
emit(
|
||||
event: "request",
|
||||
req: InstanceType<Request>,
|
||||
res: InstanceType<Response> & {
|
||||
req: InstanceType<Request>;
|
||||
},
|
||||
res: InstanceType<Response>,
|
||||
): boolean;
|
||||
emit(event: "upgrade", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
@@ -276,8 +270,8 @@ declare module "https" {
|
||||
/**
|
||||
* ```js
|
||||
* // curl -k https://localhost:8000/
|
||||
* const https = require('node:https');
|
||||
* const fs = require('node:fs');
|
||||
* import https from 'node:https';
|
||||
* import fs from 'node:fs';
|
||||
*
|
||||
* const options = {
|
||||
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
||||
@@ -293,8 +287,8 @@ declare module "https" {
|
||||
* Or
|
||||
*
|
||||
* ```js
|
||||
* const https = require('node:https');
|
||||
* const fs = require('node:fs');
|
||||
* import https from 'node:https';
|
||||
* import fs from 'node:fs';
|
||||
*
|
||||
* const options = {
|
||||
* pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
|
||||
@@ -312,11 +306,11 @@ declare module "https" {
|
||||
*/
|
||||
function createServer<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
|
||||
>(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>;
|
||||
function createServer<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
|
||||
>(
|
||||
options: ServerOptions<Request, Response>,
|
||||
requestListener?: http.RequestListener<Request, Response>,
|
||||
@@ -324,8 +318,8 @@ declare module "https" {
|
||||
/**
|
||||
* 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`.
|
||||
* 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.
|
||||
@@ -334,7 +328,7 @@ declare module "https" {
|
||||
* upload a file with a POST request, then write to the `ClientRequest` object.
|
||||
*
|
||||
* ```js
|
||||
* const https = require('node:https');
|
||||
* import https from 'node:https';
|
||||
*
|
||||
* const options = {
|
||||
* hostname: 'encrypted.google.com',
|
||||
@@ -407,9 +401,9 @@ declare module "https" {
|
||||
* Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`):
|
||||
*
|
||||
* ```js
|
||||
* const tls = require('node:tls');
|
||||
* const https = require('node:https');
|
||||
* const crypto = require('node:crypto');
|
||||
* import tls from 'node:tls';
|
||||
* import https from 'node:https';
|
||||
* import crypto from 'node:crypto';
|
||||
*
|
||||
* function sha256(s) {
|
||||
* return crypto.createHash('sha256').update(s).digest('base64');
|
||||
@@ -517,7 +511,7 @@ declare module "https" {
|
||||
* 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('node:https');
|
||||
* import https from 'node:https';
|
||||
*
|
||||
* https.get('https://encrypted.google.com/', (res) => {
|
||||
* console.log('statusCode:', res.statusCode);
|
||||
|
||||
21
node_modules/@types/node/index.d.ts
generated
vendored
21
node_modules/@types/node/index.d.ts
generated
vendored
@@ -22,18 +22,22 @@
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// NOTE: These definitions support NodeJS and TypeScript 4.9+.
|
||||
// NOTE: These definitions support Node.js and TypeScript 5.7+.
|
||||
|
||||
// Reference required types from the default lib:
|
||||
// Reference required TypeScript libs:
|
||||
/// <reference lib="es2020" />
|
||||
/// <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:
|
||||
// TypeScript backwards-compatibility definitions:
|
||||
/// <reference path="compatibility/index.d.ts" />
|
||||
|
||||
// Definitions specific to TypeScript 5.7+:
|
||||
/// <reference path="globals.typedarray.d.ts" />
|
||||
/// <reference path="buffer.buffer.d.ts" />
|
||||
|
||||
// Definitions for Node.js modules that are not specific to any version of TypeScript:
|
||||
/// <reference path="globals.d.ts" />
|
||||
/// <reference path="assert.d.ts" />
|
||||
/// <reference path="assert/strict.d.ts" />
|
||||
/// <reference path="globals.d.ts" />
|
||||
/// <reference path="async_hooks.d.ts" />
|
||||
/// <reference path="buffer.d.ts" />
|
||||
/// <reference path="child_process.d.ts" />
|
||||
@@ -66,6 +70,7 @@
|
||||
/// <reference path="readline.d.ts" />
|
||||
/// <reference path="readline/promises.d.ts" />
|
||||
/// <reference path="repl.d.ts" />
|
||||
/// <reference path="sea.d.ts" />
|
||||
/// <reference path="stream.d.ts" />
|
||||
/// <reference path="stream/promises.d.ts" />
|
||||
/// <reference path="stream/consumers.d.ts" />
|
||||
@@ -84,5 +89,3 @@
|
||||
/// <reference path="wasi.d.ts" />
|
||||
/// <reference path="worker_threads.d.ts" />
|
||||
/// <reference path="zlib.d.ts" />
|
||||
|
||||
/// <reference path="globals.global.d.ts" />
|
||||
|
||||
1451
node_modules/@types/node/inspector.d.ts
generated
vendored
1451
node_modules/@types/node/inspector.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
556
node_modules/@types/node/module.d.ts
generated
vendored
556
node_modules/@types/node/module.d.ts
generated
vendored
@@ -1,20 +1,83 @@
|
||||
/**
|
||||
* @since v0.3.7
|
||||
* @experimental
|
||||
*/
|
||||
declare module "module" {
|
||||
import { URL } from "node:url";
|
||||
import { MessagePort } from "node:worker_threads";
|
||||
class Module {
|
||||
constructor(id: string, parent?: Module);
|
||||
}
|
||||
interface Module extends NodeJS.Module {}
|
||||
namespace Module {
|
||||
export { Module };
|
||||
}
|
||||
namespace Module {
|
||||
/**
|
||||
* A list of the names of all modules provided by Node.js. Can be used to verify
|
||||
* if a module is maintained by a third party or not.
|
||||
*
|
||||
* Note: the list doesn't contain prefix-only modules like `node:test`.
|
||||
* @since v9.3.0, v8.10.0, v6.13.0
|
||||
*/
|
||||
const builtinModules: readonly string[];
|
||||
/**
|
||||
* @since v12.2.0
|
||||
* @param path Filename to be used to construct the require
|
||||
* function. Must be a file URL object, file URL string, or absolute path
|
||||
* string.
|
||||
*/
|
||||
function createRequire(path: string | URL): NodeJS.Require;
|
||||
/**
|
||||
* @since v18.6.0, v16.17.0
|
||||
*/
|
||||
function isBuiltin(moduleName: string): boolean;
|
||||
interface RegisterOptions<Data> {
|
||||
/**
|
||||
* If you want to resolve `specifier` relative to a
|
||||
* base URL, such as `import.meta.url`, you can pass that URL here. This
|
||||
* property is ignored if the `parentURL` is supplied as the second argument.
|
||||
* @default 'data:'
|
||||
*/
|
||||
parentURL?: string | URL | undefined;
|
||||
/**
|
||||
* Any arbitrary, cloneable JavaScript value to pass into the
|
||||
* {@link initialize} hook.
|
||||
*/
|
||||
data?: Data | undefined;
|
||||
/**
|
||||
* [Transferable objects](https://nodejs.org/docs/latest-v20.x/api/worker_threads.html#portpostmessagevalue-transferlist)
|
||||
* to be passed into the `initialize` hook.
|
||||
*/
|
||||
transferList?: any[] | undefined;
|
||||
}
|
||||
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
||||
/**
|
||||
* Register a module that exports hooks that customize Node.js module
|
||||
* resolution and loading behavior. See
|
||||
* [Customization hooks](https://nodejs.org/docs/latest-v20.x/api/module.html#customization-hooks).
|
||||
* @since v20.6.0, v18.19.0
|
||||
* @param specifier Customization hooks to be registered; this should be
|
||||
* the same string that would be passed to `import()`, except that if it is
|
||||
* relative, it is resolved relative to `parentURL`.
|
||||
* @param parentURL f you want to resolve `specifier` relative to a base
|
||||
* URL, such as `import.meta.url`, you can pass that URL here.
|
||||
*/
|
||||
function register<Data = any>(
|
||||
specifier: string | URL,
|
||||
parentURL?: string | URL,
|
||||
options?: RegisterOptions<Data>,
|
||||
): void;
|
||||
function register<Data = any>(specifier: string | URL, options?: RegisterOptions<Data>): void;
|
||||
/* eslint-enable @definitelytyped/no-unnecessary-generics */
|
||||
/**
|
||||
* 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('node:fs');
|
||||
* const assert = require('node:assert');
|
||||
* const { syncBuiltinESMExports } = require('node:module');
|
||||
* import fs from 'node:fs';
|
||||
* import assert from 'node:assert';
|
||||
* import { syncBuiltinESMExports } from 'node:module';
|
||||
*
|
||||
* fs.readFile = newAPI;
|
||||
*
|
||||
@@ -42,13 +105,150 @@ declare module "module" {
|
||||
* @since v12.12.0
|
||||
*/
|
||||
function syncBuiltinESMExports(): void;
|
||||
/** @deprecated Use `ImportAttributes` instead */
|
||||
interface ImportAssertions extends ImportAttributes {}
|
||||
interface ImportAttributes extends NodeJS.Dict<string> {
|
||||
type?: string | undefined;
|
||||
}
|
||||
type ModuleFormat = "builtin" | "commonjs" | "json" | "module" | "wasm";
|
||||
type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray;
|
||||
/**
|
||||
* The `initialize` hook provides a way to define a custom function that runs in
|
||||
* the hooks thread when the hooks module is initialized. Initialization happens
|
||||
* when the hooks module is registered via {@link register}.
|
||||
*
|
||||
* This hook can receive data from a {@link register} invocation, including
|
||||
* ports and other transferable objects. The return value of `initialize` can be a
|
||||
* `Promise`, in which case it will be awaited before the main application thread
|
||||
* execution resumes.
|
||||
*/
|
||||
type InitializeHook<Data = any> = (data: Data) => void | Promise<void>;
|
||||
interface ResolveHookContext {
|
||||
/**
|
||||
* Export conditions of the relevant `package.json`
|
||||
*/
|
||||
conditions: string[];
|
||||
/**
|
||||
* @deprecated Use `importAttributes` instead
|
||||
*/
|
||||
importAssertions: ImportAttributes;
|
||||
/**
|
||||
* An object whose key-value pairs represent the assertions for the module to import
|
||||
*/
|
||||
importAttributes: ImportAttributes;
|
||||
/**
|
||||
* The module importing this one, or undefined if this is the Node.js entry point
|
||||
*/
|
||||
parentURL: string | undefined;
|
||||
}
|
||||
interface ResolveFnOutput {
|
||||
/**
|
||||
* A hint to the load hook (it might be ignored)
|
||||
*/
|
||||
format?: ModuleFormat | null | undefined;
|
||||
/**
|
||||
* @deprecated Use `importAttributes` instead
|
||||
*/
|
||||
importAssertions?: ImportAttributes | undefined;
|
||||
/**
|
||||
* The import attributes to use when caching the module (optional; if excluded the input will be used)
|
||||
*/
|
||||
importAttributes?: ImportAttributes | undefined;
|
||||
/**
|
||||
* A signal that this hook intends to terminate the chain of `resolve` hooks.
|
||||
* @default false
|
||||
*/
|
||||
shortCircuit?: boolean | undefined;
|
||||
/**
|
||||
* The absolute URL to which this input resolves
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
/**
|
||||
* The `resolve` hook chain is responsible for telling Node.js where to find and
|
||||
* how to cache a given `import` statement or expression, or `require` call. It can
|
||||
* optionally return a format (such as `'module'`) as a hint to the `load` hook. If
|
||||
* a format is specified, the `load` hook is ultimately responsible for providing
|
||||
* the final `format` value (and it is free to ignore the hint provided by
|
||||
* `resolve`); if `resolve` provides a `format`, a custom `load` hook is required
|
||||
* even if only to pass the value to the Node.js default `load` hook.
|
||||
*/
|
||||
type ResolveHook = (
|
||||
specifier: string,
|
||||
context: ResolveHookContext,
|
||||
nextResolve: (
|
||||
specifier: string,
|
||||
context?: Partial<ResolveHookContext>,
|
||||
) => ResolveFnOutput | Promise<ResolveFnOutput>,
|
||||
) => ResolveFnOutput | Promise<ResolveFnOutput>;
|
||||
interface LoadHookContext {
|
||||
/**
|
||||
* Export conditions of the relevant `package.json`
|
||||
*/
|
||||
conditions: string[];
|
||||
/**
|
||||
* The format optionally supplied by the `resolve` hook chain
|
||||
*/
|
||||
format: ModuleFormat | null | undefined;
|
||||
/**
|
||||
* @deprecated Use `importAttributes` instead
|
||||
*/
|
||||
importAssertions: ImportAttributes;
|
||||
/**
|
||||
* An object whose key-value pairs represent the assertions for the module to import
|
||||
*/
|
||||
importAttributes: ImportAttributes;
|
||||
}
|
||||
interface LoadFnOutput {
|
||||
format: string | null | undefined;
|
||||
/**
|
||||
* A signal that this hook intends to terminate the chain of `resolve` hooks.
|
||||
* @default false
|
||||
*/
|
||||
shortCircuit?: boolean | undefined;
|
||||
/**
|
||||
* The source for Node.js to evaluate
|
||||
*/
|
||||
source?: ModuleSource | undefined;
|
||||
}
|
||||
/**
|
||||
* The `load` hook provides a way to define a custom method of determining how a
|
||||
* URL should be interpreted, retrieved, and parsed. It is also in charge of
|
||||
* validating the import attributes.
|
||||
*/
|
||||
type LoadHook = (
|
||||
url: string,
|
||||
context: LoadHookContext,
|
||||
nextLoad: (
|
||||
url: string,
|
||||
context?: Partial<LoadHookContext>,
|
||||
) => LoadFnOutput | Promise<LoadFnOutput>,
|
||||
) => LoadFnOutput | Promise<LoadFnOutput>;
|
||||
interface GlobalPreloadContext {
|
||||
port: MessagePort;
|
||||
}
|
||||
/**
|
||||
* Sometimes it might be necessary to run some code inside of the same global
|
||||
* scope that the application runs in. This hook allows the return of a string
|
||||
* that is run as a sloppy-mode script on startup.
|
||||
* @deprecated This hook will be removed in a future version. Use
|
||||
* `initialize` instead. When a hooks module has an `initialize` export,
|
||||
* `globalPreload` will be ignored.
|
||||
*/
|
||||
type GlobalPreloadHook = (context: GlobalPreloadContext) => string;
|
||||
/**
|
||||
* `path` is the resolved path for the file for which a corresponding source map
|
||||
* should be fetched.
|
||||
* @since v13.7.0, v12.17.0
|
||||
* @return Returns `module.SourceMap` if a source map is found, `undefined` otherwise.
|
||||
*/
|
||||
function findSourceMap(path: string, error?: Error): SourceMap;
|
||||
function findSourceMap(path: string): SourceMap | undefined;
|
||||
interface SourceMapConstructorOptions {
|
||||
/**
|
||||
* @since v20.5.0
|
||||
*/
|
||||
lineLengths?: readonly number[] | undefined;
|
||||
}
|
||||
interface SourceMapPayload {
|
||||
file: string;
|
||||
version: number;
|
||||
@@ -69,7 +269,7 @@ declare module "module" {
|
||||
/**
|
||||
* The name of the range in the source map, if one was provided
|
||||
*/
|
||||
name?: string;
|
||||
name: string | undefined;
|
||||
/**
|
||||
* The file name of the original source, as reported in the SourceMap
|
||||
*/
|
||||
@@ -87,11 +287,11 @@ declare module "module" {
|
||||
* @since v13.7.0, v12.17.0
|
||||
*/
|
||||
class SourceMap {
|
||||
constructor(payload: SourceMapPayload, options?: SourceMapConstructorOptions);
|
||||
/**
|
||||
* Getter for the payload used to construct the `SourceMap` instance.
|
||||
*/
|
||||
readonly payload: SourceMapPayload;
|
||||
constructor(payload: SourceMapPayload);
|
||||
/**
|
||||
* Given a line offset and column offset in the generated source
|
||||
* file, returns an object representing the SourceMap range in the
|
||||
@@ -110,7 +310,7 @@ declare module "module" {
|
||||
* @param lineOffset The zero-indexed line number offset in the generated source
|
||||
* @param columnOffset The zero-indexed column number offset in the generated source
|
||||
*/
|
||||
findEntry(lineOffset: number, columnOffset: number): SourceMapping;
|
||||
findEntry(lineOffset: number, columnOffset: number): SourceMapping | {};
|
||||
/**
|
||||
* Given a 1-indexed `lineNumber` and `columnNumber` from a call site in the generated source,
|
||||
* find the corresponding call site location in the original source.
|
||||
@@ -122,172 +322,214 @@ declare module "module" {
|
||||
*/
|
||||
findOrigin(lineNumber: number, columnNumber: number): SourceOrigin | {};
|
||||
}
|
||||
interface ImportAssertions extends NodeJS.Dict<string> {
|
||||
type?: string | undefined;
|
||||
}
|
||||
type ModuleFormat = "builtin" | "commonjs" | "json" | "module" | "wasm";
|
||||
type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray;
|
||||
interface GlobalPreloadContext {
|
||||
port: MessagePort;
|
||||
}
|
||||
/**
|
||||
* @deprecated This hook will be removed in a future version.
|
||||
* Use `initialize` instead. When a loader has an `initialize` export, `globalPreload` will be ignored.
|
||||
*
|
||||
* Sometimes it might be necessary to run some code inside of the same global scope that the application runs in.
|
||||
* This hook allows the return of a string that is run as a sloppy-mode script on startup.
|
||||
*
|
||||
* @param context Information to assist the preload code
|
||||
* @return Code to run before application startup
|
||||
*/
|
||||
type GlobalPreloadHook = (context: GlobalPreloadContext) => string;
|
||||
/**
|
||||
* The `initialize` hook provides a way to define a custom function that runs in the hooks thread
|
||||
* when the hooks module is initialized. Initialization happens when the hooks module is registered via `register`.
|
||||
*
|
||||
* This hook can receive data from a `register` invocation, including ports and other transferrable objects.
|
||||
* The return value of `initialize` can be a `Promise`, in which case it will be awaited before the main application thread execution resumes.
|
||||
*/
|
||||
type InitializeHook<Data = any> = (data: Data) => void | Promise<void>;
|
||||
interface ResolveHookContext {
|
||||
/**
|
||||
* Export conditions of the relevant `package.json`
|
||||
*/
|
||||
conditions: string[];
|
||||
/**
|
||||
* An object whose key-value pairs represent the assertions for the module to import
|
||||
*/
|
||||
importAssertions: ImportAssertions;
|
||||
/**
|
||||
* The module importing this one, or undefined if this is the Node.js entry point
|
||||
*/
|
||||
parentURL: string | undefined;
|
||||
}
|
||||
interface ResolveFnOutput {
|
||||
/**
|
||||
* A hint to the load hook (it might be ignored)
|
||||
*/
|
||||
format?: ModuleFormat | null | undefined;
|
||||
/**
|
||||
* The import assertions to use when caching the module (optional; if excluded the input will be used)
|
||||
*/
|
||||
importAssertions?: ImportAssertions | undefined;
|
||||
/**
|
||||
* A signal that this hook intends to terminate the chain of `resolve` hooks.
|
||||
* @default false
|
||||
*/
|
||||
shortCircuit?: boolean | undefined;
|
||||
/**
|
||||
* The absolute URL to which this input resolves
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
/**
|
||||
* The `resolve` hook chain is responsible for resolving file URL for a given module specifier and parent URL, and optionally its format (such as `'module'`) as a hint to the `load` hook.
|
||||
* If a format is specified, the load hook is ultimately responsible for providing the final `format` value (and it is free to ignore the hint provided by `resolve`);
|
||||
* if `resolve` provides a format, a custom `load` hook is required even if only to pass the value to the Node.js default `load` hook.
|
||||
*
|
||||
* @param specifier The specified URL path of the module to be resolved
|
||||
* @param context
|
||||
* @param nextResolve The subsequent `resolve` hook in the chain, or the Node.js default `resolve` hook after the last user-supplied resolve hook
|
||||
*/
|
||||
type ResolveHook = (
|
||||
specifier: string,
|
||||
context: ResolveHookContext,
|
||||
nextResolve: (
|
||||
specifier: string,
|
||||
context?: ResolveHookContext,
|
||||
) => ResolveFnOutput | Promise<ResolveFnOutput>,
|
||||
) => ResolveFnOutput | Promise<ResolveFnOutput>;
|
||||
interface LoadHookContext {
|
||||
/**
|
||||
* Export conditions of the relevant `package.json`
|
||||
*/
|
||||
conditions: string[];
|
||||
/**
|
||||
* The format optionally supplied by the `resolve` hook chain
|
||||
*/
|
||||
format: ModuleFormat;
|
||||
/**
|
||||
* An object whose key-value pairs represent the assertions for the module to import
|
||||
*/
|
||||
importAssertions: ImportAssertions;
|
||||
}
|
||||
interface LoadFnOutput {
|
||||
format: ModuleFormat;
|
||||
/**
|
||||
* A signal that this hook intends to terminate the chain of `resolve` hooks.
|
||||
* @default false
|
||||
*/
|
||||
shortCircuit?: boolean | undefined;
|
||||
/**
|
||||
* The source for Node.js to evaluate
|
||||
*/
|
||||
source?: ModuleSource;
|
||||
}
|
||||
/**
|
||||
* The `load` hook provides a way to define a custom method of determining how a URL should be interpreted, retrieved, and parsed.
|
||||
* It is also in charge of validating the import assertion.
|
||||
*
|
||||
* @param url The URL/path of the module to be loaded
|
||||
* @param context Metadata about the module
|
||||
* @param nextLoad The subsequent `load` hook in the chain, or the Node.js default `load` hook after the last user-supplied `load` hook
|
||||
*/
|
||||
type LoadHook = (
|
||||
url: string,
|
||||
context: LoadHookContext,
|
||||
nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput | Promise<LoadFnOutput>,
|
||||
) => LoadFnOutput | Promise<LoadFnOutput>;
|
||||
}
|
||||
interface RegisterOptions<Data> {
|
||||
parentURL: string | URL;
|
||||
data?: Data | undefined;
|
||||
transferList?: any[] | undefined;
|
||||
}
|
||||
interface Module extends NodeModule {}
|
||||
class Module {
|
||||
static runMain(): void;
|
||||
static wrap(code: string): string;
|
||||
static createRequire(path: string | URL): NodeRequire;
|
||||
static builtinModules: string[];
|
||||
static isBuiltin(moduleName: string): boolean;
|
||||
static Module: typeof Module;
|
||||
static register<Data = any>(
|
||||
specifier: string | URL,
|
||||
parentURL?: string | URL,
|
||||
options?: RegisterOptions<Data>,
|
||||
): void;
|
||||
static register<Data = any>(specifier: string | URL, options?: RegisterOptions<Data>): void;
|
||||
constructor(id: string, parent?: Module);
|
||||
function runMain(main?: string): void;
|
||||
function wrap(script: string): string;
|
||||
}
|
||||
global {
|
||||
interface ImportMeta {
|
||||
/**
|
||||
* The directory name of the current module. This is the same as the `path.dirname()` of the `import.meta.filename`.
|
||||
* **Caveat:** only present on `file:` modules.
|
||||
*/
|
||||
dirname: string;
|
||||
/**
|
||||
* The full absolute path and filename of the current module, with symlinks resolved.
|
||||
* This is the same as the `url.fileURLToPath()` of the `import.meta.url`.
|
||||
* **Caveat:** only local modules support this property. Modules not using the `file:` protocol will not provide it.
|
||||
*/
|
||||
filename: string;
|
||||
/**
|
||||
* The absolute `file:` URL of the module.
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* Provides a module-relative resolution function scoped to each module, returning
|
||||
* the URL string.
|
||||
*
|
||||
* @since v20.6.0
|
||||
*
|
||||
* @param specifier The module specifier to resolve relative to the current module.
|
||||
* @returns The absolute (`file:`) URL string for the resolved module.
|
||||
*/
|
||||
resolve(specifier: string): string;
|
||||
/**
|
||||
* This `parent` parameter is only used when the `--experimental-import-meta-resolve`
|
||||
* Second `parent` parameter is only used when the `--experimental-import-meta-resolve`
|
||||
* command flag enabled.
|
||||
*
|
||||
* Provides a module-relative resolution function scoped to each module, returning
|
||||
* the URL string.
|
||||
*
|
||||
* @since v20.6.0
|
||||
*
|
||||
* @param specifier The module specifier to resolve relative to `parent`.
|
||||
* @param parent The absolute parent module URL to resolve from.
|
||||
* @returns The absolute (`file:`) URL string for the resolved module.
|
||||
*/
|
||||
resolve(specifier: string, parent: string | URL): string;
|
||||
resolve(specifier: string, parent?: string | URL | undefined): string;
|
||||
}
|
||||
namespace NodeJS {
|
||||
interface Module {
|
||||
/**
|
||||
* The module objects required for the first time by this one.
|
||||
* @since v0.1.16
|
||||
*/
|
||||
children: Module[];
|
||||
/**
|
||||
* The `module.exports` object is created by the `Module` system. Sometimes this is
|
||||
* not acceptable; many want their module to be an instance of some class. To do
|
||||
* this, assign the desired export object to `module.exports`.
|
||||
* @since v0.1.16
|
||||
*/
|
||||
exports: any;
|
||||
/**
|
||||
* The fully resolved filename of the module.
|
||||
* @since v0.1.16
|
||||
*/
|
||||
filename: string;
|
||||
/**
|
||||
* The identifier for the module. Typically this is the fully resolved
|
||||
* filename.
|
||||
* @since v0.1.16
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* `true` if the module is running during the Node.js preload
|
||||
* phase.
|
||||
* @since v15.4.0, v14.17.0
|
||||
*/
|
||||
isPreloading: boolean;
|
||||
/**
|
||||
* Whether or not the module is done loading, or is in the process of
|
||||
* loading.
|
||||
* @since v0.1.16
|
||||
*/
|
||||
loaded: boolean;
|
||||
/**
|
||||
* The module that first required this one, or `null` if the current module is the
|
||||
* entry point of the current process, or `undefined` if the module was loaded by
|
||||
* something that is not a CommonJS module (e.g. REPL or `import`).
|
||||
* @since v0.1.16
|
||||
* @deprecated Please use `require.main` and `module.children` instead.
|
||||
*/
|
||||
parent: Module | null | undefined;
|
||||
/**
|
||||
* The directory name of the module. This is usually the same as the
|
||||
* `path.dirname()` of the `module.id`.
|
||||
* @since v11.14.0
|
||||
*/
|
||||
path: string;
|
||||
/**
|
||||
* The search paths for the module.
|
||||
* @since v0.4.0
|
||||
*/
|
||||
paths: string[];
|
||||
/**
|
||||
* The `module.require()` method provides a way to load a module as if
|
||||
* `require()` was called from the original module.
|
||||
* @since v0.5.1
|
||||
*/
|
||||
require(id: string): any;
|
||||
}
|
||||
interface Require {
|
||||
/**
|
||||
* Used to import modules, `JSON`, and local files.
|
||||
* @since v0.1.13
|
||||
*/
|
||||
(id: string): any;
|
||||
/**
|
||||
* Modules are cached in this object when they are required. By deleting a key
|
||||
* value from this object, the next `require` will reload the module.
|
||||
* This does not apply to
|
||||
* [native addons](https://nodejs.org/docs/latest-v20.x/api/addons.html),
|
||||
* for which reloading will result in an error.
|
||||
* @since v0.3.0
|
||||
*/
|
||||
cache: Dict<Module>;
|
||||
/**
|
||||
* Instruct `require` on how to handle certain file extensions.
|
||||
* @since v0.3.0
|
||||
* @deprecated
|
||||
*/
|
||||
extensions: RequireExtensions;
|
||||
/**
|
||||
* The `Module` object representing the entry script loaded when the Node.js
|
||||
* process launched, or `undefined` if the entry point of the program is not a
|
||||
* CommonJS module.
|
||||
* @since v0.1.17
|
||||
*/
|
||||
main: Module | undefined;
|
||||
/**
|
||||
* @since v0.3.0
|
||||
*/
|
||||
resolve: RequireResolve;
|
||||
}
|
||||
/** @deprecated */
|
||||
interface RequireExtensions extends Dict<(module: Module, filename: string) => any> {
|
||||
".js": (module: Module, filename: string) => any;
|
||||
".json": (module: Module, filename: string) => any;
|
||||
".node": (module: Module, filename: string) => any;
|
||||
}
|
||||
interface RequireResolveOptions {
|
||||
/**
|
||||
* Paths to resolve module location from. If present, these
|
||||
* paths are used instead of the default resolution paths, with the exception
|
||||
* of
|
||||
* [GLOBAL\_FOLDERS](https://nodejs.org/docs/latest-v20.x/api/modules.html#loading-from-the-global-folders)
|
||||
* like `$HOME/.node_modules`, which are
|
||||
* always included. Each of these paths is used as a starting point for
|
||||
* the module resolution algorithm, meaning that the `node_modules` hierarchy
|
||||
* is checked from this location.
|
||||
* @since v8.9.0
|
||||
*/
|
||||
paths?: string[] | undefined;
|
||||
}
|
||||
interface RequireResolve {
|
||||
/**
|
||||
* Use the internal `require()` machinery to look up the location of a module,
|
||||
* but rather than loading the module, just return the resolved filename.
|
||||
*
|
||||
* If the module can not be found, a `MODULE_NOT_FOUND` error is thrown.
|
||||
* @since v0.3.0
|
||||
* @param request The module path to resolve.
|
||||
*/
|
||||
(id: string, options?: RequireResolveOptions): string;
|
||||
/**
|
||||
* Returns an array containing the paths searched during resolution of `request` or
|
||||
* `null` if the `request` string references a core module, for example `http` or
|
||||
* `fs`.
|
||||
* @since v8.9.0
|
||||
* @param request The module path whose lookup paths are being retrieved.
|
||||
*/
|
||||
paths(request: string): string[] | null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The directory name of the current module. This is the same as the
|
||||
* `path.dirname()` of the `__filename`.
|
||||
* @since v0.1.27
|
||||
*/
|
||||
var __dirname: string;
|
||||
/**
|
||||
* The file name of the current module. This is the current module file's absolute
|
||||
* path with symlinks resolved.
|
||||
*
|
||||
* For a main program this is not necessarily the same as the file name used in the
|
||||
* command line.
|
||||
* @since v0.0.1
|
||||
*/
|
||||
var __filename: string;
|
||||
/**
|
||||
* The `exports` variable is available within a module's file-level scope, and is
|
||||
* assigned the value of `module.exports` before the module is evaluated.
|
||||
* @since v0.1.16
|
||||
*/
|
||||
var exports: NodeJS.Module["exports"];
|
||||
/**
|
||||
* A reference to the current module.
|
||||
* @since v0.1.16
|
||||
*/
|
||||
var module: NodeJS.Module;
|
||||
/**
|
||||
* @since v0.1.13
|
||||
*/
|
||||
var require: NodeJS.Require;
|
||||
// Global-scope aliases for backwards compatibility with @types/node <13.0.x
|
||||
/** @deprecated Use `NodeJS.Module` instead. */
|
||||
interface NodeModule extends NodeJS.Module {}
|
||||
/** @deprecated Use `NodeJS.Require` instead. */
|
||||
interface NodeRequire extends NodeJS.Require {}
|
||||
/** @deprecated Use `NodeJS.RequireResolve` instead. */
|
||||
interface RequireResolve extends NodeJS.RequireResolve {}
|
||||
}
|
||||
export = Module;
|
||||
}
|
||||
|
||||
104
node_modules/@types/node/net.d.ts
generated
vendored
104
node_modules/@types/node/net.d.ts
generated
vendored
@@ -8,9 +8,9 @@
|
||||
* It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const net = require('node:net');
|
||||
* import net from 'node:net';
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/net.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/net.js)
|
||||
*/
|
||||
declare module "net" {
|
||||
import * as stream from "node:stream";
|
||||
@@ -18,8 +18,8 @@ declare module "net" {
|
||||
import * as dns from "node:dns";
|
||||
type LookupFunction = (
|
||||
hostname: string,
|
||||
options: dns.LookupAllOptions,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: dns.LookupAddress[]) => void,
|
||||
options: dns.LookupOptions,
|
||||
callback: (err: NodeJS.ErrnoException | null, address: string | dns.LookupAddress[], family?: number) => void,
|
||||
) => void;
|
||||
interface AddressInfo {
|
||||
address: string;
|
||||
@@ -112,8 +112,8 @@ declare module "net" {
|
||||
* @since v0.1.90
|
||||
* @param [encoding='utf8'] Only used when data is `string`.
|
||||
*/
|
||||
write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
||||
write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean;
|
||||
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
|
||||
write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
|
||||
/**
|
||||
* Initiate a connection on a given socket.
|
||||
*
|
||||
@@ -278,7 +278,7 @@ declare module "net" {
|
||||
*/
|
||||
readonly bytesWritten: number;
|
||||
/**
|
||||
* If `true`,`socket.connect(options[, connectListener])` was
|
||||
* 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.
|
||||
@@ -363,17 +363,29 @@ declare module "net" {
|
||||
* events.EventEmitter
|
||||
* 1. close
|
||||
* 2. connect
|
||||
* 3. data
|
||||
* 4. drain
|
||||
* 5. end
|
||||
* 6. error
|
||||
* 7. lookup
|
||||
* 8. ready
|
||||
* 9. timeout
|
||||
* 3. connectionAttempt
|
||||
* 4. connectionAttemptFailed
|
||||
* 5. connectionAttemptTimeout
|
||||
* 6. data
|
||||
* 7. drain
|
||||
* 8. end
|
||||
* 9. error
|
||||
* 10. lookup
|
||||
* 11. ready
|
||||
* 12. timeout
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: "close", listener: (hadError: boolean) => void): this;
|
||||
addListener(event: "connect", listener: () => void): this;
|
||||
addListener(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this;
|
||||
addListener(
|
||||
event: "connectionAttemptFailed",
|
||||
listener: (ip: string, port: number, family: number, error: Error) => void,
|
||||
): this;
|
||||
addListener(
|
||||
event: "connectionAttemptTimeout",
|
||||
listener: (ip: string, port: number, family: number) => void,
|
||||
): this;
|
||||
addListener(event: "data", listener: (data: Buffer) => void): this;
|
||||
addListener(event: "drain", listener: () => void): this;
|
||||
addListener(event: "end", listener: () => void): this;
|
||||
@@ -387,6 +399,9 @@ declare module "net" {
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: "close", hadError: boolean): boolean;
|
||||
emit(event: "connect"): boolean;
|
||||
emit(event: "connectionAttempt", ip: string, port: number, family: number): boolean;
|
||||
emit(event: "connectionAttemptFailed", ip: string, port: number, family: number, error: Error): boolean;
|
||||
emit(event: "connectionAttemptTimeout", ip: string, port: number, family: number): boolean;
|
||||
emit(event: "data", data: Buffer): boolean;
|
||||
emit(event: "drain"): boolean;
|
||||
emit(event: "end"): boolean;
|
||||
@@ -397,6 +412,12 @@ declare module "net" {
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: "close", listener: (hadError: boolean) => void): this;
|
||||
on(event: "connect", listener: () => void): this;
|
||||
on(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this;
|
||||
on(
|
||||
event: "connectionAttemptFailed",
|
||||
listener: (ip: string, port: number, family: number, error: Error) => void,
|
||||
): this;
|
||||
on(event: "connectionAttemptTimeout", listener: (ip: string, port: number, family: number) => void): this;
|
||||
on(event: "data", listener: (data: Buffer) => void): this;
|
||||
on(event: "drain", listener: () => void): this;
|
||||
on(event: "end", listener: () => void): this;
|
||||
@@ -409,6 +430,12 @@ declare module "net" {
|
||||
on(event: "timeout", listener: () => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: "close", listener: (hadError: boolean) => void): this;
|
||||
once(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this;
|
||||
once(
|
||||
event: "connectionAttemptFailed",
|
||||
listener: (ip: string, port: number, family: number, error: Error) => void,
|
||||
): this;
|
||||
once(event: "connectionAttemptTimeout", listener: (ip: string, port: number, family: number) => void): this;
|
||||
once(event: "connect", listener: () => void): this;
|
||||
once(event: "data", listener: (data: Buffer) => void): this;
|
||||
once(event: "drain", listener: () => void): this;
|
||||
@@ -423,6 +450,15 @@ declare module "net" {
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "close", listener: (hadError: boolean) => void): this;
|
||||
prependListener(event: "connect", listener: () => void): this;
|
||||
prependListener(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this;
|
||||
prependListener(
|
||||
event: "connectionAttemptFailed",
|
||||
listener: (ip: string, port: number, family: number, error: Error) => void,
|
||||
): this;
|
||||
prependListener(
|
||||
event: "connectionAttemptTimeout",
|
||||
listener: (ip: string, port: number, family: number) => void,
|
||||
): this;
|
||||
prependListener(event: "data", listener: (data: Buffer) => void): this;
|
||||
prependListener(event: "drain", listener: () => void): this;
|
||||
prependListener(event: "end", listener: () => void): this;
|
||||
@@ -436,6 +472,18 @@ declare module "net" {
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "close", listener: (hadError: boolean) => void): this;
|
||||
prependOnceListener(event: "connect", listener: () => void): this;
|
||||
prependOnceListener(
|
||||
event: "connectionAttempt",
|
||||
listener: (ip: string, port: number, family: number) => void,
|
||||
): this;
|
||||
prependOnceListener(
|
||||
event: "connectionAttemptFailed",
|
||||
listener: (ip: string, port: number, family: number, error: Error) => void,
|
||||
): this;
|
||||
prependOnceListener(
|
||||
event: "connectionAttemptTimeout",
|
||||
listener: (ip: string, port: number, family: number) => void,
|
||||
): this;
|
||||
prependOnceListener(event: "data", listener: (data: Buffer) => void): this;
|
||||
prependOnceListener(event: "drain", listener: () => void): this;
|
||||
prependOnceListener(event: "end", listener: () => void): this;
|
||||
@@ -490,6 +538,12 @@ declare module "net" {
|
||||
* @since v16.5.0
|
||||
*/
|
||||
keepAliveInitialDelay?: number | undefined;
|
||||
/**
|
||||
* Optionally overrides all `net.Socket`s' `readableHighWaterMark` and `writableHighWaterMark`.
|
||||
* @default See [stream.getDefaultHighWaterMark()](https://nodejs.org/docs/latest-v20.x/api/stream.html#streamgetdefaulthighwatermarkobjectmode).
|
||||
* @since v18.17.0, v20.1.0
|
||||
*/
|
||||
highWaterMark?: number | undefined;
|
||||
}
|
||||
interface DropArgument {
|
||||
localAddress?: string;
|
||||
@@ -522,7 +576,7 @@ declare module "net" {
|
||||
*
|
||||
* 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).
|
||||
* 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).
|
||||
@@ -601,7 +655,7 @@ declare module "net" {
|
||||
* 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): this;
|
||||
/**
|
||||
* 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.
|
||||
@@ -628,7 +682,7 @@ declare module "net" {
|
||||
* Indicates whether or not the server is listening for connections.
|
||||
* @since v5.7.0
|
||||
*/
|
||||
listening: boolean;
|
||||
readonly listening: boolean;
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. close
|
||||
@@ -736,6 +790,11 @@ declare module "net" {
|
||||
*/
|
||||
check(address: SocketAddress): boolean;
|
||||
check(address: string, type?: IPVersion): boolean;
|
||||
/**
|
||||
* The list of rules added to the blocklist.
|
||||
* @since v15.0.0, v14.18.0
|
||||
*/
|
||||
rules: readonly string[];
|
||||
}
|
||||
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
|
||||
timeout?: number | undefined;
|
||||
@@ -765,7 +824,7 @@ declare module "net" {
|
||||
* on port 8124:
|
||||
*
|
||||
* ```js
|
||||
* const net = require('node:net');
|
||||
* import net from 'node:net';
|
||||
* const server = net.createServer((c) => {
|
||||
* // 'connection' listener.
|
||||
* console.log('client connected');
|
||||
@@ -852,13 +911,16 @@ declare module "net" {
|
||||
function setDefaultAutoSelectFamily(value: boolean): void;
|
||||
/**
|
||||
* Gets the current default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`.
|
||||
* The initial default value is `250`.
|
||||
* @since v19.8.0
|
||||
* The initial default value is `250` or the value specified via the command line option `--network-family-autoselection-attempt-timeout`.
|
||||
* @returns The current default value of the `autoSelectFamilyAttemptTimeout` option.
|
||||
* @since v19.8.0, v18.8.0
|
||||
*/
|
||||
function getDefaultAutoSelectFamilyAttemptTimeout(): number;
|
||||
/**
|
||||
* Sets the default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`.
|
||||
* @since v19.8.0
|
||||
* @param value The new default value, which must be a positive number. If the number is less than `10`, the value `10` is used instead. The initial default value is `250` or the value specified via the command line
|
||||
* option `--network-family-autoselection-attempt-timeout`.
|
||||
* @since v19.8.0, v18.8.0
|
||||
*/
|
||||
function setDefaultAutoSelectFamilyAttemptTimeout(value: number): void;
|
||||
/**
|
||||
|
||||
44
node_modules/@types/node/os.d.ts
generated
vendored
44
node_modules/@types/node/os.d.ts
generated
vendored
@@ -3,19 +3,24 @@
|
||||
* properties. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const os = require('node:os');
|
||||
* import os from 'node:os';
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/os.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/os.js)
|
||||
*/
|
||||
declare module "os" {
|
||||
interface CpuInfo {
|
||||
model: string;
|
||||
speed: number;
|
||||
times: {
|
||||
/** The number of milliseconds the CPU has spent in user mode. */
|
||||
user: number;
|
||||
/** The number of milliseconds the CPU has spent in nice mode. */
|
||||
nice: number;
|
||||
/** The number of milliseconds the CPU has spent in sys mode. */
|
||||
sys: number;
|
||||
/** The number of milliseconds the CPU has spent in idle mode. */
|
||||
idle: number;
|
||||
/** The number of milliseconds the CPU has spent in irq mode. */
|
||||
irq: number;
|
||||
};
|
||||
}
|
||||
@@ -75,7 +80,7 @@ declare module "os" {
|
||||
function totalmem(): number;
|
||||
/**
|
||||
* Returns an array of objects containing information about each logical CPU core.
|
||||
* The array will be empty if no CPU information is available, such as if the`/proc` file system is unavailable.
|
||||
* The array will be empty if no CPU information is available, such as if the `/proc` file system is unavailable.
|
||||
*
|
||||
* The properties included on each object include:
|
||||
*
|
||||
@@ -229,14 +234,14 @@ declare module "os" {
|
||||
/**
|
||||
* 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 `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`.
|
||||
* Throws a [`SystemError`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-systemerror) if a user has no `username` or `homedir`.
|
||||
* @since v6.0.0
|
||||
*/
|
||||
function userInfo(options: { encoding: "buffer" }): UserInfo<Buffer>;
|
||||
@@ -387,6 +392,13 @@ declare module "os" {
|
||||
const WSA_E_CANCELLED: number;
|
||||
const WSAEREFUSED: number;
|
||||
}
|
||||
namespace dlopen {
|
||||
const RTLD_LAZY: number;
|
||||
const RTLD_NOW: number;
|
||||
const RTLD_GLOBAL: number;
|
||||
const RTLD_LOCAL: number;
|
||||
const RTLD_DEEPBIND: number;
|
||||
}
|
||||
namespace priority {
|
||||
const PRIORITY_LOW: number;
|
||||
const PRIORITY_BELOW_NORMAL: number;
|
||||
@@ -397,12 +409,18 @@ declare module "os" {
|
||||
}
|
||||
}
|
||||
const devNull: string;
|
||||
/**
|
||||
* The operating system-specific end-of-line marker.
|
||||
* * `\n` on POSIX
|
||||
* * `\r\n` on Windows
|
||||
*/
|
||||
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'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`.
|
||||
* compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`, `'mips'`, `'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`,
|
||||
* and `'x64'`.
|
||||
*
|
||||
* The return value is equivalent to `process.arch`.
|
||||
* The return value is equivalent to [process.arch](https://nodejs.org/docs/latest-v20.x/api/process.html#processarch).
|
||||
* @since v0.5.0
|
||||
*/
|
||||
function arch(): string;
|
||||
@@ -417,7 +435,7 @@ declare module "os" {
|
||||
/**
|
||||
* Returns a string identifying the operating system platform for which
|
||||
* the Node.js binary was compiled. The value is set at compile time.
|
||||
* Possible values are `'aix'`, `'darwin'`, `'freebsd'`,`'linux'`,`'openbsd'`, `'sunos'`, and `'win32'`.
|
||||
* Possible values are `'aix'`, `'darwin'`, `'freebsd'`, `'linux'`, `'openbsd'`, `'sunos'`, and `'win32'`.
|
||||
*
|
||||
* The return value is equivalent to `process.platform`.
|
||||
*
|
||||
@@ -427,7 +445,7 @@ declare module "os" {
|
||||
*/
|
||||
function platform(): NodeJS.Platform;
|
||||
/**
|
||||
* Returns the machine type as a string, such as `arm`, `arm64`, `aarch64`,`mips`, `mips64`, `ppc64`, `ppc64le`, `s390`, `s390x`, `i386`, `i686`, `x86_64`.
|
||||
* Returns the machine type as a string, such as `arm`, `arm64`, `aarch64`, `mips`, `mips64`, `ppc64`, `ppc64le`, `s390`, `s390x`, `i386`, `i686`, `x86_64`.
|
||||
*
|
||||
* On POSIX systems, the machine type 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.
|
||||
@@ -456,15 +474,15 @@ declare module "os" {
|
||||
*/
|
||||
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.
|
||||
* 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.
|
||||
*
|
||||
* 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
|
||||
* 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`.
|
||||
* privileges. Otherwise the set priority will be silently reduced to `PRIORITY_HIGH`.
|
||||
* @since v10.10.0
|
||||
* @param [pid=0] The process ID to set scheduling priority for.
|
||||
* @param priority The scheduling priority to assign to the process.
|
||||
|
||||
104
node_modules/@types/node/package.json
generated
vendored
104
node_modules/@types/node/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@types/node",
|
||||
"version": "20.9.0",
|
||||
"version": "20.19.9",
|
||||
"description": "TypeScript definitions for node",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
||||
"license": "MIT",
|
||||
@@ -15,11 +15,6 @@
|
||||
"githubUsername": "jkomyno",
|
||||
"url": "https://github.com/jkomyno"
|
||||
},
|
||||
{
|
||||
"name": "Alvis HT Tang",
|
||||
"githubUsername": "alvis",
|
||||
"url": "https://github.com/alvis"
|
||||
},
|
||||
{
|
||||
"name": "Andrew Makarov",
|
||||
"githubUsername": "r3nya",
|
||||
@@ -30,111 +25,31 @@
|
||||
"githubUsername": "btoueg",
|
||||
"url": "https://github.com/btoueg"
|
||||
},
|
||||
{
|
||||
"name": "Chigozirim C.",
|
||||
"githubUsername": "smac89",
|
||||
"url": "https://github.com/smac89"
|
||||
},
|
||||
{
|
||||
"name": "David Junger",
|
||||
"githubUsername": "touffy",
|
||||
"url": "https://github.com/touffy"
|
||||
},
|
||||
{
|
||||
"name": "Deividas Bakanas",
|
||||
"githubUsername": "DeividasBakanas",
|
||||
"url": "https://github.com/DeividasBakanas"
|
||||
},
|
||||
{
|
||||
"name": "Eugene Y. Q. Shen",
|
||||
"githubUsername": "eyqs",
|
||||
"url": "https://github.com/eyqs"
|
||||
},
|
||||
{
|
||||
"name": "Hannes Magnusson",
|
||||
"githubUsername": "Hannes-Magnusson-CK",
|
||||
"url": "https://github.com/Hannes-Magnusson-CK"
|
||||
},
|
||||
{
|
||||
"name": "Huw",
|
||||
"githubUsername": "hoo29",
|
||||
"url": "https://github.com/hoo29"
|
||||
},
|
||||
{
|
||||
"name": "Kelvin Jin",
|
||||
"githubUsername": "kjin",
|
||||
"url": "https://github.com/kjin"
|
||||
},
|
||||
{
|
||||
"name": "Klaus Meinhardt",
|
||||
"githubUsername": "ajafff",
|
||||
"url": "https://github.com/ajafff"
|
||||
},
|
||||
{
|
||||
"name": "Lishude",
|
||||
"githubUsername": "islishude",
|
||||
"url": "https://github.com/islishude"
|
||||
},
|
||||
{
|
||||
"name": "Mariusz Wiktorczyk",
|
||||
"githubUsername": "mwiktorczyk",
|
||||
"url": "https://github.com/mwiktorczyk"
|
||||
},
|
||||
{
|
||||
"name": "Mohsen Azimi",
|
||||
"githubUsername": "mohsen1",
|
||||
"url": "https://github.com/mohsen1"
|
||||
},
|
||||
{
|
||||
"name": "Nicolas Even",
|
||||
"githubUsername": "n-e",
|
||||
"url": "https://github.com/n-e"
|
||||
},
|
||||
{
|
||||
"name": "Nikita Galkin",
|
||||
"githubUsername": "galkin",
|
||||
"url": "https://github.com/galkin"
|
||||
},
|
||||
{
|
||||
"name": "Parambir Singh",
|
||||
"githubUsername": "parambirs",
|
||||
"url": "https://github.com/parambirs"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Silbermann",
|
||||
"githubUsername": "eps1lon",
|
||||
"url": "https://github.com/eps1lon"
|
||||
},
|
||||
{
|
||||
"name": "Thomas den Hollander",
|
||||
"githubUsername": "ThomasdenH",
|
||||
"url": "https://github.com/ThomasdenH"
|
||||
},
|
||||
{
|
||||
"name": "Wilco Bakker",
|
||||
"githubUsername": "WilcoBakker",
|
||||
"url": "https://github.com/WilcoBakker"
|
||||
},
|
||||
{
|
||||
"name": "wwwy3y3",
|
||||
"githubUsername": "wwwy3y3",
|
||||
"url": "https://github.com/wwwy3y3"
|
||||
},
|
||||
{
|
||||
"name": "Samuel Ainsworth",
|
||||
"githubUsername": "samuela",
|
||||
"url": "https://github.com/samuela"
|
||||
},
|
||||
{
|
||||
"name": "Kyle Uehlein",
|
||||
"githubUsername": "kuehlein",
|
||||
"url": "https://github.com/kuehlein"
|
||||
},
|
||||
{
|
||||
"name": "Thanik Bhongbhibhat",
|
||||
"githubUsername": "bhongy",
|
||||
"url": "https://github.com/bhongy"
|
||||
},
|
||||
{
|
||||
"name": "Marcin Kopacz",
|
||||
"githubUsername": "chyzwar",
|
||||
@@ -175,11 +90,6 @@
|
||||
"githubUsername": "victorperin",
|
||||
"url": "https://github.com/victorperin"
|
||||
},
|
||||
{
|
||||
"name": "Yongsheng Zhang",
|
||||
"githubUsername": "ZYSzys",
|
||||
"url": "https://github.com/ZYSzys"
|
||||
},
|
||||
{
|
||||
"name": "NodeJS Contributors",
|
||||
"githubUsername": "NodeJS",
|
||||
@@ -209,9 +119,9 @@
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"typesVersions": {
|
||||
"<=4.8": {
|
||||
"<=5.6": {
|
||||
"*": [
|
||||
"ts4.8/*"
|
||||
"ts5.6/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -222,9 +132,9 @@
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
"undici-types": "~6.21.0"
|
||||
},
|
||||
"typesPublisherContentHash": "a1b366d7b3bf1afaa88e038010565763e234c0e5fa8044db8b0d7c44995bfbf8",
|
||||
"typeScriptVersion": "4.5",
|
||||
"nonNpm": true
|
||||
"peerDependencies": {},
|
||||
"typesPublisherContentHash": "3750c2bc17c26965bb2e8e18153c13e2b78690ea2e5d00315a7b0f1a3375a950",
|
||||
"typeScriptVersion": "5.1"
|
||||
}
|
||||
13
node_modules/@types/node/path.d.ts
generated
vendored
13
node_modules/@types/node/path.d.ts
generated
vendored
@@ -11,9 +11,9 @@ declare module "path/win32" {
|
||||
* paths. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const path = require('node:path');
|
||||
* import path from 'node:path';
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/path.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/path.js)
|
||||
*/
|
||||
declare module "path" {
|
||||
namespace path {
|
||||
@@ -94,6 +94,15 @@ declare module "path" {
|
||||
* @throws {TypeError} if any of the arguments is not a string.
|
||||
*/
|
||||
resolve(...paths: string[]): string;
|
||||
/**
|
||||
* The `path.matchesGlob()` method determines if `path` matches the `pattern`.
|
||||
* @param path The path to glob-match against.
|
||||
* @param pattern The glob to check the path against.
|
||||
* @returns Whether or not the `path` matched the `pattern`.
|
||||
* @throws {TypeError} if `path` or `pattern` are not strings.
|
||||
* @since v20.17.0
|
||||
*/
|
||||
matchesGlob(path: string, pattern: string): boolean;
|
||||
/**
|
||||
* Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
|
||||
*
|
||||
|
||||
460
node_modules/@types/node/perf_hooks.d.ts
generated
vendored
460
node_modules/@types/node/perf_hooks.d.ts
generated
vendored
@@ -10,7 +10,7 @@
|
||||
* * [Resource Timing](https://www.w3.org/TR/resource-timing-2/)
|
||||
*
|
||||
* ```js
|
||||
* const { PerformanceObserver, performance } = require('node:perf_hooks');
|
||||
* import { PerformanceObserver, performance } from 'node:perf_hooks';
|
||||
*
|
||||
* const obs = new PerformanceObserver((items) => {
|
||||
* console.log(items.getEntries()[0].duration);
|
||||
@@ -27,14 +27,24 @@
|
||||
* performance.measure('A to B', 'A', 'B');
|
||||
* });
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/perf_hooks.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/perf_hooks.js)
|
||||
*/
|
||||
declare module "perf_hooks" {
|
||||
import { AsyncResource } from "node:async_hooks";
|
||||
type EntryType = "node" | "mark" | "measure" | "gc" | "function" | "http2" | "http" | "dns" | "net";
|
||||
type EntryType =
|
||||
| "dns" // Node.js only
|
||||
| "function" // Node.js only
|
||||
| "gc" // Node.js only
|
||||
| "http2" // Node.js only
|
||||
| "http" // Node.js only
|
||||
| "mark" // available on the Web
|
||||
| "measure" // available on the Web
|
||||
| "net" // Node.js only
|
||||
| "node" // Node.js only
|
||||
| "resource"; // available on the Web
|
||||
interface NodeGCPerformanceDetail {
|
||||
/**
|
||||
* When `performanceEntry.entryType` is equal to 'gc', `the performance.kind` property identifies
|
||||
* 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.
|
||||
*/
|
||||
@@ -106,6 +116,20 @@ declare module "perf_hooks" {
|
||||
class PerformanceMeasure extends PerformanceEntry {
|
||||
readonly entryType: "measure";
|
||||
}
|
||||
interface UVMetrics {
|
||||
/**
|
||||
* Number of event loop iterations.
|
||||
*/
|
||||
readonly loopCount: number;
|
||||
/**
|
||||
* Number of events that have been processed by the event handler.
|
||||
*/
|
||||
readonly events: number;
|
||||
/**
|
||||
* Number of events that were waiting to be processed when the event provider was called.
|
||||
*/
|
||||
readonly eventsWaiting: number;
|
||||
}
|
||||
/**
|
||||
* _This property is an extension by Node.js. It is not available in Web browsers._
|
||||
*
|
||||
@@ -150,6 +174,21 @@ declare module "perf_hooks" {
|
||||
* @since v8.5.0
|
||||
*/
|
||||
readonly loopStart: number;
|
||||
/**
|
||||
* The high resolution millisecond timestamp at which the Node.js process was initialized.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
readonly nodeStart: number;
|
||||
/**
|
||||
* This is a wrapper to the `uv_metrics_info` function.
|
||||
* It returns the current set of event loop metrics.
|
||||
*
|
||||
* It is recommended to use this property inside a function whose execution was
|
||||
* scheduled using `setImmediate` to avoid collecting metrics before finishing all
|
||||
* operations scheduled during the current loop iteration.
|
||||
* @since v20.18.0
|
||||
*/
|
||||
readonly uvMetricsInfo: UVMetrics;
|
||||
/**
|
||||
* The high resolution millisecond timestamp at which the V8 platform was
|
||||
* initialized.
|
||||
@@ -163,12 +202,12 @@ declare module "perf_hooks" {
|
||||
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
|
||||
* @param utilization1 The result of a previous call to `eventLoopUtilization()`.
|
||||
* @param utilization2 The result of a previous call to `eventLoopUtilization()` prior to `utilization1`.
|
||||
*/
|
||||
type EventLoopUtilityFunction = (
|
||||
util1?: EventLoopUtilization,
|
||||
util2?: EventLoopUtilization,
|
||||
utilization1?: EventLoopUtilization,
|
||||
utilization2?: EventLoopUtilization,
|
||||
) => EventLoopUtilization;
|
||||
interface MarkOptions {
|
||||
/**
|
||||
@@ -177,7 +216,7 @@ declare module "perf_hooks" {
|
||||
detail?: unknown | undefined;
|
||||
/**
|
||||
* An optional timestamp to be used as the mark time.
|
||||
* @default `performance.now()`.
|
||||
* @default `performance.now()`
|
||||
*/
|
||||
startTime?: number | undefined;
|
||||
}
|
||||
@@ -201,26 +240,36 @@ declare module "perf_hooks" {
|
||||
}
|
||||
interface TimerifyOptions {
|
||||
/**
|
||||
* A histogram object created using
|
||||
* `perf_hooks.createHistogram()` that will record runtime durations in
|
||||
* nanoseconds.
|
||||
* A histogram object created using `perf_hooks.createHistogram()` that will record runtime
|
||||
* durations in nanoseconds.
|
||||
*/
|
||||
histogram?: RecordableHistogram | undefined;
|
||||
}
|
||||
interface Performance {
|
||||
/**
|
||||
* If name is not provided, removes all PerformanceMark objects from the Performance Timeline.
|
||||
* If name is provided, removes only the named mark.
|
||||
* @param name
|
||||
* If `name` is not provided, removes all `PerformanceMark` objects from the Performance Timeline.
|
||||
* If `name` is provided, removes only the named mark.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
clearMarks(name?: string): void;
|
||||
/**
|
||||
* If name is not provided, removes all PerformanceMeasure objects from the Performance Timeline.
|
||||
* If name is provided, removes only the named measure.
|
||||
* @param name
|
||||
* If `name` is not provided, removes all `PerformanceMeasure` objects from the Performance Timeline.
|
||||
* If `name` is provided, removes only the named measure.
|
||||
* @since v16.7.0
|
||||
*/
|
||||
clearMeasures(name?: string): void;
|
||||
/**
|
||||
* If `name` is not provided, removes all `PerformanceResourceTiming` objects from the Resource Timeline.
|
||||
* If `name` is provided, removes only the named resource.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
clearResourceTimings(name?: string): void;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime`.
|
||||
* If you are only interested in performance entries of certain types or that have certain names, see
|
||||
@@ -244,14 +293,35 @@ declare module "perf_hooks" {
|
||||
*/
|
||||
getEntriesByType(type: EntryType): PerformanceEntry[];
|
||||
/**
|
||||
* Creates a new PerformanceMark entry in the Performance Timeline.
|
||||
* A PerformanceMark is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'mark',
|
||||
* and whose performanceEntry.duration is always 0.
|
||||
* Creates a new `PerformanceMark` entry in the Performance Timeline.
|
||||
* A `PerformanceMark` is a subclass of `PerformanceEntry` whose `performanceEntry.entryType` is always `'mark'`,
|
||||
* and whose `performanceEntry.duration` is always `0`.
|
||||
* Performance marks are used to mark specific significant moments in the Performance Timeline.
|
||||
*
|
||||
* The created `PerformanceMark` entry is put in the global Performance Timeline and can be queried with
|
||||
* `performance.getEntries`, `performance.getEntriesByName`, and `performance.getEntriesByType`. When the observation is
|
||||
* performed, the entries should be cleared from the global Performance Timeline manually with `performance.clearMarks`.
|
||||
* @param name
|
||||
* @return The PerformanceMark entry that was created
|
||||
*/
|
||||
mark(name?: string, options?: MarkOptions): PerformanceMark;
|
||||
mark(name: string, options?: MarkOptions): PerformanceMark;
|
||||
/**
|
||||
* Creates a new `PerformanceResourceTiming` entry in the Resource Timeline.
|
||||
* A `PerformanceResourceTiming` is a subclass of `PerformanceEntry` whose `performanceEntry.entryType` is always `'resource'`.
|
||||
* Performance resources are used to mark moments in the Resource Timeline.
|
||||
* @param timingInfo [Fetch Timing Info](https://fetch.spec.whatwg.org/#fetch-timing-info)
|
||||
* @param requestedUrl The resource url
|
||||
* @param initiatorType The initiator name, e.g: 'fetch'
|
||||
* @param global
|
||||
* @param cacheMode The cache mode must be an empty string ('') or 'local'
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
markResourceTiming(
|
||||
timingInfo: object,
|
||||
requestedUrl: string,
|
||||
initiatorType: string,
|
||||
global: object,
|
||||
cacheMode: "" | "local",
|
||||
): PerformanceResourceTiming;
|
||||
/**
|
||||
* Creates a new PerformanceMeasure entry in the Performance Timeline.
|
||||
* A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
|
||||
@@ -271,40 +341,83 @@ declare module "perf_hooks" {
|
||||
measure(name: string, startMark?: string, endMark?: string): PerformanceMeasure;
|
||||
measure(name: string, options: MeasureOptions): PerformanceMeasure;
|
||||
/**
|
||||
* An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones.
|
||||
* _This property is an extension by Node.js. It is not available in Web browsers._
|
||||
*
|
||||
* An instance of the `PerformanceNodeTiming` class that provides performance metrics for specific Node.js operational milestones.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
readonly nodeTiming: PerformanceNodeTiming;
|
||||
/**
|
||||
* @return the current high resolution millisecond timestamp
|
||||
* Returns the current high resolution millisecond timestamp, where 0 represents the start of the current `node` process.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
now(): number;
|
||||
/**
|
||||
* The timeOrigin specifies the high resolution millisecond timestamp from which all performance metric durations are measured.
|
||||
* Sets the global performance resource timing buffer size to the specified number of "resource" type performance entry objects.
|
||||
*
|
||||
* By default the max buffer size is set to 250.
|
||||
* @since v18.8.0
|
||||
*/
|
||||
setResourceTimingBufferSize(maxSize: number): void;
|
||||
/**
|
||||
* The [`timeOrigin`](https://w3c.github.io/hr-time/#dom-performance-timeorigin) specifies the high resolution millisecond timestamp
|
||||
* at which the current `node` process began, measured in Unix time.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
readonly timeOrigin: number;
|
||||
/**
|
||||
* _This property is an extension by Node.js. It is not available in Web browsers._
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ```js
|
||||
* import {
|
||||
* performance,
|
||||
* PerformanceObserver,
|
||||
* } from 'node:perf_hooks';
|
||||
*
|
||||
* function someFunction() {
|
||||
* console.log('hello world');
|
||||
* }
|
||||
*
|
||||
* const wrapped = performance.timerify(someFunction);
|
||||
*
|
||||
* const obs = new PerformanceObserver((list) => {
|
||||
* console.log(list.getEntries()[0].duration);
|
||||
*
|
||||
* performance.clearMarks();
|
||||
* performance.clearMeasures();
|
||||
* obs.disconnect();
|
||||
* });
|
||||
* obs.observe({ entryTypes: ['function'] });
|
||||
*
|
||||
* // A performance timeline entry will be created
|
||||
* wrapped();
|
||||
* ```
|
||||
*
|
||||
* If the wrapped function returns a promise, a finally handler will be attached to the promise and the duration will be reported
|
||||
* once the finally handler is invoked.
|
||||
* @param fn
|
||||
*/
|
||||
timerify<T extends (...params: any[]) => any>(fn: T, options?: TimerifyOptions): 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.
|
||||
* An object which is JSON representation of the performance object. It is similar to
|
||||
* [`window.performance.toJSON`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/toJSON) in browsers.
|
||||
* @since v16.1.0
|
||||
*/
|
||||
eventLoopUtilization: EventLoopUtilityFunction;
|
||||
toJSON(): any;
|
||||
}
|
||||
interface PerformanceObserverEntryList {
|
||||
class PerformanceObserverEntryList {
|
||||
/**
|
||||
* Returns a list of `PerformanceEntry` objects in chronological order
|
||||
* with respect to `performanceEntry.startTime`.
|
||||
*
|
||||
* ```js
|
||||
* const {
|
||||
* import {
|
||||
* performance,
|
||||
* PerformanceObserver,
|
||||
* } = require('node:perf_hooks');
|
||||
* } from 'node:perf_hooks';
|
||||
*
|
||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
||||
* console.log(perfObserverList.getEntries());
|
||||
@@ -314,13 +427,15 @@ declare module "perf_hooks" {
|
||||
* * name: 'test',
|
||||
* * entryType: 'mark',
|
||||
* * startTime: 81.465639,
|
||||
* * duration: 0
|
||||
* * duration: 0,
|
||||
* * detail: null
|
||||
* * },
|
||||
* * PerformanceEntry {
|
||||
* * name: 'meow',
|
||||
* * entryType: 'mark',
|
||||
* * startTime: 81.860064,
|
||||
* * duration: 0
|
||||
* * duration: 0,
|
||||
* * detail: null
|
||||
* * }
|
||||
* * ]
|
||||
*
|
||||
@@ -342,10 +457,10 @@ declare module "perf_hooks" {
|
||||
* equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to`type`.
|
||||
*
|
||||
* ```js
|
||||
* const {
|
||||
* import {
|
||||
* performance,
|
||||
* PerformanceObserver,
|
||||
* } = require('node:perf_hooks');
|
||||
* } from 'node:perf_hooks';
|
||||
*
|
||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
||||
* console.log(perfObserverList.getEntriesByName('meow'));
|
||||
@@ -355,7 +470,8 @@ declare module "perf_hooks" {
|
||||
* * name: 'meow',
|
||||
* * entryType: 'mark',
|
||||
* * startTime: 98.545991,
|
||||
* * duration: 0
|
||||
* * duration: 0,
|
||||
* * detail: null
|
||||
* * }
|
||||
* * ]
|
||||
*
|
||||
@@ -368,7 +484,8 @@ declare module "perf_hooks" {
|
||||
* * name: 'test',
|
||||
* * entryType: 'mark',
|
||||
* * startTime: 63.518931,
|
||||
* * duration: 0
|
||||
* * duration: 0,
|
||||
* * detail: null
|
||||
* * }
|
||||
* * ]
|
||||
*
|
||||
@@ -388,13 +505,13 @@ declare module "perf_hooks" {
|
||||
getEntriesByName(name: string, type?: EntryType): PerformanceEntry[];
|
||||
/**
|
||||
* Returns a list of `PerformanceEntry` objects in chronological order
|
||||
* with respect to `performanceEntry.startTime` whose `performanceEntry.entryType`is equal to `type`.
|
||||
* with respect to `performanceEntry.startTime` whose `performanceEntry.entryType` is equal to `type`.
|
||||
*
|
||||
* ```js
|
||||
* const {
|
||||
* import {
|
||||
* performance,
|
||||
* PerformanceObserver,
|
||||
* } = require('node:perf_hooks');
|
||||
* } from 'node:perf_hooks';
|
||||
*
|
||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
||||
* console.log(perfObserverList.getEntriesByType('mark'));
|
||||
@@ -404,13 +521,15 @@ declare module "perf_hooks" {
|
||||
* * name: 'test',
|
||||
* * entryType: 'mark',
|
||||
* * startTime: 55.897834,
|
||||
* * duration: 0
|
||||
* * duration: 0,
|
||||
* * detail: null
|
||||
* * },
|
||||
* * PerformanceEntry {
|
||||
* * name: 'meow',
|
||||
* * entryType: 'mark',
|
||||
* * startTime: 56.350146,
|
||||
* * duration: 0
|
||||
* * duration: 0,
|
||||
* * detail: null
|
||||
* * }
|
||||
* * ]
|
||||
*
|
||||
@@ -439,13 +558,13 @@ declare module "perf_hooks" {
|
||||
*/
|
||||
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 either by `options.entryTypes` or `options.type`:
|
||||
*
|
||||
* ```js
|
||||
* const {
|
||||
* import {
|
||||
* performance,
|
||||
* PerformanceObserver,
|
||||
* } = require('node:perf_hooks');
|
||||
* } from 'node:perf_hooks';
|
||||
*
|
||||
* const obs = new PerformanceObserver((list, observer) => {
|
||||
* // Called once asynchronously. `list` contains three items.
|
||||
@@ -460,7 +579,7 @@ declare module "perf_hooks" {
|
||||
observe(
|
||||
options:
|
||||
| {
|
||||
entryTypes: ReadonlyArray<EntryType>;
|
||||
entryTypes: readonly EntryType[];
|
||||
buffered?: boolean | undefined;
|
||||
}
|
||||
| {
|
||||
@@ -468,6 +587,109 @@ declare module "perf_hooks" {
|
||||
buffered?: boolean | undefined;
|
||||
},
|
||||
): void;
|
||||
/**
|
||||
* @since v16.0.0
|
||||
* @returns Current list of entries stored in the performance observer, emptying it out.
|
||||
*/
|
||||
takeRecords(): PerformanceEntry[];
|
||||
}
|
||||
/**
|
||||
* Provides detailed network timing data regarding the loading of an application's resources.
|
||||
*
|
||||
* The constructor of this class is not exposed to users directly.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
class PerformanceResourceTiming extends PerformanceEntry {
|
||||
readonly entryType: "resource";
|
||||
protected constructor();
|
||||
/**
|
||||
* The high resolution millisecond timestamp at immediately before dispatching the `fetch`
|
||||
* request. If the resource is not intercepted by a worker the property will always return 0.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly workerStart: number;
|
||||
/**
|
||||
* The high resolution millisecond timestamp that represents the start time of the fetch which
|
||||
* initiates the redirect.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly redirectStart: number;
|
||||
/**
|
||||
* The high resolution millisecond timestamp that will be created immediately after receiving
|
||||
* the last byte of the response of the last redirect.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly redirectEnd: number;
|
||||
/**
|
||||
* The high resolution millisecond timestamp immediately before the Node.js starts to fetch the resource.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly fetchStart: number;
|
||||
/**
|
||||
* The high resolution millisecond timestamp immediately before the Node.js starts the domain name lookup
|
||||
* for the resource.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly domainLookupStart: number;
|
||||
/**
|
||||
* The high resolution millisecond timestamp representing the time immediately after the Node.js finished
|
||||
* the domain name lookup for the resource.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly domainLookupEnd: number;
|
||||
/**
|
||||
* The high resolution millisecond timestamp representing the time immediately before Node.js starts to
|
||||
* establish the connection to the server to retrieve the resource.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly connectStart: number;
|
||||
/**
|
||||
* The high resolution millisecond timestamp representing the time immediately after Node.js finishes
|
||||
* establishing the connection to the server to retrieve the resource.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly connectEnd: number;
|
||||
/**
|
||||
* The high resolution millisecond timestamp representing the time immediately before Node.js starts the
|
||||
* handshake process to secure the current connection.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly secureConnectionStart: number;
|
||||
/**
|
||||
* The high resolution millisecond timestamp representing the time immediately before Node.js receives the
|
||||
* first byte of the response from the server.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly requestStart: number;
|
||||
/**
|
||||
* The high resolution millisecond timestamp representing the time immediately after Node.js receives the
|
||||
* last byte of the resource or immediately before the transport connection is closed, whichever comes first.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly responseEnd: number;
|
||||
/**
|
||||
* A number representing the size (in octets) of the fetched resource. The size includes the response header
|
||||
* fields plus the response payload body.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly transferSize: number;
|
||||
/**
|
||||
* A number representing the size (in octets) received from the fetch (HTTP or cache), of the payload body, before
|
||||
* removing any applied content-codings.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly encodedBodySize: number;
|
||||
/**
|
||||
* A number representing the size (in octets) received from the fetch (HTTP or cache), of the message body, after
|
||||
* removing any applied content-codings.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
readonly decodedBodySize: number;
|
||||
/**
|
||||
* Returns a `object` that is the JSON representation of the `PerformanceResourceTiming` object
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
toJSON(): any;
|
||||
}
|
||||
namespace constants {
|
||||
const NODE_PERFORMANCE_GC_MAJOR: number;
|
||||
@@ -493,10 +715,15 @@ declare module "perf_hooks" {
|
||||
}
|
||||
interface Histogram {
|
||||
/**
|
||||
* Returns a `Map` object detailing the accumulated percentile distribution.
|
||||
* @since v11.10.0
|
||||
* The number of samples recorded by the histogram.
|
||||
* @since v17.4.0, v16.14.0
|
||||
*/
|
||||
readonly percentiles: Map<number, number>;
|
||||
readonly count: number;
|
||||
/**
|
||||
* The number of samples recorded by the histogram.
|
||||
* v17.4.0, v16.14.0
|
||||
*/
|
||||
readonly countBigInt: bigint;
|
||||
/**
|
||||
* The number of times the event loop delay exceeded the maximum 1 hour event
|
||||
* loop delay threshold.
|
||||
@@ -504,36 +731,67 @@ declare module "perf_hooks" {
|
||||
*/
|
||||
readonly exceeds: number;
|
||||
/**
|
||||
* The minimum recorded event loop delay.
|
||||
* @since v11.10.0
|
||||
* The number of times the event loop delay exceeded the maximum 1 hour event loop delay threshold.
|
||||
* @since v17.4.0, v16.14.0
|
||||
*/
|
||||
readonly min: number;
|
||||
readonly exceedsBigInt: bigint;
|
||||
/**
|
||||
* The maximum recorded event loop delay.
|
||||
* @since v11.10.0
|
||||
*/
|
||||
readonly max: number;
|
||||
/**
|
||||
* The maximum recorded event loop delay.
|
||||
* v17.4.0, v16.14.0
|
||||
*/
|
||||
readonly maxBigInt: 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.
|
||||
* The minimum recorded event loop delay.
|
||||
* @since v11.10.0
|
||||
*/
|
||||
readonly stddev: number;
|
||||
readonly min: number;
|
||||
/**
|
||||
* Resets the collected histogram data.
|
||||
* @since v11.10.0
|
||||
* The minimum recorded event loop delay.
|
||||
* v17.4.0, v16.14.0
|
||||
*/
|
||||
reset(): void;
|
||||
readonly minBigInt: bigint;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* Returns the value at the given percentile.
|
||||
* @since v17.4.0, v16.14.0
|
||||
* @param percentile A percentile value in the range (0, 100].
|
||||
*/
|
||||
percentileBigInt(percentile: number): bigint;
|
||||
/**
|
||||
* Returns a `Map` object detailing the accumulated percentile distribution.
|
||||
* @since v11.10.0
|
||||
*/
|
||||
readonly percentiles: Map<number, number>;
|
||||
/**
|
||||
* Returns a `Map` object detailing the accumulated percentile distribution.
|
||||
* @since v17.4.0, v16.14.0
|
||||
*/
|
||||
readonly percentilesBigInt: Map<bigint, bigint>;
|
||||
/**
|
||||
* Resets the collected histogram data.
|
||||
* @since v11.10.0
|
||||
*/
|
||||
reset(): void;
|
||||
/**
|
||||
* The standard deviation of the recorded event loop delays.
|
||||
* @since v11.10.0
|
||||
*/
|
||||
readonly stddev: number;
|
||||
}
|
||||
interface IntervalHistogram extends Histogram {
|
||||
/**
|
||||
@@ -558,8 +816,6 @@ declare module "perf_hooks" {
|
||||
/**
|
||||
* 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, v14.18.0
|
||||
*/
|
||||
recordDelta(): void;
|
||||
@@ -582,7 +838,7 @@ declare module "perf_hooks" {
|
||||
* detect.
|
||||
*
|
||||
* ```js
|
||||
* const { monitorEventLoopDelay } = require('node:perf_hooks');
|
||||
* import { monitorEventLoopDelay } from 'node:perf_hooks';
|
||||
* const h = monitorEventLoopDelay({ resolution: 20 });
|
||||
* h.enable();
|
||||
* // Do something.
|
||||
@@ -603,12 +859,12 @@ declare module "perf_hooks" {
|
||||
* The minimum recordable value. Must be an integer value greater than 0.
|
||||
* @default 1
|
||||
*/
|
||||
min?: number | bigint | undefined;
|
||||
lowest?: number | bigint | undefined;
|
||||
/**
|
||||
* The maximum recordable value. Must be an integer value greater than min.
|
||||
* @default Number.MAX_SAFE_INTEGER
|
||||
*/
|
||||
max?: number | bigint | undefined;
|
||||
highest?: number | bigint | undefined;
|
||||
/**
|
||||
* The number of accuracy digits. Must be a number between 1 and 5.
|
||||
* @default 3
|
||||
@@ -620,11 +876,79 @@ declare module "perf_hooks" {
|
||||
* @since v15.9.0, v14.18.0
|
||||
*/
|
||||
function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
|
||||
import { performance as _performance } from "perf_hooks";
|
||||
import {
|
||||
performance as _performance,
|
||||
PerformanceEntry as _PerformanceEntry,
|
||||
PerformanceMark as _PerformanceMark,
|
||||
PerformanceMeasure as _PerformanceMeasure,
|
||||
PerformanceObserver as _PerformanceObserver,
|
||||
PerformanceObserverEntryList as _PerformanceObserverEntryList,
|
||||
PerformanceResourceTiming as _PerformanceResourceTiming,
|
||||
} from "perf_hooks";
|
||||
global {
|
||||
/**
|
||||
* `performance` is a global reference for `require('perf_hooks').performance`
|
||||
* https://nodejs.org/api/globals.html#performance
|
||||
* `PerformanceEntry` is a global reference for `import { PerformanceEntry } from 'node:node:perf_hooks'`
|
||||
* @see https://nodejs.org/docs/latest-v20.x/api/globals.html#performanceentry
|
||||
* @since v19.0.0
|
||||
*/
|
||||
var PerformanceEntry: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
PerformanceEntry: infer T;
|
||||
} ? T
|
||||
: typeof _PerformanceEntry;
|
||||
/**
|
||||
* `PerformanceMark` is a global reference for `import { PerformanceMark } from 'node:node:perf_hooks'`
|
||||
* @see https://nodejs.org/docs/latest-v20.x/api/globals.html#performancemark
|
||||
* @since v19.0.0
|
||||
*/
|
||||
var PerformanceMark: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
PerformanceMark: infer T;
|
||||
} ? T
|
||||
: typeof _PerformanceMark;
|
||||
/**
|
||||
* `PerformanceMeasure` is a global reference for `import { PerformanceMeasure } from 'node:node:perf_hooks'`
|
||||
* @see https://nodejs.org/docs/latest-v20.x/api/globals.html#performancemeasure
|
||||
* @since v19.0.0
|
||||
*/
|
||||
var PerformanceMeasure: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
PerformanceMeasure: infer T;
|
||||
} ? T
|
||||
: typeof _PerformanceMeasure;
|
||||
/**
|
||||
* `PerformanceObserver` is a global reference for `import { PerformanceObserver } from 'node:node:perf_hooks'`
|
||||
* @see https://nodejs.org/docs/latest-v20.x/api/globals.html#performanceobserver
|
||||
* @since v19.0.0
|
||||
*/
|
||||
var PerformanceObserver: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
PerformanceObserver: infer T;
|
||||
} ? T
|
||||
: typeof _PerformanceObserver;
|
||||
/**
|
||||
* `PerformanceObserverEntryList` is a global reference for `import { PerformanceObserverEntryList } from 'node:node:perf_hooks'`
|
||||
* @see https://nodejs.org/docs/latest-v20.x/api/globals.html#performanceobserverentrylist
|
||||
* @since v19.0.0
|
||||
*/
|
||||
var PerformanceObserverEntryList: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
PerformanceObserverEntryList: infer T;
|
||||
} ? T
|
||||
: typeof _PerformanceObserverEntryList;
|
||||
/**
|
||||
* `PerformanceResourceTiming` is a global reference for `import { PerformanceResourceTiming } from 'node:node:perf_hooks'`
|
||||
* @see https://nodejs.org/docs/latest-v20.x/api/globals.html#performanceresourcetiming
|
||||
* @since v19.0.0
|
||||
*/
|
||||
var PerformanceResourceTiming: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
PerformanceResourceTiming: infer T;
|
||||
} ? T
|
||||
: typeof _PerformanceResourceTiming;
|
||||
/**
|
||||
* `performance` is a global reference for `import { performance } from 'node:node:perf_hooks'`
|
||||
* @see https://nodejs.org/docs/latest-v20.x/api/globals.html#performance
|
||||
* @since v16.0.0
|
||||
*/
|
||||
var performance: typeof globalThis extends {
|
||||
|
||||
568
node_modules/@types/node/process.d.ts
generated
vendored
568
node_modules/@types/node/process.d.ts
generated
vendored
@@ -1,6 +1,121 @@
|
||||
declare module "process" {
|
||||
import * as tty from "node:tty";
|
||||
import { Worker } from "node:worker_threads";
|
||||
|
||||
interface BuiltInModule {
|
||||
"assert": typeof import("assert");
|
||||
"node:assert": typeof import("node:assert");
|
||||
"assert/strict": typeof import("assert/strict");
|
||||
"node:assert/strict": typeof import("node:assert/strict");
|
||||
"async_hooks": typeof import("async_hooks");
|
||||
"node:async_hooks": typeof import("node:async_hooks");
|
||||
"buffer": typeof import("buffer");
|
||||
"node:buffer": typeof import("node:buffer");
|
||||
"child_process": typeof import("child_process");
|
||||
"node:child_process": typeof import("node:child_process");
|
||||
"cluster": typeof import("cluster");
|
||||
"node:cluster": typeof import("node:cluster");
|
||||
"console": typeof import("console");
|
||||
"node:console": typeof import("node:console");
|
||||
"constants": typeof import("constants");
|
||||
"node:constants": typeof import("node:constants");
|
||||
"crypto": typeof import("crypto");
|
||||
"node:crypto": typeof import("node:crypto");
|
||||
"dgram": typeof import("dgram");
|
||||
"node:dgram": typeof import("node:dgram");
|
||||
"diagnostics_channel": typeof import("diagnostics_channel");
|
||||
"node:diagnostics_channel": typeof import("node:diagnostics_channel");
|
||||
"dns": typeof import("dns");
|
||||
"node:dns": typeof import("node:dns");
|
||||
"dns/promises": typeof import("dns/promises");
|
||||
"node:dns/promises": typeof import("node:dns/promises");
|
||||
"domain": typeof import("domain");
|
||||
"node:domain": typeof import("node:domain");
|
||||
"events": typeof import("events");
|
||||
"node:events": typeof import("node:events");
|
||||
"fs": typeof import("fs");
|
||||
"node:fs": typeof import("node:fs");
|
||||
"fs/promises": typeof import("fs/promises");
|
||||
"node:fs/promises": typeof import("node:fs/promises");
|
||||
"http": typeof import("http");
|
||||
"node:http": typeof import("node:http");
|
||||
"http2": typeof import("http2");
|
||||
"node:http2": typeof import("node:http2");
|
||||
"https": typeof import("https");
|
||||
"node:https": typeof import("node:https");
|
||||
"inspector": typeof import("inspector");
|
||||
"node:inspector": typeof import("node:inspector");
|
||||
"inspector/promises": typeof import("inspector/promises");
|
||||
"node:inspector/promises": typeof import("node:inspector/promises");
|
||||
"module": typeof import("module");
|
||||
"node:module": typeof import("node:module");
|
||||
"net": typeof import("net");
|
||||
"node:net": typeof import("node:net");
|
||||
"os": typeof import("os");
|
||||
"node:os": typeof import("node:os");
|
||||
"path": typeof import("path");
|
||||
"node:path": typeof import("node:path");
|
||||
"path/posix": typeof import("path/posix");
|
||||
"node:path/posix": typeof import("node:path/posix");
|
||||
"path/win32": typeof import("path/win32");
|
||||
"node:path/win32": typeof import("node:path/win32");
|
||||
"perf_hooks": typeof import("perf_hooks");
|
||||
"node:perf_hooks": typeof import("node:perf_hooks");
|
||||
"process": typeof import("process");
|
||||
"node:process": typeof import("node:process");
|
||||
"punycode": typeof import("punycode");
|
||||
"node:punycode": typeof import("node:punycode");
|
||||
"querystring": typeof import("querystring");
|
||||
"node:querystring": typeof import("node:querystring");
|
||||
"readline": typeof import("readline");
|
||||
"node:readline": typeof import("node:readline");
|
||||
"readline/promises": typeof import("readline/promises");
|
||||
"node:readline/promises": typeof import("node:readline/promises");
|
||||
"repl": typeof import("repl");
|
||||
"node:repl": typeof import("node:repl");
|
||||
"node:sea": typeof import("node:sea");
|
||||
"stream": typeof import("stream");
|
||||
"node:stream": typeof import("node:stream");
|
||||
"stream/consumers": typeof import("stream/consumers");
|
||||
"node:stream/consumers": typeof import("node:stream/consumers");
|
||||
"stream/promises": typeof import("stream/promises");
|
||||
"node:stream/promises": typeof import("node:stream/promises");
|
||||
"stream/web": typeof import("stream/web");
|
||||
"node:stream/web": typeof import("node:stream/web");
|
||||
"string_decoder": typeof import("string_decoder");
|
||||
"node:string_decoder": typeof import("node:string_decoder");
|
||||
"node:test": typeof import("node:test");
|
||||
"node:test/reporters": typeof import("node:test/reporters");
|
||||
"timers": typeof import("timers");
|
||||
"node:timers": typeof import("node:timers");
|
||||
"timers/promises": typeof import("timers/promises");
|
||||
"node:timers/promises": typeof import("node:timers/promises");
|
||||
"tls": typeof import("tls");
|
||||
"node:tls": typeof import("node:tls");
|
||||
"trace_events": typeof import("trace_events");
|
||||
"node:trace_events": typeof import("node:trace_events");
|
||||
"tty": typeof import("tty");
|
||||
"node:tty": typeof import("node:tty");
|
||||
"url": typeof import("url");
|
||||
"node:url": typeof import("node:url");
|
||||
"util": typeof import("util");
|
||||
"node:util": typeof import("node:util");
|
||||
"sys": typeof import("util");
|
||||
"node:sys": typeof import("node:util");
|
||||
"util/types": typeof import("util/types");
|
||||
"node:util/types": typeof import("node:util/types");
|
||||
"v8": typeof import("v8");
|
||||
"node:v8": typeof import("node:v8");
|
||||
"vm": typeof import("vm");
|
||||
"node:vm": typeof import("node:vm");
|
||||
"wasi": typeof import("wasi");
|
||||
"node:wasi": typeof import("node:wasi");
|
||||
"worker_threads": typeof import("worker_threads");
|
||||
"node:worker_threads": typeof import("node:worker_threads");
|
||||
"zlib": typeof import("zlib");
|
||||
"node:zlib": typeof import("node:zlib");
|
||||
}
|
||||
|
||||
global {
|
||||
var process: NodeJS.Process;
|
||||
namespace NodeJS {
|
||||
@@ -21,10 +136,25 @@ declare module "process" {
|
||||
rss(): number;
|
||||
}
|
||||
interface MemoryUsage {
|
||||
/**
|
||||
* Resident Set Size, is the amount of space occupied in the main memory device (that is a subset of the total allocated memory) for the
|
||||
* process, including all C++ and JavaScript objects and code.
|
||||
*/
|
||||
rss: number;
|
||||
/**
|
||||
* Refers to V8's memory usage.
|
||||
*/
|
||||
heapTotal: number;
|
||||
/**
|
||||
* Refers to V8's memory usage.
|
||||
*/
|
||||
heapUsed: number;
|
||||
external: number;
|
||||
/**
|
||||
* Refers to memory allocated for `ArrayBuffer`s and `SharedArrayBuffer`s, including all Node.js Buffers. This is also included
|
||||
* in the external value. When Node.js is used as an embedded library, this value may be `0` because allocations for `ArrayBuffer`s
|
||||
* may not be tracked in that case.
|
||||
*/
|
||||
arrayBuffers: number;
|
||||
}
|
||||
interface CpuUsage {
|
||||
@@ -38,6 +168,59 @@ declare module "process" {
|
||||
libUrl?: string | undefined;
|
||||
lts?: string | undefined;
|
||||
}
|
||||
interface ProcessFeatures {
|
||||
/**
|
||||
* A boolean value that is `true` if the current Node.js build is caching builtin modules.
|
||||
* @since v12.0.0
|
||||
*/
|
||||
readonly cached_builtins: boolean;
|
||||
/**
|
||||
* A boolean value that is `true` if the current Node.js build is a debug build.
|
||||
* @since v0.5.5
|
||||
*/
|
||||
readonly debug: boolean;
|
||||
/**
|
||||
* A boolean value that is `true` if the current Node.js build includes the inspector.
|
||||
* @since v11.10.0
|
||||
*/
|
||||
readonly inspector: boolean;
|
||||
/**
|
||||
* A boolean value that is `true` if the current Node.js build includes support for IPv6.
|
||||
* @since v0.5.3
|
||||
*/
|
||||
readonly ipv6: boolean;
|
||||
/**
|
||||
* A boolean value that is `true` if the current Node.js build supports
|
||||
* [loading ECMAScript modules using `require()`](https://nodejs.org/docs/latest-v20.x/api/modules.html#loading-ecmascript-modules-using-require).
|
||||
* @since v20.19.0
|
||||
*/
|
||||
readonly require_module: boolean;
|
||||
/**
|
||||
* A boolean value that is `true` if the current Node.js build includes support for TLS.
|
||||
* @since v0.5.3
|
||||
*/
|
||||
readonly tls: boolean;
|
||||
/**
|
||||
* A boolean value that is `true` if the current Node.js build includes support for ALPN in TLS.
|
||||
* @since v4.8.0
|
||||
*/
|
||||
readonly tls_alpn: boolean;
|
||||
/**
|
||||
* A boolean value that is `true` if the current Node.js build includes support for OCSP in TLS.
|
||||
* @since v0.11.13
|
||||
*/
|
||||
readonly tls_ocsp: boolean;
|
||||
/**
|
||||
* A boolean value that is `true` if the current Node.js build includes support for SNI in TLS.
|
||||
* @since v0.5.3
|
||||
*/
|
||||
readonly tls_sni: boolean;
|
||||
/**
|
||||
* A boolean value that is `true` if the current Node.js build includes support for libuv.
|
||||
* @since v0.5.3
|
||||
*/
|
||||
readonly uv: boolean;
|
||||
}
|
||||
interface ProcessVersions extends Dict<string> {
|
||||
http_parser: string;
|
||||
node: string;
|
||||
@@ -64,6 +247,7 @@ declare module "process" {
|
||||
| "arm"
|
||||
| "arm64"
|
||||
| "ia32"
|
||||
| "loong64"
|
||||
| "mips"
|
||||
| "mipsel"
|
||||
| "ppc"
|
||||
@@ -142,28 +326,110 @@ declare module "process" {
|
||||
TZ?: string;
|
||||
}
|
||||
interface HRTime {
|
||||
/**
|
||||
* This is the legacy version of {@link process.hrtime.bigint()}
|
||||
* before bigint was introduced in JavaScript.
|
||||
*
|
||||
* The `process.hrtime()` method returns the current high-resolution real time in a `[seconds, nanoseconds]` tuple `Array`,
|
||||
* where `nanoseconds` is the remaining part of the real time that can't be represented in second precision.
|
||||
*
|
||||
* `time` is an optional parameter that must be the result of a previous `process.hrtime()` call to diff with the current time.
|
||||
* If the parameter passed in is not a tuple `Array`, a TypeError will be thrown.
|
||||
* Passing in a user-defined array instead of the result of a previous call to `process.hrtime()` will lead to undefined behavior.
|
||||
*
|
||||
* These times are relative to an arbitrary time in the past,
|
||||
* and not related to the time of day and therefore not subject to clock drift.
|
||||
* The primary use is for measuring performance between intervals:
|
||||
* ```js
|
||||
* const { hrtime } = require('node:process');
|
||||
* const NS_PER_SEC = 1e9;
|
||||
* const time = hrtime();
|
||||
* // [ 1800216, 25 ]
|
||||
*
|
||||
* setTimeout(() => {
|
||||
* const diff = hrtime(time);
|
||||
* // [ 1, 552 ]
|
||||
*
|
||||
* console.log(`Benchmark took ${diff[0] * NS_PER_SEC + diff[1]} nanoseconds`);
|
||||
* // Benchmark took 1000000552 nanoseconds
|
||||
* }, 1000);
|
||||
* ```
|
||||
* @since 0.7.6
|
||||
* @legacy Use {@link process.hrtime.bigint()} instead.
|
||||
* @param time The result of a previous call to `process.hrtime()`
|
||||
*/
|
||||
(time?: [number, number]): [number, number];
|
||||
/**
|
||||
* The `bigint` version of the {@link process.hrtime()} method returning the current high-resolution real time in nanoseconds as a `bigint`.
|
||||
*
|
||||
* Unlike {@link process.hrtime()}, it does not support an additional time argument since the difference can just be computed directly by subtraction of the two `bigint`s.
|
||||
* ```js
|
||||
* import { hrtime } from 'node:process';
|
||||
*
|
||||
* const start = hrtime.bigint();
|
||||
* // 191051479007711n
|
||||
*
|
||||
* setTimeout(() => {
|
||||
* const end = hrtime.bigint();
|
||||
* // 191052633396993n
|
||||
*
|
||||
* console.log(`Benchmark took ${end - start} nanoseconds`);
|
||||
* // Benchmark took 1154389282 nanoseconds
|
||||
* }, 1000);
|
||||
* ```
|
||||
* @since v10.7.0
|
||||
*/
|
||||
bigint(): bigint;
|
||||
}
|
||||
interface ProcessPermission {
|
||||
/**
|
||||
* Verifies that the process is able to access the given scope and reference.
|
||||
* If no reference is provided, a global scope is assumed, for instance, `process.permission.has('fs.read')`
|
||||
* will check if the process has ALL file system read permissions.
|
||||
*
|
||||
* The reference has a meaning based on the provided scope. For example, the reference when the scope is File System means files and folders.
|
||||
*
|
||||
* The available scopes are:
|
||||
*
|
||||
* * `fs` - All File System
|
||||
* * `fs.read` - File System read operations
|
||||
* * `fs.write` - File System write operations
|
||||
* * `child` - Child process spawning operations
|
||||
* * `worker` - Worker thread spawning operation
|
||||
*
|
||||
* ```js
|
||||
* // Check if the process has permission to read the README file
|
||||
* process.permission.has('fs.read', './README.md');
|
||||
* // Check if the process has read permission operations
|
||||
* process.permission.has('fs.read');
|
||||
* ```
|
||||
* @since v20.0.0
|
||||
*/
|
||||
has(scope: string, reference?: string): boolean;
|
||||
}
|
||||
interface ProcessReport {
|
||||
/**
|
||||
* Write reports in a compact format, single-line JSON, more easily consumable by log processing systems
|
||||
* than the default multi-line format designed for human consumption.
|
||||
* @since v13.12.0, v12.17.0
|
||||
*/
|
||||
compact: boolean;
|
||||
/**
|
||||
* Directory where the report is written.
|
||||
* The default value is the empty string, indicating that reports are written to the current
|
||||
* working directory of the Node.js process.
|
||||
* @default '' indicating that reports are written to the current
|
||||
*/
|
||||
directory: string;
|
||||
/**
|
||||
* Filename where the report is written.
|
||||
* The default value is the empty string.
|
||||
* @default '' the output filename will be comprised of a timestamp,
|
||||
* PID, and sequence number.
|
||||
* Filename where the report is written. If set to the empty string, the output filename will be comprised
|
||||
* of a timestamp, PID, and sequence number. The default value is the empty string.
|
||||
*/
|
||||
filename: string;
|
||||
/**
|
||||
* Returns a JSON-formatted diagnostic report for the running process.
|
||||
* The report's JavaScript stack trace is taken from err, if present.
|
||||
* Returns a JavaScript Object representation of a diagnostic report for the running process.
|
||||
* The report's JavaScript stack trace is taken from `err`, if present.
|
||||
*/
|
||||
getReport(err?: Error): string;
|
||||
getReport(err?: Error): object;
|
||||
/**
|
||||
* If true, a diagnostic report is generated on fatal errors,
|
||||
* such as out of memory errors or failed C++ assertions.
|
||||
@@ -189,18 +455,19 @@ declare module "process" {
|
||||
/**
|
||||
* Writes a diagnostic report to a file. If filename is not provided, the default filename
|
||||
* includes the date, time, PID, and a sequence number.
|
||||
* The report's JavaScript stack trace is taken from err, if present.
|
||||
* The report's JavaScript stack trace is taken from `err`, if present.
|
||||
*
|
||||
* If the value of filename is set to `'stdout'` or `'stderr'`, the report is written
|
||||
* to the stdout or stderr of the process respectively.
|
||||
* @param fileName Name of the file where the report is written.
|
||||
* This should be a relative path, that will be appended to the directory specified in
|
||||
* `process.report.directory`, or the current working directory of the Node.js process,
|
||||
* if unspecified.
|
||||
* @param error A custom error used for reporting the JavaScript stack.
|
||||
* @param err A custom error used for reporting the JavaScript stack.
|
||||
* @return Filename of the generated report.
|
||||
*/
|
||||
writeReport(fileName?: string): string;
|
||||
writeReport(error?: Error): string;
|
||||
writeReport(fileName?: string, err?: Error): string;
|
||||
writeReport(err?: Error): string;
|
||||
}
|
||||
interface ResourceUsage {
|
||||
fsRead: number;
|
||||
@@ -306,12 +573,11 @@ declare module "process" {
|
||||
* For more information see `Stream compatibility`.
|
||||
*
|
||||
* In "old" streams mode the `stdin` stream is paused by default, so one
|
||||
* must call `process.stdin.resume()` to read from it. Note also that calling`process.stdin.resume()` itself would switch stream to "old" mode.
|
||||
* must call `process.stdin.resume()` to read from it. Note also that calling `process.stdin.resume()` itself would switch stream to "old" mode.
|
||||
*/
|
||||
stdin: ReadStream & {
|
||||
fd: 0;
|
||||
};
|
||||
openStdin(): Socket;
|
||||
/**
|
||||
* The `process.argv` property returns an array containing the command-line
|
||||
* arguments passed when the Node.js process was launched. The first element will
|
||||
@@ -371,13 +637,13 @@ declare module "process" {
|
||||
* the same execution environment as the parent.
|
||||
*
|
||||
* ```bash
|
||||
* node --harmony script.js --version
|
||||
* node --icu-data-dir=./foo --require ./bar.js script.js --version
|
||||
* ```
|
||||
*
|
||||
* Results in `process.execArgv`:
|
||||
*
|
||||
* ```js
|
||||
* ['--harmony']
|
||||
* ["--icu-data-dir=./foo", "--require", "./bar.js"]
|
||||
* ```
|
||||
*
|
||||
* And `process.argv`:
|
||||
@@ -453,6 +719,32 @@ declare module "process" {
|
||||
* @since v0.7.2
|
||||
*/
|
||||
debugPort: number;
|
||||
/**
|
||||
* The `process.dlopen()` method allows dynamically loading shared objects. It is primarily used by `require()` to load C++ Addons, and
|
||||
* should not be used directly, except in special cases. In other words, `require()` should be preferred over `process.dlopen()`
|
||||
* unless there are specific reasons such as custom dlopen flags or loading from ES modules.
|
||||
*
|
||||
* The `flags` argument is an integer that allows to specify dlopen behavior. See the `[os.constants.dlopen](https://nodejs.org/docs/latest-v20.x/api/os.html#dlopen-constants)`
|
||||
* documentation for details.
|
||||
*
|
||||
* An important requirement when calling `process.dlopen()` is that the `module` instance must be passed. Functions exported by the C++ Addon
|
||||
* are then accessible via `module.exports`.
|
||||
*
|
||||
* The example below shows how to load a C++ Addon, named `local.node`, that exports a `foo` function. All the symbols are loaded before the call returns, by passing the `RTLD_NOW` constant.
|
||||
* In this example the constant is assumed to be available.
|
||||
*
|
||||
* ```js
|
||||
* import { dlopen } from 'node:process';
|
||||
* import { constants } from 'node:os';
|
||||
* import { fileURLToPath } from 'node:url';
|
||||
*
|
||||
* const module = { exports: {} };
|
||||
* dlopen(module, fileURLToPath(new URL('local.node', import.meta.url)),
|
||||
* constants.dlopen.RTLD_NOW);
|
||||
* module.exports.foo();
|
||||
* ```
|
||||
*/
|
||||
dlopen(module: object, filename: string, flags?: number): void;
|
||||
/**
|
||||
* The `process.emitWarning()` method can be used to emit custom or application
|
||||
* specific process warnings. These can be listened for by adding a handler to the `'warning'` event.
|
||||
@@ -460,17 +752,27 @@ declare module "process" {
|
||||
* ```js
|
||||
* import { emitWarning } from 'node:process';
|
||||
*
|
||||
* // Emit a warning with a code and additional detail.
|
||||
* emitWarning('Something happened!', {
|
||||
* code: 'MY_WARNING',
|
||||
* detail: 'This is some additional information',
|
||||
* });
|
||||
* // Emits:
|
||||
* // (node:56338) [MY_WARNING] Warning: Something happened!
|
||||
* // This is some additional information
|
||||
* // Emit a warning using a string.
|
||||
* emitWarning('Something happened!');
|
||||
* // Emits: (node: 56338) Warning: Something happened!
|
||||
* ```
|
||||
*
|
||||
* In this example, an `Error` object is generated internally by`process.emitWarning()` and passed through to the `'warning'` handler.
|
||||
* ```js
|
||||
* import { emitWarning } from 'node:process';
|
||||
*
|
||||
* // Emit a warning using a string and a type.
|
||||
* emitWarning('Something Happened!', 'CustomWarning');
|
||||
* // Emits: (node:56338) CustomWarning: Something Happened!
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import { emitWarning } from 'node:process';
|
||||
*
|
||||
* emitWarning('Something happened!', 'CustomWarning', 'WARN001');
|
||||
* // Emits: (node:56338) [WARN001] CustomWarning: Something happened!
|
||||
* ```js
|
||||
*
|
||||
* In each of the previous examples, an `Error` object is generated internally by `process.emitWarning()` and passed through to the `'warning'` handler.
|
||||
*
|
||||
* ```js
|
||||
* import process from 'node:process';
|
||||
@@ -484,7 +786,30 @@ declare module "process" {
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* If `warning` is passed as an `Error` object, the `options` argument is ignored.
|
||||
* If `warning` is passed as an `Error` object, it will be passed through to the `'warning'` event handler
|
||||
* unmodified (and the optional `type`, `code` and `ctor` arguments will be ignored):
|
||||
*
|
||||
* ```js
|
||||
* import { emitWarning } from 'node:process';
|
||||
*
|
||||
* // Emit a warning using an Error object.
|
||||
* const myWarning = new Error('Something happened!');
|
||||
* // Use the Error name property to specify the type name
|
||||
* myWarning.name = 'CustomWarning';
|
||||
* myWarning.code = 'WARN001';
|
||||
*
|
||||
* emitWarning(myWarning);
|
||||
* // Emits: (node:56338) [WARN001] CustomWarning: Something happened!
|
||||
* ```
|
||||
*
|
||||
* A `TypeError` is thrown if `warning` is anything other than a string or `Error` object.
|
||||
*
|
||||
* While process warnings use `Error` objects, the process warning mechanism is not a replacement for normal error handling mechanisms.
|
||||
*
|
||||
* The following additional handling is implemented if the warning `type` is `'DeprecationWarning'`:
|
||||
* * If the `--throw-deprecation` command-line flag is used, the deprecation warning is thrown as an exception rather than being emitted as an event.
|
||||
* * If the `--no-deprecation` command-line flag is used, the deprecation warning is suppressed.
|
||||
* * If the `--trace-deprecation` command-line flag is used, the deprecation warning is printed to `stderr` along with the full stack trace.
|
||||
* @since v8.0.0
|
||||
* @param warning The warning to emit.
|
||||
*/
|
||||
@@ -572,7 +897,7 @@ declare module "process" {
|
||||
* parent thread's `process.env`, or whatever was specified as the `env` option
|
||||
* to the `Worker` constructor. Changes to `process.env` will not be visible
|
||||
* across `Worker` threads, and only the main thread can make changes that
|
||||
* are visible to the operating system or to native add-ons. On Windows, a copy of`process.env` on a `Worker` instance operates in a case-sensitive manner
|
||||
* are visible to the operating system or to native add-ons. On Windows, a copy of `process.env` on a `Worker` instance operates in a case-sensitive manner
|
||||
* unlike the main thread.
|
||||
* @since v0.1.27
|
||||
*/
|
||||
@@ -596,13 +921,13 @@ declare module "process" {
|
||||
*
|
||||
* Calling `process.exit()` will force the process to exit as quickly as possible
|
||||
* even if there are still asynchronous operations pending that have not yet
|
||||
* completed fully, including I/O operations to `process.stdout` and`process.stderr`.
|
||||
* completed fully, including I/O operations to `process.stdout` and `process.stderr`.
|
||||
*
|
||||
* In most situations, it is not actually necessary to call `process.exit()`explicitly. The Node.js process will exit on its own _if there is no additional_
|
||||
* In most situations, it is not actually necessary to call `process.exit()` explicitly. The Node.js process will exit on its own _if there is no additional_
|
||||
* _work pending_ in the event loop. The `process.exitCode` property can be set to
|
||||
* tell the process which exit code to use when the process exits gracefully.
|
||||
*
|
||||
* For instance, the following example illustrates a _misuse_ of the`process.exit()` method that could lead to data printed to stdout being
|
||||
* For instance, the following example illustrates a _misuse_ of the `process.exit()` method that could lead to data printed to stdout being
|
||||
* truncated and lost:
|
||||
*
|
||||
* ```js
|
||||
@@ -619,7 +944,7 @@ declare module "process" {
|
||||
* are sometimes _asynchronous_ and may occur over multiple ticks of the Node.js
|
||||
* event loop. Calling `process.exit()`, however, forces the process to exit _before_ those additional writes to `stdout` can be performed.
|
||||
*
|
||||
* Rather than calling `process.exit()` directly, the code _should_ set the`process.exitCode` and allow the process to exit naturally by avoiding
|
||||
* Rather than calling `process.exit()` directly, the code _should_ set the `process.exitCode` and allow the process to exit naturally by avoiding
|
||||
* scheduling any additional work for the event loop:
|
||||
*
|
||||
* ```js
|
||||
@@ -642,7 +967,7 @@ declare module "process" {
|
||||
* @since v0.1.13
|
||||
* @param [code=0] The exit code. For string type, only integer strings (e.g.,'1') are allowed.
|
||||
*/
|
||||
exit(code?: number): never;
|
||||
exit(code?: number | string | null | undefined): never;
|
||||
/**
|
||||
* A number which will be the process exit code, when the process either
|
||||
* exits gracefully, or is exited via {@link exit} without specifying
|
||||
@@ -650,15 +975,41 @@ declare module "process" {
|
||||
*
|
||||
* Specifying a code to {@link exit} will override any
|
||||
* previous setting of `process.exitCode`.
|
||||
* @default undefined
|
||||
* @since v0.11.8
|
||||
*/
|
||||
exitCode?: number | undefined;
|
||||
exitCode?: number | string | number | undefined;
|
||||
/**
|
||||
* The `process.getActiveResourcesInfo()` method returns an array of strings containing
|
||||
* the types of the active resources that are currently keeping the event loop alive.
|
||||
*
|
||||
* ```js
|
||||
* import { getActiveResourcesInfo } from 'node:process';
|
||||
* import { setTimeout } from 'node:timers';
|
||||
|
||||
* console.log('Before:', getActiveResourcesInfo());
|
||||
* setTimeout(() => {}, 1000);
|
||||
* console.log('After:', getActiveResourcesInfo());
|
||||
* // Prints:
|
||||
* // Before: [ 'TTYWrap', 'TTYWrap', 'TTYWrap' ]
|
||||
* // After: [ 'TTYWrap', 'TTYWrap', 'TTYWrap', 'Timeout' ]
|
||||
* ```
|
||||
* @since v17.3.0, v16.14.0
|
||||
*/
|
||||
getActiveResourcesInfo(): string[];
|
||||
/**
|
||||
* Provides a way to load built-in modules in a globally available function.
|
||||
* @param id ID of the built-in module being requested.
|
||||
* @since v20.16.0
|
||||
*/
|
||||
getBuiltinModule<ID extends keyof BuiltInModule>(id: ID): BuiltInModule[ID];
|
||||
getBuiltinModule(id: string): object | undefined;
|
||||
/**
|
||||
* The `process.getgid()` method returns the numerical group identity of the
|
||||
* process. (See [`getgid(2)`](http://man7.org/linux/man-pages/man2/getgid.2.html).)
|
||||
*
|
||||
* ```js
|
||||
* import process from 'process';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* if (process.getgid) {
|
||||
* console.log(`Current gid: ${process.getgid()}`);
|
||||
@@ -677,7 +1028,7 @@ declare module "process" {
|
||||
* associated numeric ID.
|
||||
*
|
||||
* ```js
|
||||
* import process from 'process';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* if (process.getgid && process.setgid) {
|
||||
* console.log(`Current gid: ${process.getgid()}`);
|
||||
@@ -702,7 +1053,7 @@ declare module "process" {
|
||||
* (See [`getuid(2)`](http://man7.org/linux/man-pages/man2/getuid.2.html).)
|
||||
*
|
||||
* ```js
|
||||
* import process from 'process';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* if (process.getuid) {
|
||||
* console.log(`Current uid: ${process.getuid()}`);
|
||||
@@ -721,7 +1072,7 @@ declare module "process" {
|
||||
* numeric ID.
|
||||
*
|
||||
* ```js
|
||||
* import process from 'process';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* if (process.getuid && process.setuid) {
|
||||
* console.log(`Current uid: ${process.getuid()}`);
|
||||
@@ -745,7 +1096,7 @@ declare module "process" {
|
||||
* the process. (See [`geteuid(2)`](http://man7.org/linux/man-pages/man2/geteuid.2.html).)
|
||||
*
|
||||
* ```js
|
||||
* import process from 'process';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* if (process.geteuid) {
|
||||
* console.log(`Current uid: ${process.geteuid()}`);
|
||||
@@ -764,7 +1115,7 @@ declare module "process" {
|
||||
* associated numeric ID.
|
||||
*
|
||||
* ```js
|
||||
* import process from 'process';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* if (process.geteuid && process.seteuid) {
|
||||
* console.log(`Current uid: ${process.geteuid()}`);
|
||||
@@ -789,7 +1140,7 @@ declare module "process" {
|
||||
* of the Node.js process. (See [`getegid(2)`](http://man7.org/linux/man-pages/man2/getegid.2.html).)
|
||||
*
|
||||
* ```js
|
||||
* import process from 'process';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* if (process.getegid) {
|
||||
* console.log(`Current gid: ${process.getegid()}`);
|
||||
@@ -808,7 +1159,7 @@ declare module "process" {
|
||||
* the associated a numeric ID.
|
||||
*
|
||||
* ```js
|
||||
* import process from 'process';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* if (process.getegid && process.setegid) {
|
||||
* console.log(`Current gid: ${process.getegid()}`);
|
||||
@@ -834,7 +1185,7 @@ declare module "process" {
|
||||
* Node.js ensures it always is.
|
||||
*
|
||||
* ```js
|
||||
* import process from 'process';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* if (process.getgroups) {
|
||||
* console.log(process.getgroups()); // [ 16, 21, 297 ]
|
||||
@@ -854,7 +1205,7 @@ declare module "process" {
|
||||
* The `groups` array can contain numeric group IDs, group names, or both.
|
||||
*
|
||||
* ```js
|
||||
* import process from 'process';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* if (process.getgroups && process.setgroups) {
|
||||
* try {
|
||||
@@ -883,7 +1234,7 @@ declare module "process" {
|
||||
* not abort. Actions configured to take place on exceptions such as report
|
||||
* generations will be affected too
|
||||
*
|
||||
* To unset the capture function,`process.setUncaughtExceptionCaptureCallback(null)` may be used. Calling this
|
||||
* To unset the capture function, `process.setUncaughtExceptionCaptureCallback(null)` may be used. Calling this
|
||||
* method with a non-`null` argument while another capture function is set will
|
||||
* throw an error.
|
||||
*
|
||||
@@ -902,6 +1253,18 @@ declare module "process" {
|
||||
* @experimental
|
||||
*/
|
||||
readonly sourceMapsEnabled: boolean;
|
||||
/**
|
||||
* This function enables or disables the [Source Map v3](https://sourcemaps.info/spec.html) support for
|
||||
* stack traces.
|
||||
*
|
||||
* It provides same features as launching Node.js process with commandline options `--enable-source-maps`.
|
||||
*
|
||||
* Only source maps in JavaScript files that are loaded after source maps has been
|
||||
* enabled will be parsed and loaded.
|
||||
* @since v16.6.0, v14.18.0
|
||||
* @experimental
|
||||
*/
|
||||
setSourceMapsEnabled(value: boolean): void;
|
||||
/**
|
||||
* The `process.version` property contains the Node.js version string.
|
||||
*
|
||||
@@ -1032,6 +1395,21 @@ declare module "process" {
|
||||
* @param [signal='SIGTERM'] The signal to send, either as a string or number.
|
||||
*/
|
||||
kill(pid: number, signal?: string | number): true;
|
||||
/**
|
||||
* Loads the environment configuration from a `.env` file into `process.env`. If
|
||||
* the file is not found, error will be thrown.
|
||||
*
|
||||
* To load a specific .env file by specifying its path, use the following code:
|
||||
*
|
||||
* ```js
|
||||
* import { loadEnvFile } from 'node:process';
|
||||
*
|
||||
* loadEnvFile('./development.env')
|
||||
* ```
|
||||
* @since v20.12.0
|
||||
* @param path The path to the .env file
|
||||
*/
|
||||
loadEnvFile(path?: string | URL | Buffer): void;
|
||||
/**
|
||||
* The `process.pid` property returns the PID of the process.
|
||||
*
|
||||
@@ -1063,8 +1441,8 @@ declare module "process" {
|
||||
* When a new value is assigned, different platforms will impose different maximum
|
||||
* length restrictions on the title. Usually such restrictions are quite limited.
|
||||
* For instance, on Linux and macOS, `process.title` is limited to the size of the
|
||||
* binary name plus the length of the command-line arguments because setting the`process.title` overwrites the `argv` memory of the process. Node.js v0.8
|
||||
* allowed for longer process title strings by also overwriting the `environ`memory but that was potentially insecure and confusing in some (rather obscure)
|
||||
* binary name plus the length of the command-line arguments because setting the `process.title` overwrites the `argv` memory of the process. Node.js v0.8
|
||||
* allowed for longer process title strings by also overwriting the `environ` memory but that was potentially insecure and confusing in some (rather obscure)
|
||||
* cases.
|
||||
*
|
||||
* Assigning a value to `process.title` might not result in an accurate label
|
||||
@@ -1075,7 +1453,7 @@ declare module "process" {
|
||||
title: string;
|
||||
/**
|
||||
* The operating system CPU architecture for which the Node.js binary was compiled.
|
||||
* Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`,`'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`.
|
||||
* Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`, `'mips'`, `'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`.
|
||||
*
|
||||
* ```js
|
||||
* import { arch } from 'node:process';
|
||||
@@ -1126,14 +1504,21 @@ declare module "process" {
|
||||
/**
|
||||
* Gets the amount of memory available to the process (in bytes) based on
|
||||
* limits imposed by the OS. If there is no such constraint, or the constraint
|
||||
* is unknown, `undefined` is returned.
|
||||
* is unknown, `0` is returned.
|
||||
*
|
||||
* See [`uv_get_constrained_memory`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_get_constrained_memory) for more
|
||||
* information.
|
||||
* @since v19.6.0, v18.15.0
|
||||
* @experimental
|
||||
*/
|
||||
constrainedMemory(): number | undefined;
|
||||
constrainedMemory(): number;
|
||||
/**
|
||||
* Gets the amount of free memory that is still available to the process (in bytes).
|
||||
* See [`uv_get_available_memory`](https://nodejs.org/docs/latest-v20.x/api/process.html#processavailablememory) for more information.
|
||||
* @experimental
|
||||
* @since v20.13.0
|
||||
*/
|
||||
availableMemory(): number;
|
||||
/**
|
||||
* The `process.cpuUsage()` method returns the user and system CPU time usage of
|
||||
* the current process, in an object with properties `user` and `system`, whose
|
||||
@@ -1250,6 +1635,14 @@ declare module "process" {
|
||||
* @param args Additional arguments to pass when invoking the `callback`
|
||||
*/
|
||||
nextTick(callback: Function, ...args: any[]): void;
|
||||
/**
|
||||
* This API is available through the [--experimental-permission](https://nodejs.org/api/cli.html#--experimental-permission) flag.
|
||||
*
|
||||
* `process.permission` is an object whose methods are used to manage permissions for the current process.
|
||||
* Additional documentation is available in the [Permission Model](https://nodejs.org/api/permissions.html#permission-model).
|
||||
* @since v20.0.0
|
||||
*/
|
||||
permission: ProcessPermission;
|
||||
/**
|
||||
* The `process.release` property returns an `Object` containing metadata related
|
||||
* to the current release, including URLs for the source tarball and headers-only
|
||||
@@ -1267,26 +1660,17 @@ declare module "process" {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* In custom builds from non-release versions of the source tree, only the`name` property may be present. The additional properties should not be
|
||||
* In custom builds from non-release versions of the source tree, only the `name` property may be present. The additional properties should not be
|
||||
* relied upon to exist.
|
||||
* @since v3.0.0
|
||||
*/
|
||||
readonly release: ProcessRelease;
|
||||
features: {
|
||||
inspector: boolean;
|
||||
debug: boolean;
|
||||
uv: boolean;
|
||||
ipv6: boolean;
|
||||
tls_alpn: boolean;
|
||||
tls_sni: boolean;
|
||||
tls_ocsp: boolean;
|
||||
tls: boolean;
|
||||
};
|
||||
readonly features: ProcessFeatures;
|
||||
/**
|
||||
* `process.umask()` returns the Node.js process's file mode creation mask. Child
|
||||
* processes inherit the mask from the parent process.
|
||||
* @since v0.1.19
|
||||
* @deprecated Calling `process.umask()` with no argument causes the process-wide umask to be written twice. This introduces a race condition between threads, and is a potential *
|
||||
* @deprecated Calling `process.umask()` with no argument causes the process-wide umask to be written twice. This introduces a race condition between threads, and is a potential
|
||||
* security vulnerability. There is no safe, cross-platform alternative API.
|
||||
*/
|
||||
umask(): number;
|
||||
@@ -1304,6 +1688,23 @@ declare module "process" {
|
||||
*/
|
||||
uptime(): number;
|
||||
hrtime: HRTime;
|
||||
/**
|
||||
* If the Node.js process was spawned with an IPC channel, the process.channel property is a reference to the IPC channel.
|
||||
* If no IPC channel exists, this property is undefined.
|
||||
* @since v7.1.0
|
||||
*/
|
||||
channel?: {
|
||||
/**
|
||||
* This method makes the IPC channel keep the event loop of the process running if .unref() has been called before.
|
||||
* @since v7.1.0
|
||||
*/
|
||||
ref(): void;
|
||||
/**
|
||||
* This method makes the IPC channel not keep the event loop of the process running, and lets it finish even while the channel is open.
|
||||
* @since v7.1.0
|
||||
*/
|
||||
unref(): void;
|
||||
};
|
||||
/**
|
||||
* If Node.js is spawned with an IPC channel, the `process.send()` method can be
|
||||
* used to send messages to the parent process. Messages will be received as a `'message'` event on the parent's `ChildProcess` object.
|
||||
@@ -1313,13 +1714,13 @@ declare module "process" {
|
||||
* The message goes through serialization and parsing. The resulting message might
|
||||
* not be the same as what is originally sent.
|
||||
* @since v0.5.9
|
||||
* @param options used to parameterize the sending of certain types of handles.`options` supports the following properties:
|
||||
* @param options used to parameterize the sending of certain types of handles. `options` supports the following properties:
|
||||
*/
|
||||
send?(
|
||||
message: any,
|
||||
sendHandle?: any,
|
||||
options?: {
|
||||
swallowErrors?: boolean | undefined;
|
||||
keepOpen?: boolean | undefined;
|
||||
},
|
||||
callback?: (error: Error | null) => void,
|
||||
): boolean;
|
||||
@@ -1330,13 +1731,13 @@ declare module "process" {
|
||||
*
|
||||
* The effect of calling `process.disconnect()` is the same as calling `ChildProcess.disconnect()` from the parent process.
|
||||
*
|
||||
* If the Node.js process was not spawned with an IPC channel,`process.disconnect()` will be `undefined`.
|
||||
* If the Node.js process was not spawned with an IPC channel, `process.disconnect()` will be `undefined`.
|
||||
* @since v0.7.2
|
||||
*/
|
||||
disconnect(): void;
|
||||
/**
|
||||
* If the Node.js process is spawned with an IPC channel (see the `Child Process` and `Cluster` documentation), the `process.connected` property will return`true` so long as the IPC
|
||||
* channel is connected and will return `false` after`process.disconnect()` is called.
|
||||
* If the Node.js process is spawned with an IPC channel (see the `Child Process` and `Cluster` documentation), the `process.connected` property will return `true` so long as the IPC
|
||||
* channel is connected and will return `false` after `process.disconnect()` is called.
|
||||
*
|
||||
* Once `process.connected` is `false`, it is no longer possible to send messages
|
||||
* over the IPC channel using `process.send()`.
|
||||
@@ -1347,11 +1748,11 @@ declare module "process" {
|
||||
* The `process.allowedNodeEnvironmentFlags` property is a special,
|
||||
* read-only `Set` of flags allowable within the `NODE_OPTIONS` environment variable.
|
||||
*
|
||||
* `process.allowedNodeEnvironmentFlags` extends `Set`, but overrides`Set.prototype.has` to recognize several different possible flag
|
||||
* `process.allowedNodeEnvironmentFlags` extends `Set`, but overrides `Set.prototype.has` to recognize several different possible flag
|
||||
* representations. `process.allowedNodeEnvironmentFlags.has()` will
|
||||
* return `true` in the following cases:
|
||||
*
|
||||
* * Flags may omit leading single (`-`) or double (`--`) dashes; e.g.,`inspect-brk` for `--inspect-brk`, or `r` for `-r`.
|
||||
* * Flags may omit leading single (`-`) or double (`--`) dashes; e.g., `inspect-brk` for `--inspect-brk`, or `r` for `-r`.
|
||||
* * Flags passed through to V8 (as listed in `--v8-options`) may replace
|
||||
* one or more _non-leading_ dashes for an underscore, or vice-versa;
|
||||
* e.g., `--perf_basic_prof`, `--perf-basic-prof`, `--perf_basic-prof`,
|
||||
@@ -1386,11 +1787,11 @@ declare module "process" {
|
||||
*/
|
||||
allowedNodeEnvironmentFlags: ReadonlySet<string>;
|
||||
/**
|
||||
* `process.report` is an object whose methods are used to generate diagnostic
|
||||
* reports for the current process. Additional documentation is available in the `report documentation`.
|
||||
* `process.report` is an object whose methods are used to generate diagnostic reports for the current process.
|
||||
* Additional documentation is available in the [report documentation](https://nodejs.org/docs/latest-v20.x/api/report.html).
|
||||
* @since v11.8.0
|
||||
*/
|
||||
report?: ProcessReport | undefined;
|
||||
report: ProcessReport;
|
||||
/**
|
||||
* ```js
|
||||
* import { resourceUsage } from 'node:process';
|
||||
@@ -1423,7 +1824,30 @@ declare module "process" {
|
||||
*/
|
||||
resourceUsage(): ResourceUsage;
|
||||
/**
|
||||
* The `process.traceDeprecation` property indicates whether the`--trace-deprecation` flag is set on the current Node.js process. See the
|
||||
* The initial value of `process.throwDeprecation` indicates whether the `--throw-deprecation` flag is set on the current Node.js process. `process.throwDeprecation`
|
||||
* is mutable, so whether or not deprecation warnings result in errors may be altered at runtime. See the documentation for the 'warning' event and the emitWarning()
|
||||
* method for more information.
|
||||
*
|
||||
* ```bash
|
||||
* $ node --throw-deprecation -p "process.throwDeprecation"
|
||||
* true
|
||||
* $ node -p "process.throwDeprecation"
|
||||
* undefined
|
||||
* $ node
|
||||
* > process.emitWarning('test', 'DeprecationWarning');
|
||||
* undefined
|
||||
* > (node:26598) DeprecationWarning: test
|
||||
* > process.throwDeprecation = true;
|
||||
* true
|
||||
* > process.emitWarning('test', 'DeprecationWarning');
|
||||
* Thrown:
|
||||
* [DeprecationWarning: test] { name: 'DeprecationWarning' }
|
||||
* ```
|
||||
* @since v0.9.12
|
||||
*/
|
||||
throwDeprecation: boolean;
|
||||
/**
|
||||
* The `process.traceDeprecation` property indicates whether the `--trace-deprecation` flag is set on the current Node.js process. See the
|
||||
* documentation for the `'warning' event` and the `emitWarning() method` for more information about this
|
||||
* flag's behavior.
|
||||
* @since v0.8.0
|
||||
|
||||
12
node_modules/@types/node/punycode.d.ts
generated
vendored
12
node_modules/@types/node/punycode.d.ts
generated
vendored
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* **The version of the punycode module bundled in Node.js is being deprecated.**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. **In a future major version of Node.js this module will be removed. Users
|
||||
* currently depending on the `punycode` module should switch to using the
|
||||
* userland-provided [Punycode.js](https://github.com/bestiejs/punycode.js) module instead. For punycode-based URL
|
||||
* encoding, see `url.domainToASCII` or, more generally, the `WHATWG URL API`.
|
||||
@@ -8,15 +8,15 @@
|
||||
* can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const punycode = require('punycode');
|
||||
* import punycode from 'node: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'`.
|
||||
* 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.
|
||||
*
|
||||
@@ -24,7 +24,7 @@
|
||||
* 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/v20.2.0/lib/punycode.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/punycode.js)
|
||||
*/
|
||||
declare module "punycode" {
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ declare module "punycode" {
|
||||
* Users currently depending on the punycode module should switch to using
|
||||
* the userland-provided Punycode.js module instead.
|
||||
*/
|
||||
encode(codePoints: ReadonlyArray<number>): string;
|
||||
encode(codePoints: readonly number[]): string;
|
||||
}
|
||||
/**
|
||||
* @deprecated since v7.0.0
|
||||
|
||||
37
node_modules/@types/node/querystring.d.ts
generated
vendored
37
node_modules/@types/node/querystring.d.ts
generated
vendored
@@ -3,20 +3,32 @@
|
||||
* query strings. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const querystring = require('node:querystring');
|
||||
* import querystring from 'node:querystring';
|
||||
* ```
|
||||
*
|
||||
* `querystring` is more performant than `URLSearchParams` but is not a
|
||||
* standardized API. Use `URLSearchParams` when performance is not critical or
|
||||
* when compatibility with browser code is desirable.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/querystring.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/querystring.js)
|
||||
*/
|
||||
declare module "querystring" {
|
||||
interface StringifyOptions {
|
||||
/**
|
||||
* The function to use when converting URL-unsafe characters to percent-encoding in the query string.
|
||||
* @default `querystring.escape()`
|
||||
*/
|
||||
encodeURIComponent?: ((str: string) => string) | undefined;
|
||||
}
|
||||
interface ParseOptions {
|
||||
/**
|
||||
* Specifies the maximum number of keys to parse. Specify `0` to remove key counting limitations.
|
||||
* @default 1000
|
||||
*/
|
||||
maxKeys?: number | undefined;
|
||||
/**
|
||||
* The function to use when decoding percent-encoded characters in the query string.
|
||||
* @default `querystring.unescape()`
|
||||
*/
|
||||
decodeURIComponent?: ((str: string) => string) | undefined;
|
||||
}
|
||||
interface ParsedUrlQuery extends NodeJS.Dict<string | string[]> {}
|
||||
@@ -25,9 +37,8 @@ declare module "querystring" {
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| ReadonlyArray<string>
|
||||
| ReadonlyArray<number>
|
||||
| ReadonlyArray<boolean>
|
||||
| bigint
|
||||
| ReadonlyArray<string | number | boolean | bigint>
|
||||
| null
|
||||
>
|
||||
{}
|
||||
@@ -35,7 +46,7 @@ declare module "querystring" {
|
||||
* The `querystring.stringify()` method produces a URL query string from a
|
||||
* given `obj` by iterating through the object's "own properties".
|
||||
*
|
||||
* It serializes the following types of values passed in `obj`:[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) |
|
||||
* 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) |
|
||||
@@ -54,7 +65,7 @@ declare module "querystring" {
|
||||
* ```
|
||||
*
|
||||
* 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:
|
||||
* 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,
|
||||
@@ -74,14 +85,14 @@ declare module "querystring" {
|
||||
*
|
||||
* For example, the query string `'foo=bar&abc=xyz&abc=123'` is parsed into:
|
||||
*
|
||||
* ```js
|
||||
* ```json
|
||||
* {
|
||||
* foo: 'bar',
|
||||
* abc: ['xyz', '123']
|
||||
* "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()`,
|
||||
* 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_.
|
||||
*
|
||||
@@ -98,7 +109,7 @@ declare module "querystring" {
|
||||
* @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.
|
||||
* @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;
|
||||
/**
|
||||
@@ -110,7 +121,7 @@ declare module "querystring" {
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
|
||||
132
node_modules/@types/node/readline.d.ts
generated
vendored
132
node_modules/@types/node/readline.d.ts
generated
vendored
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* The `node:readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) one line at a time.
|
||||
* The `node:readline` module provides an interface for reading data from a [Readable](https://nodejs.org/docs/https://nodejs.org/docs/latest-v20.x/api/stream.html#readable-streams) stream
|
||||
* (such as [`process.stdin`](https://nodejs.org/docs/https://nodejs.org/docs/latest-v20.x/api/process.html#processstdin)) one line at a time.
|
||||
*
|
||||
* To use the promise-based APIs:
|
||||
*
|
||||
@@ -13,7 +14,7 @@
|
||||
* import * as readline from 'node:readline';
|
||||
* ```
|
||||
*
|
||||
* The following simple example illustrates the basic use of the `node:readline`module.
|
||||
* The following simple example illustrates the basic use of the `node:readline` module.
|
||||
*
|
||||
* ```js
|
||||
* import * as readline from 'node:readline/promises';
|
||||
@@ -28,9 +29,9 @@
|
||||
* 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
|
||||
* 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/v20.2.0/lib/readline.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/readline.js)
|
||||
*/
|
||||
declare module "readline" {
|
||||
import { Abortable, EventEmitter } from "node:events";
|
||||
@@ -44,8 +45,8 @@ declare module "readline" {
|
||||
shift?: boolean | undefined;
|
||||
}
|
||||
/**
|
||||
* Instances of the `readline.Interface` class are constructed using the`readline.createInterface()` method. Every instance is associated with a
|
||||
* single `input` `Readable` stream and a single `output` `Writable` stream.
|
||||
* Instances of the `readline.Interface` class are constructed using the `readline.createInterface()` method. Every instance is associated with a
|
||||
* single `input` [Readable](https://nodejs.org/docs/https://nodejs.org/docs/latest-v20.x/api/stream.html#readable-streams) stream and a single `output` [Writable](https://nodejs.org/docs/https://nodejs.org/docs/latest-v20.x/api/stream.html#writable-streams) 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
|
||||
@@ -99,7 +100,7 @@ declare module "readline" {
|
||||
* > Instances of the `readline.Interface` class are constructed using the
|
||||
* > `readline.createInterface()` method.
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor
|
||||
* @see https://nodejs.org/docs/latest-v20.x/api/readline.html#class-interfaceconstructor
|
||||
*/
|
||||
protected constructor(
|
||||
input: NodeJS.ReadableStream,
|
||||
@@ -113,7 +114,7 @@ declare module "readline" {
|
||||
* > Instances of the `readline.Interface` class are constructed using the
|
||||
* > `readline.createInterface()` method.
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor
|
||||
* @see https://nodejs.org/docs/latest-v20.x/api/readline.html#class-interfaceconstructor
|
||||
*/
|
||||
protected constructor(options: ReadLineOptions);
|
||||
/**
|
||||
@@ -123,7 +124,7 @@ declare module "readline" {
|
||||
*/
|
||||
getPrompt(): string;
|
||||
/**
|
||||
* The `rl.setPrompt()` method sets the prompt that will be written to `output`whenever `rl.prompt()` is called.
|
||||
* 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;
|
||||
@@ -134,19 +135,19 @@ declare module "readline" {
|
||||
* When called, `rl.prompt()` will resume the `input` stream if it has been
|
||||
* paused.
|
||||
*
|
||||
* If the `Interface` was created with `output` set to `null` or`undefined` the prompt is not written.
|
||||
* If the `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;
|
||||
/**
|
||||
* 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.
|
||||
* 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 `Interface` was created with `output` set to `null` or`undefined` the `query` is not written.
|
||||
* If the `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.
|
||||
@@ -188,7 +189,7 @@ declare module "readline" {
|
||||
* 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 `Interface` instance.
|
||||
* Calling `rl.pause()` does not immediately pause other events (including `'line'`) from being emitted by the `Interface` instance.
|
||||
* @since v0.3.4
|
||||
*/
|
||||
pause(): this;
|
||||
@@ -218,7 +219,7 @@ declare module "readline" {
|
||||
* When called, `rl.write()` will resume the `input` stream if it has been
|
||||
* paused.
|
||||
*
|
||||
* If the `Interface` was created with `output` set to `null` or`undefined` the `data` and `key` are not written.
|
||||
* If the `Interface` was created with `output` set to `null` or `undefined` the `data` and `key` are not written.
|
||||
*
|
||||
* ```js
|
||||
* rl.write('Delete this!');
|
||||
@@ -226,7 +227,7 @@ declare module "readline" {
|
||||
* 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_.
|
||||
* 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;
|
||||
@@ -303,7 +304,7 @@ declare module "readline" {
|
||||
prependOnceListener(event: "SIGINT", listener: () => void): this;
|
||||
prependOnceListener(event: "SIGTSTP", listener: () => void): this;
|
||||
prependOnceListener(event: "history", listener: (history: string[]) => void): this;
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<string>;
|
||||
[Symbol.asyncIterator](): NodeJS.AsyncIterator<string>;
|
||||
}
|
||||
export type ReadLine = Interface; // type forwarded for backwards compatibility
|
||||
export type Completer = (line: string) => CompleterResult;
|
||||
@@ -313,35 +314,84 @@ declare module "readline" {
|
||||
) => void;
|
||||
export type CompleterResult = [string[], string];
|
||||
export interface ReadLineOptions {
|
||||
/**
|
||||
* The [`Readable`](https://nodejs.org/docs/latest-v20.x/api/stream.html#readable-streams) stream to listen to
|
||||
*/
|
||||
input: NodeJS.ReadableStream;
|
||||
/**
|
||||
* The [`Writable`](https://nodejs.org/docs/latest-v20.x/api/stream.html#writable-streams) stream to write readline data to.
|
||||
*/
|
||||
output?: NodeJS.WritableStream | undefined;
|
||||
/**
|
||||
* An optional function used for Tab autocompletion.
|
||||
*/
|
||||
completer?: Completer | AsyncCompleter | undefined;
|
||||
/**
|
||||
* `true` if the `input` and `output` streams should be treated like a TTY,
|
||||
* and have ANSI/VT100 escape codes written to it.
|
||||
* Default: checking `isTTY` on the `output` stream upon instantiation.
|
||||
*/
|
||||
terminal?: boolean | undefined;
|
||||
/**
|
||||
* Initial list of history lines. This option makes sense
|
||||
* only if `terminal` is set to `true` by the user or by an internal `output`
|
||||
* check, otherwise the history caching mechanism is not initialized at all.
|
||||
* Initial list of history lines.
|
||||
* This option makes sense only if `terminal` is set to `true` by the user or by an internal `output` check,
|
||||
* otherwise the history caching mechanism is not initialized at all.
|
||||
* @default []
|
||||
*/
|
||||
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.
|
||||
* Maximum number of history lines retained.
|
||||
* To disable the history set this value to `0`.
|
||||
* This option makes sense only if `terminal` is set to `true` by the user or by an internal `output` check,
|
||||
* otherwise the history caching mechanism is not initialized at all.
|
||||
* @default 30
|
||||
*/
|
||||
historySize?: 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;
|
||||
/**
|
||||
* The prompt string to use.
|
||||
* @default "> "
|
||||
*/
|
||||
prompt?: string | undefined;
|
||||
/**
|
||||
* If the delay between `\r` and `\n` exceeds `crlfDelay` milliseconds,
|
||||
* both `\r` and `\n` will be treated as separate end-of-line input.
|
||||
* `crlfDelay` will be coerced to a number no less than `100`.
|
||||
* It can be set to `Infinity`, in which case
|
||||
* `\r` followed by `\n` will always be considered a single newline
|
||||
* (which may be reasonable for [reading files](https://nodejs.org/docs/latest-v20.x/api/readline.html#example-read-file-stream-line-by-line) with `\r\n` line delimiter).
|
||||
* @default 100
|
||||
*/
|
||||
crlfDelay?: number | undefined;
|
||||
/**
|
||||
* The duration `readline` will wait for a character
|
||||
* (when reading an ambiguous key sequence in milliseconds
|
||||
* one that can both form a complete key sequence using the input read so far
|
||||
* and can take additional input to complete a longer key sequence).
|
||||
* @default 500
|
||||
*/
|
||||
escapeCodeTimeout?: number | undefined;
|
||||
/**
|
||||
* The number of spaces a tab is equal to (minimum 1).
|
||||
* @default 8
|
||||
*/
|
||||
tabSize?: number | undefined;
|
||||
/**
|
||||
* Allows closing the interface using an AbortSignal.
|
||||
* Aborting the signal will internally call `close` on the interface.
|
||||
*/
|
||||
signal?: AbortSignal | undefined;
|
||||
}
|
||||
/**
|
||||
* The `readline.createInterface()` method creates a new `readline.Interface`instance.
|
||||
* The `readline.createInterface()` method creates a new `readline.Interface` instance.
|
||||
*
|
||||
* ```js
|
||||
* const readline = require('node:readline');
|
||||
* import readline from 'node:readline';
|
||||
* const rl = readline.createInterface({
|
||||
* input: process.stdin,
|
||||
* output: process.stdout,
|
||||
@@ -382,7 +432,7 @@ declare module "readline" {
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
@@ -397,7 +447,7 @@ declare module "readline" {
|
||||
* implement a small command-line interface:
|
||||
*
|
||||
* ```js
|
||||
* const readline = require('node:readline');
|
||||
* import readline from 'node:readline';
|
||||
* const rl = readline.createInterface({
|
||||
* input: process.stdin,
|
||||
* output: process.stdout,
|
||||
@@ -429,8 +479,8 @@ declare module "readline" {
|
||||
* well as a `for await...of` loop:
|
||||
*
|
||||
* ```js
|
||||
* const fs = require('node:fs');
|
||||
* const readline = require('node:readline');
|
||||
* import fs from 'node:fs';
|
||||
* import readline from 'node:readline';
|
||||
*
|
||||
* async function processLineByLine() {
|
||||
* const fileStream = fs.createReadStream('input.txt');
|
||||
@@ -454,8 +504,8 @@ declare module "readline" {
|
||||
* Alternatively, one could use the `'line'` event:
|
||||
*
|
||||
* ```js
|
||||
* const fs = require('node:fs');
|
||||
* const readline = require('node:readline');
|
||||
* import fs from 'node:fs';
|
||||
* import readline from 'node:readline';
|
||||
*
|
||||
* const rl = readline.createInterface({
|
||||
* input: fs.createReadStream('sample.txt'),
|
||||
@@ -467,12 +517,12 @@ declare module "readline" {
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* 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:
|
||||
* 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('node:events');
|
||||
* const { createReadStream } = require('node:fs');
|
||||
* const { createInterface } = require('node:readline');
|
||||
* import { once } from 'node:events';
|
||||
* import { createReadStream } from 'node:fs';
|
||||
* import { createInterface } from 'node:readline';
|
||||
*
|
||||
* (async function processLineByLine() {
|
||||
* try {
|
||||
@@ -502,7 +552,7 @@ declare module "readline" {
|
||||
cols: number;
|
||||
}
|
||||
/**
|
||||
* The `readline.clearLine()` method clears current line of given `TTY` stream
|
||||
* The `readline.clearLine()` method clears current line of given [TTY](https://nodejs.org/docs/https://nodejs.org/docs/latest-v20.x/api/tty.html) stream
|
||||
* in a specified direction identified by `dir`.
|
||||
* @since v0.7.7
|
||||
* @param callback Invoked once the operation completes.
|
||||
@@ -510,7 +560,7 @@ declare module "readline" {
|
||||
*/
|
||||
export function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
|
||||
/**
|
||||
* The `readline.clearScreenDown()` method clears the given `TTY` stream from
|
||||
* The `readline.clearScreenDown()` method clears the given [TTY](https://nodejs.org/docs/https://nodejs.org/docs/latest-v20.x/api/tty.html) stream from
|
||||
* the current position of the cursor down.
|
||||
* @since v0.7.7
|
||||
* @param callback Invoked once the operation completes.
|
||||
@@ -519,7 +569,7 @@ declare module "readline" {
|
||||
export function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
|
||||
/**
|
||||
* The `readline.cursorTo()` method moves cursor to the specified position in a
|
||||
* given `TTY` `stream`.
|
||||
* given [TTY](https://nodejs.org/docs/https://nodejs.org/docs/latest-v20.x/api/tty.html) `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`.
|
||||
@@ -527,7 +577,7 @@ declare module "readline" {
|
||||
export function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean;
|
||||
/**
|
||||
* The `readline.moveCursor()` method moves the cursor _relative_ to its current
|
||||
* position in a given `TTY` `stream`.
|
||||
* position in a given [TTY](https://nodejs.org/docs/https://nodejs.org/docs/latest-v20.x/api/tty.html) `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`.
|
||||
|
||||
36
node_modules/@types/node/readline/promises.d.ts
generated
vendored
36
node_modules/@types/node/readline/promises.d.ts
generated
vendored
@@ -3,10 +3,15 @@
|
||||
* @experimental
|
||||
*/
|
||||
declare module "readline/promises" {
|
||||
import { AsyncCompleter, Completer, Direction, Interface as _Interface, ReadLineOptions } from "node:readline";
|
||||
import { Abortable } from "node:events";
|
||||
import {
|
||||
CompleterResult,
|
||||
Direction,
|
||||
Interface as _Interface,
|
||||
ReadLineOptions as _ReadLineOptions,
|
||||
} from "node:readline";
|
||||
/**
|
||||
* Instances of the `readlinePromises.Interface` class are constructed using the`readlinePromises.createInterface()` method. Every instance is associated with a
|
||||
* Instances of the `readlinePromises.Interface` class are constructed using the `readlinePromises.createInterface()` method. Every instance is associated with a
|
||||
* 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.
|
||||
@@ -15,12 +20,12 @@ declare module "readline/promises" {
|
||||
class Interface extends _Interface {
|
||||
/**
|
||||
* 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.
|
||||
* 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 `Interface` was created with `output` set to `null` or`undefined` the `query` is not written.
|
||||
* If the `Interface` was created with `output` set to `null` or `undefined` the `query` is not written.
|
||||
*
|
||||
* If the question is called after `rl.close()`, it returns a rejected promise.
|
||||
*
|
||||
@@ -67,7 +72,7 @@ declare module "readline/promises" {
|
||||
* The `rl.clearLine()` method adds to the internal list of pending action an
|
||||
* action that clears current line of the associated `stream` in a specified
|
||||
* direction identified by `dir`.
|
||||
* Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor.
|
||||
* Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor.
|
||||
* @since v17.0.0
|
||||
* @return this
|
||||
*/
|
||||
@@ -76,20 +81,20 @@ declare module "readline/promises" {
|
||||
* The `rl.clearScreenDown()` method adds to the internal list of pending action an
|
||||
* action that clears the associated stream from the current position of the
|
||||
* cursor down.
|
||||
* Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor.
|
||||
* Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor.
|
||||
* @since v17.0.0
|
||||
* @return this
|
||||
*/
|
||||
clearScreenDown(): this;
|
||||
/**
|
||||
* The `rl.commit()` method sends all the pending actions to the associated`stream` and clears the internal list of pending actions.
|
||||
* The `rl.commit()` method sends all the pending actions to the associated `stream` and clears the internal list of pending actions.
|
||||
* @since v17.0.0
|
||||
*/
|
||||
commit(): Promise<void>;
|
||||
/**
|
||||
* The `rl.cursorTo()` method adds to the internal list of pending action an action
|
||||
* that moves cursor to the specified position in the associated `stream`.
|
||||
* Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor.
|
||||
* Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor.
|
||||
* @since v17.0.0
|
||||
* @return this
|
||||
*/
|
||||
@@ -98,7 +103,7 @@ declare module "readline/promises" {
|
||||
* The `rl.moveCursor()` method adds to the internal list of pending action an
|
||||
* action that moves the cursor _relative_ to its current position in the
|
||||
* associated `stream`.
|
||||
* Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor.
|
||||
* Call `rl.commit()` to see the effect of this method, unless `autoCommit: true` was passed to the constructor.
|
||||
* @since v17.0.0
|
||||
* @return this
|
||||
*/
|
||||
@@ -111,11 +116,18 @@ declare module "readline/promises" {
|
||||
*/
|
||||
rollback(): this;
|
||||
}
|
||||
type Completer = (line: string) => CompleterResult | Promise<CompleterResult>;
|
||||
interface ReadLineOptions extends Omit<_ReadLineOptions, "completer"> {
|
||||
/**
|
||||
* An optional function used for Tab autocompletion.
|
||||
*/
|
||||
completer?: Completer | undefined;
|
||||
}
|
||||
/**
|
||||
* The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface`instance.
|
||||
* The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface` instance.
|
||||
*
|
||||
* ```js
|
||||
* const readlinePromises = require('node:readline/promises');
|
||||
* import readlinePromises from 'node:readline/promises';
|
||||
* const rl = readlinePromises.createInterface({
|
||||
* input: process.stdin,
|
||||
* output: process.stdout,
|
||||
@@ -140,7 +152,7 @@ declare module "readline/promises" {
|
||||
function createInterface(
|
||||
input: NodeJS.ReadableStream,
|
||||
output?: NodeJS.WritableStream,
|
||||
completer?: Completer | AsyncCompleter,
|
||||
completer?: Completer,
|
||||
terminal?: boolean,
|
||||
): Interface;
|
||||
function createInterface(options: ReadLineOptions): Interface;
|
||||
|
||||
28
node_modules/@types/node/repl.d.ts
generated
vendored
28
node_modules/@types/node/repl.d.ts
generated
vendored
@@ -4,9 +4,9 @@
|
||||
* applications. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const repl = require('node:repl');
|
||||
* import repl from 'node:repl';
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/repl.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/repl.js)
|
||||
*/
|
||||
declare module "repl" {
|
||||
import { AsyncCompleter, Completer, Interface } from "node:readline";
|
||||
@@ -54,25 +54,25 @@ declare module "repl" {
|
||||
* 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
|
||||
* effect.
|
||||
* Default: the REPL instance's `terminal` value.
|
||||
* @default the REPL instance's `terminal` value
|
||||
*/
|
||||
useColors?: boolean | undefined;
|
||||
/**
|
||||
* 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
|
||||
* instance. The node CLI REPL sets this value to `true`.
|
||||
* Default: `false`.
|
||||
* @default false
|
||||
*/
|
||||
useGlobal?: boolean | undefined;
|
||||
/**
|
||||
* If `true`, specifies that the default writer will not output the return value of a
|
||||
* command if it evaluates to `undefined`.
|
||||
* Default: `false`.
|
||||
* @default false
|
||||
*/
|
||||
ignoreUndefined?: boolean | undefined;
|
||||
/**
|
||||
* 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-v20.x/docs/api/repl.html#repl_customizing_repl_output
|
||||
*/
|
||||
@@ -95,7 +95,7 @@ declare module "repl" {
|
||||
/**
|
||||
* 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.
|
||||
* Default: `false`.
|
||||
* @default false
|
||||
*/
|
||||
breakEvalOnSigint?: boolean | undefined;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ declare module "repl" {
|
||||
* or directly using the JavaScript `new` keyword.
|
||||
*
|
||||
* ```js
|
||||
* const repl = require('node:repl');
|
||||
* import repl from 'node:repl';
|
||||
*
|
||||
* const options = { useColors: true };
|
||||
*
|
||||
@@ -251,13 +251,13 @@ declare module "repl" {
|
||||
private constructor();
|
||||
/**
|
||||
* The `replServer.defineCommand()` method is used to add new `.`\-prefixed commands
|
||||
* 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
|
||||
* 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
|
||||
* properties:
|
||||
*
|
||||
* The following example shows two new commands added to the REPL instance:
|
||||
*
|
||||
* ```js
|
||||
* const repl = require('node:repl');
|
||||
* import repl from 'node:repl';
|
||||
*
|
||||
* const replServer = repl.start({ prompt: '> ' });
|
||||
* replServer.defineCommand('sayhello', {
|
||||
@@ -289,7 +289,7 @@ declare module "repl" {
|
||||
defineCommand(keyword: string, cmd: REPLCommandAction | REPLCommand): void;
|
||||
/**
|
||||
* The `replServer.displayPrompt()` method readies the REPL instance for input
|
||||
* from the user, printing the configured `prompt` to a new line in the `output`and resuming the `input` to accept new input.
|
||||
* from the user, printing the configured `prompt` to a 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
|
||||
* 'prompt'.
|
||||
@@ -297,14 +297,14 @@ declare module "repl" {
|
||||
* When `preserveCursor` is `true`, the cursor placement will not be reset to `0`.
|
||||
*
|
||||
* The `replServer.displayPrompt` method is primarily intended to be called from
|
||||
* within the action function for commands registered using the`replServer.defineCommand()` method.
|
||||
* within the action function for commands registered using the `replServer.defineCommand()` method.
|
||||
* @since v0.1.91
|
||||
*/
|
||||
displayPrompt(preserveCursor?: boolean): void;
|
||||
/**
|
||||
* The `replServer.clearBufferedCommand()` method clears any command that has been
|
||||
* 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.
|
||||
* called from within the action function for commands registered using the `replServer.defineCommand()` method.
|
||||
* @since v9.0.0
|
||||
*/
|
||||
clearBufferedCommand(): void;
|
||||
@@ -407,7 +407,7 @@ declare module "repl" {
|
||||
* If `options` is a string, then it specifies the input prompt:
|
||||
*
|
||||
* ```js
|
||||
* const repl = require('node:repl');
|
||||
* import repl from 'node:repl';
|
||||
*
|
||||
* // a Unix style prompt
|
||||
* repl.start('$ ');
|
||||
|
||||
153
node_modules/@types/node/sea.d.ts
generated
vendored
Normal file
153
node_modules/@types/node/sea.d.ts
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* This feature allows the distribution of a Node.js application conveniently to a
|
||||
* system that does not have Node.js installed.
|
||||
*
|
||||
* Node.js supports the creation of [single executable applications](https://github.com/nodejs/single-executable) by allowing
|
||||
* the injection of a blob prepared by Node.js, which can contain a bundled script,
|
||||
* into the `node` binary. During start up, the program checks if anything has been
|
||||
* injected. If the blob is found, it executes the script in the blob. Otherwise
|
||||
* Node.js operates as it normally does.
|
||||
*
|
||||
* The single executable application feature currently only supports running a
|
||||
* single embedded script using the `CommonJS` module system.
|
||||
*
|
||||
* Users can create a single executable application from their bundled script
|
||||
* with the `node` binary itself and any tool which can inject resources into the
|
||||
* binary.
|
||||
*
|
||||
* Here are the steps for creating a single executable application using one such
|
||||
* tool, [postject](https://github.com/nodejs/postject):
|
||||
*
|
||||
* 1. Create a JavaScript file:
|
||||
* ```bash
|
||||
* echo 'console.log(`Hello, ${process.argv[2]}!`);' > hello.js
|
||||
* ```
|
||||
* 2. Create a configuration file building a blob that can be injected into the
|
||||
* single executable application (see `Generating single executable preparation blobs` for details):
|
||||
* ```bash
|
||||
* echo '{ "main": "hello.js", "output": "sea-prep.blob" }' > sea-config.json
|
||||
* ```
|
||||
* 3. Generate the blob to be injected:
|
||||
* ```bash
|
||||
* node --experimental-sea-config sea-config.json
|
||||
* ```
|
||||
* 4. Create a copy of the `node` executable and name it according to your needs:
|
||||
* * On systems other than Windows:
|
||||
* ```bash
|
||||
* cp $(command -v node) hello
|
||||
* ```
|
||||
* * On Windows:
|
||||
* ```text
|
||||
* node -e "require('fs').copyFileSync(process.execPath, 'hello.exe')"
|
||||
* ```
|
||||
* The `.exe` extension is necessary.
|
||||
* 5. Remove the signature of the binary (macOS and Windows only):
|
||||
* * On macOS:
|
||||
* ```bash
|
||||
* codesign --remove-signature hello
|
||||
* ```
|
||||
* * On Windows (optional):
|
||||
* [signtool](https://learn.microsoft.com/en-us/windows/win32/seccrypto/signtool) can be used from the installed [Windows SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/).
|
||||
* If this step is
|
||||
* skipped, ignore any signature-related warning from postject.
|
||||
* ```powershell
|
||||
* signtool remove /s hello.exe
|
||||
* ```
|
||||
* 6. Inject the blob into the copied binary by running `postject` with
|
||||
* the following options:
|
||||
* * `hello` / `hello.exe` \- The name of the copy of the `node` executable
|
||||
* created in step 4.
|
||||
* * `NODE_SEA_BLOB` \- The name of the resource / note / section in the binary
|
||||
* where the contents of the blob will be stored.
|
||||
* * `sea-prep.blob` \- The name of the blob created in step 1.
|
||||
* * `--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2` \- The [fuse](https://www.electronjs.org/docs/latest/tutorial/fuses) used by the Node.js project to detect if a file has been
|
||||
* injected.
|
||||
* * `--macho-segment-name NODE_SEA` (only needed on macOS) - The name of the
|
||||
* segment in the binary where the contents of the blob will be
|
||||
* stored.
|
||||
* To summarize, here is the required command for each platform:
|
||||
* * On Linux:
|
||||
* ```bash
|
||||
* npx postject hello NODE_SEA_BLOB sea-prep.blob \
|
||||
* --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
|
||||
* ```
|
||||
* * On Windows - PowerShell:
|
||||
* ```powershell
|
||||
* npx postject hello.exe NODE_SEA_BLOB sea-prep.blob `
|
||||
* --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
|
||||
* ```
|
||||
* * On Windows - Command Prompt:
|
||||
* ```text
|
||||
* npx postject hello.exe NODE_SEA_BLOB sea-prep.blob ^
|
||||
* --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
|
||||
* ```
|
||||
* * On macOS:
|
||||
* ```bash
|
||||
* npx postject hello NODE_SEA_BLOB sea-prep.blob \
|
||||
* --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \
|
||||
* --macho-segment-name NODE_SEA
|
||||
* ```
|
||||
* 7. Sign the binary (macOS and Windows only):
|
||||
* * On macOS:
|
||||
* ```bash
|
||||
* codesign --sign - hello
|
||||
* ```
|
||||
* * On Windows (optional):
|
||||
* A certificate needs to be present for this to work. However, the unsigned
|
||||
* binary would still be runnable.
|
||||
* ```powershell
|
||||
* signtool sign /fd SHA256 hello.exe
|
||||
* ```
|
||||
* 8. Run the binary:
|
||||
* * On systems other than Windows
|
||||
* ```console
|
||||
* $ ./hello world
|
||||
* Hello, world!
|
||||
* ```
|
||||
* * On Windows
|
||||
* ```console
|
||||
* $ .\hello.exe world
|
||||
* Hello, world!
|
||||
* ```
|
||||
* @since v19.7.0, v18.16.0
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.12.0/src/node_sea.cc)
|
||||
*/
|
||||
declare module "node:sea" {
|
||||
type AssetKey = string;
|
||||
/**
|
||||
* @since v20.12.0
|
||||
* @return Whether this script is running inside a single-executable application.
|
||||
*/
|
||||
function isSea(): boolean;
|
||||
/**
|
||||
* This method can be used to retrieve the assets configured to be bundled into the
|
||||
* single-executable application at build time.
|
||||
* An error is thrown when no matching asset can be found.
|
||||
* @since v20.12.0
|
||||
*/
|
||||
function getAsset(key: AssetKey): ArrayBuffer;
|
||||
function getAsset(key: AssetKey, encoding: string): string;
|
||||
/**
|
||||
* Similar to `sea.getAsset()`, but returns the result in a [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
|
||||
* An error is thrown when no matching asset can be found.
|
||||
* @since v20.12.0
|
||||
*/
|
||||
function getAssetAsBlob(key: AssetKey, options?: {
|
||||
type: string;
|
||||
}): Blob;
|
||||
/**
|
||||
* This method can be used to retrieve the assets configured to be bundled into the
|
||||
* single-executable application at build time.
|
||||
* An error is thrown when no matching asset can be found.
|
||||
*
|
||||
* Unlike `sea.getRawAsset()` or `sea.getAssetAsBlob()`, this method does not
|
||||
* return a copy. Instead, it returns the raw asset bundled inside the executable.
|
||||
*
|
||||
* For now, users should avoid writing to the returned array buffer. If the
|
||||
* injected section is not marked as writable or not aligned properly,
|
||||
* writes to the returned array buffer is likely to result in a crash.
|
||||
* @since v20.12.0
|
||||
*/
|
||||
function getRawAsset(key: AssetKey): string | ArrayBuffer;
|
||||
}
|
||||
2001
node_modules/@types/node/stream.d.ts
generated
vendored
2001
node_modules/@types/node/stream.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
38
node_modules/@types/node/stream/consumers.d.ts
generated
vendored
38
node_modules/@types/node/stream/consumers.d.ts
generated
vendored
@@ -1,11 +1,37 @@
|
||||
/**
|
||||
* The utility consumer functions provide common options for consuming
|
||||
* streams.
|
||||
* @since v16.7.0
|
||||
*/
|
||||
declare module "stream/consumers" {
|
||||
import { Blob as NodeBlob } from "node:buffer";
|
||||
import { Readable } from "node:stream";
|
||||
function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<Buffer>;
|
||||
function text(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<string>;
|
||||
function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<ArrayBuffer>;
|
||||
function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<NodeBlob>;
|
||||
function json(stream: NodeJS.ReadableStream | Readable | AsyncIterable<any>): Promise<unknown>;
|
||||
import { ReadableStream as WebReadableStream } from "node:stream/web";
|
||||
/**
|
||||
* @since v16.7.0
|
||||
* @returns Fulfills with an `ArrayBuffer` containing the full contents of the stream.
|
||||
*/
|
||||
function arrayBuffer(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<ArrayBuffer>;
|
||||
/**
|
||||
* @since v16.7.0
|
||||
* @returns Fulfills with a `Blob` containing the full contents of the stream.
|
||||
*/
|
||||
function blob(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<NodeBlob>;
|
||||
/**
|
||||
* @since v16.7.0
|
||||
* @returns Fulfills with a `Buffer` containing the full contents of the stream.
|
||||
*/
|
||||
function buffer(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<Buffer>;
|
||||
/**
|
||||
* @since v16.7.0
|
||||
* @returns Fulfills with the contents of the stream parsed as a
|
||||
* UTF-8 encoded string that is then passed through `JSON.parse()`.
|
||||
*/
|
||||
function json(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<unknown>;
|
||||
/**
|
||||
* @since v16.7.0
|
||||
* @returns Fulfills with the contents of the stream parsed as a UTF-8 encoded string.
|
||||
*/
|
||||
function text(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<string>;
|
||||
}
|
||||
declare module "node:stream/consumers" {
|
||||
export * from "stream/consumers";
|
||||
|
||||
9
node_modules/@types/node/stream/promises.d.ts
generated
vendored
9
node_modules/@types/node/stream/promises.d.ts
generated
vendored
@@ -1,12 +1,19 @@
|
||||
declare module "stream/promises" {
|
||||
import {
|
||||
FinishedOptions,
|
||||
FinishedOptions as _FinishedOptions,
|
||||
PipelineDestination,
|
||||
PipelineOptions,
|
||||
PipelinePromise,
|
||||
PipelineSource,
|
||||
PipelineTransform,
|
||||
} from "node:stream";
|
||||
interface FinishedOptions extends _FinishedOptions {
|
||||
/**
|
||||
* If true, removes the listeners registered by this function before the promise is fulfilled.
|
||||
* @default false
|
||||
*/
|
||||
cleanup?: boolean | undefined;
|
||||
}
|
||||
function finished(
|
||||
stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream,
|
||||
options?: FinishedOptions,
|
||||
|
||||
223
node_modules/@types/node/stream/web.d.ts
generated
vendored
223
node_modules/@types/node/stream/web.d.ts
generated
vendored
@@ -1,3 +1,38 @@
|
||||
type _ByteLengthQueuingStrategy = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").ByteLengthQueuingStrategy;
|
||||
type _CompressionStream = typeof globalThis extends { onmessage: any; ReportingObserver: any } ? {}
|
||||
: import("stream/web").CompressionStream;
|
||||
type _CountQueuingStrategy = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").CountQueuingStrategy;
|
||||
type _DecompressionStream = typeof globalThis extends { onmessage: any; ReportingObserver: any } ? {}
|
||||
: import("stream/web").DecompressionStream;
|
||||
type _ReadableByteStreamController = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").ReadableByteStreamController;
|
||||
type _ReadableStream<R = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").ReadableStream<R>;
|
||||
type _ReadableStreamBYOBReader = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").ReadableStreamBYOBReader;
|
||||
type _ReadableStreamBYOBRequest = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").ReadableStreamBYOBRequest;
|
||||
type _ReadableStreamDefaultController<R = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").ReadableStreamDefaultController<R>;
|
||||
type _ReadableStreamDefaultReader<R = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").ReadableStreamDefaultReader<R>;
|
||||
type _TextDecoderStream = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").TextDecoderStream;
|
||||
type _TextEncoderStream = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").TextEncoderStream;
|
||||
type _TransformStream<I = any, O = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").TransformStream<I, O>;
|
||||
type _TransformStreamDefaultController<O = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").TransformStreamDefaultController<O>;
|
||||
type _WritableStream<W = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").WritableStream<W>;
|
||||
type _WritableStreamDefaultController = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").WritableStreamDefaultController;
|
||||
type _WritableStreamDefaultWriter<W = any> = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("stream/web").WritableStreamDefaultWriter<W>;
|
||||
|
||||
declare module "stream/web" {
|
||||
// stub module, pending copy&paste from .d.ts or manual impl
|
||||
// copy from lib.dom.d.ts
|
||||
@@ -62,21 +97,10 @@ declare module "stream/web" {
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
interface ReadableStreamGenericReader {
|
||||
readonly closed: Promise<undefined>;
|
||||
readonly closed: Promise<void>;
|
||||
cancel(reason?: any): Promise<void>;
|
||||
}
|
||||
interface ReadableStreamDefaultReadValueResult<T> {
|
||||
done: false;
|
||||
value: T;
|
||||
}
|
||||
interface ReadableStreamDefaultReadDoneResult {
|
||||
done: true;
|
||||
value?: undefined;
|
||||
}
|
||||
type ReadableStreamController<T> = ReadableStreamDefaultController<T>;
|
||||
type ReadableStreamDefaultReadResult<T> =
|
||||
| ReadableStreamDefaultReadValueResult<T>
|
||||
| ReadableStreamDefaultReadDoneResult;
|
||||
interface ReadableStreamReadValueResult<T> {
|
||||
done: false;
|
||||
value: T;
|
||||
@@ -142,37 +166,75 @@ declare module "stream/web" {
|
||||
interface ReadableStreamErrorCallback {
|
||||
(reason: any): void | PromiseLike<void>;
|
||||
}
|
||||
interface ReadableStreamAsyncIterator<T> extends NodeJS.AsyncIterator<T, NodeJS.BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.asyncIterator](): ReadableStreamAsyncIterator<T>;
|
||||
}
|
||||
/** This Streams API interface represents a readable stream of byte data. */
|
||||
interface ReadableStream<R = any> {
|
||||
readonly locked: boolean;
|
||||
cancel(reason?: any): Promise<void>;
|
||||
getReader(): ReadableStreamDefaultReader<R>;
|
||||
getReader(options: { mode: "byob" }): ReadableStreamBYOBReader;
|
||||
getReader(): ReadableStreamDefaultReader<R>;
|
||||
getReader(options?: ReadableStreamGetReaderOptions): ReadableStreamReader<R>;
|
||||
pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
|
||||
pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
|
||||
tee(): [ReadableStream<R>, ReadableStream<R>];
|
||||
values(options?: { preventCancel?: boolean }): AsyncIterableIterator<R>;
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<R>;
|
||||
values(options?: { preventCancel?: boolean }): ReadableStreamAsyncIterator<R>;
|
||||
[Symbol.asyncIterator](): ReadableStreamAsyncIterator<R>;
|
||||
}
|
||||
const ReadableStream: {
|
||||
prototype: ReadableStream;
|
||||
from<T>(iterable: Iterable<T> | AsyncIterable<T>): ReadableStream<T>;
|
||||
new(underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
|
||||
new<R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
|
||||
};
|
||||
type ReadableStreamReaderMode = "byob";
|
||||
interface ReadableStreamGetReaderOptions {
|
||||
/**
|
||||
* Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
|
||||
*
|
||||
* This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation.
|
||||
*/
|
||||
mode?: ReadableStreamReaderMode;
|
||||
}
|
||||
type ReadableStreamReader<T> = ReadableStreamDefaultReader<T> | ReadableStreamBYOBReader;
|
||||
interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader {
|
||||
read(): Promise<ReadableStreamDefaultReadResult<R>>;
|
||||
read(): Promise<ReadableStreamReadResult<R>>;
|
||||
releaseLock(): void;
|
||||
}
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) */
|
||||
interface ReadableStreamBYOBReader extends ReadableStreamGenericReader {
|
||||
read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) */
|
||||
read<T extends ArrayBufferView>(
|
||||
view: T,
|
||||
options?: {
|
||||
min?: number;
|
||||
},
|
||||
): Promise<ReadableStreamReadResult<T>>;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) */
|
||||
releaseLock(): void;
|
||||
}
|
||||
const ReadableStreamDefaultReader: {
|
||||
prototype: ReadableStreamDefaultReader;
|
||||
new<R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
|
||||
};
|
||||
const ReadableStreamBYOBReader: any;
|
||||
const ReadableStreamBYOBRequest: any;
|
||||
const ReadableStreamBYOBReader: {
|
||||
prototype: ReadableStreamBYOBReader;
|
||||
new(stream: ReadableStream): ReadableStreamBYOBReader;
|
||||
};
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest) */
|
||||
interface ReadableStreamBYOBRequest {
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view) */
|
||||
readonly view: ArrayBufferView | null;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond) */
|
||||
respond(bytesWritten: number): void;
|
||||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView) */
|
||||
respondWithNewView(view: ArrayBufferView): void;
|
||||
}
|
||||
const ReadableStreamBYOBRequest: {
|
||||
prototype: ReadableStreamBYOBRequest;
|
||||
new(): ReadableStreamBYOBRequest;
|
||||
};
|
||||
interface ReadableByteStreamController {
|
||||
readonly byobRequest: undefined;
|
||||
readonly desiredSize: number | null;
|
||||
@@ -245,9 +307,9 @@ declare module "stream/web" {
|
||||
* sink.
|
||||
*/
|
||||
interface WritableStreamDefaultWriter<W = any> {
|
||||
readonly closed: Promise<undefined>;
|
||||
readonly closed: Promise<void>;
|
||||
readonly desiredSize: number | null;
|
||||
readonly ready: Promise<undefined>;
|
||||
readonly ready: Promise<void>;
|
||||
abort(reason?: any): Promise<void>;
|
||||
close(): Promise<void>;
|
||||
releaseLock(): void;
|
||||
@@ -342,8 +404,125 @@ declare module "stream/web" {
|
||||
}
|
||||
const TextDecoderStream: {
|
||||
prototype: TextDecoderStream;
|
||||
new(label?: string, options?: TextDecoderOptions): TextDecoderStream;
|
||||
new(encoding?: string, options?: TextDecoderOptions): TextDecoderStream;
|
||||
};
|
||||
interface CompressionStream {
|
||||
readonly readable: ReadableStream;
|
||||
readonly writable: WritableStream;
|
||||
}
|
||||
const CompressionStream: {
|
||||
prototype: CompressionStream;
|
||||
new(format: "deflate" | "deflate-raw" | "gzip"): CompressionStream;
|
||||
};
|
||||
interface DecompressionStream {
|
||||
readonly writable: WritableStream;
|
||||
readonly readable: ReadableStream;
|
||||
}
|
||||
const DecompressionStream: {
|
||||
prototype: DecompressionStream;
|
||||
new(format: "deflate" | "deflate-raw" | "gzip"): DecompressionStream;
|
||||
};
|
||||
|
||||
global {
|
||||
interface ByteLengthQueuingStrategy extends _ByteLengthQueuingStrategy {}
|
||||
var ByteLengthQueuingStrategy: typeof globalThis extends { onmessage: any; ByteLengthQueuingStrategy: infer T }
|
||||
? T
|
||||
: typeof import("stream/web").ByteLengthQueuingStrategy;
|
||||
|
||||
interface CompressionStream extends _CompressionStream {}
|
||||
var CompressionStream: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
// CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit.
|
||||
// If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts
|
||||
ReportingObserver: any;
|
||||
CompressionStream: infer T;
|
||||
} ? T
|
||||
// TS 4.8, 4.9, 5.0
|
||||
: typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? {
|
||||
prototype: T;
|
||||
new(format: "deflate" | "deflate-raw" | "gzip"): T;
|
||||
}
|
||||
: typeof import("stream/web").CompressionStream;
|
||||
|
||||
interface CountQueuingStrategy extends _CountQueuingStrategy {}
|
||||
var CountQueuingStrategy: typeof globalThis extends { onmessage: any; CountQueuingStrategy: infer T } ? T
|
||||
: typeof import("stream/web").CountQueuingStrategy;
|
||||
|
||||
interface DecompressionStream extends _DecompressionStream {}
|
||||
var DecompressionStream: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
// CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit.
|
||||
// If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts
|
||||
ReportingObserver: any;
|
||||
DecompressionStream: infer T;
|
||||
} ? T
|
||||
// TS 4.8, 4.9, 5.0
|
||||
: typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? {
|
||||
prototype: T;
|
||||
new(format: "deflate" | "deflate-raw" | "gzip"): T;
|
||||
}
|
||||
: typeof import("stream/web").DecompressionStream;
|
||||
|
||||
interface ReadableByteStreamController extends _ReadableByteStreamController {}
|
||||
var ReadableByteStreamController: typeof globalThis extends
|
||||
{ onmessage: any; ReadableByteStreamController: infer T } ? T
|
||||
: typeof import("stream/web").ReadableByteStreamController;
|
||||
|
||||
interface ReadableStream<R = any> extends _ReadableStream<R> {}
|
||||
var ReadableStream: typeof globalThis extends { onmessage: any; ReadableStream: infer T } ? T
|
||||
: typeof import("stream/web").ReadableStream;
|
||||
|
||||
interface ReadableStreamBYOBReader extends _ReadableStreamBYOBReader {}
|
||||
var ReadableStreamBYOBReader: typeof globalThis extends { onmessage: any; ReadableStreamBYOBReader: infer T }
|
||||
? T
|
||||
: typeof import("stream/web").ReadableStreamBYOBReader;
|
||||
|
||||
interface ReadableStreamBYOBRequest extends _ReadableStreamBYOBRequest {}
|
||||
var ReadableStreamBYOBRequest: typeof globalThis extends { onmessage: any; ReadableStreamBYOBRequest: infer T }
|
||||
? T
|
||||
: typeof import("stream/web").ReadableStreamBYOBRequest;
|
||||
|
||||
interface ReadableStreamDefaultController<R = any> extends _ReadableStreamDefaultController<R> {}
|
||||
var ReadableStreamDefaultController: typeof globalThis extends
|
||||
{ onmessage: any; ReadableStreamDefaultController: infer T } ? T
|
||||
: typeof import("stream/web").ReadableStreamDefaultController;
|
||||
|
||||
interface ReadableStreamDefaultReader<R = any> extends _ReadableStreamDefaultReader<R> {}
|
||||
var ReadableStreamDefaultReader: typeof globalThis extends
|
||||
{ onmessage: any; ReadableStreamDefaultReader: infer T } ? T
|
||||
: typeof import("stream/web").ReadableStreamDefaultReader;
|
||||
|
||||
interface TextDecoderStream extends _TextDecoderStream {}
|
||||
var TextDecoderStream: typeof globalThis extends { onmessage: any; TextDecoderStream: infer T } ? T
|
||||
: typeof import("stream/web").TextDecoderStream;
|
||||
|
||||
interface TextEncoderStream extends _TextEncoderStream {}
|
||||
var TextEncoderStream: typeof globalThis extends { onmessage: any; TextEncoderStream: infer T } ? T
|
||||
: typeof import("stream/web").TextEncoderStream;
|
||||
|
||||
interface TransformStream<I = any, O = any> extends _TransformStream<I, O> {}
|
||||
var TransformStream: typeof globalThis extends { onmessage: any; TransformStream: infer T } ? T
|
||||
: typeof import("stream/web").TransformStream;
|
||||
|
||||
interface TransformStreamDefaultController<O = any> extends _TransformStreamDefaultController<O> {}
|
||||
var TransformStreamDefaultController: typeof globalThis extends
|
||||
{ onmessage: any; TransformStreamDefaultController: infer T } ? T
|
||||
: typeof import("stream/web").TransformStreamDefaultController;
|
||||
|
||||
interface WritableStream<W = any> extends _WritableStream<W> {}
|
||||
var WritableStream: typeof globalThis extends { onmessage: any; WritableStream: infer T } ? T
|
||||
: typeof import("stream/web").WritableStream;
|
||||
|
||||
interface WritableStreamDefaultController extends _WritableStreamDefaultController {}
|
||||
var WritableStreamDefaultController: typeof globalThis extends
|
||||
{ onmessage: any; WritableStreamDefaultController: infer T } ? T
|
||||
: typeof import("stream/web").WritableStreamDefaultController;
|
||||
|
||||
interface WritableStreamDefaultWriter<W = any> extends _WritableStreamDefaultWriter<W> {}
|
||||
var WritableStreamDefaultWriter: typeof globalThis extends
|
||||
{ onmessage: any; WritableStreamDefaultWriter: infer T } ? T
|
||||
: typeof import("stream/web").WritableStreamDefaultWriter;
|
||||
}
|
||||
}
|
||||
declare module "node:stream/web" {
|
||||
export * from "stream/web";
|
||||
|
||||
16
node_modules/@types/node/string_decoder.d.ts
generated
vendored
16
node_modules/@types/node/string_decoder.d.ts
generated
vendored
@@ -4,13 +4,13 @@
|
||||
* characters. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const { StringDecoder } = require('node:string_decoder');
|
||||
* import { StringDecoder } from 'node:string_decoder';
|
||||
* ```
|
||||
*
|
||||
* The following example shows the basic use of the `StringDecoder` class.
|
||||
*
|
||||
* ```js
|
||||
* const { StringDecoder } = require('node:string_decoder');
|
||||
* import { StringDecoder } from 'node:string_decoder';
|
||||
* const decoder = new StringDecoder('utf8');
|
||||
*
|
||||
* const cent = Buffer.from([0xC2, 0xA2]);
|
||||
@@ -29,14 +29,14 @@
|
||||
* symbol (`€`) are written over three separate operations:
|
||||
*
|
||||
* ```js
|
||||
* const { StringDecoder } = require('node:string_decoder');
|
||||
* import { StringDecoder } from 'node:string_decoder';
|
||||
* const decoder = new StringDecoder('utf8');
|
||||
*
|
||||
* decoder.write(Buffer.from([0xE2]));
|
||||
* decoder.write(Buffer.from([0x82]));
|
||||
* console.log(decoder.end(Buffer.from([0xAC]))); // Prints: €
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/string_decoder.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/string_decoder.js)
|
||||
*/
|
||||
declare module "string_decoder" {
|
||||
class StringDecoder {
|
||||
@@ -44,22 +44,22 @@ declare module "string_decoder" {
|
||||
/**
|
||||
* 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()`.
|
||||
* returned string and stored in an internal buffer for the next call to `stringDecoder.write()` or `stringDecoder.end()`.
|
||||
* @since v0.1.99
|
||||
* @param buffer The bytes to decode.
|
||||
*/
|
||||
write(buffer: Buffer): string;
|
||||
write(buffer: string | Buffer | NodeJS.ArrayBufferView): 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.
|
||||
* 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 The bytes to decode.
|
||||
*/
|
||||
end(buffer?: Buffer): string;
|
||||
end(buffer?: string | Buffer | NodeJS.ArrayBufferView): string;
|
||||
}
|
||||
}
|
||||
declare module "node:string_decoder" {
|
||||
|
||||
2759
node_modules/@types/node/test.d.ts
generated
vendored
2759
node_modules/@types/node/test.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
306
node_modules/@types/node/timers.d.ts
generated
vendored
306
node_modules/@types/node/timers.d.ts
generated
vendored
@@ -1,21 +1,17 @@
|
||||
/**
|
||||
* The `timer` module exposes a global API for scheduling functions to
|
||||
* be called at some future period of time. Because the timer functions are
|
||||
* globals, there is no need to call `require('node:timers')` to use the API.
|
||||
* globals, there is no need to import `node: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/v20.2.0/lib/timers.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.x/lib/timers.js)
|
||||
*/
|
||||
declare module "timers" {
|
||||
import { Abortable } from "node:events";
|
||||
import {
|
||||
setImmediate as setImmediatePromise,
|
||||
setInterval as setIntervalPromise,
|
||||
setTimeout as setTimeoutPromise,
|
||||
} from "node:timers/promises";
|
||||
interface TimerOptions extends Abortable {
|
||||
import * as promises from "node:timers/promises";
|
||||
export interface TimerOptions extends Abortable {
|
||||
/**
|
||||
* Set to `false` to indicate that the scheduled `Timeout`
|
||||
* should not require the Node.js event loop to remain active.
|
||||
@@ -23,38 +19,33 @@ declare module "timers" {
|
||||
*/
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* This object is created internally and is returned from `setImmediate()`. It
|
||||
* can be passed to `clearImmediate()` in order to cancel the scheduled
|
||||
* actions.
|
||||
*
|
||||
* By default, when an immediate is scheduled, the Node.js event loop will continue
|
||||
* running as long as the immediate is active. The `Immediate` object returned by `setImmediate()` exports both `immediate.ref()` and `immediate.unref()`functions that can be used to
|
||||
* control this default behavior.
|
||||
* running as long as the immediate is active. The `Immediate` object returned by
|
||||
* `setImmediate()` exports both `immediate.ref()` and `immediate.unref()`
|
||||
* functions that can be used to control this default behavior.
|
||||
*/
|
||||
class Immediate implements RefCounted {
|
||||
interface Immediate extends RefCounted, Disposable {
|
||||
/**
|
||||
* When called, requests that the Node.js event loop _not_ exit so long as the`Immediate` is active. Calling `immediate.ref()` multiple times will have no
|
||||
* If true, the `Immediate` object will keep the Node.js event loop active.
|
||||
* @since v11.0.0
|
||||
*/
|
||||
hasRef(): boolean;
|
||||
/**
|
||||
* When called, requests that the Node.js event loop _not_ exit so long as the
|
||||
* `Immediate` is active. Calling `immediate.ref()` multiple times will have no
|
||||
* effect.
|
||||
*
|
||||
* By default, all `Immediate` objects are "ref'ed", making it normally unnecessary
|
||||
* to call `immediate.ref()` unless `immediate.unref()` had been called previously.
|
||||
* @since v9.7.0
|
||||
* @return a reference to `immediate`
|
||||
* @returns a reference to `immediate`
|
||||
*/
|
||||
ref(): this;
|
||||
/**
|
||||
@@ -63,53 +54,58 @@ declare module "timers" {
|
||||
* running, the process may exit before the `Immediate` object's callback is
|
||||
* invoked. Calling `immediate.unref()` multiple times will have no effect.
|
||||
* @since v9.7.0
|
||||
* @return a reference to `immediate`
|
||||
* @returns a reference to `immediate`
|
||||
*/
|
||||
unref(): this;
|
||||
/**
|
||||
* 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
|
||||
/**
|
||||
* Cancels the immediate. This is similar to calling `clearImmediate()`.
|
||||
* @since v20.5.0
|
||||
* @since v20.5.0, v18.18.0
|
||||
* @experimental
|
||||
*/
|
||||
[Symbol.dispose](): void;
|
||||
_onImmediate(...args: any[]): void;
|
||||
}
|
||||
// Legacy interface used in Node.js v9 and prior
|
||||
/** @deprecated Use `NodeJS.Timeout` instead. */
|
||||
interface Timer extends RefCounted {
|
||||
hasRef(): boolean;
|
||||
refresh(): this;
|
||||
[Symbol.toPrimitive](): number;
|
||||
}
|
||||
/**
|
||||
* This object is created internally and is returned from `setTimeout()` and `setInterval()`. It can be passed to either `clearTimeout()` or `clearInterval()` in order to cancel the
|
||||
* scheduled actions.
|
||||
* This object is created internally and is returned from `setTimeout()` and
|
||||
* `setInterval()`. It can be passed to either `clearTimeout()` or
|
||||
* `clearInterval()` in order to cancel the scheduled actions.
|
||||
*
|
||||
* By default, when a timer is scheduled using either `setTimeout()` or `setInterval()`, the Node.js event loop will continue running as long as the
|
||||
* By default, when a timer is scheduled using either `setTimeout()` or
|
||||
* `setInterval()`, the Node.js event loop will continue running as long as the
|
||||
* timer is active. Each of the `Timeout` objects returned by these functions
|
||||
* export both `timeout.ref()` and `timeout.unref()` functions that can be used to
|
||||
* control this default behavior.
|
||||
*/
|
||||
class Timeout implements Timer {
|
||||
interface Timeout extends RefCounted, Disposable, Timer {
|
||||
/**
|
||||
* When called, requests that the Node.js event loop _not_ exit so long as the`Timeout` is active. Calling `timeout.ref()` multiple times will have no effect.
|
||||
*
|
||||
* By default, all `Timeout` objects are "ref'ed", making it normally unnecessary
|
||||
* to call `timeout.ref()` unless `timeout.unref()` had been called previously.
|
||||
* Cancels the timeout.
|
||||
* @since v0.9.1
|
||||
* @return a reference to `timeout`
|
||||
* @legacy Use `clearTimeout()` instead.
|
||||
* @returns a reference to `timeout`
|
||||
*/
|
||||
ref(): this;
|
||||
/**
|
||||
* When called, the active `Timeout` object will not require the Node.js event loop
|
||||
* to remain active. If there is no other activity keeping the event loop running,
|
||||
* the process may exit before the `Timeout` object's callback is invoked. Calling`timeout.unref()` multiple times will have no effect.
|
||||
* @since v0.9.1
|
||||
* @return a reference to `timeout`
|
||||
*/
|
||||
unref(): this;
|
||||
close(): this;
|
||||
/**
|
||||
* If true, the `Timeout` object will keep the Node.js event loop active.
|
||||
* @since v11.0.0
|
||||
*/
|
||||
hasRef(): boolean;
|
||||
/**
|
||||
* When called, requests that the Node.js event loop _not_ exit so long as the
|
||||
* `Timeout` is active. Calling `timeout.ref()` multiple times will have no effect.
|
||||
*
|
||||
* By default, all `Timeout` objects are "ref'ed", making it normally unnecessary
|
||||
* to call `timeout.ref()` unless `timeout.unref()` had been called previously.
|
||||
* @since v0.9.1
|
||||
* @returns a reference to `timeout`
|
||||
*/
|
||||
ref(): this;
|
||||
/**
|
||||
* 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
|
||||
@@ -119,85 +115,37 @@ declare module "timers" {
|
||||
* Using this on a timer that has already called its callback will reactivate the
|
||||
* timer.
|
||||
* @since v10.2.0
|
||||
* @return a reference to `timeout`
|
||||
* @returns a reference to `timeout`
|
||||
*/
|
||||
refresh(): this;
|
||||
/**
|
||||
* When called, the active `Timeout` object will not require the Node.js event loop
|
||||
* to remain active. If there is no other activity keeping the event loop running,
|
||||
* the process may exit before the `Timeout` object's callback is invoked. Calling
|
||||
* `timeout.unref()` multiple times will have no effect.
|
||||
* @since v0.9.1
|
||||
* @returns a reference to `timeout`
|
||||
*/
|
||||
unref(): this;
|
||||
/**
|
||||
* Coerce a `Timeout` to a primitive. The primitive can be used to
|
||||
* clear the `Timeout`. The primitive can only be used in the
|
||||
* same thread where the timeout was created. Therefore, to use it
|
||||
* across `worker_threads` it must first be passed to the correct
|
||||
* thread. This allows enhanced compatibility with browser
|
||||
* `setTimeout()` and `setInterval()` implementations.
|
||||
* @since v14.9.0, v12.19.0
|
||||
*/
|
||||
[Symbol.toPrimitive](): number;
|
||||
/**
|
||||
* Cancels the timeout.
|
||||
* @since v20.5.0
|
||||
* @since v20.5.0, v18.18.0
|
||||
* @experimental
|
||||
*/
|
||||
[Symbol.dispose](): void;
|
||||
_onTimeout(...args: any[]): void;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Schedules execution of a one-time `callback` after `delay` milliseconds.
|
||||
*
|
||||
* The `callback` will likely not be invoked in precisely `delay` milliseconds.
|
||||
* Node.js makes no guarantees about the exact timing of when callbacks will fire,
|
||||
* nor of their ordering. The callback will be called as close as possible to the
|
||||
* time specified.
|
||||
*
|
||||
* When `delay` is larger than `2147483647` or less than `1`, the `delay`will be set to `1`. Non-integer delays are truncated to an integer.
|
||||
*
|
||||
* If `callback` is not a function, a `TypeError` will be thrown.
|
||||
*
|
||||
* This method has a custom variant for promises that is available using `timersPromises.setTimeout()`.
|
||||
* @since v0.0.1
|
||||
* @param callback The function to call when the timer elapses.
|
||||
* @param [delay=1] The number of milliseconds to wait before calling the `callback`.
|
||||
* @param args Optional arguments to pass when the `callback` is called.
|
||||
* @return for use with {@link clearTimeout}
|
||||
*/
|
||||
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 {
|
||||
const __promisify__: typeof setTimeoutPromise;
|
||||
}
|
||||
/**
|
||||
* Cancels a `Timeout` object created by `setTimeout()`.
|
||||
* @since v0.0.1
|
||||
* @param timeout A `Timeout` object as returned by {@link setTimeout} or the `primitive` of the `Timeout` object as a string or a number.
|
||||
*/
|
||||
function clearTimeout(timeoutId: NodeJS.Timeout | string | number | undefined): void;
|
||||
/**
|
||||
* Schedules repeated execution of `callback` every `delay` milliseconds.
|
||||
*
|
||||
* When `delay` is larger than `2147483647` or less than `1`, the `delay` will be
|
||||
* set to `1`. Non-integer delays are truncated to an integer.
|
||||
*
|
||||
* If `callback` is not a function, a `TypeError` will be thrown.
|
||||
*
|
||||
* This method has a custom variant for promises that is available using `timersPromises.setInterval()`.
|
||||
* @since v0.0.1
|
||||
* @param callback The function to call when the timer elapses.
|
||||
* @param [delay=1] The number of milliseconds to wait before calling the `callback`.
|
||||
* @param args Optional arguments to pass when the `callback` is called.
|
||||
* @return for use with {@link clearInterval}
|
||||
*/
|
||||
function setInterval<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 setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timeout;
|
||||
namespace setInterval {
|
||||
const __promisify__: typeof setIntervalPromise;
|
||||
}
|
||||
/**
|
||||
* Cancels a `Timeout` object created by `setInterval()`.
|
||||
* @since v0.0.1
|
||||
* @param timeout A `Timeout` object as returned by {@link setInterval} or the `primitive` of the `Timeout` object as a string or a number.
|
||||
*/
|
||||
function clearInterval(intervalId: NodeJS.Timeout | string | number | undefined): void;
|
||||
/**
|
||||
* Schedules the "immediate" execution of the `callback` after I/O events'
|
||||
* callbacks.
|
||||
@@ -210,30 +158,128 @@ declare module "timers" {
|
||||
*
|
||||
* If `callback` is not a function, a `TypeError` will be thrown.
|
||||
*
|
||||
* This method has a custom variant for promises that is available using `timersPromises.setImmediate()`.
|
||||
* This method has a custom variant for promises that is available using
|
||||
* `timersPromises.setImmediate()`.
|
||||
* @since v0.9.1
|
||||
* @param callback The function to call at the end of this turn of the Node.js `Event Loop`
|
||||
* @param callback The function to call at the end of this turn of
|
||||
* the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout)
|
||||
* @param args Optional arguments to pass when the `callback` is called.
|
||||
* @return for use with {@link clearImmediate}
|
||||
* @returns for use with `clearImmediate()`
|
||||
*/
|
||||
function setImmediate<TArgs extends any[]>(
|
||||
callback: (...args: TArgs) => void,
|
||||
...args: TArgs
|
||||
): NodeJS.Immediate;
|
||||
// util.promisify no rest args compability
|
||||
// tslint:disable-next-line void-return
|
||||
function setImmediate(callback: (args: void) => void): NodeJS.Immediate;
|
||||
// Allow a single void-accepting argument to be optional in arguments lists.
|
||||
// Allows usage such as `new Promise(resolve => setTimeout(resolve, ms))` (#54258)
|
||||
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
||||
function setImmediate(callback: (_: void) => void): NodeJS.Immediate;
|
||||
namespace setImmediate {
|
||||
const __promisify__: typeof setImmediatePromise;
|
||||
import __promisify__ = promises.setImmediate;
|
||||
export { __promisify__ };
|
||||
}
|
||||
/**
|
||||
* Schedules repeated execution of `callback` every `delay` milliseconds.
|
||||
*
|
||||
* When `delay` is larger than `2147483647` or less than `1`, the `delay` will be
|
||||
* set to `1`. Non-integer delays are truncated to an integer.
|
||||
*
|
||||
* If `callback` is not a function, a `TypeError` will be thrown.
|
||||
*
|
||||
* This method has a custom variant for promises that is available using
|
||||
* `timersPromises.setInterval()`.
|
||||
* @since v0.0.1
|
||||
* @param callback The function to call when the timer elapses.
|
||||
* @param delay The number of milliseconds to wait before calling the
|
||||
* `callback`. **Default:** `1`.
|
||||
* @param args Optional arguments to pass when the `callback` is called.
|
||||
* @returns for use with `clearInterval()`
|
||||
*/
|
||||
function setInterval<TArgs extends any[]>(
|
||||
callback: (...args: TArgs) => void,
|
||||
delay?: number,
|
||||
...args: TArgs
|
||||
): NodeJS.Timeout;
|
||||
// Allow a single void-accepting argument to be optional in arguments lists.
|
||||
// Allows usage such as `new Promise(resolve => setTimeout(resolve, ms))` (#54258)
|
||||
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
||||
function setInterval(callback: (_: void) => void, delay?: number): NodeJS.Timeout;
|
||||
/**
|
||||
* Schedules execution of a one-time `callback` after `delay` milliseconds.
|
||||
*
|
||||
* The `callback` will likely not be invoked in precisely `delay` milliseconds.
|
||||
* Node.js makes no guarantees about the exact timing of when callbacks will fire,
|
||||
* nor of their ordering. The callback will be called as close as possible to the
|
||||
* time specified.
|
||||
*
|
||||
* When `delay` is larger than `2147483647` or less than `1` or `NaN`, the `delay`
|
||||
* will be set to `1`. Non-integer delays are truncated to an integer.
|
||||
*
|
||||
* If `callback` is not a function, a `TypeError` will be thrown.
|
||||
*
|
||||
* This method has a custom variant for promises that is available using
|
||||
* `timersPromises.setTimeout()`.
|
||||
* @since v0.0.1
|
||||
* @param callback The function to call when the timer elapses.
|
||||
* @param delay The number of milliseconds to wait before calling the
|
||||
* `callback`. **Default:** `1`.
|
||||
* @param args Optional arguments to pass when the `callback` is called.
|
||||
* @returns for use with `clearTimeout()`
|
||||
*/
|
||||
function setTimeout<TArgs extends any[]>(
|
||||
callback: (...args: TArgs) => void,
|
||||
delay?: number,
|
||||
...args: TArgs
|
||||
): NodeJS.Timeout;
|
||||
// Allow a single void-accepting argument to be optional in arguments lists.
|
||||
// Allows usage such as `new Promise(resolve => setTimeout(resolve, ms))` (#54258)
|
||||
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
||||
function setTimeout(callback: (_: void) => void, delay?: number): NodeJS.Timeout;
|
||||
namespace setTimeout {
|
||||
import __promisify__ = promises.setTimeout;
|
||||
export { __promisify__ };
|
||||
}
|
||||
/**
|
||||
* Cancels an `Immediate` object created by `setImmediate()`.
|
||||
* @since v0.9.1
|
||||
* @param immediate An `Immediate` object as returned by {@link setImmediate}.
|
||||
* @param immediate An `Immediate` object as returned by `setImmediate()`.
|
||||
*/
|
||||
function clearImmediate(immediate: NodeJS.Immediate | undefined): void;
|
||||
/**
|
||||
* Cancels a `Timeout` object created by `setInterval()`.
|
||||
* @since v0.0.1
|
||||
* @param timeout A `Timeout` object as returned by `setInterval()`
|
||||
* or the primitive of the `Timeout` object as a string or a number.
|
||||
*/
|
||||
function clearInterval(timeout: NodeJS.Timeout | string | number | undefined): void;
|
||||
/**
|
||||
* Cancels a `Timeout` object created by `setTimeout()`.
|
||||
* @since v0.0.1
|
||||
* @param timeout A `Timeout` object as returned by `setTimeout()`
|
||||
* or the primitive of the `Timeout` object as a string or a number.
|
||||
*/
|
||||
function clearTimeout(timeout: NodeJS.Timeout | string | number | undefined): void;
|
||||
/**
|
||||
* The `queueMicrotask()` method queues a microtask to invoke `callback`. If
|
||||
* `callback` throws an exception, the `process` object `'uncaughtException'`
|
||||
* event will be emitted.
|
||||
*
|
||||
* The microtask queue is managed by V8 and may be used in a similar manner to
|
||||
* the `process.nextTick()` queue, which is managed by Node.js. The
|
||||
* `process.nextTick()` queue is always processed before the microtask queue
|
||||
* within each turn of the Node.js event loop.
|
||||
* @since v11.0.0
|
||||
* @param callback Function to be queued.
|
||||
*/
|
||||
function clearImmediate(immediateId: NodeJS.Immediate | undefined): void;
|
||||
function queueMicrotask(callback: () => void): void;
|
||||
}
|
||||
import clearImmediate = globalThis.clearImmediate;
|
||||
import clearInterval = globalThis.clearInterval;
|
||||
import clearTimeout = globalThis.clearTimeout;
|
||||
import setImmediate = globalThis.setImmediate;
|
||||
import setInterval = globalThis.setInterval;
|
||||
import setTimeout = globalThis.setTimeout;
|
||||
export { clearImmediate, clearInterval, clearTimeout, promises, setImmediate, setInterval, setTimeout };
|
||||
}
|
||||
declare module "node:timers" {
|
||||
export * from "timers";
|
||||
|
||||
47
node_modules/@types/node/timers/promises.d.ts
generated
vendored
47
node_modules/@types/node/timers/promises.d.ts
generated
vendored
@@ -1,15 +1,17 @@
|
||||
/**
|
||||
* The `timers/promises` API provides an alternative set of timer functions
|
||||
* that return `Promise` objects. The API is accessible via`require('node:timers/promises')`.
|
||||
* that return `Promise` objects. The API is accessible via
|
||||
* `require('node:timers/promises')`.
|
||||
*
|
||||
* ```js
|
||||
* import {
|
||||
* setTimeout,
|
||||
* setImmediate,
|
||||
* setInterval,
|
||||
* } from 'timers/promises';
|
||||
* } from 'node:timers/promises';
|
||||
* ```
|
||||
* @since v15.0.0
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.x/lib/timers/promises.js)
|
||||
*/
|
||||
declare module "timers/promises" {
|
||||
import { TimerOptions } from "node:timers";
|
||||
@@ -17,14 +19,15 @@ declare module "timers/promises" {
|
||||
* ```js
|
||||
* import {
|
||||
* setTimeout,
|
||||
* } from 'timers/promises';
|
||||
* } from 'node:timers/promises';
|
||||
*
|
||||
* const res = await setTimeout(100, 'result');
|
||||
*
|
||||
* console.log(res); // Prints 'result'
|
||||
* ```
|
||||
* @since v15.0.0
|
||||
* @param [delay=1] The number of milliseconds to wait before fulfilling the promise.
|
||||
* @param delay The number of milliseconds to wait before fulfilling the
|
||||
* promise. **Default:** `1`.
|
||||
* @param value A value with which the promise is fulfilled.
|
||||
*/
|
||||
function setTimeout<T = void>(delay?: number, value?: T, options?: TimerOptions): Promise<T>;
|
||||
@@ -32,7 +35,7 @@ declare module "timers/promises" {
|
||||
* ```js
|
||||
* import {
|
||||
* setImmediate,
|
||||
* } from 'timers/promises';
|
||||
* } from 'node:timers/promises';
|
||||
*
|
||||
* const res = await setImmediate('result');
|
||||
*
|
||||
@@ -50,7 +53,7 @@ declare module "timers/promises" {
|
||||
* ```js
|
||||
* import {
|
||||
* setInterval,
|
||||
* } from 'timers/promises';
|
||||
* } from 'node:timers/promises';
|
||||
*
|
||||
* const interval = 100;
|
||||
* for await (const startTime of setInterval(interval, Date.now())) {
|
||||
@@ -62,29 +65,41 @@ declare module "timers/promises" {
|
||||
* console.log(Date.now());
|
||||
* ```
|
||||
* @since v15.9.0
|
||||
* @param delay The number of milliseconds to wait between iterations.
|
||||
* **Default:** `1`.
|
||||
* @param value A value with which the iterator returns.
|
||||
*/
|
||||
function setInterval<T = void>(delay?: number, value?: T, options?: TimerOptions): AsyncIterable<T>;
|
||||
function setInterval<T = void>(delay?: number, value?: T, options?: TimerOptions): NodeJS.AsyncIterator<T>;
|
||||
interface Scheduler {
|
||||
/**
|
||||
* An experimental API defined by the [Scheduling APIs](https://github.com/WICG/scheduling-apis) draft specification
|
||||
* being developed as a standard Web Platform API.
|
||||
*
|
||||
* Calling `timersPromises.scheduler.wait(delay, options)` is roughly equivalent
|
||||
* to calling `timersPromises.setTimeout(delay, undefined, options)` except that
|
||||
* the `ref` option is not supported.
|
||||
*
|
||||
* ```js
|
||||
* import { scheduler } from 'node:timers/promises';
|
||||
*
|
||||
* await scheduler.wait(1000); // Wait one second before continuing
|
||||
* ```
|
||||
* An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API.
|
||||
* Calling timersPromises.scheduler.wait(delay, options) is roughly equivalent to calling timersPromises.setTimeout(delay, undefined, options) except that the ref option is not supported.
|
||||
* @since v16.14.0
|
||||
* @since v17.3.0, v16.14.0
|
||||
* @experimental
|
||||
* @param [delay=1] The number of milliseconds to wait before fulfilling the promise.
|
||||
* @param delay The number of milliseconds to wait before resolving the
|
||||
* promise.
|
||||
*/
|
||||
wait: (delay?: number, options?: TimerOptions) => Promise<void>;
|
||||
wait(delay: number, options?: { signal?: AbortSignal }): Promise<void>;
|
||||
/**
|
||||
* An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API.
|
||||
* Calling timersPromises.scheduler.yield() is equivalent to calling timersPromises.setImmediate() with no arguments.
|
||||
* @since v16.14.0
|
||||
* An experimental API defined by the [Scheduling APIs](https://github.com/WICG/scheduling-apis) draft specification
|
||||
* being developed as a standard Web Platform API.
|
||||
*
|
||||
* Calling `timersPromises.scheduler.yield()` is equivalent to calling
|
||||
* `timersPromises.setImmediate()` with no arguments.
|
||||
* @since v17.3.0, v16.14.0
|
||||
* @experimental
|
||||
*/
|
||||
yield: () => Promise<void>;
|
||||
yield(): Promise<void>;
|
||||
}
|
||||
const scheduler: Scheduler;
|
||||
}
|
||||
|
||||
101
node_modules/@types/node/tls.d.ts
generated
vendored
101
node_modules/@types/node/tls.d.ts
generated
vendored
@@ -4,9 +4,9 @@
|
||||
* The module can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const tls = require('node:tls');
|
||||
* import tls from 'node:tls';
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/tls.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/tls.js)
|
||||
*/
|
||||
declare module "tls" {
|
||||
import { X509Certificate } from "node:crypto";
|
||||
@@ -125,7 +125,7 @@ declare module "tls" {
|
||||
*/
|
||||
asn1Curve?: string;
|
||||
/**
|
||||
* The NIST name for the elliptic curve,if it has one
|
||||
* The NIST name for the elliptic curve, if it has one
|
||||
* (not all well-known curves have been assigned names by NIST).
|
||||
*/
|
||||
nistCurve?: string;
|
||||
@@ -220,7 +220,7 @@ declare module "tls" {
|
||||
/**
|
||||
* Construct a new tls.TLSSocket object from an existing TCP socket.
|
||||
*/
|
||||
constructor(socket: net.Socket, options?: TLSSocketOptions);
|
||||
constructor(socket: net.Socket | stream.Duplex, options?: TLSSocketOptions);
|
||||
/**
|
||||
* This property is `true` if the peer certificate was signed by one of the CAs
|
||||
* specified when creating the `tls.TLSSocket` instance, otherwise `false`.
|
||||
@@ -278,7 +278,7 @@ declare module "tls" {
|
||||
* an ephemeral key exchange in `perfect forward secrecy` on a client
|
||||
* connection. It returns an empty object when the key exchange is not
|
||||
* ephemeral. As this is only supported on a client socket; `null` is returned
|
||||
* if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The`name` property is available only when type is `'ECDH'`.
|
||||
* if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The `name` property is available only when type is `'ECDH'`.
|
||||
*
|
||||
* For example: `{ type: 'ECDH', name: 'prime256v1', size: 256 }`.
|
||||
* @since v5.0.0
|
||||
@@ -382,7 +382,7 @@ declare module "tls" {
|
||||
* This method can be used to request a peer's certificate after the secure
|
||||
* connection has been established.
|
||||
*
|
||||
* When running as the server, the socket will be destroyed with an error after`handshakeTimeout` timeout.
|
||||
* When running as the server, the socket will be destroyed with an error after `handshakeTimeout` timeout.
|
||||
*
|
||||
* For TLSv1.3, renegotiation cannot be initiated, it is not supported by the
|
||||
* protocol.
|
||||
@@ -398,6 +398,14 @@ declare module "tls" {
|
||||
},
|
||||
callback: (err: Error | null) => void,
|
||||
): undefined | boolean;
|
||||
/**
|
||||
* The `tlsSocket.setKeyCert()` method sets the private key and certificate to use for the socket.
|
||||
* This is mainly useful if you wish to select a server certificate from a TLS server's `ALPNCallback`.
|
||||
* @since v22.5.0, v20.17.0
|
||||
* @param context An object containing at least `key` and `cert` properties from the {@link createSecureContext()} `options`,
|
||||
* or a TLS context object created with {@link createSecureContext()} itself.
|
||||
*/
|
||||
setKeyCert(context: SecureContextOptions | SecureContext): void;
|
||||
/**
|
||||
* The `tlsSocket.setMaxSendFragment()` method sets the maximum TLS fragment size.
|
||||
* Returns `true` if setting the limit succeeded; `false` otherwise.
|
||||
@@ -639,7 +647,7 @@ declare module "tls" {
|
||||
* @param context An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc), or a TLS context object created
|
||||
* with {@link createSecureContext} itself.
|
||||
*/
|
||||
addContext(hostname: string, context: SecureContextOptions): void;
|
||||
addContext(hostname: string, context: SecureContextOptions | SecureContext): void;
|
||||
/**
|
||||
* Returns the session ticket keys.
|
||||
*
|
||||
@@ -809,6 +817,12 @@ declare module "tls" {
|
||||
* This option cannot be used with the `ALPNProtocols` option, and setting both options will throw an error.
|
||||
*/
|
||||
ALPNCallback?: ((arg: { servername: string; protocols: string[] }) => string | undefined) | undefined;
|
||||
/**
|
||||
* Treat intermediate (non-self-signed)
|
||||
* certificates in the trust CA certificate list as trusted.
|
||||
* @since v22.9.0, v20.18.0
|
||||
*/
|
||||
allowPartialTrustChain?: boolean | undefined;
|
||||
/**
|
||||
* Optionally override the trusted CA certificates. Default is to trust
|
||||
* the well-known CAs curated by Mozilla. Mozilla's CAs are completely
|
||||
@@ -975,7 +989,7 @@ declare module "tls" {
|
||||
* This function is intended to be used in combination with the`checkServerIdentity` option that can be passed to {@link connect} and as
|
||||
* such operates on a `certificate object`. For other purposes, consider using `x509.checkHost()` instead.
|
||||
*
|
||||
* This function can be overwritten by providing an alternative function as the`options.checkServerIdentity` option that is passed to `tls.connect()`. The
|
||||
* This function can be overwritten by providing an alternative function as the `options.checkServerIdentity` option that is passed to `tls.connect()`. The
|
||||
* overwriting function can call `tls.checkServerIdentity()` of course, to augment
|
||||
* the checks done with additional verification.
|
||||
*
|
||||
@@ -984,7 +998,7 @@ declare module "tls" {
|
||||
*
|
||||
* Earlier versions of Node.js incorrectly accepted certificates for a given`hostname` if a matching `uniformResourceIdentifier` subject alternative name
|
||||
* was present (see [CVE-2021-44531](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44531)). Applications that wish to accept`uniformResourceIdentifier` subject alternative names can use
|
||||
* a custom`options.checkServerIdentity` function that implements the desired behavior.
|
||||
* a custom `options.checkServerIdentity` function that implements the desired behavior.
|
||||
* @since v0.8.4
|
||||
* @param hostname The host name or IP address to verify the certificate against.
|
||||
* @param cert A `certificate object` representing the peer's certificate.
|
||||
@@ -1000,8 +1014,8 @@ declare module "tls" {
|
||||
* The following illustrates a simple echo server:
|
||||
*
|
||||
* ```js
|
||||
* const tls = require('node:tls');
|
||||
* const fs = require('node:fs');
|
||||
* import tls from 'node:tls';
|
||||
* import fs from 'node:fs';
|
||||
*
|
||||
* const options = {
|
||||
* key: fs.readFileSync('server-key.pem'),
|
||||
@@ -1046,8 +1060,8 @@ declare module "tls" {
|
||||
*
|
||||
* ```js
|
||||
* // Assumes an echo server that is listening on port 8000.
|
||||
* const tls = require('node:tls');
|
||||
* const fs = require('node:fs');
|
||||
* import tls from 'node:tls';
|
||||
* import fs from 'node:fs';
|
||||
*
|
||||
* const options = {
|
||||
* // Necessary only if the server requires client certificate authentication.
|
||||
@@ -1092,7 +1106,7 @@ declare module "tls" {
|
||||
* stream and the cleartext one is used as a replacement for the initial encrypted
|
||||
* stream.
|
||||
*
|
||||
* `tls.createSecurePair()` returns a `tls.SecurePair` object with `cleartext` and`encrypted` stream properties.
|
||||
* `tls.createSecurePair()` returns a `tls.SecurePair` object with `cleartext` and `encrypted` stream properties.
|
||||
*
|
||||
* Using `cleartext` has the same API as {@link TLSSocket}.
|
||||
*
|
||||
@@ -1125,10 +1139,10 @@ declare module "tls" {
|
||||
rejectUnauthorized?: boolean,
|
||||
): SecurePair;
|
||||
/**
|
||||
* {@link createServer} sets the default value of the `honorCipherOrder` option
|
||||
* `{@link createServer}` sets the default value of the `honorCipherOrder` option
|
||||
* to `true`, other APIs that create secure contexts leave it unset.
|
||||
*
|
||||
* {@link createServer} uses a 128 bit truncated SHA1 hash value generated
|
||||
* `{@link createServer}` uses a 128 bit truncated SHA1 hash value generated
|
||||
* from `process.argv` as the default value of the `sessionIdContext` option, other
|
||||
* APIs that create secure contexts have no default value.
|
||||
*
|
||||
@@ -1136,12 +1150,12 @@ declare module "tls" {
|
||||
* usable as an argument to several `tls` APIs, such as `server.addContext()`,
|
||||
* but has no public methods. The {@link Server} constructor and the {@link createServer} method do not support the `secureContext` option.
|
||||
*
|
||||
* A key is _required_ for ciphers that use certificates. Either `key` or`pfx` can be used to provide it.
|
||||
* A key is _required_ for ciphers that use certificates. Either `key` or `pfx` can be used to provide it.
|
||||
*
|
||||
* If the `ca` option is not given, then Node.js will default to using [Mozilla's publicly trusted list of
|
||||
* CAs](https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt).
|
||||
*
|
||||
* Custom DHE parameters are discouraged in favor of the new `dhparam: 'auto'`option. When set to `'auto'`, well-known DHE parameters of sufficient strength
|
||||
* Custom DHE parameters are discouraged in favor of the new `dhparam: 'auto' `option. When set to `'auto'`, well-known DHE parameters of sufficient strength
|
||||
* will be selected automatically. Otherwise, if necessary, `openssl dhparam` can
|
||||
* be used to create custom parameters. The key length must be greater than or
|
||||
* equal to 1024 bits or else an error will be thrown. Although 1024 bits is
|
||||
@@ -1152,9 +1166,10 @@ declare module "tls" {
|
||||
/**
|
||||
* Returns an array with the names of the supported TLS ciphers. The names are
|
||||
* lower-case for historical reasons, but must be uppercased to be used in
|
||||
* the `ciphers` option of {@link createSecureContext}.
|
||||
* the `ciphers` option of `{@link createSecureContext}`.
|
||||
*
|
||||
* Not all supported ciphers are enabled by default. See `Modifying the default TLS cipher suite`.
|
||||
* Not all supported ciphers are enabled by default. See
|
||||
* [Modifying the default TLS cipher suite](https://nodejs.org/docs/latest-v20.x/api/tls.html#modifying-the-default-tls-cipher-suite).
|
||||
*
|
||||
* Cipher names that start with `'tls_'` are for TLSv1.3, all the others are for
|
||||
* TLSv1.2 and below.
|
||||
@@ -1167,43 +1182,49 @@ declare module "tls" {
|
||||
function getCiphers(): string[];
|
||||
/**
|
||||
* The default curve name to use for ECDH key agreement in a tls server.
|
||||
* The default value is 'auto'. See tls.createSecureContext() for further
|
||||
* The default value is `'auto'`. See `{@link createSecureContext()}` for further
|
||||
* information.
|
||||
* @since v0.11.13
|
||||
*/
|
||||
let DEFAULT_ECDH_CURVE: string;
|
||||
/**
|
||||
* The default value of the maxVersion option of
|
||||
* tls.createSecureContext(). It can be assigned any of the supported TLS
|
||||
* protocol versions, 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or 'TLSv1'. Default:
|
||||
* 'TLSv1.3', unless changed using CLI options. Using --tls-max-v1.2 sets
|
||||
* the default to 'TLSv1.2'. Using --tls-max-v1.3 sets the default to
|
||||
* 'TLSv1.3'. If multiple of the options are provided, the highest maximum
|
||||
* is used.
|
||||
* The default value of the `maxVersion` option of `{@link createSecureContext()}`.
|
||||
* It can be assigned any of the supported TLS protocol versions,
|
||||
* `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. **Default:** `'TLSv1.3'`, unless
|
||||
* changed using CLI options. Using `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using
|
||||
* `--tls-max-v1.3` sets the default to `'TLSv1.3'`. If multiple of the options
|
||||
* are provided, the highest maximum is used.
|
||||
* @since v11.4.0
|
||||
*/
|
||||
let DEFAULT_MAX_VERSION: SecureVersion;
|
||||
/**
|
||||
* The default value of the minVersion option of tls.createSecureContext().
|
||||
* The default value of the `minVersion` option of `{@link createSecureContext()}`.
|
||||
* It can be assigned any of the supported TLS protocol versions,
|
||||
* 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or 'TLSv1'. Default: 'TLSv1.2', unless
|
||||
* changed using CLI options. Using --tls-min-v1.0 sets the default to
|
||||
* 'TLSv1'. Using --tls-min-v1.1 sets the default to 'TLSv1.1'. Using
|
||||
* --tls-min-v1.3 sets the default to 'TLSv1.3'. If multiple of the options
|
||||
* `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. **Default:** `'TLSv1.2'`, unless
|
||||
* changed using CLI options. Using `--tls-min-v1.0` sets the default to
|
||||
* `'TLSv1'`. Using `--tls-min-v1.1` sets the default to `'TLSv1.1'`. Using
|
||||
* `--tls-min-v1.3` sets the default to `'TLSv1.3'`. If multiple of the options
|
||||
* are provided, the lowest minimum is used.
|
||||
* @since v11.4.0
|
||||
*/
|
||||
let DEFAULT_MIN_VERSION: SecureVersion;
|
||||
/**
|
||||
* The default value of the ciphers option of tls.createSecureContext().
|
||||
* The default value of the `ciphers` option of `{@link createSecureContext()}`.
|
||||
* It can be assigned any of the supported OpenSSL ciphers.
|
||||
* Defaults to the content of crypto.constants.defaultCoreCipherList, unless
|
||||
* changed using CLI options using --tls-default-ciphers.
|
||||
* Defaults to the content of `crypto.constants.defaultCoreCipherList`, unless
|
||||
* changed using CLI options using `--tls-default-ciphers`.
|
||||
* @since v19.8.0
|
||||
*/
|
||||
let DEFAULT_CIPHERS: string;
|
||||
/**
|
||||
* An immutable array of strings representing the root certificates (in PEM
|
||||
* format) used for verifying peer certificates. This is the default value
|
||||
* of the ca option to tls.createSecureContext().
|
||||
* An immutable array of strings representing the root certificates (in PEM format)
|
||||
* from the bundled Mozilla CA store as supplied by the current Node.js version.
|
||||
*
|
||||
* The bundled CA store, as supplied by Node.js, is a snapshot of Mozilla CA store
|
||||
* that is fixed at release time. It is identical on all supported platforms.
|
||||
* @since v12.3.0
|
||||
*/
|
||||
const rootCertificates: ReadonlyArray<string>;
|
||||
const rootCertificates: readonly string[];
|
||||
}
|
||||
declare module "node:tls" {
|
||||
export * from "tls";
|
||||
|
||||
71
node_modules/@types/node/trace_events.d.ts
generated
vendored
71
node_modules/@types/node/trace_events.d.ts
generated
vendored
@@ -1,40 +1,36 @@
|
||||
/**
|
||||
* The `node:trace_events` module provides a mechanism to centralize tracing
|
||||
* information generated by V8, Node.js core, and userspace code.
|
||||
* The `node: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 `node:trace_events` module. The `--trace-event-categories` 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.async_hooks`: Enables capture of detailed [`async_hooks`](https://nodejs.org/docs/latest-v20.x/api/async_hooks.html) trace data.
|
||||
* The [`async_hooks`](https://nodejs.org/docs/latest-v20.x/api/async_hooks.html) 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.threadpoolwork.sync`: Enables capture of trace data for threadpool
|
||||
* synchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`.
|
||||
* * `node.threadpoolwork.async`: Enables capture of trace data for threadpool
|
||||
* asynchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`.
|
||||
* * `node.console`: Enables capture of `console.time()` and `console.count()` output.
|
||||
* * `node.threadpoolwork.sync`: Enables capture of trace data for threadpool synchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`.
|
||||
* * `node.threadpoolwork.async`: Enables capture of trace data for threadpool asynchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`.
|
||||
* * `node.dns.native`: Enables capture of trace data for DNS queries.
|
||||
* * `node.net.native`: Enables capture of trace data for network.
|
||||
* * `node.environment`: Enables capture of Node.js Environment milestones.
|
||||
* * `node.fs.sync`: Enables capture of trace data for file system sync methods.
|
||||
* * `node.fs_dir.sync`: Enables capture of trace data for file system sync
|
||||
* directory methods.
|
||||
* * `node.fs_dir.sync`: Enables capture of trace data for file system sync directory methods.
|
||||
* * `node.fs.async`: Enables capture of trace data for file system async methods.
|
||||
* * `node.fs_dir.async`: Enables capture of trace data for file system async
|
||||
* directory methods.
|
||||
* * `node.perf`: Enables capture of `Performance API` measurements.
|
||||
* * `node.fs_dir.async`: Enables capture of trace data for file system async directory methods.
|
||||
* * `node.perf`: Enables capture of [Performance API](https://nodejs.org/docs/latest-v20.x/api/perf_hooks.html) 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 `node:vm` module's`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods.
|
||||
* * `v8`: The `V8` events are GC, compiling, and execution related.
|
||||
* * `node.vm.script`: Enables capture of trace data for the `node:vm` module's `runInNewContext()`, `runInContext()`, and `runInThisContext()` methods.
|
||||
* * `v8`: The [V8](https://nodejs.org/docs/latest-v20.x/api/v8.html) events are GC, compiling, and execution related.
|
||||
* * `node.http`: Enables capture of trace data for http request / response.
|
||||
*
|
||||
* By default the `node`, `node.async_hooks`, and `v8` categories are enabled.
|
||||
@@ -43,8 +39,8 @@
|
||||
* 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.
|
||||
* 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
|
||||
@@ -57,7 +53,7 @@
|
||||
* Alternatively, trace events may be enabled using the `node:trace_events` module:
|
||||
*
|
||||
* ```js
|
||||
* const trace_events = require('node:trace_events');
|
||||
* import trace_events from 'node:trace_events';
|
||||
* const tracing = trace_events.createTracing({ categories: ['node.perf'] });
|
||||
* tracing.enable(); // Enable trace event capture for the 'node.perf' category
|
||||
*
|
||||
@@ -69,7 +65,7 @@
|
||||
* 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
|
||||
* 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}`:
|
||||
*
|
||||
@@ -77,7 +73,7 @@
|
||||
* node --trace-event-categories v8 --trace-event-file-pattern '${pid}-${rotation}.log' server.js
|
||||
* ```
|
||||
*
|
||||
* To guarantee that the log file is properly generated after signal events like`SIGINT`, `SIGTERM`, or `SIGBREAK`, make sure to have the appropriate handlers
|
||||
* To guarantee that the log file is properly generated after signal events like `SIGINT`, `SIGTERM`, or `SIGBREAK`, make sure to have the appropriate handlers
|
||||
* in your code, such as:
|
||||
*
|
||||
* ```js
|
||||
@@ -92,9 +88,9 @@
|
||||
* 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.
|
||||
* The features from this module are not available in [`Worker`](https://nodejs.org/docs/latest-v20.x/api/worker_threads.html#class-worker) threads.
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/trace_events.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/trace_events.js)
|
||||
*/
|
||||
declare module "trace_events" {
|
||||
/**
|
||||
@@ -111,6 +107,7 @@ declare module "trace_events" {
|
||||
/**
|
||||
* A comma-separated list of the trace event categories covered by this
|
||||
* `Tracing` object.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
readonly categories: string;
|
||||
/**
|
||||
@@ -119,15 +116,34 @@ declare module "trace_events" {
|
||||
* Only trace event categories _not_ covered by other enabled `Tracing`
|
||||
* objects and _not_ specified by the `--trace-event-categories` flag
|
||||
* will be disabled.
|
||||
*
|
||||
* ```js
|
||||
* import trace_events from 'node:trace_events';
|
||||
* const t1 = trace_events.createTracing({ categories: ['node', 'v8'] });
|
||||
* const t2 = trace_events.createTracing({ categories: ['node.perf', 'node'] });
|
||||
* t1.enable();
|
||||
* t2.enable();
|
||||
*
|
||||
* // Prints 'node,node.perf,v8'
|
||||
* console.log(trace_events.getEnabledCategories());
|
||||
*
|
||||
* t2.disable(); // Will only disable emission of the 'node.perf' category
|
||||
*
|
||||
* // Prints 'node,v8'
|
||||
* console.log(trace_events.getEnabledCategories());
|
||||
* ```
|
||||
* @since v10.0.0
|
||||
*/
|
||||
disable(): void;
|
||||
/**
|
||||
* Enables this `Tracing` object for the set of categories covered by
|
||||
* the `Tracing` object.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
enable(): void;
|
||||
/**
|
||||
* `true` only if the `Tracing` object has been enabled.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
readonly enabled: boolean;
|
||||
}
|
||||
@@ -143,7 +159,7 @@ declare module "trace_events" {
|
||||
* Creates and returns a `Tracing` object for the given set of `categories`.
|
||||
*
|
||||
* ```js
|
||||
* const trace_events = require('node:trace_events');
|
||||
* import trace_events from 'node:trace_events';
|
||||
* const categories = ['node.perf', 'node.async_hooks'];
|
||||
* const tracing = trace_events.createTracing({ categories });
|
||||
* tracing.enable();
|
||||
@@ -151,7 +167,6 @@ declare module "trace_events" {
|
||||
* tracing.disable();
|
||||
* ```
|
||||
* @since v10.0.0
|
||||
* @return .
|
||||
*/
|
||||
function createTracing(options: CreateTracingOptions): Tracing;
|
||||
/**
|
||||
@@ -160,10 +175,10 @@ declare module "trace_events" {
|
||||
* by the _union_ of all currently-enabled `Tracing` objects and 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.
|
||||
* 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('node:trace_events');
|
||||
* import trace_events from 'node: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'] });
|
||||
|
||||
996
node_modules/@types/node/ts4.8/assert.d.ts
generated
vendored
996
node_modules/@types/node/ts4.8/assert.d.ts
generated
vendored
@@ -1,996 +0,0 @@
|
||||
/**
|
||||
* The `node:assert` module provides a set of assertion functions for verifying
|
||||
* invariants.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/assert.js)
|
||||
*/
|
||||
declare module "assert" {
|
||||
/**
|
||||
* An alias of {@link ok}.
|
||||
* @since v0.5.9
|
||||
* @param value The input that is checked for being truthy.
|
||||
*/
|
||||
function assert(value: unknown, message?: string | Error): asserts value;
|
||||
namespace assert {
|
||||
/**
|
||||
* Indicates the failure of an assertion. All errors thrown by the `node:assert`module will be instances of the `AssertionError` class.
|
||||
*/
|
||||
class AssertionError extends Error {
|
||||
/**
|
||||
* Set to the `actual` argument for methods such as {@link assert.strictEqual()}.
|
||||
*/
|
||||
actual: unknown;
|
||||
/**
|
||||
* Set to the `expected` argument for methods such as {@link assert.strictEqual()}.
|
||||
*/
|
||||
expected: unknown;
|
||||
/**
|
||||
* Set to the passed in operator value.
|
||||
*/
|
||||
operator: string;
|
||||
/**
|
||||
* Indicates if the message was auto-generated (`true`) or not.
|
||||
*/
|
||||
generatedMessage: boolean;
|
||||
/**
|
||||
* Value is always `ERR_ASSERTION` to show that the error is an assertion error.
|
||||
*/
|
||||
code: "ERR_ASSERTION";
|
||||
constructor(options?: {
|
||||
/** If provided, the error message is set to this value. */
|
||||
message?: string | undefined;
|
||||
/** The `actual` property on the error instance. */
|
||||
actual?: unknown | undefined;
|
||||
/** The `expected` property on the error instance. */
|
||||
expected?: unknown | undefined;
|
||||
/** The `operator` property on the error instance. */
|
||||
operator?: string | undefined;
|
||||
/** If provided, the generated stack trace omits frames before this function. */
|
||||
// tslint:disable-next-line:ban-types
|
||||
stackStartFn?: Function | undefined;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* This feature is deprecated and will be removed in a future version.
|
||||
* Please consider using alternatives such as the `mock` helper function.
|
||||
* @since v14.2.0, v12.19.0
|
||||
* @deprecated Deprecated
|
||||
*/
|
||||
class CallTracker {
|
||||
/**
|
||||
* The wrapper function is expected to be called exactly `exact` times. If the
|
||||
* function has not been called exactly `exact` times when `tracker.verify()` is called, then `tracker.verify()` will throw an
|
||||
* error.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* // Creates call tracker.
|
||||
* const tracker = new assert.CallTracker();
|
||||
*
|
||||
* function func() {}
|
||||
*
|
||||
* // Returns a function that wraps func() that must be called exact times
|
||||
* // before tracker.verify().
|
||||
* const callsfunc = tracker.calls(func);
|
||||
* ```
|
||||
* @since v14.2.0, v12.19.0
|
||||
* @param [fn='A no-op function']
|
||||
* @param [exact=1]
|
||||
* @return that wraps `fn`.
|
||||
*/
|
||||
calls(exact?: number): () => void;
|
||||
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
|
||||
/**
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* const tracker = new assert.CallTracker();
|
||||
*
|
||||
* function func() {}
|
||||
* const callsfunc = tracker.calls(func);
|
||||
* callsfunc(1, 2, 3);
|
||||
*
|
||||
* assert.deepStrictEqual(tracker.getCalls(callsfunc),
|
||||
* [{ thisArg: undefined, arguments: [1, 2, 3] }]);
|
||||
* ```
|
||||
* @since v18.8.0, v16.18.0
|
||||
* @param fn
|
||||
* @return An Array with all the calls to a tracked function.
|
||||
*/
|
||||
getCalls(fn: Function): CallTrackerCall[];
|
||||
/**
|
||||
* The arrays contains information about the expected and actual number of calls of
|
||||
* the functions that have not been called the expected number of times.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* // Creates call tracker.
|
||||
* const tracker = new assert.CallTracker();
|
||||
*
|
||||
* function func() {}
|
||||
*
|
||||
* // Returns a function that wraps func() that must be called exact times
|
||||
* // before tracker.verify().
|
||||
* const callsfunc = tracker.calls(func, 2);
|
||||
*
|
||||
* // Returns an array containing information on callsfunc()
|
||||
* console.log(tracker.report());
|
||||
* // [
|
||||
* // {
|
||||
* // message: 'Expected the func function to be executed 2 time(s) but was
|
||||
* // executed 0 time(s).',
|
||||
* // actual: 0,
|
||||
* // expected: 2,
|
||||
* // operator: 'func',
|
||||
* // stack: stack trace
|
||||
* // }
|
||||
* // ]
|
||||
* ```
|
||||
* @since v14.2.0, v12.19.0
|
||||
* @return An Array of objects containing information about the wrapper functions returned by `calls`.
|
||||
*/
|
||||
report(): CallTrackerReportInformation[];
|
||||
/**
|
||||
* Reset calls of the call tracker.
|
||||
* If a tracked function is passed as an argument, the calls will be reset for it.
|
||||
* If no arguments are passed, all tracked functions will be reset.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* const tracker = new assert.CallTracker();
|
||||
*
|
||||
* function func() {}
|
||||
* const callsfunc = tracker.calls(func);
|
||||
*
|
||||
* callsfunc();
|
||||
* // Tracker was called once
|
||||
* assert.strictEqual(tracker.getCalls(callsfunc).length, 1);
|
||||
*
|
||||
* tracker.reset(callsfunc);
|
||||
* assert.strictEqual(tracker.getCalls(callsfunc).length, 0);
|
||||
* ```
|
||||
* @since v18.8.0, v16.18.0
|
||||
* @param fn a tracked function to reset.
|
||||
*/
|
||||
reset(fn?: Function): void;
|
||||
/**
|
||||
* Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that
|
||||
* have not been called the expected number of times.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* // Creates call tracker.
|
||||
* const tracker = new assert.CallTracker();
|
||||
*
|
||||
* function func() {}
|
||||
*
|
||||
* // Returns a function that wraps func() that must be called exact times
|
||||
* // before tracker.verify().
|
||||
* const callsfunc = tracker.calls(func, 2);
|
||||
*
|
||||
* callsfunc();
|
||||
*
|
||||
* // Will throw an error since callsfunc() was only called once.
|
||||
* tracker.verify();
|
||||
* ```
|
||||
* @since v14.2.0, v12.19.0
|
||||
*/
|
||||
verify(): void;
|
||||
}
|
||||
interface CallTrackerCall {
|
||||
thisArg: object;
|
||||
arguments: unknown[];
|
||||
}
|
||||
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;
|
||||
/**
|
||||
* Throws an `AssertionError` with the provided error message or a default
|
||||
* error message. If the `message` parameter is an instance of an `Error` then
|
||||
* it will be thrown instead of the `AssertionError`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.fail();
|
||||
* // AssertionError [ERR_ASSERTION]: Failed
|
||||
*
|
||||
* assert.fail('boom');
|
||||
* // AssertionError [ERR_ASSERTION]: boom
|
||||
*
|
||||
* assert.fail(new TypeError('need array'));
|
||||
* // TypeError: need array
|
||||
* ```
|
||||
*
|
||||
* Using `assert.fail()` with more than two arguments is possible but deprecated.
|
||||
* See below for further details.
|
||||
* @since v0.1.21
|
||||
* @param [message='Failed']
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* Tests if `value` is truthy. It is equivalent to`assert.equal(!!value, true, message)`.
|
||||
*
|
||||
* If `value` is not truthy, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is `undefined`, a default
|
||||
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
||||
* If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``.
|
||||
*
|
||||
* Be aware that in the `repl` the error message will be different to the one
|
||||
* thrown in a file! See below for further details.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.ok(true);
|
||||
* // OK
|
||||
* assert.ok(1);
|
||||
* // OK
|
||||
*
|
||||
* assert.ok();
|
||||
* // AssertionError: No value argument passed to `assert.ok()`
|
||||
*
|
||||
* assert.ok(false, 'it\'s false');
|
||||
* // AssertionError: it's false
|
||||
*
|
||||
* // In the repl:
|
||||
* assert.ok(typeof 123 === 'string');
|
||||
* // AssertionError: false == true
|
||||
*
|
||||
* // In a file (e.g. test.js):
|
||||
* assert.ok(typeof 123 === 'string');
|
||||
* // AssertionError: The expression evaluated to a falsy value:
|
||||
* //
|
||||
* // assert.ok(typeof 123 === 'string')
|
||||
*
|
||||
* assert.ok(false);
|
||||
* // AssertionError: The expression evaluated to a falsy value:
|
||||
* //
|
||||
* // assert.ok(false)
|
||||
*
|
||||
* assert.ok(0);
|
||||
* // AssertionError: The expression evaluated to a falsy value:
|
||||
* //
|
||||
* // assert.ok(0)
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* // Using `assert()` works the same:
|
||||
* assert(0);
|
||||
* // AssertionError: The expression evaluated to a falsy value:
|
||||
* //
|
||||
* // assert(0)
|
||||
* ```
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function ok(value: unknown, message?: string | Error): asserts value;
|
||||
/**
|
||||
* **Strict assertion mode**
|
||||
*
|
||||
* An alias of {@link strictEqual}.
|
||||
*
|
||||
* **Legacy assertion mode**
|
||||
*
|
||||
* > Stability: 3 - Legacy: Use {@link strictEqual} instead.
|
||||
*
|
||||
* Tests shallow, coercive equality between the `actual` and `expected` parameters
|
||||
* using the [`==` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality). `NaN` is specially handled
|
||||
* and treated as being identical if both sides are `NaN`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* assert.equal(1, 1);
|
||||
* // OK, 1 == 1
|
||||
* assert.equal(1, '1');
|
||||
* // OK, 1 == '1'
|
||||
* assert.equal(NaN, NaN);
|
||||
* // OK
|
||||
*
|
||||
* assert.equal(1, 2);
|
||||
* // AssertionError: 1 == 2
|
||||
* assert.equal({ a: { b: 1 } }, { a: { b: 1 } });
|
||||
* // AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
|
||||
* ```
|
||||
*
|
||||
* If the values are not equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default
|
||||
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function equal(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* **Strict assertion mode**
|
||||
*
|
||||
* An alias of {@link notStrictEqual}.
|
||||
*
|
||||
* **Legacy assertion mode**
|
||||
*
|
||||
* > Stability: 3 - Legacy: Use {@link notStrictEqual} instead.
|
||||
*
|
||||
* Tests shallow, coercive inequality with the [`!=` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality). `NaN` is
|
||||
* specially handled and treated as being identical if both sides are `NaN`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* assert.notEqual(1, 2);
|
||||
* // OK
|
||||
*
|
||||
* assert.notEqual(1, 1);
|
||||
* // AssertionError: 1 != 1
|
||||
*
|
||||
* assert.notEqual(1, '1');
|
||||
* // AssertionError: 1 != '1'
|
||||
* ```
|
||||
*
|
||||
* If the values are equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default error
|
||||
* message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* **Strict assertion mode**
|
||||
*
|
||||
* An alias of {@link deepStrictEqual}.
|
||||
*
|
||||
* **Legacy assertion mode**
|
||||
*
|
||||
* > Stability: 3 - Legacy: Use {@link deepStrictEqual} instead.
|
||||
*
|
||||
* Tests for deep equality between the `actual` and `expected` parameters. Consider
|
||||
* using {@link deepStrictEqual} instead. {@link deepEqual} can have
|
||||
* surprising results.
|
||||
*
|
||||
* _Deep equality_ means that the enumerable "own" properties of child objects
|
||||
* are also recursively evaluated by the following rules.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* **Strict assertion mode**
|
||||
*
|
||||
* An alias of {@link notDeepStrictEqual}.
|
||||
*
|
||||
* **Legacy assertion mode**
|
||||
*
|
||||
* > Stability: 3 - Legacy: Use {@link notDeepStrictEqual} instead.
|
||||
*
|
||||
* Tests for any deep inequality. Opposite of {@link deepEqual}.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* const obj1 = {
|
||||
* a: {
|
||||
* b: 1,
|
||||
* },
|
||||
* };
|
||||
* const obj2 = {
|
||||
* a: {
|
||||
* b: 2,
|
||||
* },
|
||||
* };
|
||||
* const obj3 = {
|
||||
* a: {
|
||||
* b: 1,
|
||||
* },
|
||||
* };
|
||||
* const obj4 = { __proto__: obj1 };
|
||||
*
|
||||
* assert.notDeepEqual(obj1, obj1);
|
||||
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
||||
*
|
||||
* assert.notDeepEqual(obj1, obj2);
|
||||
* // OK
|
||||
*
|
||||
* assert.notDeepEqual(obj1, obj3);
|
||||
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
||||
*
|
||||
* assert.notDeepEqual(obj1, obj4);
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values are deeply equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a default
|
||||
* error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* Tests strict equality between the `actual` and `expected` parameters as
|
||||
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.strictEqual(1, 2);
|
||||
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
||||
* //
|
||||
* // 1 !== 2
|
||||
*
|
||||
* assert.strictEqual(1, 1);
|
||||
* // OK
|
||||
*
|
||||
* assert.strictEqual('Hello foobar', 'Hello World!');
|
||||
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
||||
* // + actual - expected
|
||||
* //
|
||||
* // + 'Hello foobar'
|
||||
* // - 'Hello World!'
|
||||
* // ^
|
||||
*
|
||||
* const apples = 1;
|
||||
* const oranges = 2;
|
||||
* assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`);
|
||||
* // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
|
||||
*
|
||||
* assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
|
||||
* // TypeError: Inputs are not identical
|
||||
* ```
|
||||
*
|
||||
* If the values are not strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
|
||||
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function strictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
||||
/**
|
||||
* Tests strict inequality between the `actual` and `expected` parameters as
|
||||
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.notStrictEqual(1, 2);
|
||||
* // OK
|
||||
*
|
||||
* assert.notStrictEqual(1, 1);
|
||||
* // AssertionError [ERR_ASSERTION]: Expected "actual" to be strictly unequal to:
|
||||
* //
|
||||
* // 1
|
||||
*
|
||||
* assert.notStrictEqual(1, '1');
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values are strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
|
||||
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* Tests for deep equality between the `actual` and `expected` parameters.
|
||||
* "Deep" equality means that the enumerable "own" properties of child objects
|
||||
* are recursively evaluated also by the following rules.
|
||||
* @since v1.2.0
|
||||
*/
|
||||
function deepStrictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
||||
/**
|
||||
* Tests for deep strict inequality. Opposite of {@link deepStrictEqual}.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values are deeply and strictly equal, an `AssertionError` is thrown
|
||||
* with a `message` property set equal to the value of the `message` parameter. If
|
||||
* the `message` parameter is undefined, a default error message is assigned. If
|
||||
* the `message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v1.2.0
|
||||
*/
|
||||
function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* Expects the function `fn` to throw an error.
|
||||
*
|
||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
|
||||
* a validation object where each property will be tested for strict deep equality,
|
||||
* or an instance of error where each property will be tested for strict deep
|
||||
* equality including the non-enumerable `message` and `name` properties. When
|
||||
* using an object, it is also possible to use a regular expression, when
|
||||
* validating against a string property. See below for examples.
|
||||
*
|
||||
* If specified, `message` will be appended to the message provided by the`AssertionError` if the `fn` call fails to throw or in case the error validation
|
||||
* fails.
|
||||
*
|
||||
* Custom validation object/error instance:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* const err = new TypeError('Wrong value');
|
||||
* err.code = 404;
|
||||
* err.foo = 'bar';
|
||||
* err.info = {
|
||||
* nested: true,
|
||||
* baz: 'text',
|
||||
* };
|
||||
* err.reg = /abc/i;
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw err;
|
||||
* },
|
||||
* {
|
||||
* name: 'TypeError',
|
||||
* message: 'Wrong value',
|
||||
* info: {
|
||||
* nested: true,
|
||||
* baz: 'text',
|
||||
* },
|
||||
* // Only properties on the validation object will be tested for.
|
||||
* // Using nested objects requires all properties to be present. Otherwise
|
||||
* // the validation is going to fail.
|
||||
* },
|
||||
* );
|
||||
*
|
||||
* // Using regular expressions to validate error properties:
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw err;
|
||||
* },
|
||||
* {
|
||||
* // The `name` and `message` properties are strings and using regular
|
||||
* // expressions on those will match against the string. If they fail, an
|
||||
* // error is thrown.
|
||||
* name: /^TypeError$/,
|
||||
* message: /Wrong/,
|
||||
* foo: 'bar',
|
||||
* info: {
|
||||
* nested: true,
|
||||
* // It is not possible to use regular expressions for nested properties!
|
||||
* baz: 'text',
|
||||
* },
|
||||
* // The `reg` property contains a regular expression and only if the
|
||||
* // validation object contains an identical regular expression, it is going
|
||||
* // to pass.
|
||||
* reg: /abc/i,
|
||||
* },
|
||||
* );
|
||||
*
|
||||
* // Fails due to the different `message` and `name` properties:
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* const otherErr = new Error('Not found');
|
||||
* // Copy all enumerable properties from `err` to `otherErr`.
|
||||
* for (const [key, value] of Object.entries(err)) {
|
||||
* otherErr[key] = value;
|
||||
* }
|
||||
* throw otherErr;
|
||||
* },
|
||||
* // The error's `message` and `name` properties will also be checked when using
|
||||
* // an error as validation object.
|
||||
* err,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* Validate instanceof using constructor:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw new Error('Wrong value');
|
||||
* },
|
||||
* Error,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* Validate error message using [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions):
|
||||
*
|
||||
* Using a regular expression runs `.toString` on the error object, and will
|
||||
* therefore also include the error name.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw new Error('Wrong value');
|
||||
* },
|
||||
* /^Error: Wrong value$/,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* Custom error validation:
|
||||
*
|
||||
* The function must return `true` to indicate all internal validations passed.
|
||||
* It will otherwise fail with an `AssertionError`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw new Error('Wrong value');
|
||||
* },
|
||||
* (err) => {
|
||||
* assert(err instanceof Error);
|
||||
* assert(/value/.test(err));
|
||||
* // Avoid returning anything from validation functions besides `true`.
|
||||
* // Otherwise, it's not clear what part of the validation failed. Instead,
|
||||
* // throw an error about the specific validation that failed (as done in this
|
||||
* // example) and add as much helpful debugging information to that error as
|
||||
* // possible.
|
||||
* return true;
|
||||
* },
|
||||
* 'unexpected error',
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* `error` cannot be a string. If a string is provided as the second
|
||||
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Using the same
|
||||
* message as the thrown error message is going to result in an`ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
|
||||
* a string as the second argument gets considered:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* function throwingFirst() {
|
||||
* throw new Error('First');
|
||||
* }
|
||||
*
|
||||
* function throwingSecond() {
|
||||
* throw new Error('Second');
|
||||
* }
|
||||
*
|
||||
* function notThrowing() {}
|
||||
*
|
||||
* // The second argument is a string and the input function threw an Error.
|
||||
* // The first case will not throw as it does not match for the error message
|
||||
* // thrown by the input function!
|
||||
* assert.throws(throwingFirst, 'Second');
|
||||
* // In the next example the message has no benefit over the message from the
|
||||
* // error and since it is not clear if the user intended to actually match
|
||||
* // against the error message, Node.js throws an `ERR_AMBIGUOUS_ARGUMENT` error.
|
||||
* assert.throws(throwingSecond, 'Second');
|
||||
* // TypeError [ERR_AMBIGUOUS_ARGUMENT]
|
||||
*
|
||||
* // The string is only used (as message) in case the function does not throw:
|
||||
* assert.throws(notThrowing, 'Second');
|
||||
* // AssertionError [ERR_ASSERTION]: Missing expected exception: Second
|
||||
*
|
||||
* // If it was intended to match for the error message do this instead:
|
||||
* // It does not throw because the error messages match.
|
||||
* assert.throws(throwingSecond, /Second$/);
|
||||
*
|
||||
* // If the error message does not match, an AssertionError is thrown.
|
||||
* assert.throws(throwingFirst, /Second$/);
|
||||
* // AssertionError [ERR_ASSERTION]
|
||||
* ```
|
||||
*
|
||||
* Due to the confusing error-prone notation, avoid a string as the second
|
||||
* argument.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function throws(block: () => unknown, message?: string | Error): void;
|
||||
function throws(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
||||
/**
|
||||
* Asserts that the function `fn` does not throw an error.
|
||||
*
|
||||
* Using `assert.doesNotThrow()` is actually not useful because there
|
||||
* is no benefit in catching an error and then rethrowing it. Instead, consider
|
||||
* adding a comment next to the specific code path that should not throw and keep
|
||||
* error messages as expressive as possible.
|
||||
*
|
||||
* When `assert.doesNotThrow()` is called, it will immediately call the `fn`function.
|
||||
*
|
||||
* If an error is thrown and it is the same type as that specified by the `error`parameter, then an `AssertionError` is thrown. If the error is of a
|
||||
* different type, or if the `error` parameter is undefined, the error is
|
||||
* propagated back to the caller.
|
||||
*
|
||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation
|
||||
* function. See {@link throws} for more details.
|
||||
*
|
||||
* The following, for instance, will throw the `TypeError` because there is no
|
||||
* matching error type in the assertion:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotThrow(
|
||||
* () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* SyntaxError,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* However, the following will result in an `AssertionError` with the message
|
||||
* 'Got unwanted exception...':
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotThrow(
|
||||
* () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* TypeError,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* If an `AssertionError` is thrown and a value is provided for the `message`parameter, the value of `message` will be appended to the `AssertionError` message:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotThrow(
|
||||
* () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* /Wrong value/,
|
||||
* 'Whoops',
|
||||
* );
|
||||
* // Throws: AssertionError: Got unwanted exception: Whoops
|
||||
* ```
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function doesNotThrow(block: () => unknown, message?: string | Error): void;
|
||||
function doesNotThrow(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
||||
/**
|
||||
* Throws `value` if `value` is not `undefined` or `null`. This is useful when
|
||||
* testing the `error` argument in callbacks. The stack trace contains all frames
|
||||
* from the error passed to `ifError()` including the potential new frames for`ifError()` itself.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.ifError(null);
|
||||
* // OK
|
||||
* assert.ifError(0);
|
||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 0
|
||||
* assert.ifError('error');
|
||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error'
|
||||
* assert.ifError(new Error());
|
||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Error
|
||||
*
|
||||
* // Create some random error frames.
|
||||
* let err;
|
||||
* (function errorFrame() {
|
||||
* err = new Error('test error');
|
||||
* })();
|
||||
*
|
||||
* (function ifErrorFrame() {
|
||||
* assert.ifError(err);
|
||||
* })();
|
||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
|
||||
* // at ifErrorFrame
|
||||
* // at errorFrame
|
||||
* ```
|
||||
* @since v0.1.97
|
||||
*/
|
||||
function ifError(value: unknown): asserts value is null | undefined;
|
||||
/**
|
||||
* Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
|
||||
* calls the function and awaits the returned promise to complete. It will then
|
||||
* check that the promise is rejected.
|
||||
*
|
||||
* If `asyncFn` is a function and it throws an error synchronously,`assert.rejects()` will return a rejected `Promise` with that error. If the
|
||||
* function does not return a promise, `assert.rejects()` will return a rejected`Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases the error
|
||||
* handler is skipped.
|
||||
*
|
||||
* Besides the async nature to await the completion behaves identically to {@link throws}.
|
||||
*
|
||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
|
||||
* an object where each property will be tested for, or an instance of error where
|
||||
* each property will be tested for including the non-enumerable `message` and`name` properties.
|
||||
*
|
||||
* If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* await assert.rejects(
|
||||
* async () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* {
|
||||
* name: 'TypeError',
|
||||
* message: 'Wrong value',
|
||||
* },
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* await assert.rejects(
|
||||
* async () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* (err) => {
|
||||
* assert.strictEqual(err.name, 'TypeError');
|
||||
* assert.strictEqual(err.message, 'Wrong value');
|
||||
* return true;
|
||||
* },
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.rejects(
|
||||
* Promise.reject(new Error('Wrong value')),
|
||||
* Error,
|
||||
* ).then(() => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* `error` cannot be a string. If a string is provided as the second
|
||||
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Please read the
|
||||
* example in {@link throws} carefully if using a string as the second
|
||||
* argument gets considered.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
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>;
|
||||
/**
|
||||
* Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
|
||||
* calls the function and awaits the returned promise to complete. It will then
|
||||
* check that the promise is not rejected.
|
||||
*
|
||||
* If `asyncFn` is a function and it throws an error synchronously,`assert.doesNotReject()` will return a rejected `Promise` with that error. If
|
||||
* the function does not return a promise, `assert.doesNotReject()` will return a
|
||||
* rejected `Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases
|
||||
* the error handler is skipped.
|
||||
*
|
||||
* Using `assert.doesNotReject()` is actually not useful because there is little
|
||||
* benefit in catching a rejection and then rejecting it again. Instead, consider
|
||||
* adding a comment next to the specific code path that should not reject and keep
|
||||
* error messages as expressive as possible.
|
||||
*
|
||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation
|
||||
* function. See {@link throws} for more details.
|
||||
*
|
||||
* Besides the async nature to await the completion behaves identically to {@link doesNotThrow}.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* await assert.doesNotReject(
|
||||
* async () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* SyntaxError,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotReject(Promise.reject(new TypeError('Wrong value')))
|
||||
* .then(() => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
* @since v10.0.0
|
||||
*/
|
||||
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>;
|
||||
/**
|
||||
* Expects the `string` input to match the regular expression.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.match('I will fail', /pass/);
|
||||
* // AssertionError [ERR_ASSERTION]: The input did not match the regular ...
|
||||
*
|
||||
* assert.match(123, /pass/);
|
||||
* // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
|
||||
*
|
||||
* assert.match('I will pass', /pass/);
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values do not match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
|
||||
* to the value of the `message` parameter. If the `message` parameter is
|
||||
* undefined, a default error message is assigned. If the `message` parameter is an
|
||||
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
||||
* @since v13.6.0, v12.16.0
|
||||
*/
|
||||
function match(value: string, regExp: RegExp, message?: string | Error): void;
|
||||
/**
|
||||
* Expects the `string` input not to match the regular expression.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotMatch('I will fail', /fail/);
|
||||
* // AssertionError [ERR_ASSERTION]: The input was expected to not match the ...
|
||||
*
|
||||
* assert.doesNotMatch(123, /pass/);
|
||||
* // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
|
||||
*
|
||||
* assert.doesNotMatch('I will pass', /different/);
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values do match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
|
||||
* to the value of the `message` parameter. If the `message` parameter is
|
||||
* undefined, a default error message is assigned. If the `message` parameter is an
|
||||
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
||||
* @since v13.6.0, v12.16.0
|
||||
*/
|
||||
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
|
||||
const strict:
|
||||
& Omit<
|
||||
typeof assert,
|
||||
| "equal"
|
||||
| "notEqual"
|
||||
| "deepEqual"
|
||||
| "notDeepEqual"
|
||||
| "ok"
|
||||
| "strictEqual"
|
||||
| "deepStrictEqual"
|
||||
| "ifError"
|
||||
| "strict"
|
||||
>
|
||||
& {
|
||||
(value: unknown, message?: string | Error): asserts value;
|
||||
equal: typeof strictEqual;
|
||||
notEqual: typeof notStrictEqual;
|
||||
deepEqual: typeof deepStrictEqual;
|
||||
notDeepEqual: typeof notDeepStrictEqual;
|
||||
// Mapped types and assertion functions are incompatible?
|
||||
// TS2775: Assertions require every name in the call target
|
||||
// to be declared with an explicit type annotation.
|
||||
ok: typeof ok;
|
||||
strictEqual: typeof strictEqual;
|
||||
deepStrictEqual: typeof deepStrictEqual;
|
||||
ifError: typeof ifError;
|
||||
strict: typeof strict;
|
||||
};
|
||||
}
|
||||
export = assert;
|
||||
}
|
||||
declare module "node:assert" {
|
||||
import assert = require("assert");
|
||||
export = assert;
|
||||
}
|
||||
8
node_modules/@types/node/ts4.8/assert/strict.d.ts
generated
vendored
8
node_modules/@types/node/ts4.8/assert/strict.d.ts
generated
vendored
@@ -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;
|
||||
}
|
||||
539
node_modules/@types/node/ts4.8/async_hooks.d.ts
generated
vendored
539
node_modules/@types/node/ts4.8/async_hooks.d.ts
generated
vendored
@@ -1,539 +0,0 @@
|
||||
/**
|
||||
* We strongly discourage the use of the `async_hooks` API.
|
||||
* Other APIs that can cover most of its use cases include:
|
||||
*
|
||||
* * `AsyncLocalStorage` tracks async context
|
||||
* * `process.getActiveResourcesInfo()` tracks active resources
|
||||
*
|
||||
* The `node:async_hooks` module provides an API to track asynchronous resources.
|
||||
* It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* import async_hooks from 'node:async_hooks';
|
||||
* ```
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/async_hooks.js)
|
||||
*/
|
||||
declare module "async_hooks" {
|
||||
/**
|
||||
* ```js
|
||||
* import { executionAsyncId } from 'node:async_hooks';
|
||||
* import fs from 'node:fs';
|
||||
*
|
||||
* console.log(executionAsyncId()); // 1 - bootstrap
|
||||
* const path = '.';
|
||||
* fs.open(path, 'r', (err, fd) => {
|
||||
* console.log(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;
|
||||
/**
|
||||
* Resource objects returned by `executionAsyncResource()` are most often internal
|
||||
* Node.js handle objects with undocumented APIs. Using any functions or properties
|
||||
* on the object is likely to crash your application and should be avoided.
|
||||
*
|
||||
* Using `executionAsyncResource()` in the top-level execution context will
|
||||
* return an empty object as there is no handle or request object to use,
|
||||
* but having an object representing the top-level can be helpful.
|
||||
*
|
||||
* ```js
|
||||
* import { open } from 'node:fs';
|
||||
* import { executionAsyncId, executionAsyncResource } from 'node:async_hooks';
|
||||
*
|
||||
* console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
|
||||
* open(new URL(import.meta.url), '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
|
||||
* import { createServer } from 'node:http';
|
||||
* import {
|
||||
* executionAsyncId,
|
||||
* executionAsyncResource,
|
||||
* createHook,
|
||||
* } from 'async_hooks';
|
||||
* const sym = Symbol('state'); // Private symbol to avoid pollution
|
||||
*
|
||||
* createHook({
|
||||
* init(asyncId, type, triggerAsyncId, resource) {
|
||||
* const cr = executionAsyncResource();
|
||||
* if (cr) {
|
||||
* resource[sym] = cr[sym];
|
||||
* }
|
||||
* },
|
||||
* }).enable();
|
||||
*
|
||||
* const server = createServer((req, res) => {
|
||||
* executionAsyncResource()[sym] = { state: req.url };
|
||||
* setTimeout(function() {
|
||||
* res.end(JSON.stringify(executionAsyncResource()[sym]));
|
||||
* }, 100);
|
||||
* }).listen(3000);
|
||||
* ```
|
||||
* @since v13.9.0, v12.17.0
|
||||
* @return The resource representing the current execution. Useful to store data within the resource.
|
||||
*/
|
||||
function executionAsyncResource(): object;
|
||||
/**
|
||||
* ```js
|
||||
* const server = net.createServer((conn) => {
|
||||
* // The resource that caused (or triggered) this callback to be called
|
||||
* // was that of the new connection. Thus the return value of triggerAsyncId()
|
||||
* // is the asyncId of "conn".
|
||||
* async_hooks.triggerAsyncId();
|
||||
*
|
||||
* }).listen(port, () => {
|
||||
* // Even though all callbacks passed to .listen() are wrapped in a nextTick()
|
||||
* // the callback itself exists because the call to the server's .listen()
|
||||
* // was made. So the return value would be the ID of the server.
|
||||
* async_hooks.triggerAsyncId();
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Promise contexts may not get valid `triggerAsyncId`s by default. See
|
||||
* the section on `promise execution tracking`.
|
||||
* @return The ID of the resource responsible for calling the callback that is currently being executed.
|
||||
*/
|
||||
function triggerAsyncId(): number;
|
||||
interface HookCallbacks {
|
||||
/**
|
||||
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
||||
* @param asyncId a unique ID for the async resource
|
||||
* @param type the type of the async resource
|
||||
* @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
|
||||
* @param resource reference to the resource representing the async operation, needs to be released during destroy
|
||||
*/
|
||||
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
|
||||
/**
|
||||
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
|
||||
* The before callback is called just before said callback is executed.
|
||||
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
|
||||
*/
|
||||
before?(asyncId: number): void;
|
||||
/**
|
||||
* Called immediately after the callback specified in before is completed.
|
||||
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
||||
*/
|
||||
after?(asyncId: number): void;
|
||||
/**
|
||||
* Called when a promise has resolve() called. This may not be in the same execution id
|
||||
* as the promise itself.
|
||||
* @param asyncId the unique id for the promise that was resolve()d.
|
||||
*/
|
||||
promiseResolve?(asyncId: number): void;
|
||||
/**
|
||||
* Called after the resource corresponding to asyncId is destroyed
|
||||
* @param asyncId a unique ID for the async resource
|
||||
*/
|
||||
destroy?(asyncId: number): void;
|
||||
}
|
||||
interface AsyncHook {
|
||||
/**
|
||||
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
||||
*/
|
||||
enable(): this;
|
||||
/**
|
||||
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
|
||||
*/
|
||||
disable(): this;
|
||||
}
|
||||
/**
|
||||
* Registers functions to be called for different lifetime events of each async
|
||||
* operation.
|
||||
*
|
||||
* 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
|
||||
* import { createHook } from 'node:async_hooks';
|
||||
*
|
||||
* const asyncHook = 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;
|
||||
interface AsyncResourceOptions {
|
||||
/**
|
||||
* The ID of the execution context that created this async event.
|
||||
* @default executionAsyncId()
|
||||
*/
|
||||
triggerAsyncId?: number | undefined;
|
||||
/**
|
||||
* Disables automatic `emitDestroy` when the object is garbage collected.
|
||||
* This usually does not need to be set (even if `emitDestroy` is called
|
||||
* manually), unless the resource's `asyncId` is retrieved and the
|
||||
* sensitive API's `emitDestroy` is called with it.
|
||||
* @default false
|
||||
*/
|
||||
requireManualDestroy?: boolean | undefined;
|
||||
}
|
||||
/**
|
||||
* The class `AsyncResource` is designed to be extended by the embedder's async
|
||||
* resources. Using this, users can easily trigger the lifetime events of their
|
||||
* own resources.
|
||||
*
|
||||
* The `init` hook will trigger when an `AsyncResource` is instantiated.
|
||||
*
|
||||
* The following is an overview of the `AsyncResource` API.
|
||||
*
|
||||
* ```js
|
||||
* import { AsyncResource, executionAsyncId } from 'node: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 {
|
||||
/**
|
||||
* AsyncResource() is meant to be extended. Instantiating a
|
||||
* new AsyncResource() also triggers init. If triggerAsyncId is omitted then
|
||||
* async_hook.executionAsyncId() is used.
|
||||
* @param type The type of async event.
|
||||
* @param triggerAsyncId The ID of the execution context that created
|
||||
* this async event (default: `executionAsyncId()`), or an
|
||||
* AsyncResourceOptions object (since v9.3.0)
|
||||
*/
|
||||
constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
|
||||
/**
|
||||
* Binds the given function to the current execution context.
|
||||
* @since v14.8.0, v12.19.0
|
||||
* @param fn The function to bind to the current execution context.
|
||||
* @param type An optional name to associate with the underlying `AsyncResource`.
|
||||
*/
|
||||
static bind<Func extends (this: ThisArg, ...args: any[]) => any, ThisArg>(
|
||||
fn: Func,
|
||||
type?: string,
|
||||
thisArg?: ThisArg,
|
||||
): Func;
|
||||
/**
|
||||
* Binds the given function to execute to this `AsyncResource`'s scope.
|
||||
* @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;
|
||||
/**
|
||||
* Call the provided function with the provided arguments in the execution context
|
||||
* of the async resource. This will establish the context, trigger the AsyncHooks
|
||||
* before callbacks, call the function, trigger the AsyncHooks after callbacks, and
|
||||
* then restore the original execution context.
|
||||
* @since v9.6.0
|
||||
* @param fn The function to call in the execution context of this async resource.
|
||||
* @param thisArg The receiver to be used for the function call.
|
||||
* @param args Optional arguments to pass to the function.
|
||||
*/
|
||||
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
|
||||
* 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;
|
||||
/**
|
||||
* @return The unique `asyncId` assigned to the resource.
|
||||
*/
|
||||
asyncId(): number;
|
||||
/**
|
||||
* @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor.
|
||||
*/
|
||||
triggerAsyncId(): number;
|
||||
}
|
||||
/**
|
||||
* This class creates stores that stay coherent through asynchronous operations.
|
||||
*
|
||||
* While you can create your own implementation on top of the `node: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
|
||||
* import http from 'node:http';
|
||||
* import { AsyncLocalStorage } from 'node: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's data.
|
||||
* @since v13.10.0, v12.17.0
|
||||
*/
|
||||
class AsyncLocalStorage<T> {
|
||||
/**
|
||||
* Binds the given function to the current execution context.
|
||||
* @since v19.8.0
|
||||
* @experimental
|
||||
* @param fn The function to bind to the current execution context.
|
||||
* @return A new function that calls `fn` within the captured execution context.
|
||||
*/
|
||||
static bind<Func extends (...args: any[]) => any>(fn: Func): Func;
|
||||
/**
|
||||
* Captures the current execution context and returns a function that accepts a
|
||||
* function as an argument. Whenever the returned function is called, it
|
||||
* calls the function passed to it within the captured context.
|
||||
*
|
||||
* ```js
|
||||
* const asyncLocalStorage = new AsyncLocalStorage();
|
||||
* const runInAsyncScope = asyncLocalStorage.run(123, () => AsyncLocalStorage.snapshot());
|
||||
* const result = asyncLocalStorage.run(321, () => runInAsyncScope(() => asyncLocalStorage.getStore()));
|
||||
* console.log(result); // returns 123
|
||||
* ```
|
||||
*
|
||||
* AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple
|
||||
* async context tracking purposes, for example:
|
||||
*
|
||||
* ```js
|
||||
* class Foo {
|
||||
* #runInAsyncScope = AsyncLocalStorage.snapshot();
|
||||
*
|
||||
* get() { return this.#runInAsyncScope(() => asyncLocalStorage.getStore()); }
|
||||
* }
|
||||
*
|
||||
* const foo = asyncLocalStorage.run(123, () => new Foo());
|
||||
* console.log(asyncLocalStorage.run(321, () => foo.get())); // returns 123
|
||||
* ```
|
||||
* @since v19.8.0
|
||||
* @experimental
|
||||
* @return A new function with the signature `(fn: (...args) : R, ...args) : R`.
|
||||
*/
|
||||
static snapshot(): <R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs) => R;
|
||||
/**
|
||||
* Disables the instance of `AsyncLocalStorage`. All subsequent calls
|
||||
* to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
|
||||
*
|
||||
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
||||
* instance will be exited.
|
||||
*
|
||||
* Calling `asyncLocalStorage.disable()` is required before the`asyncLocalStorage` can be garbage collected. This does not apply to stores
|
||||
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
||||
* along with the corresponding async resources.
|
||||
*
|
||||
* Use this method when the `asyncLocalStorage` is not in use anymore
|
||||
* in the current process.
|
||||
* @since v13.10.0, v12.17.0
|
||||
* @experimental
|
||||
*/
|
||||
disable(): void;
|
||||
/**
|
||||
* Returns the current store.
|
||||
* If called outside of an asynchronous context initialized by
|
||||
* calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
|
||||
* returns `undefined`.
|
||||
* @since v13.10.0, v12.17.0
|
||||
*/
|
||||
getStore(): T | undefined;
|
||||
/**
|
||||
* Runs a function synchronously within a context and returns its
|
||||
* return value. The store is not accessible outside of the callback function.
|
||||
* The store is accessible to any asynchronous operations created within the
|
||||
* callback.
|
||||
*
|
||||
* The optional `args` are passed to the callback function.
|
||||
*
|
||||
* If the callback function throws an error, the error is thrown by `run()` too.
|
||||
* The stacktrace is not impacted by this call and the context is exited.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* const store = { id: 2 };
|
||||
* try {
|
||||
* asyncLocalStorage.run(store, () => {
|
||||
* asyncLocalStorage.getStore(); // Returns the store object
|
||||
* setTimeout(() => {
|
||||
* asyncLocalStorage.getStore(); // Returns the store object
|
||||
* }, 200);
|
||||
* throw new Error();
|
||||
* });
|
||||
* } catch (e) {
|
||||
* asyncLocalStorage.getStore(); // Returns undefined
|
||||
* // The error will be caught here
|
||||
* }
|
||||
* ```
|
||||
* @since v13.10.0, v12.17.0
|
||||
*/
|
||||
run<R>(store: T, callback: () => R): R;
|
||||
run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
|
||||
/**
|
||||
* Runs a function synchronously outside of a context and returns its
|
||||
* return value. The store is not accessible within the callback function or
|
||||
* the asynchronous operations created within the callback. Any `getStore()`call done within the callback function will always return `undefined`.
|
||||
*
|
||||
* The optional `args` are passed to the callback function.
|
||||
*
|
||||
* If the callback function throws an error, the error is thrown by `exit()` too.
|
||||
* The stacktrace is not impacted by this call and the context is re-entered.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* // Within a call to run
|
||||
* try {
|
||||
* asyncLocalStorage.getStore(); // Returns the store object or value
|
||||
* asyncLocalStorage.exit(() => {
|
||||
* asyncLocalStorage.getStore(); // Returns undefined
|
||||
* throw new Error();
|
||||
* });
|
||||
* } catch (e) {
|
||||
* asyncLocalStorage.getStore(); // Returns the same object or value
|
||||
* // The error will be caught here
|
||||
* }
|
||||
* ```
|
||||
* @since v13.10.0, v12.17.0
|
||||
* @experimental
|
||||
*/
|
||||
exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
|
||||
/**
|
||||
* Transitions into the context for the remainder of the current
|
||||
* synchronous execution and then persists the store through any following
|
||||
* asynchronous calls.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* const store = { id: 1 };
|
||||
* // Replaces previous store with the given store object
|
||||
* asyncLocalStorage.enterWith(store);
|
||||
* asyncLocalStorage.getStore(); // Returns the store object
|
||||
* someAsyncOperation(() => {
|
||||
* asyncLocalStorage.getStore(); // Returns the same object
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* This transition will continue for the _entire_ synchronous execution.
|
||||
* This means that if, for example, the context is entered within an event
|
||||
* handler subsequent event handlers will also run within that context unless
|
||||
* specifically bound to another context with an `AsyncResource`. That is why`run()` should be preferred over `enterWith()` unless there are strong reasons
|
||||
* to use the latter method.
|
||||
*
|
||||
* ```js
|
||||
* const store = { id: 1 };
|
||||
*
|
||||
* emitter.on('my-event', () => {
|
||||
* asyncLocalStorage.enterWith(store);
|
||||
* });
|
||||
* emitter.on('my-event', () => {
|
||||
* asyncLocalStorage.getStore(); // Returns the same object
|
||||
* });
|
||||
*
|
||||
* asyncLocalStorage.getStore(); // Returns undefined
|
||||
* emitter.emit('my-event');
|
||||
* asyncLocalStorage.getStore(); // Returns the same object
|
||||
* ```
|
||||
* @since v13.11.0, v12.17.0
|
||||
* @experimental
|
||||
*/
|
||||
enterWith(store: T): void;
|
||||
}
|
||||
}
|
||||
declare module "node:async_hooks" {
|
||||
export * from "async_hooks";
|
||||
}
|
||||
2362
node_modules/@types/node/ts4.8/buffer.d.ts
generated
vendored
2362
node_modules/@types/node/ts4.8/buffer.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
1540
node_modules/@types/node/ts4.8/child_process.d.ts
generated
vendored
1540
node_modules/@types/node/ts4.8/child_process.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
432
node_modules/@types/node/ts4.8/cluster.d.ts
generated
vendored
432
node_modules/@types/node/ts4.8/cluster.d.ts
generated
vendored
@@ -1,432 +0,0 @@
|
||||
/**
|
||||
* Clusters of Node.js processes can be used to run multiple instances of Node.js
|
||||
* that can distribute workloads among their application threads. When process
|
||||
* isolation is not needed, use the `worker_threads` module instead, which
|
||||
* allows running multiple application threads within a single Node.js instance.
|
||||
*
|
||||
* The cluster module allows easy creation of child processes that all share
|
||||
* server ports.
|
||||
*
|
||||
* ```js
|
||||
* import cluster from 'node:cluster';
|
||||
* import http from 'node:http';
|
||||
* import { availableParallelism } from 'node:os';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* const numCPUs = availableParallelism();
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* console.log(`Primary ${process.pid} is running`);
|
||||
*
|
||||
* // Fork workers.
|
||||
* for (let i = 0; i < numCPUs; i++) {
|
||||
* cluster.fork();
|
||||
* }
|
||||
*
|
||||
* cluster.on('exit', (worker, code, signal) => {
|
||||
* console.log(`worker ${worker.process.pid} died`);
|
||||
* });
|
||||
* } else {
|
||||
* // Workers can share any TCP connection
|
||||
* // In this case it is an HTTP server
|
||||
* http.createServer((req, res) => {
|
||||
* res.writeHead(200);
|
||||
* res.end('hello world\n');
|
||||
* }).listen(8000);
|
||||
*
|
||||
* console.log(`Worker ${process.pid} started`);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Running Node.js will now share port 8000 between the workers:
|
||||
*
|
||||
* ```console
|
||||
* $ node server.js
|
||||
* Primary 3596 is running
|
||||
* Worker 4324 started
|
||||
* Worker 4520 started
|
||||
* Worker 6056 started
|
||||
* Worker 5644 started
|
||||
* ```
|
||||
*
|
||||
* On Windows, it is not yet possible to set up a named pipe server in a worker.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/cluster.js)
|
||||
*/
|
||||
declare module "cluster" {
|
||||
import * as child from "node:child_process";
|
||||
import EventEmitter = require("node:events");
|
||||
import * as net from "node:net";
|
||||
type SerializationType = "json" | "advanced";
|
||||
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;
|
||||
serialization?: SerializationType | undefined;
|
||||
cwd?: string | undefined;
|
||||
windowsHide?: boolean | undefined;
|
||||
}
|
||||
export interface Address {
|
||||
address: string;
|
||||
port: number;
|
||||
addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6"
|
||||
}
|
||||
/**
|
||||
* A `Worker` object contains all public information and method about a worker.
|
||||
* In the primary it can be obtained using `cluster.workers`. In a worker
|
||||
* it can be obtained using `cluster.worker`.
|
||||
* @since v0.7.0
|
||||
*/
|
||||
export class Worker extends EventEmitter {
|
||||
/**
|
||||
* Each new worker is given its own unique id, this id is stored in the`id`.
|
||||
*
|
||||
* While a worker is alive, this is the key that indexes it in`cluster.workers`.
|
||||
* @since v0.8.0
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* All workers are created using `child_process.fork()`, the returned object
|
||||
* from this function is stored as `.process`. In a worker, the global `process`is stored.
|
||||
*
|
||||
* See: `Child Process module`.
|
||||
*
|
||||
* Workers will call `process.exit(0)` if the `'disconnect'` event occurs
|
||||
* on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
|
||||
* accidental disconnection.
|
||||
* @since v0.7.0
|
||||
*/
|
||||
process: child.ChildProcess;
|
||||
/**
|
||||
* Send 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 worker, it does this by
|
||||
* disconnecting the `worker.process`, and once disconnected, killing with`signal`. In the worker, it does it by killing the process with `signal`.
|
||||
*
|
||||
* The `kill()` function kills the worker process without waiting for a graceful
|
||||
* disconnect, it has the same behavior as `worker.process.kill()`.
|
||||
*
|
||||
* This method is aliased as `worker.destroy()` for backwards compatibility.
|
||||
*
|
||||
* In a worker, `process.kill()` exists, but it is not this function;
|
||||
* it is `kill()`.
|
||||
* @since v0.9.12
|
||||
* @param [signal='SIGTERM'] Name of the kill signal to send to the worker process.
|
||||
*/
|
||||
kill(signal?: string): void;
|
||||
destroy(signal?: string): void;
|
||||
/**
|
||||
* In a worker, this function will close all servers, wait for the `'close'` event
|
||||
* on those servers, and then disconnect the IPC channel.
|
||||
*
|
||||
* In the primary, an internal message is sent to the worker causing it to call`.disconnect()` on itself.
|
||||
*
|
||||
* Causes `.exitedAfterDisconnect` to be set.
|
||||
*
|
||||
* After a server is closed, it will no longer accept new connections,
|
||||
* but connections may be accepted by any other listening worker. Existing
|
||||
* connections will be allowed to close as usual. When no more connections exist,
|
||||
* see `server.close()`, the IPC channel to the worker will close allowing it
|
||||
* to die gracefully.
|
||||
*
|
||||
* The above applies _only_ to server connections, client connections are not
|
||||
* automatically closed by workers, and disconnect does not wait for them to close
|
||||
* before exiting.
|
||||
*
|
||||
* In a worker, `process.disconnect` exists, but it is not this function;
|
||||
* it is `disconnect()`.
|
||||
*
|
||||
* Because long living server connections may block workers from disconnecting, it
|
||||
* may be useful to send a message, so application specific actions may be taken to
|
||||
* close them. It also may be useful to implement a timeout, killing a worker if
|
||||
* the `'disconnect'` event has not been emitted after some time.
|
||||
*
|
||||
* ```js
|
||||
* if (cluster.isPrimary) {
|
||||
* const worker = cluster.fork();
|
||||
* let timeout;
|
||||
*
|
||||
* worker.on('listening', (address) => {
|
||||
* worker.send('shutdown');
|
||||
* worker.disconnect();
|
||||
* timeout = setTimeout(() => {
|
||||
* worker.kill();
|
||||
* }, 2000);
|
||||
* });
|
||||
*
|
||||
* worker.on('disconnect', () => {
|
||||
* clearTimeout(timeout);
|
||||
* });
|
||||
*
|
||||
* } else if (cluster.isWorker) {
|
||||
* const net = require('node:net');
|
||||
* const server = net.createServer((socket) => {
|
||||
* // Connections never end
|
||||
* });
|
||||
*
|
||||
* server.listen(8000);
|
||||
*
|
||||
* process.on('message', (msg) => {
|
||||
* if (msg === 'shutdown') {
|
||||
* // Initiate graceful close of any connections to server
|
||||
* }
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
* @since v0.7.7
|
||||
* @return A reference to `worker`.
|
||||
*/
|
||||
disconnect(): void;
|
||||
/**
|
||||
* This function returns `true` if the worker is connected to its primary via its
|
||||
* IPC channel, `false` otherwise. A worker is connected to its primary after it
|
||||
* has been created. It is disconnected after the `'disconnect'` event is emitted.
|
||||
* @since v0.11.14
|
||||
*/
|
||||
isConnected(): boolean;
|
||||
/**
|
||||
* This function returns `true` if the worker's process has terminated (either
|
||||
* because of exiting or being signaled). Otherwise, it returns `false`.
|
||||
*
|
||||
* ```js
|
||||
* import cluster from 'node:cluster';
|
||||
* import http from 'node:http';
|
||||
* import { availableParallelism } from 'node:os';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* const numCPUs = availableParallelism();
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* console.log(`Primary ${process.pid} is running`);
|
||||
*
|
||||
* // Fork workers.
|
||||
* for (let i = 0; i < numCPUs; i++) {
|
||||
* cluster.fork();
|
||||
* }
|
||||
*
|
||||
* cluster.on('fork', (worker) => {
|
||||
* console.log('worker is dead:', worker.isDead());
|
||||
* });
|
||||
*
|
||||
* cluster.on('exit', (worker, code, signal) => {
|
||||
* console.log('worker is dead:', worker.isDead());
|
||||
* });
|
||||
* } else {
|
||||
* // Workers can share any TCP connection. In this case, it is an HTTP server.
|
||||
* http.createServer((req, res) => {
|
||||
* res.writeHead(200);
|
||||
* res.end(`Current process\n ${process.pid}`);
|
||||
* process.kill(process.pid);
|
||||
* }).listen(8000);
|
||||
* }
|
||||
* ```
|
||||
* @since v0.11.14
|
||||
*/
|
||||
isDead(): boolean;
|
||||
/**
|
||||
* This property is `true` if the worker exited due to `.disconnect()`.
|
||||
* If the worker exited any other way, it is `false`. If the
|
||||
* worker has not exited, it is `undefined`.
|
||||
*
|
||||
* The boolean `worker.exitedAfterDisconnect` allows distinguishing between
|
||||
* voluntary and accidental exit, the primary may choose not to respawn a worker
|
||||
* based on this value.
|
||||
*
|
||||
* ```js
|
||||
* cluster.on('exit', (worker, code, signal) => {
|
||||
* if (worker.exitedAfterDisconnect === true) {
|
||||
* console.log('Oh, it was just voluntary – no need to worry');
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // kill worker
|
||||
* worker.kill();
|
||||
* ```
|
||||
* @since v6.0.0
|
||||
*/
|
||||
exitedAfterDisconnect: boolean;
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. disconnect
|
||||
* 2. error
|
||||
* 3. exit
|
||||
* 4. listening
|
||||
* 5. message
|
||||
* 6. online
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: "disconnect", listener: () => void): this;
|
||||
addListener(event: "error", listener: (error: Error) => void): this;
|
||||
addListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||
addListener(event: "listening", listener: (address: Address) => void): this;
|
||||
addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
addListener(event: "online", listener: () => void): this;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: "disconnect"): boolean;
|
||||
emit(event: "error", error: Error): boolean;
|
||||
emit(event: "exit", code: number, signal: string): boolean;
|
||||
emit(event: "listening", address: Address): boolean;
|
||||
emit(event: "message", message: any, handle: net.Socket | net.Server): boolean;
|
||||
emit(event: "online"): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: "disconnect", listener: () => void): this;
|
||||
on(event: "error", listener: (error: Error) => void): this;
|
||||
on(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||
on(event: "listening", listener: (address: Address) => void): this;
|
||||
on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
on(event: "online", listener: () => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: "disconnect", listener: () => void): this;
|
||||
once(event: "error", listener: (error: Error) => void): this;
|
||||
once(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||
once(event: "listening", listener: (address: Address) => void): this;
|
||||
once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
once(event: "online", listener: () => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "disconnect", listener: () => void): this;
|
||||
prependListener(event: "error", listener: (error: Error) => void): this;
|
||||
prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||
prependListener(event: "listening", listener: (address: Address) => void): this;
|
||||
prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
prependListener(event: "online", listener: () => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "disconnect", listener: () => void): this;
|
||||
prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
||||
prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
||||
prependOnceListener(event: "listening", listener: (address: Address) => void): this;
|
||||
prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
prependOnceListener(event: "online", listener: () => void): this;
|
||||
}
|
||||
export interface Cluster extends EventEmitter {
|
||||
disconnect(callback?: () => void): void;
|
||||
fork(env?: any): Worker;
|
||||
/** @deprecated since v16.0.0 - use isPrimary. */
|
||||
readonly isMaster: boolean;
|
||||
readonly isPrimary: boolean;
|
||||
readonly isWorker: boolean;
|
||||
schedulingPolicy: number;
|
||||
readonly settings: ClusterSettings;
|
||||
/** @deprecated since v16.0.0 - use setupPrimary. */
|
||||
setupMaster(settings?: ClusterSettings): void;
|
||||
/**
|
||||
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings.
|
||||
*/
|
||||
setupPrimary(settings?: ClusterSettings): void;
|
||||
readonly worker?: Worker | undefined;
|
||||
readonly workers?: NodeJS.Dict<Worker> | undefined;
|
||||
readonly SCHED_NONE: number;
|
||||
readonly SCHED_RR: number;
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. disconnect
|
||||
* 2. exit
|
||||
* 3. fork
|
||||
* 4. listening
|
||||
* 5. message
|
||||
* 6. online
|
||||
* 7. setup
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||
addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
addListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||
addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||
addListener(
|
||||
event: "message",
|
||||
listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void,
|
||||
): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
addListener(event: "online", listener: (worker: Worker) => void): this;
|
||||
addListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: "disconnect", worker: Worker): boolean;
|
||||
emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
|
||||
emit(event: "fork", worker: Worker): boolean;
|
||||
emit(event: "listening", worker: Worker, address: Address): boolean;
|
||||
emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
|
||||
emit(event: "online", worker: Worker): boolean;
|
||||
emit(event: "setup", settings: ClusterSettings): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||
on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
on(event: "fork", listener: (worker: Worker) => void): this;
|
||||
on(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||
on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
on(event: "online", listener: (worker: Worker) => void): this;
|
||||
on(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||
once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
once(event: "fork", listener: (worker: Worker) => void): this;
|
||||
once(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||
once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
||||
once(event: "online", listener: (worker: Worker) => void): this;
|
||||
once(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||
prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
prependListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||
prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||
// 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: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
||||
prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
||||
prependOnceListener(event: "fork", listener: (worker: Worker) => void): this;
|
||||
prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
||||
// the handle is a net.Socket or net.Server object, or undefined.
|
||||
prependOnceListener(
|
||||
event: "message",
|
||||
listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void,
|
||||
): this;
|
||||
prependOnceListener(event: "online", listener: (worker: Worker) => void): this;
|
||||
prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
||||
}
|
||||
const cluster: Cluster;
|
||||
export default cluster;
|
||||
}
|
||||
declare module "node:cluster" {
|
||||
export * from "cluster";
|
||||
export { default as default } from "cluster";
|
||||
}
|
||||
415
node_modules/@types/node/ts4.8/console.d.ts
generated
vendored
415
node_modules/@types/node/ts4.8/console.d.ts
generated
vendored
@@ -1,415 +0,0 @@
|
||||
/**
|
||||
* The `node: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('node: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/v20.2.0/lib/console.js)
|
||||
*/
|
||||
declare module "console" {
|
||||
import console = require("node:console");
|
||||
export = console;
|
||||
}
|
||||
declare module "node:console" {
|
||||
import { InspectOptions } from "node:util";
|
||||
global {
|
||||
// This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
|
||||
interface Console {
|
||||
Console: console.ConsoleConstructor;
|
||||
/**
|
||||
* `console.assert()` writes a message if `value` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) or omitted. It only
|
||||
* writes a message and does not otherwise affect execution. The output always
|
||||
* starts with `"Assertion failed"`. If provided, `message` is formatted using `util.format()`.
|
||||
*
|
||||
* If `value` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), nothing happens.
|
||||
*
|
||||
* ```js
|
||||
* console.assert(true, 'does nothing');
|
||||
*
|
||||
* console.assert(false, 'Whoops %s work', 'didn\'t');
|
||||
* // Assertion failed: Whoops didn't work
|
||||
*
|
||||
* console.assert();
|
||||
* // Assertion failed
|
||||
* ```
|
||||
* @since v0.1.101
|
||||
* @param value The value tested for being truthy.
|
||||
* @param message All arguments besides `value` are used as error message.
|
||||
*/
|
||||
assert(value: any, message?: string, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* When `stdout` is a TTY, calling `console.clear()` will attempt to clear the
|
||||
* TTY. When `stdout` is not a TTY, this method does nothing.
|
||||
*
|
||||
* The specific operation of `console.clear()` can vary across operating systems
|
||||
* and terminal types. For most Linux operating systems, `console.clear()`operates similarly to the `clear` shell command. On Windows, `console.clear()`will clear only the output in the
|
||||
* current terminal viewport for the Node.js
|
||||
* binary.
|
||||
* @since v8.3.0
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* Maintains an internal counter specific to `label` and outputs to `stdout` the
|
||||
* number of times `console.count()` has been called with the given `label`.
|
||||
*
|
||||
* ```js
|
||||
* > console.count()
|
||||
* default: 1
|
||||
* undefined
|
||||
* > console.count('default')
|
||||
* default: 2
|
||||
* undefined
|
||||
* > console.count('abc')
|
||||
* abc: 1
|
||||
* undefined
|
||||
* > console.count('xyz')
|
||||
* xyz: 1
|
||||
* undefined
|
||||
* > console.count('abc')
|
||||
* abc: 2
|
||||
* undefined
|
||||
* > console.count()
|
||||
* default: 3
|
||||
* undefined
|
||||
* >
|
||||
* ```
|
||||
* @since v8.3.0
|
||||
* @param [label='default'] 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='default'] 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
|
||||
* @param [label='default']
|
||||
*/
|
||||
time(label?: string): void;
|
||||
/**
|
||||
* Stops a timer that was previously started by calling {@link time} and
|
||||
* prints the result to `stdout`:
|
||||
*
|
||||
* ```js
|
||||
* console.time('bunch-of-stuff');
|
||||
* // Do a bunch of stuff.
|
||||
* console.timeEnd('bunch-of-stuff');
|
||||
* // Prints: bunch-of-stuff: 225.438ms
|
||||
* ```
|
||||
* @since v0.1.104
|
||||
* @param [label='default']
|
||||
*/
|
||||
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
|
||||
* @param [label='default']
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* Set group indentation
|
||||
* @default 2
|
||||
*/
|
||||
groupIndentation?: number | 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;
|
||||
}
|
||||
19
node_modules/@types/node/ts4.8/constants.d.ts
generated
vendored
19
node_modules/@types/node/ts4.8/constants.d.ts
generated
vendored
@@ -1,19 +0,0 @@
|
||||
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
|
||||
declare module "constants" {
|
||||
import { constants as osConstants, SignalConstants } from "node:os";
|
||||
import { constants as cryptoConstants } from "node:crypto";
|
||||
import { constants as fsConstants } from "node:fs";
|
||||
|
||||
const exp:
|
||||
& typeof osConstants.errno
|
||||
& typeof osConstants.priority
|
||||
& SignalConstants
|
||||
& typeof cryptoConstants
|
||||
& typeof fsConstants;
|
||||
export = exp;
|
||||
}
|
||||
|
||||
declare module "node:constants" {
|
||||
import constants = require("constants");
|
||||
export = constants;
|
||||
}
|
||||
4455
node_modules/@types/node/ts4.8/crypto.d.ts
generated
vendored
4455
node_modules/@types/node/ts4.8/crypto.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
586
node_modules/@types/node/ts4.8/dgram.d.ts
generated
vendored
586
node_modules/@types/node/ts4.8/dgram.d.ts
generated
vendored
@@ -1,586 +0,0 @@
|
||||
/**
|
||||
* The `node:dgram` module provides an implementation of UDP datagram sockets.
|
||||
*
|
||||
* ```js
|
||||
* import dgram from 'node:dgram';
|
||||
*
|
||||
* const server = dgram.createSocket('udp4');
|
||||
*
|
||||
* server.on('error', (err) => {
|
||||
* console.error(`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/v20.2.0/lib/dgram.js)
|
||||
*/
|
||||
declare module "dgram" {
|
||||
import { AddressInfo } from "node:net";
|
||||
import * as dns from "node:dns";
|
||||
import { Abortable, EventEmitter } from "node:events";
|
||||
interface RemoteInfo {
|
||||
address: string;
|
||||
family: "IPv4" | "IPv6";
|
||||
port: number;
|
||||
size: number;
|
||||
}
|
||||
interface BindOptions {
|
||||
port?: number | undefined;
|
||||
address?: string | undefined;
|
||||
exclusive?: boolean | undefined;
|
||||
fd?: number | undefined;
|
||||
}
|
||||
type SocketType = "udp4" | "udp6";
|
||||
interface SocketOptions extends Abortable {
|
||||
type: SocketType;
|
||||
reuseAddr?: boolean | undefined;
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
ipv6Only?: boolean | undefined;
|
||||
recvBufferSize?: number | undefined;
|
||||
sendBufferSize?: number | undefined;
|
||||
lookup?:
|
||||
| ((
|
||||
hostname: string,
|
||||
options: dns.LookupOneOptions,
|
||||
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
|
||||
) => void)
|
||||
| undefined;
|
||||
}
|
||||
/**
|
||||
* Creates a `dgram.Socket` object. Once the socket is created, calling `socket.bind()` will instruct the socket to begin listening for datagram
|
||||
* messages. When `address` and `port` are not passed to `socket.bind()` the
|
||||
* method will bind the socket to the "all interfaces" address on a random port
|
||||
* (it does the right thing for both `udp4` and `udp6` sockets). The bound address
|
||||
* and port can be retrieved using `socket.address().address` and `socket.address().port`.
|
||||
*
|
||||
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.close()` on the socket:
|
||||
*
|
||||
* ```js
|
||||
* const controller = new AbortController();
|
||||
* const { signal } = controller;
|
||||
* const server = dgram.createSocket({ type: 'udp4', signal });
|
||||
* server.on('message', (msg, rinfo) => {
|
||||
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
||||
* });
|
||||
* // Later, when you want to close the server.
|
||||
* controller.abort();
|
||||
* ```
|
||||
* @since v0.11.13
|
||||
* @param options Available options are:
|
||||
* @param callback Attached as a listener for `'message'` events. Optional.
|
||||
*/
|
||||
function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
||||
function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
||||
/**
|
||||
* Encapsulates the datagram functionality.
|
||||
*
|
||||
* New instances of `dgram.Socket` are created using {@link createSocket}.
|
||||
* The `new` keyword is not to be used to create `dgram.Socket` instances.
|
||||
* @since v0.1.99
|
||||
*/
|
||||
class Socket extends EventEmitter {
|
||||
/**
|
||||
* Tells the kernel to join a multicast group at the given `multicastAddress` and`multicastInterface` using the `IP_ADD_MEMBERSHIP` socket option. If the`multicastInterface` argument is not
|
||||
* specified, the operating system will choose
|
||||
* one interface and will add membership to it. To add membership to every
|
||||
* available interface, call `addMembership` multiple times, once per interface.
|
||||
*
|
||||
* When called on an unbound socket, this method will implicitly bind to a random
|
||||
* port, listening on all interfaces.
|
||||
*
|
||||
* When sharing a UDP socket across multiple `cluster` workers, the`socket.addMembership()` function must be called only once or an`EADDRINUSE` error will occur:
|
||||
*
|
||||
* ```js
|
||||
* import cluster from 'node:cluster';
|
||||
* import dgram from 'node:dgram';
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* cluster.fork(); // Works ok.
|
||||
* cluster.fork(); // Fails with EADDRINUSE.
|
||||
* } else {
|
||||
* const s = dgram.createSocket('udp4');
|
||||
* s.bind(1234, () => {
|
||||
* s.addMembership('224.0.0.114');
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
* @since v0.6.9
|
||||
*/
|
||||
addMembership(multicastAddress: string, multicastInterface?: string): void;
|
||||
/**
|
||||
* Returns an object containing the address information for a socket.
|
||||
* For UDP sockets, this object will contain `address`, `family`, and `port`properties.
|
||||
*
|
||||
* This method throws `EBADF` if called on an unbound socket.
|
||||
* @since v0.1.99
|
||||
*/
|
||||
address(): AddressInfo;
|
||||
/**
|
||||
* For UDP sockets, causes the `dgram.Socket` to listen for datagram
|
||||
* messages on a named `port` and optional `address`. If `port` is not
|
||||
* specified or is `0`, the operating system will attempt to bind to a
|
||||
* random port. If `address` is not specified, the operating system will
|
||||
* attempt to listen on all addresses. Once binding is complete, a`'listening'` event is emitted and the optional `callback` function is
|
||||
* called.
|
||||
*
|
||||
* Specifying both a `'listening'` event listener and passing a`callback` to the `socket.bind()` method is not harmful but not very
|
||||
* useful.
|
||||
*
|
||||
* A bound datagram socket keeps the Node.js process running to receive
|
||||
* datagram messages.
|
||||
*
|
||||
* If binding fails, an `'error'` event is generated. In rare case (e.g.
|
||||
* attempting to bind with a closed socket), an `Error` may be thrown.
|
||||
*
|
||||
* Example of a UDP server listening on port 41234:
|
||||
*
|
||||
* ```js
|
||||
* import dgram from 'node:dgram';
|
||||
*
|
||||
* const server = dgram.createSocket('udp4');
|
||||
*
|
||||
* server.on('error', (err) => {
|
||||
* console.error(`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): this;
|
||||
bind(port?: number, callback?: () => void): this;
|
||||
bind(callback?: () => void): this;
|
||||
bind(options: BindOptions, callback?: () => void): this;
|
||||
/**
|
||||
* 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): this;
|
||||
/**
|
||||
* Associates the `dgram.Socket` to a remote address and port. Every
|
||||
* message sent by this handle is automatically sent to that destination. Also,
|
||||
* the socket will only receive messages from that remote peer.
|
||||
* Trying to call `connect()` on an already connected socket will result
|
||||
* in an `ERR_SOCKET_DGRAM_IS_CONNECTED` exception. If `address` is not
|
||||
* provided, `'127.0.0.1'` (for `udp4` sockets) or `'::1'` (for `udp6` sockets)
|
||||
* will be used by default. Once the connection is complete, a `'connect'` event
|
||||
* is emitted and the optional `callback` function is called. In case of failure,
|
||||
* the `callback` is called or, failing this, an `'error'` event is emitted.
|
||||
* @since v12.0.0
|
||||
* @param callback Called when the connection is completed or on error.
|
||||
*/
|
||||
connect(port: number, address?: string, callback?: () => void): void;
|
||||
connect(port: number, callback: () => void): void;
|
||||
/**
|
||||
* A synchronous function that disassociates a connected `dgram.Socket` from
|
||||
* its remote address. Trying to call `disconnect()` on an unbound or already
|
||||
* disconnected socket will result in an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception.
|
||||
* @since v12.0.0
|
||||
*/
|
||||
disconnect(): void;
|
||||
/**
|
||||
* Instructs the kernel to leave a multicast group at `multicastAddress` using the`IP_DROP_MEMBERSHIP` socket option. This method is automatically called by the
|
||||
* kernel when the socket is closed or the process terminates, so most apps will
|
||||
* never have reason to call this.
|
||||
*
|
||||
* If `multicastInterface` is not specified, the operating system will attempt to
|
||||
* drop membership on all valid interfaces.
|
||||
* @since v0.6.9
|
||||
*/
|
||||
dropMembership(multicastAddress: string, multicastInterface?: string): void;
|
||||
/**
|
||||
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
||||
* @since v8.7.0
|
||||
* @return the `SO_RCVBUF` socket receive buffer size in bytes.
|
||||
*/
|
||||
getRecvBufferSize(): number;
|
||||
/**
|
||||
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
||||
* @since v8.7.0
|
||||
* @return the `SO_SNDBUF` socket send buffer size in bytes.
|
||||
*/
|
||||
getSendBufferSize(): number;
|
||||
/**
|
||||
* By default, binding a socket will cause it to block the Node.js process from
|
||||
* exiting as long as the socket is open. The `socket.unref()` method can be used
|
||||
* to exclude the socket from the reference counting that keeps the Node.js
|
||||
* process active. The `socket.ref()` method adds the socket back to the reference
|
||||
* counting and restores the default behavior.
|
||||
*
|
||||
* Calling `socket.ref()` multiples times will have no additional effect.
|
||||
*
|
||||
* The `socket.ref()` method returns a reference to the socket so calls can be
|
||||
* chained.
|
||||
* @since v0.9.1
|
||||
*/
|
||||
ref(): this;
|
||||
/**
|
||||
* Returns an object containing the `address`, `family`, and `port` of the remote
|
||||
* endpoint. This method throws an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception
|
||||
* if the socket is not connected.
|
||||
* @since v12.0.0
|
||||
*/
|
||||
remoteAddress(): AddressInfo;
|
||||
/**
|
||||
* 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 nullish, `'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
|
||||
* import dgram from 'node:dgram';
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* 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
|
||||
* import dgram from 'node:dgram';
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* 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
|
||||
* import dgram from 'node:dgram';
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const message = Buffer.from('Some bytes');
|
||||
* const client = dgram.createSocket('udp4');
|
||||
* client.connect(41234, 'localhost', (err) => {
|
||||
* client.send(message, (err) => {
|
||||
* client.close();
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
* @since v0.1.99
|
||||
* @param msg Message to be sent.
|
||||
* @param offset Offset in the buffer where the message starts.
|
||||
* @param length Number of bytes in the message.
|
||||
* @param port Destination port.
|
||||
* @param address Destination host name or IP address.
|
||||
* @param callback Called when the message has been sent.
|
||||
*/
|
||||
send(
|
||||
msg: string | Uint8Array | ReadonlyArray<any>,
|
||||
port?: number,
|
||||
address?: string,
|
||||
callback?: (error: Error | null, bytes: number) => void,
|
||||
): void;
|
||||
send(
|
||||
msg: string | Uint8Array | ReadonlyArray<any>,
|
||||
port?: number,
|
||||
callback?: (error: Error | null, bytes: number) => void,
|
||||
): void;
|
||||
send(
|
||||
msg: string | Uint8Array | ReadonlyArray<any>,
|
||||
callback?: (error: Error | null, bytes: number) => void,
|
||||
): void;
|
||||
send(
|
||||
msg: string | Uint8Array,
|
||||
offset: number,
|
||||
length: number,
|
||||
port?: number,
|
||||
address?: string,
|
||||
callback?: (error: Error | null, bytes: number) => void,
|
||||
): void;
|
||||
send(
|
||||
msg: string | Uint8Array,
|
||||
offset: number,
|
||||
length: number,
|
||||
port?: number,
|
||||
callback?: (error: Error | null, bytes: number) => void,
|
||||
): void;
|
||||
send(
|
||||
msg: string | Uint8Array,
|
||||
offset: number,
|
||||
length: number,
|
||||
callback?: (error: Error | null, bytes: number) => void,
|
||||
): void;
|
||||
/**
|
||||
* Sets or clears the `SO_BROADCAST` socket option. When set to `true`, UDP
|
||||
* packets may be sent to a local interface's broadcast address.
|
||||
*
|
||||
* This method throws `EBADF` if called on an unbound socket.
|
||||
* @since v0.6.9
|
||||
*/
|
||||
setBroadcast(flag: boolean): void;
|
||||
/**
|
||||
* _All references to scope in this section are referring to [IPv6 Zone Indices](https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses), which are defined by [RFC
|
||||
* 4007](https://tools.ietf.org/html/rfc4007). In string form, an IP_
|
||||
* _with a scope index is written as `'IP%scope'` where scope is an interface name_
|
||||
* _or interface number._
|
||||
*
|
||||
* Sets the default outgoing multicast interface of the socket to a chosen
|
||||
* interface or back to system interface selection. The `multicastInterface` must
|
||||
* be a valid string representation of an IP from the socket's family.
|
||||
*
|
||||
* For IPv4 sockets, this should be the IP configured for the desired physical
|
||||
* interface. All packets sent to multicast on the socket will be sent on the
|
||||
* interface determined by the most recent successful use of this call.
|
||||
*
|
||||
* For IPv6 sockets, `multicastInterface` should include a scope to indicate the
|
||||
* interface as in the examples that follow. In IPv6, individual `send` calls can
|
||||
* also use explicit scope in addresses, so only packets sent to a multicast
|
||||
* address without specifying an explicit scope are affected by the most recent
|
||||
* successful use of this call.
|
||||
*
|
||||
* This method throws `EBADF` if called on an unbound socket.
|
||||
*
|
||||
* #### Example: IPv6 outgoing multicast interface
|
||||
*
|
||||
* On most systems, where scope format uses the interface name:
|
||||
*
|
||||
* ```js
|
||||
* const socket = dgram.createSocket('udp6');
|
||||
*
|
||||
* socket.bind(1234, () => {
|
||||
* socket.setMulticastInterface('::%eth1');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* On Windows, where scope format uses an interface number:
|
||||
*
|
||||
* ```js
|
||||
* const socket = dgram.createSocket('udp6');
|
||||
*
|
||||
* socket.bind(1234, () => {
|
||||
* socket.setMulticastInterface('::%2');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* #### Example: IPv4 outgoing multicast interface
|
||||
*
|
||||
* All systems use an IP of the host on the desired physical interface:
|
||||
*
|
||||
* ```js
|
||||
* const socket = dgram.createSocket('udp4');
|
||||
*
|
||||
* socket.bind(1234, () => {
|
||||
* socket.setMulticastInterface('10.0.0.2');
|
||||
* });
|
||||
* ```
|
||||
* @since v8.6.0
|
||||
*/
|
||||
setMulticastInterface(multicastInterface: string): void;
|
||||
/**
|
||||
* Sets or clears the `IP_MULTICAST_LOOP` socket option. When set to `true`,
|
||||
* multicast packets will also be received on the local interface.
|
||||
*
|
||||
* This method throws `EBADF` if called on an unbound socket.
|
||||
* @since v0.3.8
|
||||
*/
|
||||
setMulticastLoopback(flag: boolean): boolean;
|
||||
/**
|
||||
* 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): number;
|
||||
/**
|
||||
* Sets the `SO_RCVBUF` socket option. Sets the maximum socket receive buffer
|
||||
* in bytes.
|
||||
*
|
||||
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
||||
* @since v8.7.0
|
||||
*/
|
||||
setRecvBufferSize(size: number): void;
|
||||
/**
|
||||
* Sets the `SO_SNDBUF` socket option. Sets the maximum socket send buffer
|
||||
* in bytes.
|
||||
*
|
||||
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
||||
* @since v8.7.0
|
||||
*/
|
||||
setSendBufferSize(size: number): void;
|
||||
/**
|
||||
* Sets the `IP_TTL` socket option. While TTL generally stands for "Time to Live",
|
||||
* in this context it specifies the number of IP hops that a packet is allowed to
|
||||
* travel through. Each router or gateway that forwards a packet decrements the
|
||||
* TTL. If the TTL is decremented to 0 by a router, it will not be forwarded.
|
||||
* Changing TTL values is typically done for network probes or when multicasting.
|
||||
*
|
||||
* The `ttl` argument may be between 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): 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, allowing the process to exit even if the socket is still
|
||||
* listening.
|
||||
*
|
||||
* Calling `socket.unref()` multiple times will have no addition effect.
|
||||
*
|
||||
* The `socket.unref()` method returns a reference to the socket so calls can be
|
||||
* chained.
|
||||
* @since v0.9.1
|
||||
*/
|
||||
unref(): this;
|
||||
/**
|
||||
* Tells the kernel to join a source-specific multicast channel at the given`sourceAddress` and `groupAddress`, using the `multicastInterface` with the`IP_ADD_SOURCE_MEMBERSHIP` socket
|
||||
* option. If the `multicastInterface` argument
|
||||
* is not specified, the operating system will choose one interface and will add
|
||||
* membership to it. To add membership to every available interface, call`socket.addSourceSpecificMembership()` multiple times, once per interface.
|
||||
*
|
||||
* When called on an unbound socket, this method will implicitly bind to a random
|
||||
* port, listening on all interfaces.
|
||||
* @since v13.1.0, v12.16.0
|
||||
*/
|
||||
addSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
|
||||
/**
|
||||
* Instructs the kernel to leave a source-specific multicast channel at the given`sourceAddress` and `groupAddress` using the `IP_DROP_SOURCE_MEMBERSHIP`socket option. This method is
|
||||
* automatically called by the kernel when the
|
||||
* socket is closed or the process terminates, so most apps will never have
|
||||
* reason to call this.
|
||||
*
|
||||
* If `multicastInterface` is not specified, the operating system will attempt to
|
||||
* drop membership on all valid interfaces.
|
||||
* @since v13.1.0, v12.16.0
|
||||
*/
|
||||
dropSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. close
|
||||
* 2. connect
|
||||
* 3. error
|
||||
* 4. listening
|
||||
* 5. message
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: "close", listener: () => void): this;
|
||||
addListener(event: "connect", listener: () => void): this;
|
||||
addListener(event: "error", listener: (err: Error) => void): this;
|
||||
addListener(event: "listening", listener: () => void): this;
|
||||
addListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: "close"): boolean;
|
||||
emit(event: "connect"): boolean;
|
||||
emit(event: "error", err: Error): boolean;
|
||||
emit(event: "listening"): boolean;
|
||||
emit(event: "message", msg: Buffer, rinfo: RemoteInfo): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: "close", listener: () => void): this;
|
||||
on(event: "connect", listener: () => void): this;
|
||||
on(event: "error", listener: (err: Error) => void): this;
|
||||
on(event: "listening", listener: () => void): this;
|
||||
on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: "close", listener: () => void): this;
|
||||
once(event: "connect", listener: () => void): this;
|
||||
once(event: "error", listener: (err: Error) => void): this;
|
||||
once(event: "listening", listener: () => void): this;
|
||||
once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
prependListener(event: "connect", listener: () => void): this;
|
||||
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependListener(event: "listening", listener: () => void): this;
|
||||
prependListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
prependOnceListener(event: "connect", listener: () => void): this;
|
||||
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: "listening", listener: () => void): this;
|
||||
prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
||||
/**
|
||||
* Calls `socket.close()` and returns a promise that fulfills when the socket has closed.
|
||||
* @since v20.5.0
|
||||
*/
|
||||
[Symbol.asyncDispose](): Promise<void>;
|
||||
}
|
||||
}
|
||||
declare module "node:dgram" {
|
||||
export * from "dgram";
|
||||
}
|
||||
191
node_modules/@types/node/ts4.8/diagnostics_channel.d.ts
generated
vendored
191
node_modules/@types/node/ts4.8/diagnostics_channel.d.ts
generated
vendored
@@ -1,191 +0,0 @@
|
||||
/**
|
||||
* The `node:diagnostics_channel` module provides an API to create named channels
|
||||
* to report arbitrary message data for diagnostics purposes.
|
||||
*
|
||||
* It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node: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.
|
||||
* @since v15.1.0, v14.17.0
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/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
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* if (diagnostics_channel.hasSubscribers('my-channel')) {
|
||||
* // There are subscribers, prepare and publish message
|
||||
* }
|
||||
* ```
|
||||
* @since v15.1.0, v14.17.0
|
||||
* @param name The channel name
|
||||
* @return If there are active subscribers
|
||||
*/
|
||||
function hasSubscribers(name: string | symbol): boolean;
|
||||
/**
|
||||
* This is the primary entry-point for anyone wanting to publish to a named
|
||||
* channel. It produces a channel object which is optimized to reduce overhead at
|
||||
* publish time as much as possible.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
* ```
|
||||
* @since v15.1.0, v14.17.0
|
||||
* @param name The channel name
|
||||
* @return The named channel object
|
||||
*/
|
||||
function channel(name: string | symbol): Channel;
|
||||
type ChannelListener = (message: unknown, name: string | symbol) => void;
|
||||
/**
|
||||
* 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
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* diagnostics_channel.subscribe('my-channel', (message, name) => {
|
||||
* // Received data
|
||||
* });
|
||||
* ```
|
||||
* @since v18.7.0, v16.17.0
|
||||
* @param name The channel name
|
||||
* @param onMessage The handler to receive channel messages
|
||||
*/
|
||||
function subscribe(name: string | symbol, onMessage: ChannelListener): void;
|
||||
/**
|
||||
* Remove a message handler previously registered to this channel with {@link subscribe}.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* function onMessage(message, name) {
|
||||
* // Received data
|
||||
* }
|
||||
*
|
||||
* diagnostics_channel.subscribe('my-channel', onMessage);
|
||||
*
|
||||
* diagnostics_channel.unsubscribe('my-channel', onMessage);
|
||||
* ```
|
||||
* @since v18.7.0, v16.17.0
|
||||
* @param name The channel name
|
||||
* @param onMessage The previous subscribed handler to remove
|
||||
* @return `true` if the handler was found, `false` otherwise.
|
||||
*/
|
||||
function unsubscribe(name: string | symbol, onMessage: ChannelListener): boolean;
|
||||
/**
|
||||
* The class `Channel` represents an individual named channel within the data
|
||||
* pipeline. It is used 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.
|
||||
* @since v15.1.0, v14.17.0
|
||||
*/
|
||||
class Channel {
|
||||
readonly name: string | symbol;
|
||||
/**
|
||||
* Check if there are active subscribers to this 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
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
*
|
||||
* if (channel.hasSubscribers) {
|
||||
* // There are subscribers, prepare and publish message
|
||||
* }
|
||||
* ```
|
||||
* @since v15.1.0, v14.17.0
|
||||
*/
|
||||
readonly hasSubscribers: boolean;
|
||||
private constructor(name: string | symbol);
|
||||
/**
|
||||
* Publish a message to any subscribers to the channel. This will trigger
|
||||
* message handlers synchronously so they will execute within the same context.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
*
|
||||
* channel.publish({
|
||||
* some: 'message',
|
||||
* });
|
||||
* ```
|
||||
* @since v15.1.0, v14.17.0
|
||||
* @param message The message to send to the channel subscribers
|
||||
*/
|
||||
publish(message: unknown): void;
|
||||
/**
|
||||
* 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
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
*
|
||||
* channel.subscribe((message, name) => {
|
||||
* // Received data
|
||||
* });
|
||||
* ```
|
||||
* @since v15.1.0, v14.17.0
|
||||
* @deprecated Since v18.7.0,v16.17.0 - Use {@link subscribe(name, onMessage)}
|
||||
* @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
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
*
|
||||
* function onMessage(message, name) {
|
||||
* // Received data
|
||||
* }
|
||||
*
|
||||
* channel.subscribe(onMessage);
|
||||
*
|
||||
* channel.unsubscribe(onMessage);
|
||||
* ```
|
||||
* @since v15.1.0, v14.17.0
|
||||
* @deprecated Since v18.7.0,v16.17.0 - Use {@link unsubscribe(name, onMessage)}
|
||||
* @param onMessage The previous subscribed handler to remove
|
||||
* @return `true` if the handler was found, `false` otherwise.
|
||||
*/
|
||||
unsubscribe(onMessage: ChannelListener): void;
|
||||
}
|
||||
}
|
||||
declare module "node:diagnostics_channel" {
|
||||
export * from "diagnostics_channel";
|
||||
}
|
||||
809
node_modules/@types/node/ts4.8/dns.d.ts
generated
vendored
809
node_modules/@types/node/ts4.8/dns.d.ts
generated
vendored
@@ -1,809 +0,0 @@
|
||||
/**
|
||||
* The `node: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('node: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 `node: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('node: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/v20.2.0/lib/dns.js)
|
||||
*/
|
||||
declare module "dns" {
|
||||
import * as dnsPromises from "node:dns/promises";
|
||||
// Supported getaddrinfo flags.
|
||||
export const ADDRCONFIG: number;
|
||||
export const V4MAPPED: number;
|
||||
/**
|
||||
* If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
|
||||
* well as IPv4 mapped IPv6 addresses.
|
||||
*/
|
||||
export const ALL: number;
|
||||
export interface LookupOptions {
|
||||
family?: number | undefined;
|
||||
hints?: number | undefined;
|
||||
all?: boolean | undefined;
|
||||
/**
|
||||
* @default true
|
||||
*/
|
||||
verbatim?: boolean | undefined;
|
||||
}
|
||||
export interface LookupOneOptions extends LookupOptions {
|
||||
all?: false | undefined;
|
||||
}
|
||||
export interface LookupAllOptions extends LookupOptions {
|
||||
all: true;
|
||||
}
|
||||
export interface LookupAddress {
|
||||
address: string;
|
||||
family: number;
|
||||
}
|
||||
/**
|
||||
* 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 `0` or not provided, then
|
||||
* IPv4 and IPv6 addresses are both returned if found.
|
||||
*
|
||||
* With the `all` option set to `true`, the arguments for `callback` change to`(err, addresses)`, with `addresses` being an array of objects with the
|
||||
* properties `address` and `family`.
|
||||
*
|
||||
* On error, `err` is an `Error` object, where `err.code` is the error code.
|
||||
* Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
|
||||
* the host name does not exist but also when the lookup fails in other ways
|
||||
* such as no available file descriptors.
|
||||
*
|
||||
* `dns.lookup()` does not necessarily have anything to do with the DNS protocol.
|
||||
* The implementation uses an operating system facility that can associate names
|
||||
* with addresses and vice versa. This implementation can have subtle but
|
||||
* important consequences on the behavior of any Node.js program. Please take some
|
||||
* time to consult the `Implementation considerations section` before using`dns.lookup()`.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('node:dns');
|
||||
* const options = {
|
||||
* family: 6,
|
||||
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
||||
* };
|
||||
* dns.lookup('example.com', options, (err, address, family) =>
|
||||
* console.log('address: %j family: IPv%s', address, family));
|
||||
* // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
|
||||
*
|
||||
* // When options.all is true, the result will be an Array.
|
||||
* options.all = true;
|
||||
* dns.lookup('example.com', options, (err, addresses) =>
|
||||
* console.log('addresses: %j', addresses));
|
||||
* // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
|
||||
* ```
|
||||
*
|
||||
* If this method is invoked as its `util.promisify()` ed version, and `all`is not set to `true`, it returns a `Promise` for an `Object` with `address` and`family` properties.
|
||||
* @since v0.1.90
|
||||
*/
|
||||
export function lookup(
|
||||
hostname: string,
|
||||
family: number,
|
||||
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
|
||||
): void;
|
||||
export function lookup(
|
||||
hostname: string,
|
||||
options: LookupOneOptions,
|
||||
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
|
||||
): void;
|
||||
export function lookup(
|
||||
hostname: string,
|
||||
options: LookupAllOptions,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void,
|
||||
): void;
|
||||
export function lookup(
|
||||
hostname: string,
|
||||
options: LookupOptions,
|
||||
callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void,
|
||||
): void;
|
||||
export function lookup(
|
||||
hostname: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
|
||||
): void;
|
||||
export namespace lookup {
|
||||
function __promisify__(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
||||
function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<LookupAddress>;
|
||||
function __promisify__(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
||||
}
|
||||
/**
|
||||
* Resolves the given `address` and `port` into a host name and service using
|
||||
* the operating system's underlying `getnameinfo` implementation.
|
||||
*
|
||||
* If `address` is not a valid IP address, a `TypeError` will be thrown.
|
||||
* The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
|
||||
*
|
||||
* On an error, `err` is an `Error` object, where `err.code` is the error code.
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('node: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 {
|
||||
ttl: boolean;
|
||||
}
|
||||
export interface ResolveWithTtlOptions extends ResolveOptions {
|
||||
ttl: true;
|
||||
}
|
||||
export interface RecordWithTtl {
|
||||
address: string;
|
||||
ttl: number;
|
||||
}
|
||||
/** @deprecated Use `AnyARecord` or `AnyAaaaRecord` instead. */
|
||||
export type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
|
||||
export interface AnyARecord extends RecordWithTtl {
|
||||
type: "A";
|
||||
}
|
||||
export interface AnyAaaaRecord extends RecordWithTtl {
|
||||
type: "AAAA";
|
||||
}
|
||||
export interface CaaRecord {
|
||||
critical: number;
|
||||
issue?: string | undefined;
|
||||
issuewild?: string | undefined;
|
||||
iodef?: string | undefined;
|
||||
contactemail?: string | undefined;
|
||||
contactphone?: string | undefined;
|
||||
}
|
||||
export interface MxRecord {
|
||||
priority: number;
|
||||
exchange: string;
|
||||
}
|
||||
export interface AnyMxRecord extends MxRecord {
|
||||
type: "MX";
|
||||
}
|
||||
export interface NaptrRecord {
|
||||
flags: string;
|
||||
service: string;
|
||||
regexp: string;
|
||||
replacement: string;
|
||||
order: number;
|
||||
preference: number;
|
||||
}
|
||||
export interface AnyNaptrRecord extends NaptrRecord {
|
||||
type: "NAPTR";
|
||||
}
|
||||
export interface SoaRecord {
|
||||
nsname: string;
|
||||
hostmaster: string;
|
||||
serial: number;
|
||||
refresh: number;
|
||||
retry: number;
|
||||
expire: number;
|
||||
minttl: number;
|
||||
}
|
||||
export interface AnySoaRecord extends SoaRecord {
|
||||
type: "SOA";
|
||||
}
|
||||
export interface SrvRecord {
|
||||
priority: number;
|
||||
weight: number;
|
||||
port: number;
|
||||
name: string;
|
||||
}
|
||||
export interface AnySrvRecord extends SrvRecord {
|
||||
type: "SRV";
|
||||
}
|
||||
export interface AnyTxtRecord {
|
||||
type: "TXT";
|
||||
entries: string[];
|
||||
}
|
||||
export interface AnyNsRecord {
|
||||
type: "NS";
|
||||
value: string;
|
||||
}
|
||||
export interface AnyPtrRecord {
|
||||
type: "PTR";
|
||||
value: string;
|
||||
}
|
||||
export interface AnyCnameRecord {
|
||||
type: "CNAME";
|
||||
value: string;
|
||||
}
|
||||
export type AnyRecord =
|
||||
| AnyARecord
|
||||
| AnyAaaaRecord
|
||||
| AnyCnameRecord
|
||||
| AnyMxRecord
|
||||
| AnyNaptrRecord
|
||||
| AnyNsRecord
|
||||
| AnyPtrRecord
|
||||
| AnySoaRecord
|
||||
| AnySrvRecord
|
||||
| AnyTxtRecord;
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
|
||||
* of the resource records. The `callback` function has arguments`(err, records)`. When successful, `records` will be an array of resource
|
||||
* records. The type and structure of individual results varies based on `rrtype`:
|
||||
*
|
||||
* <omitted>
|
||||
*
|
||||
* On error, `err` is an `Error` object, where `err.code` is one of the `DNS error codes`.
|
||||
* @since v0.1.27
|
||||
* @param hostname Host name to resolve.
|
||||
* @param [rrtype='A'] Resource record type.
|
||||
*/
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "A",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "AAAA",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "ANY",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "CNAME",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "MX",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "NAPTR",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "NS",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "PTR",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "SOA",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "SRV",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: "TXT",
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void,
|
||||
): void;
|
||||
export function resolve(
|
||||
hostname: string,
|
||||
rrtype: string,
|
||||
callback: (
|
||||
err: NodeJS.ErrnoException | null,
|
||||
addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[],
|
||||
) => void,
|
||||
): void;
|
||||
export namespace resolve {
|
||||
function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
|
||||
function __promisify__(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
||||
function __promisify__(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
|
||||
function __promisify__(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
||||
function __promisify__(
|
||||
hostname: string,
|
||||
rrtype: string,
|
||||
): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
||||
* will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
||||
* @since v0.1.16
|
||||
* @param hostname Host name to resolve.
|
||||
*/
|
||||
export function resolve4(
|
||||
hostname: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve4(
|
||||
hostname: string,
|
||||
options: ResolveWithTtlOptions,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void,
|
||||
): void;
|
||||
export function resolve4(
|
||||
hostname: string,
|
||||
options: ResolveOptions,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void,
|
||||
): void;
|
||||
export namespace resolve4 {
|
||||
function __promisify__(hostname: string): Promise<string[]>;
|
||||
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
||||
* will contain an array of IPv6 addresses.
|
||||
* @since v0.1.16
|
||||
* @param hostname Host name to resolve.
|
||||
*/
|
||||
export function resolve6(
|
||||
hostname: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export function resolve6(
|
||||
hostname: string,
|
||||
options: ResolveWithTtlOptions,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void,
|
||||
): void;
|
||||
export function resolve6(
|
||||
hostname: string,
|
||||
options: ResolveOptions,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void,
|
||||
): void;
|
||||
export namespace resolve6 {
|
||||
function __promisify__(hostname: string): Promise<string[]>;
|
||||
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
||||
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The`addresses` argument passed to the `callback` function
|
||||
* will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`).
|
||||
* @since v0.3.2
|
||||
*/
|
||||
export function resolveCname(
|
||||
hostname: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export namespace resolveCname {
|
||||
function __promisify__(hostname: string): Promise<string[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. The`addresses` argument passed to the `callback` function
|
||||
* will contain an array of certification authority authorization records
|
||||
* available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`).
|
||||
* @since v15.0.0, v14.17.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[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve regular expression-based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of
|
||||
* objects with the following properties:
|
||||
*
|
||||
* * `flags`
|
||||
* * `service`
|
||||
* * `regexp`
|
||||
* * `replacement`
|
||||
* * `order`
|
||||
* * `preference`
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* flags: 's',
|
||||
* service: 'SIP+D2U',
|
||||
* regexp: '',
|
||||
* replacement: '_sip._udp.example.com',
|
||||
* order: 30,
|
||||
* preference: 100
|
||||
* }
|
||||
* ```
|
||||
* @since v0.9.12
|
||||
*/
|
||||
export function resolveNaptr(
|
||||
hostname: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void,
|
||||
): void;
|
||||
export namespace resolveNaptr {
|
||||
function __promisify__(hostname: string): Promise<NaptrRecord[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`).
|
||||
* @since v0.1.90
|
||||
*/
|
||||
export function resolveNs(
|
||||
hostname: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export namespace resolveNs {
|
||||
function __promisify__(hostname: string): Promise<string[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* be an array of strings containing the reply records.
|
||||
* @since v6.0.0
|
||||
*/
|
||||
export function resolvePtr(
|
||||
hostname: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
||||
): void;
|
||||
export namespace resolvePtr {
|
||||
function __promisify__(hostname: string): Promise<string[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
||||
* the `hostname`. The `address` argument passed to the `callback` function will
|
||||
* be an object with the following properties:
|
||||
*
|
||||
* * `nsname`
|
||||
* * `hostmaster`
|
||||
* * `serial`
|
||||
* * `refresh`
|
||||
* * `retry`
|
||||
* * `expire`
|
||||
* * `minttl`
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* nsname: 'ns.example.com',
|
||||
* hostmaster: 'root.example.com',
|
||||
* serial: 2013101809,
|
||||
* refresh: 10000,
|
||||
* retry: 2400,
|
||||
* expire: 604800,
|
||||
* minttl: 3600
|
||||
* }
|
||||
* ```
|
||||
* @since v0.11.10
|
||||
*/
|
||||
export function resolveSoa(
|
||||
hostname: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void,
|
||||
): void;
|
||||
export namespace resolveSoa {
|
||||
function __promisify__(hostname: string): Promise<SoaRecord>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
||||
* be an array of objects with the following properties:
|
||||
*
|
||||
* * `priority`
|
||||
* * `weight`
|
||||
* * `port`
|
||||
* * `name`
|
||||
*
|
||||
* ```js
|
||||
* {
|
||||
* priority: 10,
|
||||
* weight: 5,
|
||||
* port: 21223,
|
||||
* name: 'service.example.com'
|
||||
* }
|
||||
* ```
|
||||
* @since v0.1.27
|
||||
*/
|
||||
export function resolveSrv(
|
||||
hostname: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void,
|
||||
): void;
|
||||
export namespace resolveSrv {
|
||||
function __promisify__(hostname: string): Promise<SrvRecord[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. The `records` argument passed to the `callback` function is a
|
||||
* two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
||||
* one record. Depending on the use case, these could be either joined together or
|
||||
* treated separately.
|
||||
* @since v0.1.27
|
||||
*/
|
||||
export function resolveTxt(
|
||||
hostname: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void,
|
||||
): void;
|
||||
export namespace resolveTxt {
|
||||
function __promisify__(hostname: string): Promise<string[][]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
|
||||
* The `ret` argument passed to the `callback` function will be an array containing
|
||||
* various types of records. Each object has a property `type` that indicates the
|
||||
* type of the current record. And depending on the `type`, additional properties
|
||||
* will be present on the object:
|
||||
*
|
||||
* <omitted>
|
||||
*
|
||||
* Here is an example of the `ret` object passed to the callback:
|
||||
*
|
||||
* ```js
|
||||
* [ { type: 'A', address: '127.0.0.1', ttl: 299 },
|
||||
* { type: 'CNAME', value: 'example.com' },
|
||||
* { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
|
||||
* { type: 'NS', value: 'ns1.example.com' },
|
||||
* { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
|
||||
* { type: 'SOA',
|
||||
* nsname: 'ns1.example.com',
|
||||
* hostmaster: 'admin.example.com',
|
||||
* serial: 156696742,
|
||||
* refresh: 900,
|
||||
* retry: 900,
|
||||
* expire: 1800,
|
||||
* minttl: 60 } ]
|
||||
* ```
|
||||
*
|
||||
* DNS server operators may choose not to respond to `ANY`queries. It may be better to call individual methods like {@link resolve4},{@link resolveMx}, and so on. For more details, see [RFC
|
||||
* 8482](https://tools.ietf.org/html/rfc8482).
|
||||
*/
|
||||
export function resolveAny(
|
||||
hostname: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void,
|
||||
): void;
|
||||
export namespace resolveAny {
|
||||
function __promisify__(hostname: string): Promise<AnyRecord[]>;
|
||||
}
|
||||
/**
|
||||
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
||||
* array of host names.
|
||||
*
|
||||
* On error, `err` is an `Error` object, where `err.code` is
|
||||
* one of the `DNS error codes`.
|
||||
* @since v0.1.16
|
||||
*/
|
||||
export function reverse(
|
||||
ip: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void,
|
||||
): void;
|
||||
/**
|
||||
* Get the default value for `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be:
|
||||
*
|
||||
* * `ipv4first`: for `verbatim` defaulting to `false`.
|
||||
* * `verbatim`: for `verbatim` defaulting to `true`.
|
||||
* @since v20.1.0
|
||||
*/
|
||||
export function getDefaultResultOrder(): "ipv4first" | "verbatim";
|
||||
/**
|
||||
* 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[];
|
||||
/**
|
||||
* Set the default value of `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be:
|
||||
*
|
||||
* * `ipv4first`: sets default `verbatim` `false`.
|
||||
* * `verbatim`: sets default `verbatim` `true`.
|
||||
*
|
||||
* The default is `verbatim` and {@link setDefaultResultOrder} have higher
|
||||
* priority than `--dns-result-order`. When using `worker threads`,{@link setDefaultResultOrder} from the main thread won't affect the default
|
||||
* dns orders in workers.
|
||||
* @since v16.4.0, v14.18.0
|
||||
* @param order must be `'ipv4first'` or `'verbatim'`.
|
||||
*/
|
||||
export function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
|
||||
// Error codes
|
||||
export const NODATA: string;
|
||||
export const FORMERR: string;
|
||||
export const SERVFAIL: string;
|
||||
export const NOTFOUND: string;
|
||||
export const NOTIMP: string;
|
||||
export const REFUSED: string;
|
||||
export const BADQUERY: string;
|
||||
export const BADNAME: string;
|
||||
export const BADFAMILY: string;
|
||||
export const BADRESP: string;
|
||||
export const CONNREFUSED: string;
|
||||
export const TIMEOUT: string;
|
||||
export const EOF: string;
|
||||
export const FILE: string;
|
||||
export const NOMEM: string;
|
||||
export const DESTRUCTION: string;
|
||||
export const BADSTR: string;
|
||||
export const BADFLAGS: string;
|
||||
export const NONAME: string;
|
||||
export const BADHINTS: string;
|
||||
export const NOTINITIALIZED: string;
|
||||
export const LOADIPHLPAPI: string;
|
||||
export const ADDRGETNETWORKPARAMS: string;
|
||||
export const CANCELLED: string;
|
||||
export interface ResolverOptions {
|
||||
timeout?: number | undefined;
|
||||
/**
|
||||
* @default 4
|
||||
*/
|
||||
tries?: number;
|
||||
}
|
||||
/**
|
||||
* An independent resolver for DNS requests.
|
||||
*
|
||||
* Creating a new resolver uses the default server settings. Setting
|
||||
* the servers used for a resolver using `resolver.setServers()` does not affect
|
||||
* other resolvers:
|
||||
*
|
||||
* ```js
|
||||
* const { Resolver } = require('node:dns');
|
||||
* const resolver = new Resolver();
|
||||
* resolver.setServers(['4.4.4.4']);
|
||||
*
|
||||
* // This request will use the server at 4.4.4.4, independent of global settings.
|
||||
* resolver.resolve4('example.org', (err, addresses) => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* The following methods from the `node:dns` module are available:
|
||||
*
|
||||
* * `resolver.getServers()`
|
||||
* * `resolver.resolve()`
|
||||
* * `resolver.resolve4()`
|
||||
* * `resolver.resolve6()`
|
||||
* * `resolver.resolveAny()`
|
||||
* * `resolver.resolveCaa()`
|
||||
* * `resolver.resolveCname()`
|
||||
* * `resolver.resolveMx()`
|
||||
* * `resolver.resolveNaptr()`
|
||||
* * `resolver.resolveNs()`
|
||||
* * `resolver.resolvePtr()`
|
||||
* * `resolver.resolveSoa()`
|
||||
* * `resolver.resolveSrv()`
|
||||
* * `resolver.resolveTxt()`
|
||||
* * `resolver.reverse()`
|
||||
* * `resolver.setServers()`
|
||||
* @since v8.3.0
|
||||
*/
|
||||
export class Resolver {
|
||||
constructor(options?: ResolverOptions);
|
||||
/**
|
||||
* Cancel all outstanding DNS queries made by this resolver. The corresponding
|
||||
* callbacks will be called with an error with code `ECANCELLED`.
|
||||
* @since v8.3.0
|
||||
*/
|
||||
cancel(): void;
|
||||
getServers: typeof getServers;
|
||||
resolve: typeof resolve;
|
||||
resolve4: typeof resolve4;
|
||||
resolve6: typeof resolve6;
|
||||
resolveAny: typeof resolveAny;
|
||||
resolveCaa: typeof resolveCaa;
|
||||
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;
|
||||
/**
|
||||
* 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, v14.17.0
|
||||
* @param [ipv4='0.0.0.0'] A string representation of an IPv4 address.
|
||||
* @param [ipv6='::0'] A string representation of an IPv6 address.
|
||||
*/
|
||||
setLocalAddress(ipv4?: string, ipv6?: string): void;
|
||||
setServers: typeof setServers;
|
||||
}
|
||||
export { dnsPromises as promises };
|
||||
}
|
||||
declare module "node:dns" {
|
||||
export * from "dns";
|
||||
}
|
||||
417
node_modules/@types/node/ts4.8/dns/promises.d.ts
generated
vendored
417
node_modules/@types/node/ts4.8/dns/promises.d.ts
generated
vendored
@@ -1,417 +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('node:dns').promises` or `require('node:dns/promises')`.
|
||||
* @since v10.6.0
|
||||
*/
|
||||
declare module "dns/promises" {
|
||||
import {
|
||||
AnyRecord,
|
||||
CaaRecord,
|
||||
LookupAddress,
|
||||
LookupAllOptions,
|
||||
LookupOneOptions,
|
||||
LookupOptions,
|
||||
MxRecord,
|
||||
NaptrRecord,
|
||||
RecordWithTtl,
|
||||
ResolveOptions,
|
||||
ResolverOptions,
|
||||
ResolveWithTtlOptions,
|
||||
SoaRecord,
|
||||
SrvRecord,
|
||||
} 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('node: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('node: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='A'] 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, v14.17.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;
|
||||
/**
|
||||
* Set the default value of `verbatim` in `dns.lookup()` and `dnsPromises.lookup()`. The value could be:
|
||||
*
|
||||
* * `ipv4first`: sets default `verbatim` `false`.
|
||||
* * `verbatim`: sets default `verbatim` `true`.
|
||||
*
|
||||
* The default is `verbatim` and `dnsPromises.setDefaultResultOrder()` have
|
||||
* higher priority than `--dns-result-order`. When using `worker threads`,`dnsPromises.setDefaultResultOrder()` from the main thread won't affect the
|
||||
* default dns orders in workers.
|
||||
* @since v16.4.0, v14.18.0
|
||||
* @param order must be `'ipv4first'` or `'verbatim'`.
|
||||
*/
|
||||
function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
|
||||
/**
|
||||
* An independent resolver for DNS requests.
|
||||
*
|
||||
* Creating a new resolver uses the default server settings. Setting
|
||||
* the servers used for a resolver using `resolver.setServers()` does not affect
|
||||
* other resolvers:
|
||||
*
|
||||
* ```js
|
||||
* const { Resolver } = require('node:dns').promises;
|
||||
* const resolver = new Resolver();
|
||||
* resolver.setServers(['4.4.4.4']);
|
||||
*
|
||||
* // This request will use the server at 4.4.4.4, independent of global settings.
|
||||
* resolver.resolve4('example.org').then((addresses) => {
|
||||
* // ...
|
||||
* });
|
||||
*
|
||||
* // Alternatively, the same code can be written using async-await style.
|
||||
* (async function() {
|
||||
* const addresses = await resolver.resolve4('example.org');
|
||||
* })();
|
||||
* ```
|
||||
*
|
||||
* The following methods from the `dnsPromises` API 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 v10.6.0
|
||||
*/
|
||||
class Resolver {
|
||||
constructor(options?: ResolverOptions);
|
||||
cancel(): void;
|
||||
getServers: typeof getServers;
|
||||
resolve: typeof resolve;
|
||||
resolve4: typeof resolve4;
|
||||
resolve6: typeof resolve6;
|
||||
resolveAny: typeof resolveAny;
|
||||
resolveCaa: typeof resolveCaa;
|
||||
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";
|
||||
}
|
||||
122
node_modules/@types/node/ts4.8/dom-events.d.ts
generated
vendored
122
node_modules/@types/node/ts4.8/dom-events.d.ts
generated
vendored
@@ -1,122 +0,0 @@
|
||||
export {}; // Don't export anything!
|
||||
|
||||
//// DOM-like Events
|
||||
// NB: The Event / EventTarget / EventListener implementations below were copied
|
||||
// from lib.dom.d.ts, then edited to reflect Node's documentation at
|
||||
// https://nodejs.org/api/events.html#class-eventtarget.
|
||||
// Please read that link to understand important implementation differences.
|
||||
|
||||
// This conditional type will be the existing global Event in a browser, or
|
||||
// the copy below in a Node environment.
|
||||
type __Event = typeof globalThis extends { onmessage: any; Event: any } ? {}
|
||||
: {
|
||||
/** This is not used in Node.js and is provided purely for completeness. */
|
||||
readonly bubbles: boolean;
|
||||
/** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */
|
||||
cancelBubble: () => void;
|
||||
/** True if the event was created with the cancelable option */
|
||||
readonly cancelable: boolean;
|
||||
/** This is not used in Node.js and is provided purely for completeness. */
|
||||
readonly composed: boolean;
|
||||
/** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */
|
||||
composedPath(): [EventTarget?];
|
||||
/** Alias for event.target. */
|
||||
readonly currentTarget: EventTarget | null;
|
||||
/** Is true if cancelable is true and event.preventDefault() has been called. */
|
||||
readonly defaultPrevented: boolean;
|
||||
/** This is not used in Node.js and is provided purely for completeness. */
|
||||
readonly eventPhase: 0 | 2;
|
||||
/** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */
|
||||
readonly isTrusted: boolean;
|
||||
/** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */
|
||||
preventDefault(): void;
|
||||
/** This is not used in Node.js and is provided purely for completeness. */
|
||||
returnValue: boolean;
|
||||
/** Alias for event.target. */
|
||||
readonly srcElement: EventTarget | null;
|
||||
/** Stops the invocation of event listeners after the current one completes. */
|
||||
stopImmediatePropagation(): void;
|
||||
/** This is not used in Node.js and is provided purely for completeness. */
|
||||
stopPropagation(): void;
|
||||
/** The `EventTarget` dispatching the event */
|
||||
readonly target: EventTarget | null;
|
||||
/** The millisecond timestamp when the Event object was created. */
|
||||
readonly timeStamp: number;
|
||||
/** Returns the type of event, e.g. "click", "hashchange", or "submit". */
|
||||
readonly type: string;
|
||||
};
|
||||
|
||||
// See comment above explaining conditional type
|
||||
type __EventTarget = typeof globalThis extends { onmessage: any; EventTarget: any } ? {}
|
||||
: {
|
||||
/**
|
||||
* Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value.
|
||||
*
|
||||
* If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched.
|
||||
*
|
||||
* The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification.
|
||||
* Specifically, the `capture` option is used as part of the key when registering a `listener`.
|
||||
* Any individual `listener` may be added once with `capture = false`, and once with `capture = true`.
|
||||
*/
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: EventListener | EventListenerObject,
|
||||
options?: AddEventListenerOptions | boolean,
|
||||
): void;
|
||||
/** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */
|
||||
dispatchEvent(event: Event): boolean;
|
||||
/** Removes the event listener in target's event listener list with the same type, callback, and options. */
|
||||
removeEventListener(
|
||||
type: string,
|
||||
listener: EventListener | EventListenerObject,
|
||||
options?: EventListenerOptions | boolean,
|
||||
): void;
|
||||
};
|
||||
|
||||
interface EventInit {
|
||||
bubbles?: boolean;
|
||||
cancelable?: boolean;
|
||||
composed?: boolean;
|
||||
}
|
||||
|
||||
interface EventListenerOptions {
|
||||
/** Not directly used by Node.js. Added for API completeness. Default: `false`. */
|
||||
capture?: boolean;
|
||||
}
|
||||
|
||||
interface AddEventListenerOptions extends EventListenerOptions {
|
||||
/** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */
|
||||
once?: boolean;
|
||||
/** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */
|
||||
passive?: boolean;
|
||||
}
|
||||
|
||||
interface EventListener {
|
||||
(evt: Event): void;
|
||||
}
|
||||
|
||||
interface EventListenerObject {
|
||||
handleEvent(object: Event): void;
|
||||
}
|
||||
|
||||
import {} from "events"; // Make this an ambient declaration
|
||||
declare global {
|
||||
/** An event which takes place in the DOM. */
|
||||
interface Event extends __Event {}
|
||||
var Event: typeof globalThis extends { onmessage: any; Event: infer T } ? T
|
||||
: {
|
||||
prototype: __Event;
|
||||
new(type: string, eventInitDict?: EventInit): __Event;
|
||||
};
|
||||
|
||||
/**
|
||||
* EventTarget is a DOM interface implemented by objects that can
|
||||
* receive events and may have listeners for them.
|
||||
*/
|
||||
interface EventTarget extends __EventTarget {}
|
||||
var EventTarget: typeof globalThis extends { onmessage: any; EventTarget: infer T } ? T
|
||||
: {
|
||||
prototype: __EventTarget;
|
||||
new(): __EventTarget;
|
||||
};
|
||||
}
|
||||
170
node_modules/@types/node/ts4.8/domain.d.ts
generated
vendored
170
node_modules/@types/node/ts4.8/domain.d.ts
generated
vendored
@@ -1,170 +0,0 @@
|
||||
/**
|
||||
* **This module is pending deprecation.** Once a replacement API has been
|
||||
* finalized, this module will be fully deprecated. Most developers should
|
||||
* **not** have cause to use this module. Users who absolutely must have
|
||||
* the functionality that domains provide may rely on it for the time being
|
||||
* but should expect to have to migrate to a different solution
|
||||
* in the future.
|
||||
*
|
||||
* Domains provide a way to handle multiple different IO operations as a
|
||||
* single group. If any of the event emitters or callbacks registered to a
|
||||
* domain emit an `'error'` event, or throw an error, then the domain object
|
||||
* will be notified, rather than losing the context of the error in the`process.on('uncaughtException')` handler, or causing the program to
|
||||
* exit immediately with an error code.
|
||||
* @deprecated Since v1.4.2 - Deprecated
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/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 low-level 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('node:domain');
|
||||
* const fs = require('node:fs');
|
||||
* const d = domain.create();
|
||||
* d.on('error', (er) => {
|
||||
* console.error('Caught error!', er);
|
||||
* });
|
||||
* d.run(() => {
|
||||
* process.nextTick(() => {
|
||||
* setTimeout(() => { // Simulating some various async stuff
|
||||
* fs.open('non-existent file', 'r', (er, fd) => {
|
||||
* if (er) throw er;
|
||||
* // proceed...
|
||||
* });
|
||||
* }, 100);
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* In this example, the `d.on('error')` handler will be triggered, rather
|
||||
* than crashing the program.
|
||||
*/
|
||||
run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
|
||||
/**
|
||||
* Explicitly adds an emitter to the domain. If any event handlers called by
|
||||
* the emitter throw an error, or if the emitter emits an `'error'` event, it
|
||||
* will be routed to the domain's `'error'` event, just like with implicit
|
||||
* binding.
|
||||
*
|
||||
* This also works with timers that are returned from `setInterval()` and `setTimeout()`. If their callback function throws, it will be caught by
|
||||
* the domain `'error'` handler.
|
||||
*
|
||||
* If the Timer or `EventEmitter` was already bound to a domain, it is removed
|
||||
* from that one, and bound to this one instead.
|
||||
* @param emitter emitter or timer to be added to the domain
|
||||
*/
|
||||
add(emitter: EventEmitter | NodeJS.Timer): void;
|
||||
/**
|
||||
* The opposite of {@link add}. Removes domain handling from the
|
||||
* specified emitter.
|
||||
* @param emitter emitter or timer to be removed from the domain
|
||||
*/
|
||||
remove(emitter: EventEmitter | NodeJS.Timer): void;
|
||||
/**
|
||||
* The returned function will be a wrapper around the supplied callback
|
||||
* function. When the returned function is called, any errors that are
|
||||
* thrown will be routed to the domain's `'error'` event.
|
||||
*
|
||||
* ```js
|
||||
* const d = domain.create();
|
||||
*
|
||||
* function readSomeFile(filename, cb) {
|
||||
* fs.readFile(filename, 'utf8', d.bind((er, data) => {
|
||||
* // If this throws, it will also be passed to the domain.
|
||||
* return cb(er, data ? JSON.parse(data) : null);
|
||||
* }));
|
||||
* }
|
||||
*
|
||||
* d.on('error', (er) => {
|
||||
* // An error occurred somewhere. If we throw it now, it will crash the program
|
||||
* // with the normal line number and stack message.
|
||||
* });
|
||||
* ```
|
||||
* @param callback The callback function
|
||||
* @return The bound function
|
||||
*/
|
||||
bind<T extends Function>(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;
|
||||
}
|
||||
declare module "node:domain" {
|
||||
export * from "domain";
|
||||
}
|
||||
796
node_modules/@types/node/ts4.8/events.d.ts
generated
vendored
796
node_modules/@types/node/ts4.8/events.d.ts
generated
vendored
@@ -1,796 +0,0 @@
|
||||
/**
|
||||
* Much of the Node.js core API is built around an idiomatic asynchronous
|
||||
* event-driven architecture in which certain kinds of objects (called "emitters")
|
||||
* emit named events that cause `Function` objects ("listeners") to be called.
|
||||
*
|
||||
* For instance: a `net.Server` object emits an event each time a peer
|
||||
* connects to it; a `fs.ReadStream` emits an event when the file is opened;
|
||||
* a `stream` emits an event whenever data is available to be read.
|
||||
*
|
||||
* All objects that emit events are instances of the `EventEmitter` class. These
|
||||
* objects expose an `eventEmitter.on()` function that allows one or more
|
||||
* functions to be attached to named events emitted by the object. Typically,
|
||||
* event names are camel-cased strings but any valid JavaScript property key
|
||||
* can be used.
|
||||
*
|
||||
* When the `EventEmitter` object emits an event, all of the functions attached
|
||||
* to that specific event are called _synchronously_. Any values returned by the
|
||||
* called listeners are _ignored_ and discarded.
|
||||
*
|
||||
* The following example shows a simple `EventEmitter` instance with a single
|
||||
* listener. The `eventEmitter.on()` method is used to register listeners, while
|
||||
* the `eventEmitter.emit()` method is used to trigger the event.
|
||||
*
|
||||
* ```js
|
||||
* import { EventEmitter } from 'node: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/v20.2.0/lib/events.js)
|
||||
*/
|
||||
declare module "events" {
|
||||
// NOTE: This class is in the docs but is **not actually exported** by Node.
|
||||
// If https://github.com/nodejs/node/issues/39903 gets resolved and Node
|
||||
// actually starts exporting the class, uncomment below.
|
||||
// import { EventListener, EventListenerObject } from '__dom-events';
|
||||
// /** The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API. */
|
||||
// interface NodeEventTarget extends EventTarget {
|
||||
// /**
|
||||
// * Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API.
|
||||
// * The only difference between `addListener()` and `addEventListener()` is that addListener() will return a reference to the EventTarget.
|
||||
// */
|
||||
// addListener(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
|
||||
// /** Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered. */
|
||||
// eventNames(): string[];
|
||||
// /** Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`. */
|
||||
// listenerCount(type: string): number;
|
||||
// /** Node.js-specific alias for `eventTarget.removeListener()`. */
|
||||
// off(type: string, listener: EventListener | EventListenerObject): this;
|
||||
// /** Node.js-specific alias for `eventTarget.addListener()`. */
|
||||
// on(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
|
||||
// /** Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. */
|
||||
// once(type: string, listener: EventListener | EventListenerObject): this;
|
||||
// /**
|
||||
// * Node.js-specific extension to the `EventTarget` class.
|
||||
// * If `type` is specified, removes all registered listeners for `type`,
|
||||
// * otherwise removes all registered listeners.
|
||||
// */
|
||||
// removeAllListeners(type: string): this;
|
||||
// /**
|
||||
// * Node.js-specific extension to the `EventTarget` class that removes the listener for the given `type`.
|
||||
// * The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`.
|
||||
// */
|
||||
// removeListener(type: string, listener: EventListener | EventListenerObject): this;
|
||||
// }
|
||||
interface EventEmitterOptions {
|
||||
/**
|
||||
* Enables automatic capturing of promise rejection.
|
||||
*/
|
||||
captureRejections?: boolean | undefined;
|
||||
}
|
||||
// Any EventTarget with a Node-style `once` function
|
||||
interface _NodeEventTarget {
|
||||
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
// Any EventTarget with a DOM-style `addEventListener`
|
||||
interface _DOMEventTarget {
|
||||
addEventListener(
|
||||
eventName: string,
|
||||
listener: (...args: any[]) => void,
|
||||
opts?: {
|
||||
once: boolean;
|
||||
},
|
||||
): any;
|
||||
}
|
||||
interface StaticEventEmitterOptions {
|
||||
signal?: AbortSignal | undefined;
|
||||
}
|
||||
interface EventEmitter extends NodeJS.EventEmitter {}
|
||||
/**
|
||||
* The `EventEmitter` class is defined and exposed by the `node:events` module:
|
||||
*
|
||||
* ```js
|
||||
* import { EventEmitter } from 'node: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);
|
||||
/**
|
||||
* Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
|
||||
* event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
|
||||
* The `Promise` will resolve with an array of all the arguments emitted to the
|
||||
* given event.
|
||||
*
|
||||
* This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event
|
||||
* semantics and does not listen to the `'error'` event.
|
||||
*
|
||||
* ```js
|
||||
* import { once, EventEmitter } from 'node:events';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* const ee = new EventEmitter();
|
||||
*
|
||||
* process.nextTick(() => {
|
||||
* ee.emit('myevent', 42);
|
||||
* });
|
||||
*
|
||||
* const [value] = await once(ee, 'myevent');
|
||||
* console.log(value);
|
||||
*
|
||||
* const err = new Error('kaboom');
|
||||
* process.nextTick(() => {
|
||||
* ee.emit('error', err);
|
||||
* });
|
||||
*
|
||||
* try {
|
||||
* await once(ee, 'myevent');
|
||||
* } catch (err) {
|
||||
* console.error('error happened', err);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* The special handling of the `'error'` event is only used when `events.once()`is used to wait for another event. If `events.once()` is used to wait for the
|
||||
* '`error'` event itself, then it is treated as any other kind of event without
|
||||
* special handling:
|
||||
*
|
||||
* ```js
|
||||
* import { EventEmitter, once } from 'node:events';
|
||||
*
|
||||
* const ee = new EventEmitter();
|
||||
*
|
||||
* once(ee, 'error')
|
||||
* .then(([err]) => console.log('ok', err.message))
|
||||
* .catch((err) => console.error('error', err.message));
|
||||
*
|
||||
* ee.emit('error', new Error('boom'));
|
||||
*
|
||||
* // Prints: ok boom
|
||||
* ```
|
||||
*
|
||||
* An `AbortSignal` can be used to cancel waiting for the event:
|
||||
*
|
||||
* ```js
|
||||
* import { EventEmitter, once } from 'node:events';
|
||||
*
|
||||
* const ee = new EventEmitter();
|
||||
* const ac = new AbortController();
|
||||
*
|
||||
* async function foo(emitter, event, signal) {
|
||||
* try {
|
||||
* await once(emitter, event, { signal });
|
||||
* console.log('event emitted!');
|
||||
* } catch (error) {
|
||||
* if (error.name === 'AbortError') {
|
||||
* console.error('Waiting for the event was canceled!');
|
||||
* } else {
|
||||
* console.error('There was an error', error.message);
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* foo(ee, 'foo', ac.signal);
|
||||
* ac.abort(); // Abort waiting for the event
|
||||
* ee.emit('foo'); // Prints: Waiting for the event was canceled!
|
||||
* ```
|
||||
* @since v11.13.0, v10.16.0
|
||||
*/
|
||||
static once(
|
||||
emitter: _NodeEventTarget,
|
||||
eventName: string | symbol,
|
||||
options?: StaticEventEmitterOptions,
|
||||
): Promise<any[]>;
|
||||
static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||
/**
|
||||
* ```js
|
||||
* import { on, EventEmitter } from 'node:events';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* const ee = new EventEmitter();
|
||||
*
|
||||
* // Emit later on
|
||||
* process.nextTick(() => {
|
||||
* ee.emit('foo', 'bar');
|
||||
* ee.emit('foo', 42);
|
||||
* });
|
||||
*
|
||||
* for await (const event of on(ee, 'foo')) {
|
||||
* // The execution of this inner block is synchronous and it
|
||||
* // processes one event at a time (even with await). Do not use
|
||||
* // if concurrent execution is required.
|
||||
* console.log(event); // prints ['bar'] [42]
|
||||
* }
|
||||
* // Unreachable here
|
||||
* ```
|
||||
*
|
||||
* Returns an `AsyncIterator` that iterates `eventName` events. It will throw
|
||||
* if the `EventEmitter` emits `'error'`. It removes all listeners when
|
||||
* exiting the loop. The `value` returned by each iteration is an array
|
||||
* composed of the emitted event arguments.
|
||||
*
|
||||
* An `AbortSignal` can be used to cancel waiting on events:
|
||||
*
|
||||
* ```js
|
||||
* import { on, EventEmitter } from 'node:events';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* const ac = new AbortController();
|
||||
*
|
||||
* (async () => {
|
||||
* const ee = new EventEmitter();
|
||||
*
|
||||
* // Emit later on
|
||||
* process.nextTick(() => {
|
||||
* ee.emit('foo', 'bar');
|
||||
* ee.emit('foo', 42);
|
||||
* });
|
||||
*
|
||||
* for await (const event of on(ee, 'foo', { signal: ac.signal })) {
|
||||
* // The execution of this inner block is synchronous and it
|
||||
* // processes one event at a time (even with await). Do not use
|
||||
* // if concurrent execution is required.
|
||||
* console.log(event); // prints ['bar'] [42]
|
||||
* }
|
||||
* // Unreachable here
|
||||
* })();
|
||||
*
|
||||
* process.nextTick(() => ac.abort());
|
||||
* ```
|
||||
* @since v13.6.0, v12.16.0
|
||||
* @param eventName The name of the event being listened for
|
||||
* @return that iterates `eventName` events emitted by the `emitter`
|
||||
*/
|
||||
static on(
|
||||
emitter: NodeJS.EventEmitter,
|
||||
eventName: string,
|
||||
options?: StaticEventEmitterOptions,
|
||||
): AsyncIterableIterator<any>;
|
||||
/**
|
||||
* A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
|
||||
*
|
||||
* ```js
|
||||
* import { EventEmitter, listenerCount } from 'node:events';
|
||||
*
|
||||
* const myEmitter = new EventEmitter();
|
||||
* myEmitter.on('event', () => {});
|
||||
* myEmitter.on('event', () => {});
|
||||
* console.log(listenerCount(myEmitter, 'event'));
|
||||
* // Prints: 2
|
||||
* ```
|
||||
* @since v0.9.12
|
||||
* @deprecated Since v3.2.0 - Use `listenerCount` instead.
|
||||
* @param emitter The emitter to query
|
||||
* @param eventName The event name
|
||||
*/
|
||||
static listenerCount(emitter: NodeJS.EventEmitter, eventName: string | symbol): number;
|
||||
/**
|
||||
* Returns a copy of the array of listeners for the event named `eventName`.
|
||||
*
|
||||
* For `EventEmitter`s this behaves exactly the same as calling `.listeners` on
|
||||
* the emitter.
|
||||
*
|
||||
* For `EventTarget`s this is the only way to get the event listeners for the
|
||||
* event target. This is useful for debugging and diagnostic purposes.
|
||||
*
|
||||
* ```js
|
||||
* import { getEventListeners, EventEmitter } from 'node:events';
|
||||
*
|
||||
* {
|
||||
* const ee = new EventEmitter();
|
||||
* const listener = () => console.log('Events are fun');
|
||||
* ee.on('foo', listener);
|
||||
* console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
|
||||
* }
|
||||
* {
|
||||
* const et = new EventTarget();
|
||||
* const listener = () => console.log('Events are fun');
|
||||
* et.addEventListener('foo', listener);
|
||||
* console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
|
||||
* }
|
||||
* ```
|
||||
* @since v15.2.0, v14.17.0
|
||||
*/
|
||||
static getEventListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
||||
/**
|
||||
* Returns the currently set max amount of listeners.
|
||||
*
|
||||
* For `EventEmitter`s this behaves exactly the same as calling `.getMaxListeners` on
|
||||
* the emitter.
|
||||
*
|
||||
* For `EventTarget`s this is the only way to get the max event listeners for the
|
||||
* event target. If the number of event handlers on a single EventTarget exceeds
|
||||
* the max set, the EventTarget will print a warning.
|
||||
*
|
||||
* ```js
|
||||
* import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';
|
||||
*
|
||||
* {
|
||||
* const ee = new EventEmitter();
|
||||
* console.log(getMaxListeners(ee)); // 10
|
||||
* setMaxListeners(11, ee);
|
||||
* console.log(getMaxListeners(ee)); // 11
|
||||
* }
|
||||
* {
|
||||
* const et = new EventTarget();
|
||||
* console.log(getMaxListeners(et)); // 10
|
||||
* setMaxListeners(11, et);
|
||||
* console.log(getMaxListeners(et)); // 11
|
||||
* }
|
||||
* ```
|
||||
* @since v19.9.0
|
||||
*/
|
||||
static getMaxListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter): number;
|
||||
/**
|
||||
* ```js
|
||||
* import { setMaxListeners, EventEmitter } from 'node:events';
|
||||
*
|
||||
* const target = new EventTarget();
|
||||
* const emitter = new EventEmitter();
|
||||
*
|
||||
* setMaxListeners(5, target, emitter);
|
||||
* ```
|
||||
* @since v15.4.0
|
||||
* @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
|
||||
* @param eventsTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
|
||||
* objects.
|
||||
*/
|
||||
static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void;
|
||||
/**
|
||||
* Listens once to the `abort` event on the provided `signal`.
|
||||
*
|
||||
* Listening to the `abort` event on abort signals is unsafe and may
|
||||
* lead to resource leaks since another third party with the signal can
|
||||
* call `e.stopImmediatePropagation()`. Unfortunately Node.js cannot change
|
||||
* this since it would violate the web standard. Additionally, the original
|
||||
* API makes it easy to forget to remove listeners.
|
||||
*
|
||||
* This API allows safely using `AbortSignal`s in Node.js APIs by solving these
|
||||
* two issues by listening to the event such that `stopImmediatePropagation` does
|
||||
* not prevent the listener from running.
|
||||
*
|
||||
* Returns a disposable so that it may be unsubscribed from more easily.
|
||||
*
|
||||
* ```js
|
||||
* import { addAbortListener } from 'node:events';
|
||||
*
|
||||
* function example(signal) {
|
||||
* let disposable;
|
||||
* try {
|
||||
* signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
|
||||
* disposable = addAbortListener(signal, (e) => {
|
||||
* // Do something when signal is aborted.
|
||||
* });
|
||||
* } finally {
|
||||
* disposable?.[Symbol.dispose]();
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* @since v20.5.0
|
||||
* @experimental
|
||||
* @return that removes the `abort` listener.
|
||||
*/
|
||||
static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable;
|
||||
/**
|
||||
* This symbol shall be used to install a listener for only monitoring `'error'`events. Listeners installed using this symbol are called before the regular`'error'` listeners are called.
|
||||
*
|
||||
* Installing a listener using this symbol does not change the behavior once an`'error'` event is emitted. Therefore, the process will still crash if no
|
||||
* regular `'error'` listener is installed.
|
||||
* @since v13.6.0, v12.17.0
|
||||
*/
|
||||
static readonly errorMonitor: unique symbol;
|
||||
/**
|
||||
* Value: `Symbol.for('nodejs.rejection')`
|
||||
*
|
||||
* See how to write a custom `rejection handler`.
|
||||
* @since v13.4.0, v12.16.0
|
||||
*/
|
||||
static readonly captureRejectionSymbol: unique symbol;
|
||||
/**
|
||||
* Value: [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
|
||||
*
|
||||
* Change the default `captureRejections` option on all new `EventEmitter` objects.
|
||||
* @since v13.4.0, v12.16.0
|
||||
*/
|
||||
static captureRejections: boolean;
|
||||
/**
|
||||
* By default, a maximum of `10` listeners can be registered for any single
|
||||
* event. This limit can be changed for individual `EventEmitter` instances
|
||||
* using the `emitter.setMaxListeners(n)` method. To change the default
|
||||
* for _all_`EventEmitter` instances, the `events.defaultMaxListeners`property can be used. If this value is not a positive number, a `RangeError`is thrown.
|
||||
*
|
||||
* Take caution when setting the `events.defaultMaxListeners` because the
|
||||
* change affects _all_`EventEmitter` instances, including those created before
|
||||
* the change is made. However, calling `emitter.setMaxListeners(n)` still has
|
||||
* precedence over `events.defaultMaxListeners`.
|
||||
*
|
||||
* This is not a hard limit. The `EventEmitter` instance will allow
|
||||
* more listeners to be added but will output a trace warning to stderr indicating
|
||||
* that a "possible EventEmitter memory leak" has been detected. For any single`EventEmitter`, the `emitter.getMaxListeners()` and `emitter.setMaxListeners()`methods can be used to
|
||||
* temporarily avoid this warning:
|
||||
*
|
||||
* ```js
|
||||
* import { EventEmitter } from 'node:events';
|
||||
* const emitter = new EventEmitter();
|
||||
* emitter.setMaxListeners(emitter.getMaxListeners() + 1);
|
||||
* emitter.once('event', () => {
|
||||
* // do stuff
|
||||
* emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* The `--trace-warnings` command-line flag can be used to display the
|
||||
* stack trace for such warnings.
|
||||
*
|
||||
* The emitted warning can be inspected with `process.on('warning')` and will
|
||||
* have the additional `emitter`, `type`, and `count` properties, referring to
|
||||
* the event emitter instance, the event's name and the number of attached
|
||||
* listeners, respectively.
|
||||
* Its `name` property is set to `'MaxListenersExceededWarning'`.
|
||||
* @since v0.11.2
|
||||
*/
|
||||
static defaultMaxListeners: number;
|
||||
}
|
||||
import internal = require("node:events");
|
||||
namespace EventEmitter {
|
||||
// Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4
|
||||
export { internal as EventEmitter };
|
||||
export interface Abortable {
|
||||
/**
|
||||
* When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
|
||||
*/
|
||||
signal?: AbortSignal | undefined;
|
||||
}
|
||||
}
|
||||
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
|
||||
* import { EventEmitter } from 'node:events';
|
||||
* 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
|
||||
* import { EventEmitter } from 'node:events';
|
||||
* 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
|
||||
* import { EventEmitter } from 'node:events';
|
||||
* class MyEmitter extends EventEmitter {}
|
||||
* 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
|
||||
* import { EventEmitter } from 'node:events';
|
||||
* 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;
|
||||
/**
|
||||
* By default `EventEmitter`s will print a warning if more than `10` listeners are
|
||||
* added for a particular event. This is a useful default that helps finding
|
||||
* memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
|
||||
* modified for this specific `EventEmitter` instance. The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
|
||||
*
|
||||
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
||||
* @since v0.3.5
|
||||
*/
|
||||
setMaxListeners(n: number): this;
|
||||
/**
|
||||
* Returns the current max listener value for the `EventEmitter` which is either
|
||||
* set by `emitter.setMaxListeners(n)` or defaults to {@link defaultMaxListeners}.
|
||||
* @since v1.0.0
|
||||
*/
|
||||
getMaxListeners(): number;
|
||||
/**
|
||||
* Returns a copy of the array of listeners for the event named `eventName`.
|
||||
*
|
||||
* ```js
|
||||
* server.on('connection', (stream) => {
|
||||
* console.log('someone connected!');
|
||||
* });
|
||||
* console.log(util.inspect(server.listeners('connection')));
|
||||
* // Prints: [ [Function] ]
|
||||
* ```
|
||||
* @since v0.1.26
|
||||
*/
|
||||
listeners(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
|
||||
* import { EventEmitter } from 'node:events';
|
||||
* 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
|
||||
* import { EventEmitter } from 'node: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 for the event named `eventName`.
|
||||
* If `listener` is provided, it will return how many times the listener is found
|
||||
* in the list of the listeners of the event.
|
||||
* @since v3.2.0
|
||||
* @param eventName The name of the event being listened for
|
||||
* @param listener The event handler function
|
||||
*/
|
||||
listenerCount(eventName: string | symbol, listener?: Function): 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
|
||||
* import { EventEmitter } from 'node:events';
|
||||
*
|
||||
* const myEE = new EventEmitter();
|
||||
* myEE.on('foo', () => {});
|
||||
* myEE.on('bar', () => {});
|
||||
*
|
||||
* const sym = Symbol('symbol');
|
||||
* myEE.on(sym, () => {});
|
||||
*
|
||||
* console.log(myEE.eventNames());
|
||||
* // Prints: [ 'foo', 'bar', Symbol(symbol) ]
|
||||
* ```
|
||||
* @since v6.0.0
|
||||
*/
|
||||
eventNames(): Array<string | symbol>;
|
||||
}
|
||||
}
|
||||
}
|
||||
export = EventEmitter;
|
||||
}
|
||||
declare module "node:events" {
|
||||
import events = require("events");
|
||||
export = events;
|
||||
}
|
||||
4289
node_modules/@types/node/ts4.8/fs.d.ts
generated
vendored
4289
node_modules/@types/node/ts4.8/fs.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
1232
node_modules/@types/node/ts4.8/fs/promises.d.ts
generated
vendored
1232
node_modules/@types/node/ts4.8/fs/promises.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
381
node_modules/@types/node/ts4.8/globals.d.ts
generated
vendored
381
node_modules/@types/node/ts4.8/globals.d.ts
generated
vendored
@@ -1,381 +0,0 @@
|
||||
// Declare "static" methods in Error
|
||||
interface ErrorConstructor {
|
||||
/** Create .stack property on a target object */
|
||||
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
||||
|
||||
/**
|
||||
* Optional override for formatting stack traces
|
||||
*
|
||||
* @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
||||
*/
|
||||
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
||||
|
||||
stackTraceLimit: number;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------*
|
||||
* *
|
||||
* GLOBAL *
|
||||
* *
|
||||
------------------------------------------------*/
|
||||
|
||||
// For backwards compability
|
||||
interface NodeRequire extends NodeJS.Require {}
|
||||
interface RequireResolve extends NodeJS.RequireResolve {}
|
||||
interface NodeModule extends NodeJS.Module {}
|
||||
|
||||
declare var process: NodeJS.Process;
|
||||
declare var console: Console;
|
||||
|
||||
declare var __filename: string;
|
||||
declare var __dirname: string;
|
||||
|
||||
declare var require: NodeRequire;
|
||||
declare var module: NodeModule;
|
||||
|
||||
// Same as module.exports
|
||||
declare var exports: any;
|
||||
|
||||
/**
|
||||
* Only available if `--expose-gc` is passed to the process.
|
||||
*/
|
||||
declare var gc: undefined | (() => void);
|
||||
|
||||
// #region borrowed
|
||||
// from https://github.com/microsoft/TypeScript/blob/38da7c600c83e7b31193a62495239a0fe478cb67/lib/lib.webworker.d.ts#L633 until moved to separate lib
|
||||
/** A controller object that allows you to abort one or more DOM requests as and when desired. */
|
||||
interface AbortController {
|
||||
/**
|
||||
* Returns the AbortSignal object associated with this object.
|
||||
*/
|
||||
|
||||
readonly signal: AbortSignal;
|
||||
/**
|
||||
* Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted.
|
||||
*/
|
||||
abort(reason?: any): void;
|
||||
}
|
||||
|
||||
/** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */
|
||||
interface AbortSignal extends EventTarget {
|
||||
/**
|
||||
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
|
||||
*/
|
||||
readonly aborted: boolean;
|
||||
readonly reason: any;
|
||||
onabort: null | ((this: AbortSignal, event: Event) => any);
|
||||
throwIfAborted(): void;
|
||||
}
|
||||
|
||||
declare var AbortController: typeof globalThis extends { onmessage: any; AbortController: infer T } ? T
|
||||
: {
|
||||
prototype: AbortController;
|
||||
new(): AbortController;
|
||||
};
|
||||
|
||||
declare var AbortSignal: typeof globalThis extends { onmessage: any; AbortSignal: infer T } ? T
|
||||
: {
|
||||
prototype: AbortSignal;
|
||||
new(): AbortSignal;
|
||||
abort(reason?: any): AbortSignal;
|
||||
timeout(milliseconds: number): AbortSignal;
|
||||
};
|
||||
// #endregion borrowed
|
||||
|
||||
// #region Disposable
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that is used to release resources held by an object. Called by the semantics of the `using` statement.
|
||||
*/
|
||||
readonly dispose: unique symbol;
|
||||
|
||||
/**
|
||||
* A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement.
|
||||
*/
|
||||
readonly asyncDispose: unique symbol;
|
||||
}
|
||||
|
||||
interface Disposable {
|
||||
[Symbol.dispose](): void;
|
||||
}
|
||||
|
||||
interface AsyncDisposable {
|
||||
[Symbol.asyncDispose](): PromiseLike<void>;
|
||||
}
|
||||
// #endregion Disposable
|
||||
|
||||
// #region ArrayLike.at()
|
||||
interface RelativeIndexable<T> {
|
||||
/**
|
||||
* Takes an integer value and returns the item at that index,
|
||||
* allowing for positive and negative integers.
|
||||
* Negative integers count back from the last item in the array.
|
||||
*/
|
||||
at(index: number): T | undefined;
|
||||
}
|
||||
interface String extends RelativeIndexable<string> {}
|
||||
interface Array<T> extends RelativeIndexable<T> {}
|
||||
interface ReadonlyArray<T> extends RelativeIndexable<T> {}
|
||||
interface Int8Array extends RelativeIndexable<number> {}
|
||||
interface Uint8Array extends RelativeIndexable<number> {}
|
||||
interface Uint8ClampedArray extends RelativeIndexable<number> {}
|
||||
interface Int16Array extends RelativeIndexable<number> {}
|
||||
interface Uint16Array extends RelativeIndexable<number> {}
|
||||
interface Int32Array extends RelativeIndexable<number> {}
|
||||
interface Uint32Array extends RelativeIndexable<number> {}
|
||||
interface Float32Array extends RelativeIndexable<number> {}
|
||||
interface Float64Array extends RelativeIndexable<number> {}
|
||||
interface BigInt64Array extends RelativeIndexable<bigint> {}
|
||||
interface BigUint64Array extends RelativeIndexable<bigint> {}
|
||||
// #endregion ArrayLike.at() end
|
||||
|
||||
/**
|
||||
* @since v17.0.0
|
||||
*
|
||||
* Creates a deep clone of an object.
|
||||
*/
|
||||
declare function structuredClone<T>(
|
||||
value: T,
|
||||
transfer?: { transfer: ReadonlyArray<import("worker_threads").TransferListItem> },
|
||||
): T;
|
||||
|
||||
/*----------------------------------------------*
|
||||
* *
|
||||
* GLOBAL INTERFACES *
|
||||
* *
|
||||
*-----------------------------------------------*/
|
||||
declare namespace NodeJS {
|
||||
interface CallSite {
|
||||
/**
|
||||
* Value of "this"
|
||||
*/
|
||||
getThis(): unknown;
|
||||
|
||||
/**
|
||||
* Type of "this" as a string.
|
||||
* This is the name of the function stored in the constructor field of
|
||||
* "this", if available. Otherwise the object's [[Class]] internal
|
||||
* property.
|
||||
*/
|
||||
getTypeName(): string | null;
|
||||
|
||||
/**
|
||||
* Current function
|
||||
*/
|
||||
getFunction(): Function | undefined;
|
||||
|
||||
/**
|
||||
* Name of the current function, typically its name property.
|
||||
* If a name property is not available an attempt will be made to try
|
||||
* to infer a name from the function's context.
|
||||
*/
|
||||
getFunctionName(): string | null;
|
||||
|
||||
/**
|
||||
* Name of the property [of "this" or one of its prototypes] that holds
|
||||
* the current function
|
||||
*/
|
||||
getMethodName(): string | null;
|
||||
|
||||
/**
|
||||
* Name of the script [if this function was defined in a script]
|
||||
*/
|
||||
getFileName(): string | undefined;
|
||||
|
||||
/**
|
||||
* Current line number [if this function was defined in a script]
|
||||
*/
|
||||
getLineNumber(): number | null;
|
||||
|
||||
/**
|
||||
* Current column number [if this function was defined in a script]
|
||||
*/
|
||||
getColumnNumber(): number | null;
|
||||
|
||||
/**
|
||||
* A call site object representing the location where eval was called
|
||||
* [if this function was created using a call to eval]
|
||||
*/
|
||||
getEvalOrigin(): string | undefined;
|
||||
|
||||
/**
|
||||
* Is this a toplevel invocation, that is, is "this" the global object?
|
||||
*/
|
||||
isToplevel(): boolean;
|
||||
|
||||
/**
|
||||
* Does this call take place in code defined by a call to eval?
|
||||
*/
|
||||
isEval(): boolean;
|
||||
|
||||
/**
|
||||
* Is this call in native V8 code?
|
||||
*/
|
||||
isNative(): boolean;
|
||||
|
||||
/**
|
||||
* Is this a constructor call?
|
||||
*/
|
||||
isConstructor(): boolean;
|
||||
}
|
||||
|
||||
interface ErrnoException extends Error {
|
||||
errno?: number | undefined;
|
||||
code?: string | undefined;
|
||||
path?: string | undefined;
|
||||
syscall?: string | undefined;
|
||||
}
|
||||
|
||||
interface ReadableStream extends EventEmitter {
|
||||
readable: boolean;
|
||||
read(size?: number): string | Buffer;
|
||||
setEncoding(encoding: BufferEncoding): this;
|
||||
pause(): this;
|
||||
resume(): this;
|
||||
isPaused(): boolean;
|
||||
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean | undefined }): T;
|
||||
unpipe(destination?: WritableStream): this;
|
||||
unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
|
||||
wrap(oldStream: ReadableStream): this;
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
|
||||
}
|
||||
|
||||
interface WritableStream extends EventEmitter {
|
||||
writable: boolean;
|
||||
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
|
||||
write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
|
||||
end(cb?: () => void): this;
|
||||
end(data: string | Uint8Array, cb?: () => void): this;
|
||||
end(str: string, encoding?: BufferEncoding, cb?: () => void): this;
|
||||
}
|
||||
|
||||
interface ReadWriteStream extends ReadableStream, WritableStream {}
|
||||
|
||||
interface RefCounted {
|
||||
ref(): this;
|
||||
unref(): this;
|
||||
}
|
||||
|
||||
type TypedArray =
|
||||
| Uint8Array
|
||||
| Uint8ClampedArray
|
||||
| Uint16Array
|
||||
| Uint32Array
|
||||
| Int8Array
|
||||
| Int16Array
|
||||
| Int32Array
|
||||
| BigUint64Array
|
||||
| BigInt64Array
|
||||
| Float32Array
|
||||
| Float64Array;
|
||||
type ArrayBufferView = TypedArray | DataView;
|
||||
|
||||
interface Require {
|
||||
(id: string): any;
|
||||
resolve: RequireResolve;
|
||||
cache: Dict<NodeModule>;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
extensions: RequireExtensions;
|
||||
main: Module | undefined;
|
||||
}
|
||||
|
||||
interface RequireResolve {
|
||||
(id: string, options?: { paths?: string[] | undefined }): string;
|
||||
paths(request: string): string[] | null;
|
||||
}
|
||||
|
||||
interface RequireExtensions extends Dict<(m: Module, filename: string) => any> {
|
||||
".js": (m: Module, filename: string) => any;
|
||||
".json": (m: Module, filename: string) => any;
|
||||
".node": (m: Module, filename: string) => any;
|
||||
}
|
||||
interface Module {
|
||||
/**
|
||||
* `true` if the module is running during the Node.js preload
|
||||
*/
|
||||
isPreloading: boolean;
|
||||
exports: any;
|
||||
require: Require;
|
||||
id: string;
|
||||
filename: string;
|
||||
loaded: boolean;
|
||||
/** @deprecated since v14.6.0 Please use `require.main` and `module.children` instead. */
|
||||
parent: Module | null | undefined;
|
||||
children: Module[];
|
||||
/**
|
||||
* @since v11.14.0
|
||||
*
|
||||
* The directory name of the module. This is usually the same as the path.dirname() of the module.id.
|
||||
*/
|
||||
path: string;
|
||||
paths: string[];
|
||||
}
|
||||
|
||||
interface Dict<T> {
|
||||
[key: string]: T | undefined;
|
||||
}
|
||||
|
||||
interface ReadOnlyDict<T> {
|
||||
readonly [key: string]: T | undefined;
|
||||
}
|
||||
|
||||
namespace fetch {
|
||||
type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request;
|
||||
type _Response = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Response;
|
||||
type _FormData = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").FormData;
|
||||
type _Headers = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Headers;
|
||||
type _RequestInit = typeof globalThis extends { onmessage: any } ? {}
|
||||
: import("undici-types").RequestInit;
|
||||
type Request = globalThis.Request;
|
||||
type Response = globalThis.Response;
|
||||
type Headers = globalThis.Headers;
|
||||
type FormData = globalThis.FormData;
|
||||
type RequestInit = globalThis.RequestInit;
|
||||
type RequestInfo = import("undici-types").RequestInfo;
|
||||
type HeadersInit = import("undici-types").HeadersInit;
|
||||
type BodyInit = import("undici-types").BodyInit;
|
||||
type RequestRedirect = import("undici-types").RequestRedirect;
|
||||
type RequestCredentials = import("undici-types").RequestCredentials;
|
||||
type RequestMode = import("undici-types").RequestMode;
|
||||
type ReferrerPolicy = import("undici-types").ReferrerPolicy;
|
||||
type Dispatcher = import("undici-types").Dispatcher;
|
||||
type RequestDuplex = import("undici-types").RequestDuplex;
|
||||
}
|
||||
}
|
||||
|
||||
interface RequestInit extends NodeJS.fetch._RequestInit {}
|
||||
|
||||
declare function fetch(
|
||||
input: NodeJS.fetch.RequestInfo,
|
||||
init?: RequestInit,
|
||||
): Promise<Response>;
|
||||
|
||||
interface Request extends NodeJS.fetch._Request {}
|
||||
declare var Request: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
Request: infer T;
|
||||
} ? T
|
||||
: typeof import("undici-types").Request;
|
||||
|
||||
interface Response extends NodeJS.fetch._Response {}
|
||||
declare var Response: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
Response: infer T;
|
||||
} ? T
|
||||
: typeof import("undici-types").Response;
|
||||
|
||||
interface FormData extends NodeJS.fetch._FormData {}
|
||||
declare var FormData: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
FormData: infer T;
|
||||
} ? T
|
||||
: typeof import("undici-types").FormData;
|
||||
|
||||
interface Headers extends NodeJS.fetch._Headers {}
|
||||
declare var Headers: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
Headers: infer T;
|
||||
} ? T
|
||||
: typeof import("undici-types").Headers;
|
||||
1
node_modules/@types/node/ts4.8/globals.global.d.ts
generated
vendored
1
node_modules/@types/node/ts4.8/globals.global.d.ts
generated
vendored
@@ -1 +0,0 @@
|
||||
declare var global: typeof globalThis;
|
||||
1888
node_modules/@types/node/ts4.8/http.d.ts
generated
vendored
1888
node_modules/@types/node/ts4.8/http.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
2381
node_modules/@types/node/ts4.8/http2.d.ts
generated
vendored
2381
node_modules/@types/node/ts4.8/http2.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
550
node_modules/@types/node/ts4.8/https.d.ts
generated
vendored
550
node_modules/@types/node/ts4.8/https.d.ts
generated
vendored
@@ -1,550 +0,0 @@
|
||||
/**
|
||||
* HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a
|
||||
* separate module.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/https.js)
|
||||
*/
|
||||
declare module "https" {
|
||||
import { Duplex } from "node:stream";
|
||||
import * as tls from "node:tls";
|
||||
import * as http from "node:http";
|
||||
import { URL } from "node:url";
|
||||
type ServerOptions<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
> = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
|
||||
type RequestOptions =
|
||||
& http.RequestOptions
|
||||
& tls.SecureContextOptions
|
||||
& {
|
||||
checkServerIdentity?: typeof tls.checkServerIdentity | undefined;
|
||||
rejectUnauthorized?: boolean | undefined; // Defaults to true
|
||||
servername?: string | undefined; // SNI TLS Extension
|
||||
};
|
||||
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
|
||||
rejectUnauthorized?: boolean | undefined;
|
||||
maxCachedSessions?: number | undefined;
|
||||
}
|
||||
/**
|
||||
* An `Agent` object for HTTPS similar to `http.Agent`. See {@link request} for more information.
|
||||
* @since v0.4.5
|
||||
*/
|
||||
class Agent extends http.Agent {
|
||||
constructor(options?: AgentOptions);
|
||||
options: AgentOptions;
|
||||
}
|
||||
interface Server<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
> extends http.Server<Request, Response> {}
|
||||
/**
|
||||
* See `http.Server` for more information.
|
||||
* @since v0.3.4
|
||||
*/
|
||||
class Server<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
> extends tls.Server {
|
||||
constructor(requestListener?: http.RequestListener<Request, Response>);
|
||||
constructor(
|
||||
options: ServerOptions<Request, Response>,
|
||||
requestListener?: http.RequestListener<Request, Response>,
|
||||
);
|
||||
/**
|
||||
* Closes all connections connected to this server.
|
||||
* @since v18.2.0
|
||||
*/
|
||||
closeAllConnections(): void;
|
||||
/**
|
||||
* Closes all connections connected to this server which are not sending a request or waiting for a response.
|
||||
* @since v18.2.0
|
||||
*/
|
||||
closeIdleConnections(): void;
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
addListener(
|
||||
event: "newSession",
|
||||
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||
): this;
|
||||
addListener(
|
||||
event: "OCSPRequest",
|
||||
listener: (
|
||||
certificate: Buffer,
|
||||
issuer: Buffer,
|
||||
callback: (err: Error | null, resp: Buffer) => void,
|
||||
) => void,
|
||||
): this;
|
||||
addListener(
|
||||
event: "resumeSession",
|
||||
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||
): this;
|
||||
addListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
addListener(event: "close", listener: () => void): this;
|
||||
addListener(event: "connection", listener: (socket: Duplex) => void): this;
|
||||
addListener(event: "error", listener: (err: Error) => void): this;
|
||||
addListener(event: "listening", listener: () => void): this;
|
||||
addListener(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
|
||||
addListener(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
|
||||
addListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
|
||||
addListener(
|
||||
event: "connect",
|
||||
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||
): this;
|
||||
addListener(event: "request", listener: http.RequestListener<Request, Response>): this;
|
||||
addListener(
|
||||
event: "upgrade",
|
||||
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||
): this;
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
emit(event: "keylog", line: Buffer, tlsSocket: tls.TLSSocket): boolean;
|
||||
emit(
|
||||
event: "newSession",
|
||||
sessionId: Buffer,
|
||||
sessionData: Buffer,
|
||||
callback: (err: Error, resp: Buffer) => void,
|
||||
): boolean;
|
||||
emit(
|
||||
event: "OCSPRequest",
|
||||
certificate: Buffer,
|
||||
issuer: Buffer,
|
||||
callback: (err: Error | null, resp: Buffer) => void,
|
||||
): boolean;
|
||||
emit(event: "resumeSession", sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean;
|
||||
emit(event: "secureConnection", tlsSocket: tls.TLSSocket): boolean;
|
||||
emit(event: "tlsClientError", err: Error, tlsSocket: tls.TLSSocket): boolean;
|
||||
emit(event: "close"): boolean;
|
||||
emit(event: "connection", socket: Duplex): boolean;
|
||||
emit(event: "error", err: Error): boolean;
|
||||
emit(event: "listening"): boolean;
|
||||
emit(
|
||||
event: "checkContinue",
|
||||
req: InstanceType<Request>,
|
||||
res: InstanceType<Response> & {
|
||||
req: InstanceType<Request>;
|
||||
},
|
||||
): boolean;
|
||||
emit(
|
||||
event: "checkExpectation",
|
||||
req: InstanceType<Request>,
|
||||
res: InstanceType<Response> & {
|
||||
req: InstanceType<Request>;
|
||||
},
|
||||
): boolean;
|
||||
emit(event: "clientError", err: Error, socket: Duplex): boolean;
|
||||
emit(event: "connect", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
|
||||
emit(
|
||||
event: "request",
|
||||
req: InstanceType<Request>,
|
||||
res: InstanceType<Response> & {
|
||||
req: InstanceType<Request>;
|
||||
},
|
||||
): boolean;
|
||||
emit(event: "upgrade", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
on(
|
||||
event: "newSession",
|
||||
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||
): this;
|
||||
on(
|
||||
event: "OCSPRequest",
|
||||
listener: (
|
||||
certificate: Buffer,
|
||||
issuer: Buffer,
|
||||
callback: (err: Error | null, resp: Buffer) => void,
|
||||
) => void,
|
||||
): this;
|
||||
on(
|
||||
event: "resumeSession",
|
||||
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||
): this;
|
||||
on(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
on(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
on(event: "close", listener: () => void): this;
|
||||
on(event: "connection", listener: (socket: Duplex) => void): this;
|
||||
on(event: "error", listener: (err: Error) => void): this;
|
||||
on(event: "listening", listener: () => void): this;
|
||||
on(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
|
||||
on(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
|
||||
on(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
|
||||
on(event: "connect", listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
||||
on(event: "request", listener: http.RequestListener<Request, Response>): this;
|
||||
on(event: "upgrade", listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
once(
|
||||
event: "newSession",
|
||||
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||
): this;
|
||||
once(
|
||||
event: "OCSPRequest",
|
||||
listener: (
|
||||
certificate: Buffer,
|
||||
issuer: Buffer,
|
||||
callback: (err: Error | null, resp: Buffer) => void,
|
||||
) => void,
|
||||
): this;
|
||||
once(
|
||||
event: "resumeSession",
|
||||
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||
): this;
|
||||
once(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
once(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
once(event: "close", listener: () => void): this;
|
||||
once(event: "connection", listener: (socket: Duplex) => void): this;
|
||||
once(event: "error", listener: (err: Error) => void): this;
|
||||
once(event: "listening", listener: () => void): this;
|
||||
once(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
|
||||
once(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
|
||||
once(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
|
||||
once(event: "connect", listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
||||
once(event: "request", listener: http.RequestListener<Request, Response>): this;
|
||||
once(event: "upgrade", listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependListener(
|
||||
event: "newSession",
|
||||
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||
): this;
|
||||
prependListener(
|
||||
event: "OCSPRequest",
|
||||
listener: (
|
||||
certificate: Buffer,
|
||||
issuer: Buffer,
|
||||
callback: (err: Error | null, resp: Buffer) => void,
|
||||
) => void,
|
||||
): this;
|
||||
prependListener(
|
||||
event: "resumeSession",
|
||||
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||
): this;
|
||||
prependListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
prependListener(event: "connection", listener: (socket: Duplex) => void): this;
|
||||
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependListener(event: "listening", listener: () => void): this;
|
||||
prependListener(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
|
||||
prependListener(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
|
||||
prependListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
|
||||
prependListener(
|
||||
event: "connect",
|
||||
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||
): this;
|
||||
prependListener(event: "request", listener: http.RequestListener<Request, Response>): this;
|
||||
prependListener(
|
||||
event: "upgrade",
|
||||
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||
): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependOnceListener(
|
||||
event: "newSession",
|
||||
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
||||
): this;
|
||||
prependOnceListener(
|
||||
event: "OCSPRequest",
|
||||
listener: (
|
||||
certificate: Buffer,
|
||||
issuer: Buffer,
|
||||
callback: (err: Error | null, resp: Buffer) => void,
|
||||
) => void,
|
||||
): this;
|
||||
prependOnceListener(
|
||||
event: "resumeSession",
|
||||
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
||||
): this;
|
||||
prependOnceListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
prependOnceListener(event: "connection", listener: (socket: Duplex) => void): this;
|
||||
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: "listening", listener: () => void): this;
|
||||
prependOnceListener(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
|
||||
prependOnceListener(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
|
||||
prependOnceListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
|
||||
prependOnceListener(
|
||||
event: "connect",
|
||||
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||
): this;
|
||||
prependOnceListener(event: "request", listener: http.RequestListener<Request, Response>): this;
|
||||
prependOnceListener(
|
||||
event: "upgrade",
|
||||
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
||||
): this;
|
||||
}
|
||||
/**
|
||||
* ```js
|
||||
* // curl -k https://localhost:8000/
|
||||
* const https = require('node:https');
|
||||
* const fs = require('node: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('node:https');
|
||||
* const fs = require('node: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.
|
||||
*/
|
||||
function createServer<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
>(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>;
|
||||
function createServer<
|
||||
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
||||
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
||||
>(
|
||||
options: ServerOptions<Request, Response>,
|
||||
requestListener?: http.RequestListener<Request, Response>,
|
||||
): Server<Request, Response>;
|
||||
/**
|
||||
* 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('node: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('node:tls');
|
||||
* const https = require('node:https');
|
||||
* const crypto = require('node: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-sha256 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(
|
||||
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('node: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(
|
||||
url: string | URL,
|
||||
options: RequestOptions,
|
||||
callback?: (res: http.IncomingMessage) => void,
|
||||
): http.ClientRequest;
|
||||
let globalAgent: Agent;
|
||||
}
|
||||
declare module "node:https" {
|
||||
export * from "https";
|
||||
}
|
||||
88
node_modules/@types/node/ts4.8/index.d.ts
generated
vendored
88
node_modules/@types/node/ts4.8/index.d.ts
generated
vendored
@@ -1,88 +0,0 @@
|
||||
/**
|
||||
* 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 4.8 and earlier.
|
||||
|
||||
// Reference required types from the default lib:
|
||||
/// <reference lib="es2020" />
|
||||
/// <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="assert.d.ts" />
|
||||
/// <reference path="assert/strict.d.ts" />
|
||||
/// <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="diagnostics_channel.d.ts" />
|
||||
/// <reference path="dns.d.ts" />
|
||||
/// <reference path="dns/promises.d.ts" />
|
||||
/// <reference path="dns/promises.d.ts" />
|
||||
/// <reference path="domain.d.ts" />
|
||||
/// <reference path="dom-events.d.ts" />
|
||||
/// <reference path="events.d.ts" />
|
||||
/// <reference path="fs.d.ts" />
|
||||
/// <reference path="fs/promises.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="readline/promises.d.ts" />
|
||||
/// <reference path="repl.d.ts" />
|
||||
/// <reference path="stream.d.ts" />
|
||||
/// <reference path="stream/promises.d.ts" />
|
||||
/// <reference path="stream/consumers.d.ts" />
|
||||
/// <reference path="stream/web.d.ts" />
|
||||
/// <reference path="string_decoder.d.ts" />
|
||||
/// <reference path="test.d.ts" />
|
||||
/// <reference path="timers.d.ts" />
|
||||
/// <reference path="timers/promises.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="wasi.d.ts" />
|
||||
/// <reference path="worker_threads.d.ts" />
|
||||
/// <reference path="zlib.d.ts" />
|
||||
|
||||
/// <reference path="globals.global.d.ts" />
|
||||
2747
node_modules/@types/node/ts4.8/inspector.d.ts
generated
vendored
2747
node_modules/@types/node/ts4.8/inspector.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
297
node_modules/@types/node/ts4.8/module.d.ts
generated
vendored
297
node_modules/@types/node/ts4.8/module.d.ts
generated
vendored
@@ -1,297 +0,0 @@
|
||||
/**
|
||||
* @since v0.3.7
|
||||
* @experimental
|
||||
*/
|
||||
declare module "module" {
|
||||
import { URL } from "node:url";
|
||||
import { MessagePort } from "node:worker_threads";
|
||||
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('node:fs');
|
||||
* const assert = require('node:assert');
|
||||
* const { syncBuiltinESMExports } = require('node:module');
|
||||
*
|
||||
* fs.readFile = newAPI;
|
||||
*
|
||||
* delete fs.readFileSync;
|
||||
*
|
||||
* function newAPI() {
|
||||
* // ...
|
||||
* }
|
||||
*
|
||||
* fs.newAPI = newAPI;
|
||||
*
|
||||
* syncBuiltinESMExports();
|
||||
*
|
||||
* import('node: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
|
||||
* @return Returns `module.SourceMap` if a source map is found, `undefined` otherwise.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
interface SourceOrigin {
|
||||
/**
|
||||
* The name of the range in the source map, if one was provided
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* The file name of the original source, as reported in the SourceMap
|
||||
*/
|
||||
fileName: string;
|
||||
/**
|
||||
* The 1-indexed lineNumber of the corresponding call site in the original source
|
||||
*/
|
||||
lineNumber: number;
|
||||
/**
|
||||
* The 1-indexed columnNumber of the corresponding call site in the original source
|
||||
*/
|
||||
columnNumber: number;
|
||||
}
|
||||
/**
|
||||
* @since v13.7.0, v12.17.0
|
||||
*/
|
||||
class SourceMap {
|
||||
/**
|
||||
* Getter for the payload used to construct the `SourceMap` instance.
|
||||
*/
|
||||
readonly payload: SourceMapPayload;
|
||||
constructor(payload: SourceMapPayload);
|
||||
/**
|
||||
* Given a line offset and column offset in the generated source
|
||||
* file, returns an object representing the SourceMap range in the
|
||||
* original file if found, or an empty object if not.
|
||||
*
|
||||
* The object returned contains the following keys:
|
||||
*
|
||||
* The returned value represents the raw range as it appears in the
|
||||
* SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and
|
||||
* column numbers as they appear in Error messages and CallSite
|
||||
* objects.
|
||||
*
|
||||
* To get the corresponding 1-indexed line and column numbers from a
|
||||
* lineNumber and columnNumber as they are reported by Error stacks
|
||||
* and CallSite objects, use `sourceMap.findOrigin(lineNumber, columnNumber)`
|
||||
* @param lineOffset The zero-indexed line number offset in the generated source
|
||||
* @param columnOffset The zero-indexed column number offset in the generated source
|
||||
*/
|
||||
findEntry(lineOffset: number, columnOffset: number): SourceMapping;
|
||||
/**
|
||||
* Given a 1-indexed `lineNumber` and `columnNumber` from a call site in the generated source,
|
||||
* find the corresponding call site location in the original source.
|
||||
*
|
||||
* If the `lineNumber` and `columnNumber` provided are not found in any source map,
|
||||
* then an empty object is returned.
|
||||
* @param lineNumber The 1-indexed line number of the call site in the generated source
|
||||
* @param columnNumber The 1-indexed column number of the call site in the generated source
|
||||
*/
|
||||
findOrigin(lineNumber: number, columnNumber: number): SourceOrigin | {};
|
||||
}
|
||||
interface ImportAssertions extends NodeJS.Dict<string> {
|
||||
type?: string | undefined;
|
||||
}
|
||||
type ModuleFormat = "builtin" | "commonjs" | "json" | "module" | "wasm";
|
||||
type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray;
|
||||
interface GlobalPreloadContext {
|
||||
port: MessagePort;
|
||||
}
|
||||
/**
|
||||
* @deprecated This hook will be removed in a future version.
|
||||
* Use `initialize` instead. When a loader has an `initialize` export, `globalPreload` will be ignored.
|
||||
*
|
||||
* Sometimes it might be necessary to run some code inside of the same global scope that the application runs in.
|
||||
* This hook allows the return of a string that is run as a sloppy-mode script on startup.
|
||||
*
|
||||
* @param context Information to assist the preload code
|
||||
* @return Code to run before application startup
|
||||
*/
|
||||
type GlobalPreloadHook = (context: GlobalPreloadContext) => string;
|
||||
/**
|
||||
* The `initialize` hook provides a way to define a custom function that runs in the hooks thread
|
||||
* when the hooks module is initialized. Initialization happens when the hooks module is registered via `register`.
|
||||
*
|
||||
* This hook can receive data from a `register` invocation, including ports and other transferrable objects.
|
||||
* The return value of `initialize` can be a `Promise`, in which case it will be awaited before the main application thread execution resumes.
|
||||
*/
|
||||
type InitializeHook<Data = any> = (data: Data) => void | Promise<void>;
|
||||
interface ResolveHookContext {
|
||||
/**
|
||||
* Export conditions of the relevant `package.json`
|
||||
*/
|
||||
conditions: string[];
|
||||
/**
|
||||
* An object whose key-value pairs represent the assertions for the module to import
|
||||
*/
|
||||
importAssertions: ImportAssertions;
|
||||
/**
|
||||
* The module importing this one, or undefined if this is the Node.js entry point
|
||||
*/
|
||||
parentURL: string | undefined;
|
||||
}
|
||||
interface ResolveFnOutput {
|
||||
/**
|
||||
* A hint to the load hook (it might be ignored)
|
||||
*/
|
||||
format?: ModuleFormat | null | undefined;
|
||||
/**
|
||||
* The import assertions to use when caching the module (optional; if excluded the input will be used)
|
||||
*/
|
||||
importAssertions?: ImportAssertions | undefined;
|
||||
/**
|
||||
* A signal that this hook intends to terminate the chain of `resolve` hooks.
|
||||
* @default false
|
||||
*/
|
||||
shortCircuit?: boolean | undefined;
|
||||
/**
|
||||
* The absolute URL to which this input resolves
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
/**
|
||||
* The `resolve` hook chain is responsible for resolving file URL for a given module specifier and parent URL, and optionally its format (such as `'module'`) as a hint to the `load` hook.
|
||||
* If a format is specified, the load hook is ultimately responsible for providing the final `format` value (and it is free to ignore the hint provided by `resolve`);
|
||||
* if `resolve` provides a format, a custom `load` hook is required even if only to pass the value to the Node.js default `load` hook.
|
||||
*
|
||||
* @param specifier The specified URL path of the module to be resolved
|
||||
* @param context
|
||||
* @param nextResolve The subsequent `resolve` hook in the chain, or the Node.js default `resolve` hook after the last user-supplied resolve hook
|
||||
*/
|
||||
type ResolveHook = (
|
||||
specifier: string,
|
||||
context: ResolveHookContext,
|
||||
nextResolve: (
|
||||
specifier: string,
|
||||
context?: ResolveHookContext,
|
||||
) => ResolveFnOutput | Promise<ResolveFnOutput>,
|
||||
) => ResolveFnOutput | Promise<ResolveFnOutput>;
|
||||
interface LoadHookContext {
|
||||
/**
|
||||
* Export conditions of the relevant `package.json`
|
||||
*/
|
||||
conditions: string[];
|
||||
/**
|
||||
* The format optionally supplied by the `resolve` hook chain
|
||||
*/
|
||||
format: ModuleFormat;
|
||||
/**
|
||||
* An object whose key-value pairs represent the assertions for the module to import
|
||||
*/
|
||||
importAssertions: ImportAssertions;
|
||||
}
|
||||
interface LoadFnOutput {
|
||||
format: ModuleFormat;
|
||||
/**
|
||||
* A signal that this hook intends to terminate the chain of `resolve` hooks.
|
||||
* @default false
|
||||
*/
|
||||
shortCircuit?: boolean | undefined;
|
||||
/**
|
||||
* The source for Node.js to evaluate
|
||||
*/
|
||||
source?: ModuleSource;
|
||||
}
|
||||
/**
|
||||
* The `load` hook provides a way to define a custom method of determining how a URL should be interpreted, retrieved, and parsed.
|
||||
* It is also in charge of validating the import assertion.
|
||||
*
|
||||
* @param url The URL/path of the module to be loaded
|
||||
* @param context Metadata about the module
|
||||
* @param nextLoad The subsequent `load` hook in the chain, or the Node.js default `load` hook after the last user-supplied `load` hook
|
||||
*/
|
||||
type LoadHook = (
|
||||
url: string,
|
||||
context: LoadHookContext,
|
||||
nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput | Promise<LoadFnOutput>,
|
||||
) => LoadFnOutput | Promise<LoadFnOutput>;
|
||||
}
|
||||
interface RegisterOptions<Data> {
|
||||
parentURL: string | URL;
|
||||
data?: Data | undefined;
|
||||
transferList?: any[] | undefined;
|
||||
}
|
||||
interface Module extends NodeModule {}
|
||||
class Module {
|
||||
static runMain(): void;
|
||||
static wrap(code: string): string;
|
||||
static createRequire(path: string | URL): NodeRequire;
|
||||
static builtinModules: string[];
|
||||
static isBuiltin(moduleName: string): boolean;
|
||||
static Module: typeof Module;
|
||||
static register<Data = any>(
|
||||
specifier: string | URL,
|
||||
parentURL?: string | URL,
|
||||
options?: RegisterOptions<Data>,
|
||||
): void;
|
||||
static register<Data = any>(specifier: string | URL, options?: RegisterOptions<Data>): void;
|
||||
constructor(id: string, parent?: Module);
|
||||
}
|
||||
global {
|
||||
interface ImportMeta {
|
||||
url: string;
|
||||
/**
|
||||
* Provides a module-relative resolution function scoped to each module, returning
|
||||
* the URL string.
|
||||
*
|
||||
* @since v20.6.0
|
||||
*
|
||||
* @param specifier The module specifier to resolve relative to the current module.
|
||||
* @returns The absolute (`file:`) URL string for the resolved module.
|
||||
*/
|
||||
resolve(specifier: string): string;
|
||||
/**
|
||||
* This `parent` parameter is only used when the `--experimental-import-meta-resolve`
|
||||
* command flag enabled.
|
||||
*
|
||||
* Provides a module-relative resolution function scoped to each module, returning
|
||||
* the URL string.
|
||||
*
|
||||
* @since v20.6.0
|
||||
*
|
||||
* @param specifier The module specifier to resolve relative to `parent`.
|
||||
* @param parent The absolute parent module URL to resolve from.
|
||||
* @returns The absolute (`file:`) URL string for the resolved module.
|
||||
*/
|
||||
resolve(specifier: string, parent: string | URL): string;
|
||||
}
|
||||
}
|
||||
export = Module;
|
||||
}
|
||||
declare module "node:module" {
|
||||
import module = require("module");
|
||||
export = module;
|
||||
}
|
||||
949
node_modules/@types/node/ts4.8/net.d.ts
generated
vendored
949
node_modules/@types/node/ts4.8/net.d.ts
generated
vendored
@@ -1,949 +0,0 @@
|
||||
/**
|
||||
* > Stability: 2 - Stable
|
||||
*
|
||||
* The `node:net` module provides an asynchronous network API for creating stream-based
|
||||
* TCP or `IPC` servers ({@link createServer}) and clients
|
||||
* ({@link createConnection}).
|
||||
*
|
||||
* It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const net = require('node:net');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/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.LookupAllOptions,
|
||||
callback: (err: NodeJS.ErrnoException | null, addresses: dns.LookupAddress[]) => void,
|
||||
) => void;
|
||||
interface AddressInfo {
|
||||
address: string;
|
||||
family: string;
|
||||
port: number;
|
||||
}
|
||||
interface SocketConstructorOpts {
|
||||
fd?: number | undefined;
|
||||
allowHalfOpen?: boolean | undefined;
|
||||
readable?: boolean | undefined;
|
||||
writable?: boolean | undefined;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
interface OnReadOpts {
|
||||
buffer: Uint8Array | (() => Uint8Array);
|
||||
/**
|
||||
* This function is called for every chunk of incoming data.
|
||||
* Two arguments are passed to it: the number of bytes written to buffer and a reference to buffer.
|
||||
* Return false from this function to implicitly pause() the socket.
|
||||
*/
|
||||
callback(bytesWritten: number, buf: Uint8Array): boolean;
|
||||
}
|
||||
interface ConnectOpts {
|
||||
/**
|
||||
* 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
|
||||
* still be emitted as normal and methods like pause() and resume() will also behave as expected.
|
||||
*/
|
||||
onread?: OnReadOpts | undefined;
|
||||
}
|
||||
interface TcpSocketConnectOpts extends ConnectOpts {
|
||||
port: number;
|
||||
host?: string | undefined;
|
||||
localAddress?: string | undefined;
|
||||
localPort?: number | undefined;
|
||||
hints?: number | undefined;
|
||||
family?: number | undefined;
|
||||
lookup?: LookupFunction | undefined;
|
||||
noDelay?: boolean | undefined;
|
||||
keepAlive?: boolean | undefined;
|
||||
keepAliveInitialDelay?: number | undefined;
|
||||
/**
|
||||
* @since v18.13.0
|
||||
*/
|
||||
autoSelectFamily?: boolean | undefined;
|
||||
/**
|
||||
* @since v18.13.0
|
||||
*/
|
||||
autoSelectFamilyAttemptTimeout?: number | undefined;
|
||||
}
|
||||
interface IpcSocketConnectOpts extends ConnectOpts {
|
||||
path: string;
|
||||
}
|
||||
type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
|
||||
type SocketReadyState = "opening" | "open" | "readOnly" | "writeOnly" | "closed";
|
||||
/**
|
||||
* 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 {
|
||||
constructor(options?: SocketConstructorOpts);
|
||||
/**
|
||||
* Destroys the socket after all data is written. If the `finish` event was already emitted the socket is destroyed immediately.
|
||||
* If the socket is still writable it implicitly calls `socket.end()`.
|
||||
* @since v0.3.4
|
||||
*/
|
||||
destroySoon(): void;
|
||||
/**
|
||||
* Sends data on the socket. The second parameter specifies the encoding in the
|
||||
* 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='utf8'] Only used when data is `string`.
|
||||
*/
|
||||
write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
||||
write(str: Uint8Array | string, encoding?: BufferEncoding, 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(port: number, host: string, connectionListener?: () => void): this;
|
||||
connect(port: number, 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.
|
||||
* @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;
|
||||
/**
|
||||
* Close the TCP connection by sending an RST packet and destroy the stream.
|
||||
* If this TCP socket is in connecting status, it will send an RST packet and destroy this TCP socket once it is connected.
|
||||
* Otherwise, it will call `socket.destroy` with an `ERR_SOCKET_CLOSED` Error.
|
||||
* If this is not a TCP socket (for example, a pipe), calling this method will immediately throw an `ERR_INVALID_HANDLE_TYPE` Error.
|
||||
* @since v18.3.0, v16.17.0
|
||||
*/
|
||||
resetAndDestroy(): this;
|
||||
/**
|
||||
* Resumes reading after a call to `socket.pause()`.
|
||||
* @return The socket itself.
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* 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
|
||||
* @param [noDelay=true]
|
||||
* @return The socket itself.
|
||||
*/
|
||||
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
|
||||
* @param [enable=false]
|
||||
* @param [initialDelay=0]
|
||||
* @return The socket itself.
|
||||
*/
|
||||
setKeepAlive(enable?: boolean, initialDelay?: number): this;
|
||||
/**
|
||||
* Returns the bound `address`, the address `family` name and `port` of the
|
||||
* socket as reported by the operating system:`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
|
||||
* @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 is only present if the family autoselection algorithm is enabled in `socket.connect(options)`
|
||||
* and it is an array of the addresses that have been attempted.
|
||||
*
|
||||
* Each address is a string in the form of `$IP:$PORT`.
|
||||
* If the connection was successful, then the last address is the one that the socket is currently connected to.
|
||||
* @since v19.4.0
|
||||
*/
|
||||
readonly autoSelectFamilyAttemptedAddresses: string[];
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* The amount of received bytes.
|
||||
* @since v0.5.3
|
||||
*/
|
||||
readonly bytesRead: number;
|
||||
/**
|
||||
* The amount of bytes sent.
|
||||
* @since v0.5.3
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* This is `true` if the socket is not connected yet, either because `.connect()`has not yet been called or because it is still in the process of connecting
|
||||
* (see `socket.connecting`).
|
||||
* @since v11.2.0, v10.16.0
|
||||
*/
|
||||
readonly pending: boolean;
|
||||
/**
|
||||
* See `writable.destroyed` for further details.
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* The numeric representation of the local port. For example, `80` or `21`.
|
||||
* @since v0.9.6
|
||||
*/
|
||||
readonly localPort?: number;
|
||||
/**
|
||||
* The string representation of the local IP family. `'IPv4'` or `'IPv6'`.
|
||||
* @since v18.8.0, v16.18.0
|
||||
*/
|
||||
readonly localFamily?: string;
|
||||
/**
|
||||
* This property represents the state of the connection as a string.
|
||||
*
|
||||
* * If the stream is connecting `socket.readyState` is `opening`.
|
||||
* * If the stream is readable and writable, it is `open`.
|
||||
* * If the stream is readable and not writable, it is `readOnly`.
|
||||
* * If the stream is not readable and writable, it is `writeOnly`.
|
||||
* @since v0.5.0
|
||||
*/
|
||||
readonly readyState: SocketReadyState;
|
||||
/**
|
||||
* The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if
|
||||
* the socket is destroyed (for example, if the client disconnected).
|
||||
* @since v0.5.10
|
||||
*/
|
||||
readonly remoteAddress?: string | undefined;
|
||||
/**
|
||||
* The string representation of the remote IP family. `'IPv4'` or `'IPv6'`. Value may be `undefined` if
|
||||
* the socket is destroyed (for example, if the client disconnected).
|
||||
* @since v0.11.14
|
||||
*/
|
||||
readonly remoteFamily?: string | undefined;
|
||||
/**
|
||||
* The numeric representation of the remote port. For example, `80` or `21`. Value may be `undefined` if
|
||||
* the socket is destroyed (for example, if the client disconnected).
|
||||
* @since v0.5.10
|
||||
*/
|
||||
readonly remotePort?: number | undefined;
|
||||
/**
|
||||
* The socket timeout in milliseconds as set by `socket.setTimeout()`.
|
||||
* It is `undefined` if a timeout has not been set.
|
||||
* @since v10.7.0
|
||||
*/
|
||||
readonly timeout?: 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='utf8'] Only used when data is `string`.
|
||||
* @param callback Optional callback for when the socket is finished.
|
||||
* @return The socket itself.
|
||||
*/
|
||||
end(callback?: () => void): this;
|
||||
end(buffer: Uint8Array | string, callback?: () => void): this;
|
||||
end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this;
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. close
|
||||
* 2. connect
|
||||
* 3. data
|
||||
* 4. drain
|
||||
* 5. end
|
||||
* 6. error
|
||||
* 7. lookup
|
||||
* 8. ready
|
||||
* 9. timeout
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: "close", listener: (hadError: boolean) => void): this;
|
||||
addListener(event: "connect", listener: () => void): this;
|
||||
addListener(event: "data", listener: (data: Buffer) => void): this;
|
||||
addListener(event: "drain", listener: () => void): this;
|
||||
addListener(event: "end", listener: () => void): this;
|
||||
addListener(event: "error", listener: (err: Error) => void): this;
|
||||
addListener(
|
||||
event: "lookup",
|
||||
listener: (err: Error, address: string, family: string | number, host: string) => void,
|
||||
): this;
|
||||
addListener(event: "ready", listener: () => void): this;
|
||||
addListener(event: "timeout", listener: () => void): this;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: "close", hadError: boolean): boolean;
|
||||
emit(event: "connect"): boolean;
|
||||
emit(event: "data", data: Buffer): boolean;
|
||||
emit(event: "drain"): boolean;
|
||||
emit(event: "end"): boolean;
|
||||
emit(event: "error", err: Error): boolean;
|
||||
emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean;
|
||||
emit(event: "ready"): boolean;
|
||||
emit(event: "timeout"): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: "close", listener: (hadError: boolean) => void): this;
|
||||
on(event: "connect", listener: () => void): this;
|
||||
on(event: "data", listener: (data: Buffer) => void): this;
|
||||
on(event: "drain", listener: () => void): this;
|
||||
on(event: "end", listener: () => void): this;
|
||||
on(event: "error", listener: (err: Error) => void): this;
|
||||
on(
|
||||
event: "lookup",
|
||||
listener: (err: Error, address: string, family: string | number, host: string) => void,
|
||||
): this;
|
||||
on(event: "ready", listener: () => void): this;
|
||||
on(event: "timeout", listener: () => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: "close", listener: (hadError: boolean) => void): this;
|
||||
once(event: "connect", listener: () => void): this;
|
||||
once(event: "data", listener: (data: Buffer) => void): this;
|
||||
once(event: "drain", listener: () => void): this;
|
||||
once(event: "end", listener: () => void): this;
|
||||
once(event: "error", listener: (err: Error) => void): this;
|
||||
once(
|
||||
event: "lookup",
|
||||
listener: (err: Error, address: string, family: string | number, host: string) => void,
|
||||
): this;
|
||||
once(event: "ready", listener: () => void): this;
|
||||
once(event: "timeout", listener: () => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "close", listener: (hadError: boolean) => void): this;
|
||||
prependListener(event: "connect", listener: () => void): this;
|
||||
prependListener(event: "data", listener: (data: Buffer) => void): this;
|
||||
prependListener(event: "drain", listener: () => void): this;
|
||||
prependListener(event: "end", listener: () => void): this;
|
||||
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependListener(
|
||||
event: "lookup",
|
||||
listener: (err: Error, address: string, family: string | number, host: string) => void,
|
||||
): this;
|
||||
prependListener(event: "ready", listener: () => void): this;
|
||||
prependListener(event: "timeout", listener: () => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "close", listener: (hadError: boolean) => void): this;
|
||||
prependOnceListener(event: "connect", listener: () => void): this;
|
||||
prependOnceListener(event: "data", listener: (data: Buffer) => void): this;
|
||||
prependOnceListener(event: "drain", listener: () => void): this;
|
||||
prependOnceListener(event: "end", listener: () => void): this;
|
||||
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependOnceListener(
|
||||
event: "lookup",
|
||||
listener: (err: Error, address: string, family: string | number, host: string) => void,
|
||||
): this;
|
||||
prependOnceListener(event: "ready", listener: () => void): this;
|
||||
prependOnceListener(event: "timeout", listener: () => void): this;
|
||||
}
|
||||
interface ListenOptions extends Abortable {
|
||||
port?: number | undefined;
|
||||
host?: string | undefined;
|
||||
backlog?: number | undefined;
|
||||
path?: string | undefined;
|
||||
exclusive?: boolean | undefined;
|
||||
readableAll?: boolean | undefined;
|
||||
writableAll?: boolean | undefined;
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
ipv6Only?: boolean | undefined;
|
||||
}
|
||||
interface ServerOpts {
|
||||
/**
|
||||
* Indicates whether half-opened TCP connections are allowed.
|
||||
* @default false
|
||||
*/
|
||||
allowHalfOpen?: boolean | undefined;
|
||||
/**
|
||||
* Indicates whether the socket should be paused on incoming connections.
|
||||
* @default false
|
||||
*/
|
||||
pauseOnConnect?: boolean | undefined;
|
||||
/**
|
||||
* If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received.
|
||||
* @default false
|
||||
* @since v16.5.0
|
||||
*/
|
||||
noDelay?: boolean | undefined;
|
||||
/**
|
||||
* If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
|
||||
* similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`.
|
||||
* @default false
|
||||
* @since v16.5.0
|
||||
*/
|
||||
keepAlive?: boolean | undefined;
|
||||
/**
|
||||
* If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket.
|
||||
* @default 0
|
||||
* @since v16.5.0
|
||||
*/
|
||||
keepAliveInitialDelay?: number | undefined;
|
||||
}
|
||||
interface DropArgument {
|
||||
localAddress?: string;
|
||||
localPort?: number;
|
||||
localFamily?: string;
|
||||
remoteAddress?: string;
|
||||
remotePort?: number;
|
||||
remoteFamily?: string;
|
||||
}
|
||||
/**
|
||||
* 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(options?: ServerOpts, 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.error('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, listeningListener?: () => void): this;
|
||||
listen(port?: number, backlog?: number, listeningListener?: () => void): this;
|
||||
listen(port?: number, listeningListener?: () => void): this;
|
||||
listen(path: string, backlog?: number, listeningListener?: () => void): this;
|
||||
listen(path: string, listeningListener?: () => void): this;
|
||||
listen(options: ListenOptions, listeningListener?: () => void): this;
|
||||
listen(handle: any, backlog?: number, 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;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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;
|
||||
connections: number;
|
||||
/**
|
||||
* Indicates whether or not the server is listening for connections.
|
||||
* @since v5.7.0
|
||||
*/
|
||||
listening: boolean;
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. close
|
||||
* 2. connection
|
||||
* 3. error
|
||||
* 4. listening
|
||||
* 5. drop
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: "close", listener: () => void): this;
|
||||
addListener(event: "connection", listener: (socket: Socket) => void): this;
|
||||
addListener(event: "error", listener: (err: Error) => void): this;
|
||||
addListener(event: "listening", listener: () => void): this;
|
||||
addListener(event: "drop", listener: (data?: DropArgument) => void): this;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: "close"): boolean;
|
||||
emit(event: "connection", socket: Socket): boolean;
|
||||
emit(event: "error", err: Error): boolean;
|
||||
emit(event: "listening"): boolean;
|
||||
emit(event: "drop", data?: DropArgument): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: "close", listener: () => void): this;
|
||||
on(event: "connection", listener: (socket: Socket) => void): this;
|
||||
on(event: "error", listener: (err: Error) => void): this;
|
||||
on(event: "listening", listener: () => void): this;
|
||||
on(event: "drop", listener: (data?: DropArgument) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: "close", listener: () => void): this;
|
||||
once(event: "connection", listener: (socket: Socket) => void): this;
|
||||
once(event: "error", listener: (err: Error) => void): this;
|
||||
once(event: "listening", listener: () => void): this;
|
||||
once(event: "drop", listener: (data?: DropArgument) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
prependListener(event: "connection", listener: (socket: Socket) => void): this;
|
||||
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependListener(event: "listening", listener: () => void): this;
|
||||
prependListener(event: "drop", listener: (data?: DropArgument) => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
|
||||
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: "listening", listener: () => void): this;
|
||||
prependOnceListener(event: "drop", listener: (data?: DropArgument) => void): this;
|
||||
/**
|
||||
* Calls {@link Server.close()} and returns a promise that fulfills when the server has closed.
|
||||
* @since v20.5.0
|
||||
*/
|
||||
[Symbol.asyncDispose](): Promise<void>;
|
||||
}
|
||||
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, v14.18.0
|
||||
*/
|
||||
class BlockList {
|
||||
/**
|
||||
* Adds a rule to block the given IP address.
|
||||
* @since v15.0.0, v14.18.0
|
||||
* @param address An IPv4 or IPv6 address.
|
||||
* @param [type='ipv4'] 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, v14.18.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='ipv4'] 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, v14.18.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='ipv4'] 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, v14.18.0
|
||||
* @param address The IP address to check
|
||||
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
||||
*/
|
||||
check(address: SocketAddress): boolean;
|
||||
check(address: string, type?: IPVersion): boolean;
|
||||
}
|
||||
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
|
||||
timeout?: number | undefined;
|
||||
}
|
||||
interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
|
||||
timeout?: number | undefined;
|
||||
}
|
||||
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 a TCP echo server which listens for connections
|
||||
* on port 8124:
|
||||
*
|
||||
* ```js
|
||||
* const net = require('node: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`:
|
||||
*
|
||||
* ```bash
|
||||
* 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:
|
||||
*
|
||||
* ```bash
|
||||
* 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(options?: ServerOpts, 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(port: number, host?: 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(port: number, host?: string, connectionListener?: () => void): Socket;
|
||||
function createConnection(path: string, connectionListener?: () => void): Socket;
|
||||
/**
|
||||
* Gets the current default value of the `autoSelectFamily` option of `socket.connect(options)`.
|
||||
* The initial default value is `true`, unless the command line option`--no-network-family-autoselection` is provided.
|
||||
* @since v19.4.0
|
||||
*/
|
||||
function getDefaultAutoSelectFamily(): boolean;
|
||||
/**
|
||||
* Sets the default value of the `autoSelectFamily` option of `socket.connect(options)`.
|
||||
* @since v19.4.0
|
||||
*/
|
||||
function setDefaultAutoSelectFamily(value: boolean): void;
|
||||
/**
|
||||
* Gets the current default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`.
|
||||
* The initial default value is `250`.
|
||||
* @since v19.8.0
|
||||
*/
|
||||
function getDefaultAutoSelectFamilyAttemptTimeout(): number;
|
||||
/**
|
||||
* Sets the default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`.
|
||||
* @since v19.8.0
|
||||
*/
|
||||
function setDefaultAutoSelectFamilyAttemptTimeout(value: number): void;
|
||||
/**
|
||||
* Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4
|
||||
* address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no leading zeroes. Otherwise, returns`0`.
|
||||
*
|
||||
* ```js
|
||||
* net.isIP('::1'); // returns 6
|
||||
* net.isIP('127.0.0.1'); // returns 4
|
||||
* net.isIP('127.000.000.001'); // returns 0
|
||||
* net.isIP('127.0.0.1/24'); // returns 0
|
||||
* net.isIP('fhqwhgads'); // returns 0
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
*/
|
||||
function isIP(input: string): number;
|
||||
/**
|
||||
* Returns `true` if `input` is an IPv4 address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no
|
||||
* leading zeroes. Otherwise, returns `false`.
|
||||
*
|
||||
* ```js
|
||||
* net.isIPv4('127.0.0.1'); // returns true
|
||||
* net.isIPv4('127.000.000.001'); // returns false
|
||||
* net.isIPv4('127.0.0.1/24'); // returns false
|
||||
* net.isIPv4('fhqwhgads'); // returns false
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
*/
|
||||
function isIPv4(input: string): boolean;
|
||||
/**
|
||||
* Returns `true` if `input` is an IPv6 address. Otherwise, returns `false`.
|
||||
*
|
||||
* ```js
|
||||
* net.isIPv6('::1'); // returns true
|
||||
* net.isIPv6('fhqwhgads'); // returns false
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
*/
|
||||
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, v14.18.0
|
||||
*/
|
||||
class SocketAddress {
|
||||
constructor(options: SocketAddressInitOptions);
|
||||
/**
|
||||
* Either \`'ipv4'\` or \`'ipv6'\`.
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
readonly address: string;
|
||||
/**
|
||||
* Either \`'ipv4'\` or \`'ipv6'\`.
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
readonly family: IPVersion;
|
||||
/**
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
readonly port: number;
|
||||
/**
|
||||
* @since v15.14.0, v14.18.0
|
||||
*/
|
||||
readonly flowlabel: number;
|
||||
}
|
||||
}
|
||||
declare module "node:net" {
|
||||
export * from "net";
|
||||
}
|
||||
477
node_modules/@types/node/ts4.8/os.d.ts
generated
vendored
477
node_modules/@types/node/ts4.8/os.d.ts
generated
vendored
@@ -1,477 +0,0 @@
|
||||
/**
|
||||
* The `node:os` module provides operating system-related utility methods and
|
||||
* properties. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const os = require('node:os');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/os.js)
|
||||
*/
|
||||
declare module "os" {
|
||||
interface CpuInfo {
|
||||
model: string;
|
||||
speed: number;
|
||||
times: {
|
||||
user: number;
|
||||
nice: number;
|
||||
sys: number;
|
||||
idle: number;
|
||||
irq: number;
|
||||
};
|
||||
}
|
||||
interface NetworkInterfaceBase {
|
||||
address: string;
|
||||
netmask: string;
|
||||
mac: string;
|
||||
internal: boolean;
|
||||
cidr: string | null;
|
||||
}
|
||||
interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
|
||||
family: "IPv4";
|
||||
scopeid?: undefined;
|
||||
}
|
||||
interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
|
||||
family: "IPv6";
|
||||
scopeid: number;
|
||||
}
|
||||
interface UserInfo<T> {
|
||||
username: T;
|
||||
uid: number;
|
||||
gid: number;
|
||||
shell: T | null;
|
||||
homedir: T;
|
||||
}
|
||||
type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;
|
||||
/**
|
||||
* Returns the host name of the operating system as a string.
|
||||
* @since v0.3.3
|
||||
*/
|
||||
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[];
|
||||
/**
|
||||
* Returns the system uptime in number of seconds.
|
||||
* @since v0.3.3
|
||||
*/
|
||||
function uptime(): number;
|
||||
/**
|
||||
* Returns the amount of free system memory in bytes as an integer.
|
||||
* @since v0.3.3
|
||||
*/
|
||||
function freemem(): number;
|
||||
/**
|
||||
* Returns the total amount of system memory in bytes as an integer.
|
||||
* @since v0.3.3
|
||||
*/
|
||||
function totalmem(): number;
|
||||
/**
|
||||
* Returns an array of objects containing information about each logical CPU core.
|
||||
* The array will be empty if no CPU information is available, such as if the`/proc` file system is unavailable.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* `os.cpus().length` should not be used to calculate the amount of parallelism
|
||||
* available to an application. Use {@link availableParallelism} for this purpose.
|
||||
* @since v0.3.3
|
||||
*/
|
||||
function cpus(): CpuInfo[];
|
||||
/**
|
||||
* Returns an estimate of the default amount of parallelism a program should use.
|
||||
* Always returns a value greater than zero.
|
||||
*
|
||||
* This function is a small wrapper about libuv's [`uv_available_parallelism()`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_available_parallelism).
|
||||
* @since v19.4.0, v18.14.0
|
||||
*/
|
||||
function availableParallelism(): number;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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: BufferEncoding }): UserInfo<string>;
|
||||
type SignalConstants = {
|
||||
[key in NodeJS.Signals]: number;
|
||||
};
|
||||
namespace constants {
|
||||
const UV_UDP_REUSEADDR: number;
|
||||
namespace signals {}
|
||||
const signals: SignalConstants;
|
||||
namespace errno {
|
||||
const E2BIG: number;
|
||||
const EACCES: number;
|
||||
const EADDRINUSE: number;
|
||||
const EADDRNOTAVAIL: number;
|
||||
const EAFNOSUPPORT: number;
|
||||
const EAGAIN: number;
|
||||
const EALREADY: number;
|
||||
const EBADF: number;
|
||||
const EBADMSG: number;
|
||||
const EBUSY: number;
|
||||
const ECANCELED: number;
|
||||
const ECHILD: number;
|
||||
const ECONNABORTED: number;
|
||||
const ECONNREFUSED: number;
|
||||
const ECONNRESET: number;
|
||||
const EDEADLK: number;
|
||||
const EDESTADDRREQ: number;
|
||||
const EDOM: number;
|
||||
const EDQUOT: number;
|
||||
const EEXIST: number;
|
||||
const EFAULT: number;
|
||||
const EFBIG: number;
|
||||
const EHOSTUNREACH: number;
|
||||
const EIDRM: number;
|
||||
const EILSEQ: number;
|
||||
const EINPROGRESS: number;
|
||||
const EINTR: number;
|
||||
const EINVAL: number;
|
||||
const EIO: number;
|
||||
const EISCONN: number;
|
||||
const EISDIR: number;
|
||||
const ELOOP: number;
|
||||
const EMFILE: number;
|
||||
const EMLINK: number;
|
||||
const EMSGSIZE: number;
|
||||
const EMULTIHOP: number;
|
||||
const ENAMETOOLONG: number;
|
||||
const ENETDOWN: number;
|
||||
const ENETRESET: number;
|
||||
const ENETUNREACH: number;
|
||||
const ENFILE: number;
|
||||
const ENOBUFS: number;
|
||||
const ENODATA: number;
|
||||
const ENODEV: number;
|
||||
const ENOENT: number;
|
||||
const ENOEXEC: number;
|
||||
const ENOLCK: number;
|
||||
const ENOLINK: number;
|
||||
const ENOMEM: number;
|
||||
const ENOMSG: number;
|
||||
const ENOPROTOOPT: number;
|
||||
const ENOSPC: number;
|
||||
const ENOSR: number;
|
||||
const ENOSTR: number;
|
||||
const ENOSYS: number;
|
||||
const ENOTCONN: number;
|
||||
const ENOTDIR: number;
|
||||
const ENOTEMPTY: number;
|
||||
const ENOTSOCK: number;
|
||||
const ENOTSUP: number;
|
||||
const ENOTTY: number;
|
||||
const ENXIO: number;
|
||||
const EOPNOTSUPP: number;
|
||||
const EOVERFLOW: number;
|
||||
const EPERM: number;
|
||||
const EPIPE: number;
|
||||
const EPROTO: number;
|
||||
const EPROTONOSUPPORT: number;
|
||||
const EPROTOTYPE: number;
|
||||
const ERANGE: number;
|
||||
const EROFS: number;
|
||||
const ESPIPE: number;
|
||||
const ESRCH: number;
|
||||
const ESTALE: number;
|
||||
const ETIME: number;
|
||||
const ETIMEDOUT: number;
|
||||
const ETXTBSY: number;
|
||||
const EWOULDBLOCK: number;
|
||||
const EXDEV: number;
|
||||
const WSAEINTR: number;
|
||||
const WSAEBADF: number;
|
||||
const WSAEACCES: number;
|
||||
const WSAEFAULT: number;
|
||||
const WSAEINVAL: number;
|
||||
const WSAEMFILE: number;
|
||||
const WSAEWOULDBLOCK: number;
|
||||
const WSAEINPROGRESS: number;
|
||||
const WSAEALREADY: number;
|
||||
const WSAENOTSOCK: number;
|
||||
const WSAEDESTADDRREQ: number;
|
||||
const WSAEMSGSIZE: number;
|
||||
const WSAEPROTOTYPE: number;
|
||||
const WSAENOPROTOOPT: number;
|
||||
const WSAEPROTONOSUPPORT: number;
|
||||
const WSAESOCKTNOSUPPORT: number;
|
||||
const WSAEOPNOTSUPP: number;
|
||||
const WSAEPFNOSUPPORT: number;
|
||||
const WSAEAFNOSUPPORT: number;
|
||||
const WSAEADDRINUSE: number;
|
||||
const WSAEADDRNOTAVAIL: number;
|
||||
const WSAENETDOWN: number;
|
||||
const WSAENETUNREACH: number;
|
||||
const WSAENETRESET: number;
|
||||
const WSAECONNABORTED: number;
|
||||
const WSAECONNRESET: number;
|
||||
const WSAENOBUFS: number;
|
||||
const WSAEISCONN: number;
|
||||
const WSAENOTCONN: number;
|
||||
const WSAESHUTDOWN: number;
|
||||
const WSAETOOMANYREFS: number;
|
||||
const WSAETIMEDOUT: number;
|
||||
const WSAECONNREFUSED: number;
|
||||
const WSAELOOP: number;
|
||||
const WSAENAMETOOLONG: number;
|
||||
const WSAEHOSTDOWN: number;
|
||||
const WSAEHOSTUNREACH: number;
|
||||
const WSAENOTEMPTY: number;
|
||||
const WSAEPROCLIM: number;
|
||||
const WSAEUSERS: number;
|
||||
const WSAEDQUOT: number;
|
||||
const WSAESTALE: number;
|
||||
const WSAEREMOTE: number;
|
||||
const WSASYSNOTREADY: number;
|
||||
const WSAVERNOTSUPPORTED: number;
|
||||
const WSANOTINITIALISED: number;
|
||||
const WSAEDISCON: number;
|
||||
const WSAENOMORE: number;
|
||||
const WSAECANCELLED: number;
|
||||
const WSAEINVALIDPROCTABLE: number;
|
||||
const WSAEINVALIDPROVIDER: number;
|
||||
const WSAEPROVIDERFAILEDINIT: number;
|
||||
const WSASYSCALLFAILURE: number;
|
||||
const WSASERVICE_NOT_FOUND: number;
|
||||
const WSATYPE_NOT_FOUND: number;
|
||||
const WSA_E_NO_MORE: number;
|
||||
const WSA_E_CANCELLED: number;
|
||||
const WSAEREFUSED: 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'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`.
|
||||
*
|
||||
* The return value is equivalent to `process.arch`.
|
||||
* @since v0.5.0
|
||||
*/
|
||||
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 for which
|
||||
* the Node.js binary was compiled. 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;
|
||||
/**
|
||||
* Returns the machine type as a string, such as `arm`, `arm64`, `aarch64`,`mips`, `mips64`, `ppc64`, `ppc64le`, `s390`, `s390x`, `i386`, `i686`, `x86_64`.
|
||||
*
|
||||
* On POSIX systems, the machine type 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 v18.9.0, v16.18.0
|
||||
*/
|
||||
function machine(): string;
|
||||
/**
|
||||
* Returns the operating system's default directory for temporary files as a
|
||||
* string.
|
||||
* @since v0.9.9
|
||||
*/
|
||||
function tmpdir(): string;
|
||||
/**
|
||||
* Returns a string identifying the endianness of the CPU for which the Node.js
|
||||
* binary was compiled.
|
||||
*
|
||||
* 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=0] The process ID to retrieve scheduling priority for.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* 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=0] 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(pid: number, priority: number): void;
|
||||
}
|
||||
declare module "node:os" {
|
||||
export * from "os";
|
||||
}
|
||||
191
node_modules/@types/node/ts4.8/path.d.ts
generated
vendored
191
node_modules/@types/node/ts4.8/path.d.ts
generated
vendored
@@ -1,191 +0,0 @@
|
||||
declare module "path/posix" {
|
||||
import path = require("path");
|
||||
export = path;
|
||||
}
|
||||
declare module "path/win32" {
|
||||
import path = require("path");
|
||||
export = path;
|
||||
}
|
||||
/**
|
||||
* The `node:path` module provides utilities for working with file and directory
|
||||
* paths. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const path = require('node:path');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/path.js)
|
||||
*/
|
||||
declare module "path" {
|
||||
namespace path {
|
||||
/**
|
||||
* A parsed path object generated by path.parse() or consumed by path.format().
|
||||
*/
|
||||
interface ParsedPath {
|
||||
/**
|
||||
* The root of the path such as '/' or 'c:\'
|
||||
*/
|
||||
root: string;
|
||||
/**
|
||||
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
|
||||
*/
|
||||
dir: string;
|
||||
/**
|
||||
* The file name including extension (if any) such as 'index.html'
|
||||
*/
|
||||
base: string;
|
||||
/**
|
||||
* The file extension (if any) such as '.html'
|
||||
*/
|
||||
ext: string;
|
||||
/**
|
||||
* The file name without extension (if any) such as 'index'
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
interface FormatInputPathObject {
|
||||
/**
|
||||
* The root of the path such as '/' or 'c:\'
|
||||
*/
|
||||
root?: string | undefined;
|
||||
/**
|
||||
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
|
||||
*/
|
||||
dir?: string | undefined;
|
||||
/**
|
||||
* The file name including extension (if any) such as 'index.html'
|
||||
*/
|
||||
base?: string | undefined;
|
||||
/**
|
||||
* The file extension (if any) such as '.html'
|
||||
*/
|
||||
ext?: string | undefined;
|
||||
/**
|
||||
* The file name without extension (if any) such as 'index'
|
||||
*/
|
||||
name?: string | undefined;
|
||||
}
|
||||
interface PlatformPath {
|
||||
/**
|
||||
* Normalize a string path, reducing '..' and '.' parts.
|
||||
* When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
|
||||
*
|
||||
* @param path string path to normalize.
|
||||
* @throws {TypeError} if `path` is not a string.
|
||||
*/
|
||||
normalize(path: string): string;
|
||||
/**
|
||||
* Join all arguments together and normalize the resulting path.
|
||||
*
|
||||
* @param paths paths to join.
|
||||
* @throws {TypeError} if any of the path segments is not a string.
|
||||
*/
|
||||
join(...paths: string[]): string;
|
||||
/**
|
||||
* The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
|
||||
*
|
||||
* Starting from leftmost {from} parameter, resolves {to} to an absolute path.
|
||||
*
|
||||
* If {to} isn't already absolute, {from} arguments are prepended in right to left order,
|
||||
* until an absolute path is found. If after using all {from} paths still no absolute path is found,
|
||||
* the current working directory is used as well. The resulting path is normalized,
|
||||
* and trailing slashes are removed unless the path gets resolved to the root directory.
|
||||
*
|
||||
* @param paths A sequence of paths or path segments.
|
||||
* @throws {TypeError} if any of the arguments is not a string.
|
||||
*/
|
||||
resolve(...paths: string[]): string;
|
||||
/**
|
||||
* Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
|
||||
*
|
||||
* If the given {path} is a zero-length string, `false` will be returned.
|
||||
*
|
||||
* @param path path to test.
|
||||
* @throws {TypeError} if `path` is not a string.
|
||||
*/
|
||||
isAbsolute(path: string): boolean;
|
||||
/**
|
||||
* Solve the relative path from {from} to {to} based on the current working directory.
|
||||
* 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.
|
||||
*
|
||||
* @throws {TypeError} if either `from` or `to` is not a string.
|
||||
*/
|
||||
relative(from: string, to: string): string;
|
||||
/**
|
||||
* Return the directory name of a path. Similar to the Unix dirname command.
|
||||
*
|
||||
* @param path the path to evaluate.
|
||||
* @throws {TypeError} if `path` is not a string.
|
||||
*/
|
||||
dirname(path: string): string;
|
||||
/**
|
||||
* Return the last portion of a path. Similar to the Unix basename command.
|
||||
* Often used to extract the file name from a fully qualified path.
|
||||
*
|
||||
* @param path the path to evaluate.
|
||||
* @param suffix optionally, an extension to remove from the result.
|
||||
* @throws {TypeError} if `path` is not a string or if `ext` is given and is not a string.
|
||||
*/
|
||||
basename(path: string, suffix?: string): string;
|
||||
/**
|
||||
* Return the extension of the path, from the last '.' to end of string in the last portion of the path.
|
||||
* If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string.
|
||||
*
|
||||
* @param path the path to evaluate.
|
||||
* @throws {TypeError} if `path` is not a string.
|
||||
*/
|
||||
extname(path: string): string;
|
||||
/**
|
||||
* The platform-specific file separator. '\\' or '/'.
|
||||
*/
|
||||
readonly sep: "\\" | "/";
|
||||
/**
|
||||
* The platform-specific file delimiter. ';' or ':'.
|
||||
*/
|
||||
readonly delimiter: ";" | ":";
|
||||
/**
|
||||
* Returns an object from a path string - the opposite of format().
|
||||
*
|
||||
* @param path path to evaluate.
|
||||
* @throws {TypeError} if `path` is not a string.
|
||||
*/
|
||||
parse(path: string): ParsedPath;
|
||||
/**
|
||||
* Returns a path string from an object - the opposite of parse().
|
||||
*
|
||||
* @param pathObject path to evaluate.
|
||||
*/
|
||||
format(pathObject: FormatInputPathObject): string;
|
||||
/**
|
||||
* On Windows systems only, returns an equivalent namespace-prefixed path for the given path.
|
||||
* If path is not a string, path will be returned without modifications.
|
||||
* This method is meaningful only on Windows system.
|
||||
* On POSIX systems, the method is non-operational and always returns path without modifications.
|
||||
*/
|
||||
toNamespacedPath(path: string): string;
|
||||
/**
|
||||
* Posix specific pathing.
|
||||
* Same as parent object on posix.
|
||||
*/
|
||||
readonly posix: PlatformPath;
|
||||
/**
|
||||
* Windows specific pathing.
|
||||
* Same as parent object on windows
|
||||
*/
|
||||
readonly win32: PlatformPath;
|
||||
}
|
||||
}
|
||||
const path: path.PlatformPath;
|
||||
export = path;
|
||||
}
|
||||
declare module "node:path" {
|
||||
import path = require("path");
|
||||
export = path;
|
||||
}
|
||||
declare module "node:path/posix" {
|
||||
import path = require("path/posix");
|
||||
export = path;
|
||||
}
|
||||
declare module "node:path/win32" {
|
||||
import path = require("path/win32");
|
||||
export = path;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user