added stuff to arrays
This commit is contained in:
parent
4f2987c4bf
commit
ef4a4637dd
475 changed files with 86862 additions and 7052 deletions
BIN
eng.traineddata
Normal file
BIN
eng.traineddata
Normal file
Binary file not shown.
11
index.js
11
index.js
|
@ -5,7 +5,9 @@ const {
|
|||
} = require('discord.js');
|
||||
|
||||
const Tesseract = require('tesseract.js');
|
||||
const badWords = ["fuck", "shit", "dumbass", "bitch", "nigg", "penis", "pussy", "damn", "puto", "cunt", "dyke", "fag", "beaner", "fvck", "milf", "dilf", "dick", "beaney", "gypsy", "bong", "chink", "cholo", "danm", "gyp", "injun", "jigaboo", "jigger", "negro", "whore", "slut", "redskin", "cooter", "vagina", "squaw", "twink", "shemale", "cripple", "midget", "kike"];
|
||||
const badWords = ["fuck", "shit", "dumbass", "bitch", "nigg", "penis", "pussy", "damn", "puto", "cunt", "dyke", "fag", "beaner", "fvck", "milf", "dilf", "dick", "beaney", "gypsy", "bong", "chink", "cholo", "danm", "gyp", "injun", "jigaboo", "jigger", "negro", "whore", "slut", "redskin", "cooter", "vagina", "squaw", "twink", "shemale", "cripple", "midget", "kike", "hell"];
|
||||
const potentialBadWords = ["tit", "cock", "ass"]
|
||||
const whitelist = ["title", "class", "grass", "glass", "pass", "assembly", "assemblies", "assume", "titan", "ambassador"]
|
||||
|
||||
const bot = new Client({
|
||||
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_MESSAGES]
|
||||
|
@ -41,14 +43,13 @@ bot.on('messageCreate', (message) => {
|
|||
}
|
||||
else {
|
||||
usermessage = message.content.toLowerCase();
|
||||
console.log("No image detected");
|
||||
}
|
||||
if (message.author.bot) {
|
||||
return;
|
||||
}
|
||||
else if(badWords.some(word => usermessage.includes(word))){
|
||||
const sender = `${message.author} sent the following message...`
|
||||
const modchat = '510189494809526283';
|
||||
const modchat = '1148137602944352347';
|
||||
const techwizz = ` <@331669618387058688> `;
|
||||
message.channel.send('Hey! Please keep your language school appropriate... If I deleted your message by mistake, please contact' + techwizz + 'or wait for him to see it then he will fix it.');
|
||||
message.delete();
|
||||
|
@ -67,8 +68,8 @@ bot.on('messageCreate', (message) => {
|
|||
else if(usermessage.includes("that's pretty neat")){
|
||||
message.channel.send('how neat is that?');
|
||||
}
|
||||
else if(usermessage.includes('tit') || usermessage.includes('cock') || usermessage.includes('ass')){
|
||||
if (usermessage.includes('title') || usermessage.includes('class') || usermessage.includes('grass') || usermessage.includes('glass') || usermessage.includes('pass') || usermessage.includes('assembly') || usermessage.includes('assemblies') || usermessage.includes('assume') || usermessage.includes('titan') || usermessage.includes('ambassador')){ //These are not bad words and will be bypassed
|
||||
else if(potentialBadWords.some(word => usermessage.includes(word))){
|
||||
if (whitelist.some(word => usermessage.includes(word))){ //These are not bad words and will be bypassed
|
||||
return;
|
||||
}
|
||||
const techwizz = `<@331669618387058688> `;
|
||||
|
|
1
node_modules/.bin/opencollective-postinstall
generated
vendored
Symbolic link
1
node_modules/.bin/opencollective-postinstall
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../opencollective-postinstall/index.js
|
162
node_modules/.package-lock.json
generated
vendored
162
node_modules/.package-lock.json
generated
vendored
|
@ -1,13 +1,14 @@
|
|||
{
|
||||
"name": "browntown",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/@discordjs/builders": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.11.0.tgz",
|
||||
"integrity": "sha512-ZTB8yJdJKrKlq44dpWkNUrAtEJEq0gqpb7ASdv4vmq6/mZal5kOv312hQ56I/vxwMre+VIkoHquNUAfnTbiYtg==",
|
||||
"deprecated": "no longer supported",
|
||||
"dependencies": {
|
||||
"@sindresorhus/is": "^4.2.0",
|
||||
"discord-api-types": "^0.26.0",
|
||||
|
@ -24,24 +25,25 @@
|
|||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.4.0.tgz",
|
||||
"integrity": "sha512-zmjq+l/rV35kE6zRrwe8BHqV78JvIh2ybJeZavBi5NySjWXqN3hmmAKg7kYMMXSeiWtSsMoZ/+MQi0DiQWy2lw==",
|
||||
"deprecated": "no longer supported",
|
||||
"engines": {
|
||||
"node": ">=16.0.0",
|
||||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@sapphire/async-queue": {
|
||||
"version": "1.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.1.9.tgz",
|
||||
"integrity": "sha512-CbXaGwwlEMq+l1TRu01FJCvySJ1CEFKFclHT48nIfNeZXaAAmmwwy7scUKmYHPUa3GhoMp6Qr1B3eAJux6XgOQ==",
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.0.tgz",
|
||||
"integrity": "sha512-JkLdIsP8fPAdh9ZZjrbHWR/+mZj0wvKS5ICibcLrRI1j84UmLMshx5n9QmL8b95d4onJ2xxiyugTgSAX7AalmA==",
|
||||
"engines": {
|
||||
"node": ">=v14.0.0",
|
||||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@sindresorhus/is": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.1.tgz",
|
||||
"integrity": "sha512-BrzrgtaqEre0qfvI8sMTaEvx+bayuhPmfe2rfeUGPPHYr/PLxCOqkOe4TQTDPb+qcqgNcsAtXV/Ew74mcDIE8w==",
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz",
|
||||
"integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
|
@ -50,14 +52,14 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "17.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.8.tgz",
|
||||
"integrity": "sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg=="
|
||||
"version": "20.5.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.9.tgz",
|
||||
"integrity": "sha512-PcGNd//40kHAS3sTlzKB9C9XL4K0sTup8nbG5lC14kzEteTNuAFh9u5nA0o5TWnSG2r/JNPRXFVcHJIIeRlmqQ=="
|
||||
},
|
||||
"node_modules/@types/node-fetch": {
|
||||
"version": "2.5.12",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.12.tgz",
|
||||
"integrity": "sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==",
|
||||
"version": "2.6.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.4.tgz",
|
||||
"integrity": "sha512-1ZX9fcN4Rvkvgv4E6PAY5WXUFWFcRWxZa3EW83UjycOB9ljJCedb2CupIP4RZMEwF/M3eTcCihbBRgwtGbg5Rg==",
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"form-data": "^3.0.0"
|
||||
|
@ -77,9 +79,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@types/ws": {
|
||||
"version": "8.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz",
|
||||
"integrity": "sha512-NOn5eIcgWLOo6qW8AcuLZ7G8PycXu0xTxxkS6Q18VWFxgPUSOwV0pBj2a/4viNZVu25i7RIB7GttdkAIUUXOOg==",
|
||||
"version": "8.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.5.tgz",
|
||||
"integrity": "sha512-lwhs8hktwxSjf9UaZ9tG5M03PGogvFaH8gUgLNbN9HKIg0dvv6q+gkSuJ8HN4/VbyxkuLzCjlN7GquQ0gUJfIg==",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
|
@ -87,7 +89,7 @@
|
|||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "0.24.0",
|
||||
|
@ -97,6 +99,11 @@
|
|||
"follow-redirects": "^1.14.4"
|
||||
}
|
||||
},
|
||||
"node_modules/bmp-js": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bmp-js/-/bmp-js-0.1.0.tgz",
|
||||
"integrity": "sha512-vHdS19CnY3hwiNdkaqk93DvjVLfbEcI8mys4UjuWrlX1haDmroo8o4xCzh4wD6DGV6HxRCyauwhHRqMTfERtjw=="
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
|
@ -111,7 +118,7 @@
|
|||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
|
@ -128,6 +135,7 @@
|
|||
"version": "13.5.1",
|
||||
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.5.1.tgz",
|
||||
"integrity": "sha512-ejEG5MXzB0eda9Nt+VzqgdvDWVO5U/GynGzq6DRPLaCH1yyn2YRU9J+vCMl77pWA1rzYGX+b/9RI31x0wt3qXA==",
|
||||
"deprecated": "Hard crashes on interactions with a channel in the payload, use 13.14.0 and up",
|
||||
"dependencies": {
|
||||
"@discordjs/builders": "^0.11.0",
|
||||
"@discordjs/collection": "^0.4.0",
|
||||
|
@ -184,50 +192,114 @@
|
|||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/idb-keyval": {
|
||||
"version": "6.2.1",
|
||||
"resolved": "https://registry.npmjs.org/idb-keyval/-/idb-keyval-6.2.1.tgz",
|
||||
"integrity": "sha512-8Sb3veuYCyrZL+VBt9LJfZjLUPWVvqn8tG28VqYNFCo43KHcKuq+b4EiXGeuaLAQWL2YmyDgMp2aSpH9JHsEQg=="
|
||||
},
|
||||
"node_modules/is-electron": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/is-electron/-/is-electron-2.2.2.tgz",
|
||||
"integrity": "sha512-FO/Rhvz5tuw4MCWkpMzHFKWD2LsfHzIb7i6MdPYZ/KW7AlxawyLkqdy+jPZP1WubqEADE3O4FUENlJHDfQASRg=="
|
||||
},
|
||||
"node_modules/is-url": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/is-url/-/is-url-1.2.4.tgz",
|
||||
"integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww=="
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.51.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz",
|
||||
"integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==",
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.34",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz",
|
||||
"integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==",
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dependencies": {
|
||||
"mime-db": "1.51.0"
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.6.6",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.6.tgz",
|
||||
"integrity": "sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==",
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
||||
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/opencollective-postinstall": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz",
|
||||
"integrity": "sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==",
|
||||
"bin": {
|
||||
"opencollective-postinstall": "index.js"
|
||||
}
|
||||
},
|
||||
"node_modules/regenerator-runtime": {
|
||||
"version": "0.13.11",
|
||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
||||
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg=="
|
||||
},
|
||||
"node_modules/tesseract.js": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/tesseract.js/-/tesseract.js-4.1.2.tgz",
|
||||
"integrity": "sha512-riCr/rbwt0siIf/HiC0W2J/6ndbEcRWVZvwTxeDRPgMwP4douBLYq7i4NgMigWAmJea7GA0r3XGLa2GknRYmPA==",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"bmp-js": "^0.1.0",
|
||||
"idb-keyval": "^6.2.0",
|
||||
"is-electron": "^2.2.2",
|
||||
"is-url": "^1.2.4",
|
||||
"node-fetch": "^2.6.9",
|
||||
"opencollective-postinstall": "^2.0.3",
|
||||
"regenerator-runtime": "^0.13.3",
|
||||
"tesseract.js-core": "^4.0.4",
|
||||
"wasm-feature-detect": "^1.2.11",
|
||||
"zlibjs": "^0.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/tesseract.js-core": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/tesseract.js-core/-/tesseract.js-core-4.0.4.tgz",
|
||||
"integrity": "sha512-MJ+vtktjAaT0681uPl6TDUPhbRbpD/S9emko5rtorgHRZpQo7R3BG7h+3pVHgn1KjfNf1bvnx4B7KxEK8YKqpg=="
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
|
||||
},
|
||||
"node_modules/ts-mixer": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.0.tgz",
|
||||
"integrity": "sha512-nXIb1fvdY5CBSrDIblLn73NW0qRDk5yJ0Sk1qPBF560OdJfQp9jhl+0tzcY09OZ9U+6GpeoI9RjwoIKFIoB9MQ=="
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.3.tgz",
|
||||
"integrity": "sha512-k43M7uCG1AkTyxgnmI5MPwKoUvS/bRvLvUb7+Pgpdlmok8AoqmUaZxUUw8zKM5B1lqZrt41GjYgnvAi0fppqgQ=="
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
||||
},
|
||||
"node_modules/wasm-feature-detect": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/wasm-feature-detect/-/wasm-feature-detect-1.5.1.tgz",
|
||||
"integrity": "sha512-GHr23qmuehNXHY4902/hJ6EV5sUANIJC3R/yMfQ7hWDg3nfhlcJfnIL96R2ohpIwa62araN6aN4bLzzzq5GXkg=="
|
||||
},
|
||||
"node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
|
@ -244,15 +316,15 @@
|
|||
}
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.4.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.4.0.tgz",
|
||||
"integrity": "sha512-IHVsKe2pjajSUIl4KYMQOdlyliovpEPquKkqbwswulszzI7r0SfQrxnXdWAEqOlDCLrVSJzo+O1hAwdog2sKSQ==",
|
||||
"version": "8.13.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz",
|
||||
"integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": "^5.0.2"
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
|
@ -263,10 +335,18 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/zlibjs": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/zlibjs/-/zlibjs-0.3.1.tgz",
|
||||
"integrity": "sha512-+J9RrgTKOmlxFSDHo0pI1xM6BLVUv+o0ZT9ANtCxGkjIVCCUdx9alUF8Gm+dGLKbkkkidWIHFDZHDMpfITt4+w==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/zod": {
|
||||
"version": "3.11.6",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.11.6.tgz",
|
||||
"integrity": "sha512-daZ80A81I3/9lIydI44motWe6n59kRBfNzTuS2bfzVh1nAXi667TOTWWtatxyG+fwgNUiagSj/CWZwRRbevJIg==",
|
||||
"version": "3.22.2",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.22.2.tgz",
|
||||
"integrity": "sha512-wvWkphh5WQsJbVk1tbx1l1Ly4yg+XecD+Mq280uBGt9wa5BKSWf4Mhp6GmrkPixhMxmabYY7RbzlwVP32pbGCg==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
|
|
148
node_modules/@sapphire/async-queue/CHANGELOG.md
generated
vendored
Normal file
148
node_modules/@sapphire/async-queue/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,148 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
# [@sapphire/async-queue@1.5.0](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.4.0...@sapphire/async-queue@1.5.0) - (2022-08-16)
|
||||
|
||||
## 🐛 Bug Fixes
|
||||
|
||||
- **deps:** Update all non-major dependencies ([2308bd7](https://github.com/sapphiredev/utilities/commit/2308bd74356b6b2e0c12995b25f4d8ade4803fe9))
|
||||
|
||||
## 🚀 Features
|
||||
|
||||
- Add `AsyncQueue#abortAll` (#429) ([b351e70](https://github.com/sapphiredev/utilities/commit/b351e70ebef329009daaebba89729ee84bb5704c))
|
||||
|
||||
# [@sapphire/async-queue@1.4.0](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.3.1...@sapphire/async-queue@1.4.0) - (2022-08-07)
|
||||
|
||||
## 🐛 Bug Fixes
|
||||
|
||||
- **deps:** Update all non-major dependencies ([84af0db](https://github.com/sapphiredev/utilities/commit/84af0db2db749223b036aa99fe19a2e9af5681c6))
|
||||
- **deps:** Update all non-major dependencies ([50cd8de](https://github.com/sapphiredev/utilities/commit/50cd8dea593b6f5ae75571209456b3421e2ca59a))
|
||||
|
||||
## 📝 Documentation
|
||||
|
||||
- Add @muchnameless as a contributor ([a1221fe](https://github.com/sapphiredev/utilities/commit/a1221fea68506e99591d5d00ec552a07c26833f9))
|
||||
- Add @enxg as a contributor ([d2382f0](https://github.com/sapphiredev/utilities/commit/d2382f04e3909cb4ad11798a0a10e683f6cf5383))
|
||||
- Add @EvolutionX-10 as a contributor ([efc3a32](https://github.com/sapphiredev/utilities/commit/efc3a320a72ae258996dd62866d206c33f8d4961))
|
||||
- Add @MajesticString as a contributor ([295b3e9](https://github.com/sapphiredev/utilities/commit/295b3e9849a4b0fe64074bae02f6426378a303c3))
|
||||
- Add @Mzato0001 as a contributor ([c790ef2](https://github.com/sapphiredev/utilities/commit/c790ef25df2d7e22888fa9f8169167aa555e9e19))
|
||||
- Add @NotKaskus as a contributor ([00da8f1](https://github.com/sapphiredev/utilities/commit/00da8f199137b9277119823f322d1f2d168d928a))
|
||||
- Add @imranbarbhuiya as a contributor ([fb674c2](https://github.com/sapphiredev/utilities/commit/fb674c2c5594d41e71662263553dcb4bac9e37f4))
|
||||
- Add @axisiscool as a contributor ([ce1aa31](https://github.com/sapphiredev/utilities/commit/ce1aa316871a88d3663efbdf2a42d3d8dfe6a27f))
|
||||
- Add @dhruv-kaushikk as a contributor ([ebbf43f](https://github.com/sapphiredev/utilities/commit/ebbf43f63617daba96e72c50a234bf8b64f6ddc4))
|
||||
- Add @Commandtechno as a contributor ([f1d69fa](https://github.com/sapphiredev/utilities/commit/f1d69fabe1ee0abe4be08b19e63dbec03102f7ce))
|
||||
- Fix typedoc causing OOM crashes ([63ba41c](https://github.com/sapphiredev/utilities/commit/63ba41c4b6678554b1c7043a22d3296db4f59360))
|
||||
|
||||
## 🚀 Features
|
||||
|
||||
- **AsyncQueue:** Add AbortSignal support (#417) ([c0629e7](https://github.com/sapphiredev/utilities/commit/c0629e781ebc3f48e496a0851191b32e91f62fe9))
|
||||
|
||||
## 🧪 Testing
|
||||
|
||||
- Migrate to vitest (#380) ([075ec73](https://github.com/sapphiredev/utilities/commit/075ec73c7a8e3374fad3ada612d37eb4ac36ec8d))
|
||||
|
||||
## [1.3.1](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.3.0...@sapphire/async-queue@1.3.1) (2022-04-01)
|
||||
|
||||
**Note:** Version bump only for package @sapphire/async-queue
|
||||
|
||||
# [1.3.0](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.2.0...@sapphire/async-queue@1.3.0) (2022-03-06)
|
||||
|
||||
### Features
|
||||
|
||||
- allow module: NodeNext ([#306](https://github.com/sapphiredev/utilities/issues/306)) ([9dc6dd6](https://github.com/sapphiredev/utilities/commit/9dc6dd619efab879bb2b0b3c9e64304e10a67ed6))
|
||||
- **ts-config:** add multi-config structure ([#281](https://github.com/sapphiredev/utilities/issues/281)) ([b5191d7](https://github.com/sapphiredev/utilities/commit/b5191d7f2416dc5838590c4ff221454925553e37))
|
||||
|
||||
# [1.2.0](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.1.9...@sapphire/async-queue@1.2.0) (2022-01-28)
|
||||
|
||||
### Features
|
||||
|
||||
- change build system to tsup ([#270](https://github.com/sapphiredev/utilities/issues/270)) ([365a53a](https://github.com/sapphiredev/utilities/commit/365a53a5517a01a0926cf28a83c96b63f32ed9f8))
|
||||
|
||||
## [1.1.9](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.1.8...@sapphire/async-queue@1.1.9) (2021-11-06)
|
||||
|
||||
**Note:** Version bump only for package @sapphire/async-queue
|
||||
|
||||
## [1.1.8](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.1.7...@sapphire/async-queue@1.1.8) (2021-10-26)
|
||||
|
||||
**Note:** Version bump only for package @sapphire/async-queue
|
||||
|
||||
## [1.1.7](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.1.6...@sapphire/async-queue@1.1.7) (2021-10-17)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- allow more node & npm versions in engines field ([5977d2a](https://github.com/sapphiredev/utilities/commit/5977d2a30a4b2cfdf84aff3f33af03ffde1bbec5))
|
||||
|
||||
## [1.1.6](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.1.5...@sapphire/async-queue@1.1.6) (2021-10-11)
|
||||
|
||||
**Note:** Version bump only for package @sapphire/async-queue
|
||||
|
||||
## [1.1.5](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.1.4...@sapphire/async-queue@1.1.5) (2021-10-04)
|
||||
|
||||
**Note:** Version bump only for package @sapphire/async-queue
|
||||
|
||||
## [1.1.4](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.1.3...@sapphire/async-queue@1.1.4) (2021-06-27)
|
||||
|
||||
**Note:** Version bump only for package @sapphire/async-queue
|
||||
|
||||
## [1.1.3](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.1.2...@sapphire/async-queue@1.1.3) (2021-06-06)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- remove peer deps, update dev deps, update READMEs ([#124](https://github.com/sapphiredev/utilities/issues/124)) ([67256ed](https://github.com/sapphiredev/utilities/commit/67256ed43b915b02a8b5c68230ba82d6210c5032))
|
||||
|
||||
## [1.1.2](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.1.1...@sapphire/async-queue@1.1.2) (2021-05-20)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **async-queue:** mark package as side effect free ([1c4b901](https://github.com/sapphiredev/utilities/commit/1c4b901cda3d14bd085c35cc74e160f844567ba7))
|
||||
|
||||
## [1.1.1](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.1.0...@sapphire/async-queue@1.1.1) (2021-05-02)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- drop the `www.` from the SapphireJS URL ([494d89f](https://github.com/sapphiredev/utilities/commit/494d89ffa04f78c195b93d7905b3232884f7d7e2))
|
||||
- update all the SapphireJS URLs from `.com` to `.dev` ([f59b46d](https://github.com/sapphiredev/utilities/commit/f59b46d1a0ebd39cad17b17d71cd3b9da808d5fd))
|
||||
|
||||
# [1.1.0](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.0.7...@sapphire/async-queue@1.1.0) (2021-04-21)
|
||||
|
||||
### Features
|
||||
|
||||
- add @sapphire/embed-jsx ([#100](https://github.com/sapphiredev/utilities/issues/100)) ([7277a23](https://github.com/sapphiredev/utilities/commit/7277a236015236ed8e81b7882875410facc4ce17))
|
||||
|
||||
## [1.0.7](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.0.6...@sapphire/async-queue@1.0.7) (2021-04-19)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- change all Sapphire URLs from "project"->"community" & use our domain where applicable 👨🌾🚜 ([#102](https://github.com/sapphiredev/utilities/issues/102)) ([835b408](https://github.com/sapphiredev/utilities/commit/835b408e8e57130c3787aca2e32613346ff23e4d))
|
||||
|
||||
## [1.0.6](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.0.5...@sapphire/async-queue@1.0.6) (2021-04-03)
|
||||
|
||||
**Note:** Version bump only for package @sapphire/async-queue
|
||||
|
||||
## [1.0.5](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.0.4...@sapphire/async-queue@1.0.5) (2021-03-16)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- remove terser from all packages ([#79](https://github.com/sapphiredev/utilities/issues/79)) ([1cfe4e7](https://github.com/sapphiredev/utilities/commit/1cfe4e7c804e62c142495686d2b83b81d0026c02))
|
||||
|
||||
## [1.0.4](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.0.3...@sapphire/async-queue@1.0.4) (2021-02-16)
|
||||
|
||||
**Note:** Version bump only for package @sapphire/async-queue
|
||||
|
||||
## [1.0.3](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.0.2...@sapphire/async-queue@1.0.3) (2021-02-13)
|
||||
|
||||
**Note:** Version bump only for package @sapphire/async-queue
|
||||
|
||||
## [1.0.2](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.0.1...@sapphire/async-queue@1.0.2) (2021-01-25)
|
||||
|
||||
**Note:** Version bump only for package @sapphire/async-queue
|
||||
|
||||
## [1.0.1](https://github.com/sapphiredev/utilities/compare/@sapphire/async-queue@1.0.0...@sapphire/async-queue@1.0.1) (2021-01-16)
|
||||
|
||||
**Note:** Version bump only for package @sapphire/async-queue
|
||||
|
||||
# 1.0.0 (2021-01-13)
|
||||
|
||||
### Features
|
||||
|
||||
- **async-queue:** add async-queue package ([#56](https://github.com/sapphiredev/utilities/issues/56)) ([ba81832](https://github.com/sapphiredev/utilities/commit/ba8183287dbbc3f3d7d79af6d5a2d3dd8d62f63e))
|
24
node_modules/@sapphire/async-queue/LICENSE.md
generated
vendored
24
node_modules/@sapphire/async-queue/LICENSE.md
generated
vendored
|
@ -1,24 +0,0 @@
|
|||
# The MIT License (MIT)
|
||||
|
||||
Copyright © `2020` `The Sapphire Community and its contributors`
|
||||
|
||||
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.
|
32
node_modules/@sapphire/async-queue/README.md
generated
vendored
32
node_modules/@sapphire/async-queue/README.md
generated
vendored
|
@ -20,7 +20,7 @@ Ever needed a queue for a set of promises? This is the package for you.
|
|||
## Features
|
||||
|
||||
- Written in TypeScript
|
||||
- Bundled with Rollup so it can be used in NodeJS and browsers
|
||||
- Bundled with esbuild so it can be used in NodeJS and browsers
|
||||
- Offers CommonJS, ESM and UMD bundles
|
||||
- Fully tested
|
||||
|
||||
|
@ -56,7 +56,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|||
<!-- markdownlint-disable -->
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center"><a href="https://favware.tech/"><img src="https://avatars3.githubusercontent.com/u/4019718?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Claassens</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Favna" title="Code">💻</a> <a href="#infra-Favna" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#projectManagement-Favna" title="Project Management">📆</a> <a href="https://github.com/sapphiredev/utilities/commits?author=Favna" title="Documentation">📖</a> <a href="https://github.com/sapphiredev/utilities/commits?author=Favna" title="Tests">⚠️</a></td>
|
||||
<td align="center"><a href="https://favware.tech/"><img src="https://avatars3.githubusercontent.com/u/4019718?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Claassens</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=favna" title="Code">💻</a> <a href="#infra-favna" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#projectManagement-favna" title="Project Management">📆</a> <a href="https://github.com/sapphiredev/utilities/commits?author=favna" title="Documentation">📖</a> <a href="https://github.com/sapphiredev/utilities/commits?author=favna" title="Tests">⚠️</a></td>
|
||||
<td align="center"><a href="https://github.com/kyranet"><img src="https://avatars0.githubusercontent.com/u/24852502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Antonio Román</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=kyranet" title="Code">💻</a> <a href="#projectManagement-kyranet" title="Project Management">📆</a> <a href="https://github.com/sapphiredev/utilities/pulls?q=is%3Apr+reviewed-by%3Akyranet" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/sapphiredev/utilities/commits?author=kyranet" title="Tests">⚠️</a></td>
|
||||
<td align="center"><a href="https://github.com/PyroTechniac"><img src="https://avatars2.githubusercontent.com/u/39341355?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gryffon Bellish</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=PyroTechniac" title="Code">💻</a> <a href="https://github.com/sapphiredev/utilities/pulls?q=is%3Apr+reviewed-by%3APyroTechniac" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/sapphiredev/utilities/commits?author=PyroTechniac" title="Tests">⚠️</a></td>
|
||||
<td align="center"><a href="https://github.com/vladfrangu"><img src="https://avatars3.githubusercontent.com/u/17960496?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vlad Frangu</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=vladfrangu" title="Code">💻</a> <a href="https://github.com/sapphiredev/utilities/issues?q=author%3Avladfrangu" title="Bug reports">🐛</a> <a href="https://github.com/sapphiredev/utilities/pulls?q=is%3Apr+reviewed-by%3Avladfrangu" title="Reviewed Pull Requests">👀</a> <a href="#userTesting-vladfrangu" title="User Testing">📓</a> <a href="https://github.com/sapphiredev/utilities/commits?author=vladfrangu" title="Tests">⚠️</a></td>
|
||||
|
@ -78,9 +78,33 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|||
<td align="center"><a href="https://github.com/apps/dependabot"><img src="https://avatars.githubusercontent.com/in/29110?v=4?s=100" width="100px;" alt=""/><br /><sub><b>dependabot[bot]</b></sub></a><br /><a href="#maintenance-dependabot[bot]" title="Maintenance">🚧</a></td>
|
||||
<td align="center"><a href="https://kaname.netlify.app/"><img src="https://avatars.githubusercontent.com/u/56084970?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kaname</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=kaname-png" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/nandhagk"><img src="https://avatars.githubusercontent.com/u/62976649?v=4?s=100" width="100px;" alt=""/><br /><sub><b>nandhagk</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/issues?q=author%3Anandhagk" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://megatank58.me/"><img src="https://avatars.githubusercontent.com/u/51410502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Megatank58</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Megatank58" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://megatank58.me/"><img src="https://avatars.githubusercontent.com/u/51410502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>megatank58</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=megatank58" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/UndiedGamer"><img src="https://avatars.githubusercontent.com/u/84702365?v=4?s=100" width="100px;" alt=""/><br /><sub><b>UndiedGamer</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=UndiedGamer" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/Lioness100"><img src="https://avatars.githubusercontent.com/u/65814829?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lioness100</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Lioness100" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://github.com/Lioness100"><img src="https://avatars.githubusercontent.com/u/65814829?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lioness100</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Lioness100" title="Documentation">📖</a> <a href="https://github.com/sapphiredev/utilities/commits?author=Lioness100" title="Code">💻</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://gitlab.com/DavidPH/"><img src="https://avatars.githubusercontent.com/u/44669930?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=DavidPHH" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/apps/renovate"><img src="https://avatars.githubusercontent.com/in/2740?v=4?s=100" width="100px;" alt=""/><br /><sub><b>renovate[bot]</b></sub></a><br /><a href="#maintenance-renovate[bot]" title="Maintenance">🚧</a></td>
|
||||
<td align="center"><a href="https://renovate.whitesourcesoftware.com/"><img src="https://avatars.githubusercontent.com/u/25180681?v=4?s=100" width="100px;" alt=""/><br /><sub><b>WhiteSource Renovate</b></sub></a><br /><a href="#maintenance-renovate-bot" title="Maintenance">🚧</a></td>
|
||||
<td align="center"><a href="https://fc5570.me/"><img src="https://avatars.githubusercontent.com/u/68158483?v=4?s=100" width="100px;" alt=""/><br /><sub><b>FC</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=FC5570" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/Tokipudi"><img src="https://avatars.githubusercontent.com/u/29551076?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jérémy de Saint Denis</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Tokipudi" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/ItsMrCube"><img src="https://avatars.githubusercontent.com/u/25201357?v=4?s=100" width="100px;" alt=""/><br /><sub><b>MrCube</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=ItsMrCube" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/bitomic"><img src="https://avatars.githubusercontent.com/u/35199700?v=4?s=100" width="100px;" alt=""/><br /><sub><b>bitomic</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=bitomic" title="Code">💻</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://c43721.dev/"><img src="https://avatars.githubusercontent.com/u/55610086?v=4?s=100" width="100px;" alt=""/><br /><sub><b>c43721</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=c43721" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://commandtechno.com/"><img src="https://avatars.githubusercontent.com/u/68407783?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Commandtechno</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Commandtechno" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/dhruv-kaushikk"><img src="https://avatars.githubusercontent.com/u/73697546?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aura</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=dhruv-kaushikk" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://axis.moe/"><img src="https://avatars.githubusercontent.com/u/54381371?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jonathan</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=axisiscool" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/imranbarbhuiya"><img src="https://avatars.githubusercontent.com/u/74945038?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Parbez</b></sub></a><br /><a href="#maintenance-imranbarbhuiya" title="Maintenance">🚧</a></td>
|
||||
<td align="center"><a href="https://github.com/NotKaskus"><img src="https://avatars.githubusercontent.com/u/75168528?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Paul Andrew</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=NotKaskus" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://linktr.ee/mzato0001"><img src="https://avatars.githubusercontent.com/u/62367547?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mzato</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Mzato0001" title="Code">💻</a> <a href="https://github.com/sapphiredev/utilities/issues?q=author%3AMzato0001" title="Bug reports">🐛</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/MajesticString"><img src="https://avatars.githubusercontent.com/u/66224939?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Harry Allen</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=MajesticString" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://github.com/EvolutionX-10"><img src="https://avatars.githubusercontent.com/u/85353424?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Evo</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=EvolutionX-10" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://enes.ovh/"><img src="https://avatars.githubusercontent.com/u/61084101?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Enes Genç</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=enxg" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/muchnameless"><img src="https://avatars.githubusercontent.com/u/12682826?v=4?s=100" width="100px;" alt=""/><br /><sub><b>muchnameless</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=muchnameless" title="Code">💻</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
57
node_modules/@sapphire/async-queue/dist/index.d.ts
generated
vendored
57
node_modules/@sapphire/async-queue/dist/index.d.ts
generated
vendored
|
@ -1,2 +1,55 @@
|
|||
export * from './lib/AsyncQueue';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
/**
|
||||
* The AsyncQueue class used to sequentialize burst requests
|
||||
*/
|
||||
declare class AsyncQueue {
|
||||
/**
|
||||
* The amount of entries in the queue, including the head.
|
||||
* @seealso {@link queued} for the queued count.
|
||||
*/
|
||||
get remaining(): number;
|
||||
/**
|
||||
* The amount of queued entries.
|
||||
* @seealso {@link remaining} for the count with the head.
|
||||
*/
|
||||
get queued(): number;
|
||||
/**
|
||||
* The promises array
|
||||
*/
|
||||
private promises;
|
||||
/**
|
||||
* Waits for last promise and queues a new one
|
||||
* @example
|
||||
* ```typescript
|
||||
* const queue = new AsyncQueue();
|
||||
* async function request(url, options) {
|
||||
* await queue.wait({ signal: options.signal });
|
||||
* try {
|
||||
* const result = await fetch(url, options);
|
||||
* // Do some operations with 'result'
|
||||
* } finally {
|
||||
* // Remove first entry from the queue and resolve for the next entry
|
||||
* queue.shift();
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* request(someUrl1, someOptions1); // Will call fetch() immediately
|
||||
* request(someUrl2, someOptions2); // Will call fetch() after the first finished
|
||||
* request(someUrl3, someOptions3); // Will call fetch() after the second finished
|
||||
* ```
|
||||
*/
|
||||
wait(options?: Readonly<AsyncQueueWaitOptions>): Promise<void>;
|
||||
/**
|
||||
* Unlocks the head lock and transfers the next lock (if any) to the head.
|
||||
*/
|
||||
shift(): void;
|
||||
/**
|
||||
* Aborts all the pending promises.
|
||||
* @note To avoid race conditions, this does **not** unlock the head lock.
|
||||
*/
|
||||
abortAll(): void;
|
||||
}
|
||||
interface AsyncQueueWaitOptions {
|
||||
signal?: AbortSignal | undefined | null;
|
||||
}
|
||||
|
||||
export { AsyncQueue, AsyncQueueWaitOptions };
|
||||
|
|
1
node_modules/@sapphire/async-queue/dist/index.d.ts.map
generated
vendored
1
node_modules/@sapphire/async-queue/dist/index.d.ts.map
generated
vendored
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
125
node_modules/@sapphire/async-queue/dist/index.global.js
generated
vendored
Normal file
125
node_modules/@sapphire/async-queue/dist/index.global.js
generated
vendored
Normal file
|
@ -0,0 +1,125 @@
|
|||
"use strict";
|
||||
var SapphireAsyncQueue = (() => {
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var __publicField = (obj, key, value) => {
|
||||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
||||
return value;
|
||||
};
|
||||
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
AsyncQueue: () => AsyncQueue
|
||||
});
|
||||
|
||||
// src/lib/AsyncQueueEntry.ts
|
||||
var AsyncQueueEntry = class {
|
||||
constructor(queue) {
|
||||
__publicField(this, "promise");
|
||||
__publicField(this, "resolve");
|
||||
__publicField(this, "reject");
|
||||
__publicField(this, "queue");
|
||||
__publicField(this, "signal", null);
|
||||
__publicField(this, "signalListener", null);
|
||||
this.queue = queue;
|
||||
this.promise = new Promise((resolve, reject) => {
|
||||
this.resolve = resolve;
|
||||
this.reject = reject;
|
||||
});
|
||||
}
|
||||
setSignal(signal) {
|
||||
if (signal.aborted)
|
||||
return this;
|
||||
this.signal = signal;
|
||||
this.signalListener = () => {
|
||||
const index = this.queue["promises"].indexOf(this);
|
||||
if (index !== -1)
|
||||
this.queue["promises"].splice(index, 1);
|
||||
this.reject(new Error("Request aborted manually"));
|
||||
};
|
||||
this.signal.addEventListener("abort", this.signalListener);
|
||||
return this;
|
||||
}
|
||||
use() {
|
||||
this.dispose();
|
||||
this.resolve();
|
||||
return this;
|
||||
}
|
||||
abort() {
|
||||
this.dispose();
|
||||
this.reject(new Error("Request aborted manually"));
|
||||
return this;
|
||||
}
|
||||
dispose() {
|
||||
if (this.signal) {
|
||||
this.signal.removeEventListener("abort", this.signalListener);
|
||||
this.signal = null;
|
||||
this.signalListener = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
__name(AsyncQueueEntry, "AsyncQueueEntry");
|
||||
|
||||
// src/lib/AsyncQueue.ts
|
||||
var AsyncQueue = class {
|
||||
constructor() {
|
||||
__publicField(this, "promises", []);
|
||||
}
|
||||
get remaining() {
|
||||
return this.promises.length;
|
||||
}
|
||||
get queued() {
|
||||
return this.remaining === 0 ? 0 : this.remaining - 1;
|
||||
}
|
||||
wait(options) {
|
||||
const entry = new AsyncQueueEntry(this);
|
||||
if (this.promises.length === 0) {
|
||||
this.promises.push(entry);
|
||||
return Promise.resolve();
|
||||
}
|
||||
this.promises.push(entry);
|
||||
if (options?.signal)
|
||||
entry.setSignal(options.signal);
|
||||
return entry.promise;
|
||||
}
|
||||
shift() {
|
||||
if (this.promises.length === 0)
|
||||
return;
|
||||
if (this.promises.length === 1) {
|
||||
this.promises.shift();
|
||||
return;
|
||||
}
|
||||
this.promises.shift();
|
||||
this.promises[0].use();
|
||||
}
|
||||
abortAll() {
|
||||
if (this.queued === 0)
|
||||
return;
|
||||
for (let i = 1; i < this.promises.length; ++i) {
|
||||
this.promises[i].abort();
|
||||
}
|
||||
this.promises.length = 1;
|
||||
}
|
||||
};
|
||||
__name(AsyncQueue, "AsyncQueue");
|
||||
return __toCommonJS(src_exports);
|
||||
})();
|
||||
//# sourceMappingURL=index.global.js.map
|
1
node_modules/@sapphire/async-queue/dist/index.global.js.map
generated
vendored
Normal file
1
node_modules/@sapphire/async-queue/dist/index.global.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
190
node_modules/@sapphire/async-queue/dist/index.js
generated
vendored
190
node_modules/@sapphire/async-queue/dist/index.js
generated
vendored
|
@ -1,70 +1,128 @@
|
|||
'use strict';
|
||||
"use strict";
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var __publicField = (obj, key, value) => {
|
||||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
||||
return value;
|
||||
};
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
AsyncQueue: () => AsyncQueue
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
|
||||
/**
|
||||
* The AsyncQueue class used to sequentialize burst requests
|
||||
*/
|
||||
class AsyncQueue {
|
||||
constructor() {
|
||||
/**
|
||||
* The promises array
|
||||
*/
|
||||
Object.defineProperty(this, "promises", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: []
|
||||
});
|
||||
// src/lib/AsyncQueueEntry.ts
|
||||
var AsyncQueueEntry = class {
|
||||
constructor(queue) {
|
||||
__publicField(this, "promise");
|
||||
__publicField(this, "resolve");
|
||||
__publicField(this, "reject");
|
||||
__publicField(this, "queue");
|
||||
__publicField(this, "signal", null);
|
||||
__publicField(this, "signalListener", null);
|
||||
this.queue = queue;
|
||||
this.promise = new Promise((resolve, reject) => {
|
||||
this.resolve = resolve;
|
||||
this.reject = reject;
|
||||
});
|
||||
}
|
||||
setSignal(signal) {
|
||||
if (signal.aborted)
|
||||
return this;
|
||||
this.signal = signal;
|
||||
this.signalListener = () => {
|
||||
const index = this.queue["promises"].indexOf(this);
|
||||
if (index !== -1)
|
||||
this.queue["promises"].splice(index, 1);
|
||||
this.reject(new Error("Request aborted manually"));
|
||||
};
|
||||
this.signal.addEventListener("abort", this.signalListener);
|
||||
return this;
|
||||
}
|
||||
use() {
|
||||
this.dispose();
|
||||
this.resolve();
|
||||
return this;
|
||||
}
|
||||
abort() {
|
||||
this.dispose();
|
||||
this.reject(new Error("Request aborted manually"));
|
||||
return this;
|
||||
}
|
||||
dispose() {
|
||||
if (this.signal) {
|
||||
this.signal.removeEventListener("abort", this.signalListener);
|
||||
this.signal = null;
|
||||
this.signalListener = null;
|
||||
}
|
||||
/**
|
||||
* The remaining amount of queued promises
|
||||
*/
|
||||
get remaining() {
|
||||
return this.promises.length;
|
||||
}
|
||||
/**
|
||||
* Waits for last promise and queues a new one
|
||||
* @example
|
||||
* ```typescript
|
||||
* const queue = new AsyncQueue();
|
||||
* async function request(url, options) {
|
||||
* await queue.wait();
|
||||
* try {
|
||||
* const result = await fetch(url, options);
|
||||
* // Do some operations with 'result'
|
||||
* } finally {
|
||||
* // Remove first entry from the queue and resolve for the next entry
|
||||
* queue.shift();
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* request(someUrl1, someOptions1); // Will call fetch() immediately
|
||||
* request(someUrl2, someOptions2); // Will call fetch() after the first finished
|
||||
* request(someUrl3, someOptions3); // Will call fetch() after the second finished
|
||||
* ```
|
||||
*/
|
||||
wait() {
|
||||
const next = this.promises.length ? this.promises[this.promises.length - 1].promise : Promise.resolve();
|
||||
let resolve;
|
||||
const promise = new Promise((res) => {
|
||||
resolve = res;
|
||||
});
|
||||
this.promises.push({
|
||||
resolve: resolve,
|
||||
promise
|
||||
});
|
||||
return next;
|
||||
}
|
||||
/**
|
||||
* Frees the queue's lock for the next item to process
|
||||
*/
|
||||
shift() {
|
||||
const deferred = this.promises.shift();
|
||||
if (typeof deferred !== 'undefined')
|
||||
deferred.resolve();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
__name(AsyncQueueEntry, "AsyncQueueEntry");
|
||||
|
||||
exports.AsyncQueue = AsyncQueue;
|
||||
//# sourceMappingURL=index.js.map
|
||||
// src/lib/AsyncQueue.ts
|
||||
var AsyncQueue = class {
|
||||
constructor() {
|
||||
__publicField(this, "promises", []);
|
||||
}
|
||||
get remaining() {
|
||||
return this.promises.length;
|
||||
}
|
||||
get queued() {
|
||||
return this.remaining === 0 ? 0 : this.remaining - 1;
|
||||
}
|
||||
wait(options) {
|
||||
const entry = new AsyncQueueEntry(this);
|
||||
if (this.promises.length === 0) {
|
||||
this.promises.push(entry);
|
||||
return Promise.resolve();
|
||||
}
|
||||
this.promises.push(entry);
|
||||
if (options?.signal)
|
||||
entry.setSignal(options.signal);
|
||||
return entry.promise;
|
||||
}
|
||||
shift() {
|
||||
if (this.promises.length === 0)
|
||||
return;
|
||||
if (this.promises.length === 1) {
|
||||
this.promises.shift();
|
||||
return;
|
||||
}
|
||||
this.promises.shift();
|
||||
this.promises[0].use();
|
||||
}
|
||||
abortAll() {
|
||||
if (this.queued === 0)
|
||||
return;
|
||||
for (let i = 1; i < this.promises.length; ++i) {
|
||||
this.promises[i].abort();
|
||||
}
|
||||
this.promises.length = 1;
|
||||
}
|
||||
};
|
||||
__name(AsyncQueue, "AsyncQueue");
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
AsyncQueue
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
2
node_modules/@sapphire/async-queue/dist/index.js.map
generated
vendored
2
node_modules/@sapphire/async-queue/dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
166
node_modules/@sapphire/async-queue/dist/index.mjs
generated
vendored
166
node_modules/@sapphire/async-queue/dist/index.mjs
generated
vendored
|
@ -1,66 +1,102 @@
|
|||
/**
|
||||
* The AsyncQueue class used to sequentialize burst requests
|
||||
*/
|
||||
class AsyncQueue {
|
||||
constructor() {
|
||||
/**
|
||||
* The promises array
|
||||
*/
|
||||
Object.defineProperty(this, "promises", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: []
|
||||
});
|
||||
}
|
||||
/**
|
||||
* The remaining amount of queued promises
|
||||
*/
|
||||
get remaining() {
|
||||
return this.promises.length;
|
||||
}
|
||||
/**
|
||||
* Waits for last promise and queues a new one
|
||||
* @example
|
||||
* ```typescript
|
||||
* const queue = new AsyncQueue();
|
||||
* async function request(url, options) {
|
||||
* await queue.wait();
|
||||
* try {
|
||||
* const result = await fetch(url, options);
|
||||
* // Do some operations with 'result'
|
||||
* } finally {
|
||||
* // Remove first entry from the queue and resolve for the next entry
|
||||
* queue.shift();
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* request(someUrl1, someOptions1); // Will call fetch() immediately
|
||||
* request(someUrl2, someOptions2); // Will call fetch() after the first finished
|
||||
* request(someUrl3, someOptions3); // Will call fetch() after the second finished
|
||||
* ```
|
||||
*/
|
||||
wait() {
|
||||
const next = this.promises.length ? this.promises[this.promises.length - 1].promise : Promise.resolve();
|
||||
let resolve;
|
||||
const promise = new Promise((res) => {
|
||||
resolve = res;
|
||||
});
|
||||
this.promises.push({
|
||||
resolve: resolve,
|
||||
promise
|
||||
});
|
||||
return next;
|
||||
}
|
||||
/**
|
||||
* Frees the queue's lock for the next item to process
|
||||
*/
|
||||
shift() {
|
||||
const deferred = this.promises.shift();
|
||||
if (typeof deferred !== 'undefined')
|
||||
deferred.resolve();
|
||||
}
|
||||
}
|
||||
var __defProp = Object.defineProperty;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
var __publicField = (obj, key, value) => {
|
||||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
||||
return value;
|
||||
};
|
||||
|
||||
export { AsyncQueue };
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
// src/lib/AsyncQueueEntry.ts
|
||||
var AsyncQueueEntry = class {
|
||||
constructor(queue) {
|
||||
__publicField(this, "promise");
|
||||
__publicField(this, "resolve");
|
||||
__publicField(this, "reject");
|
||||
__publicField(this, "queue");
|
||||
__publicField(this, "signal", null);
|
||||
__publicField(this, "signalListener", null);
|
||||
this.queue = queue;
|
||||
this.promise = new Promise((resolve, reject) => {
|
||||
this.resolve = resolve;
|
||||
this.reject = reject;
|
||||
});
|
||||
}
|
||||
setSignal(signal) {
|
||||
if (signal.aborted)
|
||||
return this;
|
||||
this.signal = signal;
|
||||
this.signalListener = () => {
|
||||
const index = this.queue["promises"].indexOf(this);
|
||||
if (index !== -1)
|
||||
this.queue["promises"].splice(index, 1);
|
||||
this.reject(new Error("Request aborted manually"));
|
||||
};
|
||||
this.signal.addEventListener("abort", this.signalListener);
|
||||
return this;
|
||||
}
|
||||
use() {
|
||||
this.dispose();
|
||||
this.resolve();
|
||||
return this;
|
||||
}
|
||||
abort() {
|
||||
this.dispose();
|
||||
this.reject(new Error("Request aborted manually"));
|
||||
return this;
|
||||
}
|
||||
dispose() {
|
||||
if (this.signal) {
|
||||
this.signal.removeEventListener("abort", this.signalListener);
|
||||
this.signal = null;
|
||||
this.signalListener = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
__name(AsyncQueueEntry, "AsyncQueueEntry");
|
||||
|
||||
// src/lib/AsyncQueue.ts
|
||||
var AsyncQueue = class {
|
||||
constructor() {
|
||||
__publicField(this, "promises", []);
|
||||
}
|
||||
get remaining() {
|
||||
return this.promises.length;
|
||||
}
|
||||
get queued() {
|
||||
return this.remaining === 0 ? 0 : this.remaining - 1;
|
||||
}
|
||||
wait(options) {
|
||||
const entry = new AsyncQueueEntry(this);
|
||||
if (this.promises.length === 0) {
|
||||
this.promises.push(entry);
|
||||
return Promise.resolve();
|
||||
}
|
||||
this.promises.push(entry);
|
||||
if (options?.signal)
|
||||
entry.setSignal(options.signal);
|
||||
return entry.promise;
|
||||
}
|
||||
shift() {
|
||||
if (this.promises.length === 0)
|
||||
return;
|
||||
if (this.promises.length === 1) {
|
||||
this.promises.shift();
|
||||
return;
|
||||
}
|
||||
this.promises.shift();
|
||||
this.promises[0].use();
|
||||
}
|
||||
abortAll() {
|
||||
if (this.queued === 0)
|
||||
return;
|
||||
for (let i = 1; i < this.promises.length; ++i) {
|
||||
this.promises[i].abort();
|
||||
}
|
||||
this.promises.length = 1;
|
||||
}
|
||||
};
|
||||
__name(AsyncQueue, "AsyncQueue");
|
||||
export {
|
||||
AsyncQueue
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
2
node_modules/@sapphire/async-queue/dist/index.mjs.map
generated
vendored
2
node_modules/@sapphire/async-queue/dist/index.mjs.map
generated
vendored
File diff suppressed because one or more lines are too long
76
node_modules/@sapphire/async-queue/dist/index.umd.js
generated
vendored
76
node_modules/@sapphire/async-queue/dist/index.umd.js
generated
vendored
|
@ -1,76 +0,0 @@
|
|||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SapphireAsyncQueue = {}));
|
||||
})(this, (function (exports) { 'use strict';
|
||||
|
||||
/**
|
||||
* The AsyncQueue class used to sequentialize burst requests
|
||||
*/
|
||||
class AsyncQueue {
|
||||
constructor() {
|
||||
/**
|
||||
* The promises array
|
||||
*/
|
||||
Object.defineProperty(this, "promises", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: []
|
||||
});
|
||||
}
|
||||
/**
|
||||
* The remaining amount of queued promises
|
||||
*/
|
||||
get remaining() {
|
||||
return this.promises.length;
|
||||
}
|
||||
/**
|
||||
* Waits for last promise and queues a new one
|
||||
* @example
|
||||
* ```typescript
|
||||
* const queue = new AsyncQueue();
|
||||
* async function request(url, options) {
|
||||
* await queue.wait();
|
||||
* try {
|
||||
* const result = await fetch(url, options);
|
||||
* // Do some operations with 'result'
|
||||
* } finally {
|
||||
* // Remove first entry from the queue and resolve for the next entry
|
||||
* queue.shift();
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* request(someUrl1, someOptions1); // Will call fetch() immediately
|
||||
* request(someUrl2, someOptions2); // Will call fetch() after the first finished
|
||||
* request(someUrl3, someOptions3); // Will call fetch() after the second finished
|
||||
* ```
|
||||
*/
|
||||
wait() {
|
||||
const next = this.promises.length ? this.promises[this.promises.length - 1].promise : Promise.resolve();
|
||||
let resolve;
|
||||
const promise = new Promise((res) => {
|
||||
resolve = res;
|
||||
});
|
||||
this.promises.push({
|
||||
resolve: resolve,
|
||||
promise
|
||||
});
|
||||
return next;
|
||||
}
|
||||
/**
|
||||
* Frees the queue's lock for the next item to process
|
||||
*/
|
||||
shift() {
|
||||
const deferred = this.promises.shift();
|
||||
if (typeof deferred !== 'undefined')
|
||||
deferred.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
exports.AsyncQueue = AsyncQueue;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
}));
|
||||
//# sourceMappingURL=index.umd.js.map
|
1
node_modules/@sapphire/async-queue/dist/index.umd.js.map
generated
vendored
1
node_modules/@sapphire/async-queue/dist/index.umd.js.map
generated
vendored
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"index.umd.js","sources":["../src/lib/AsyncQueue.ts"],"sourcesContent":["/**\n * The AsyncQueue class used to sequentialize burst requests\n */\nexport class AsyncQueue {\n\t/**\n\t * The remaining amount of queued promises\n\t */\n\tpublic get remaining(): number {\n\t\treturn this.promises.length;\n\t}\n\n\t/**\n\t * The promises array\n\t */\n\tprivate promises: InternalAsyncQueueDeferredPromise[] = [];\n\n\t/**\n\t * Waits for last promise and queues a new one\n\t * @example\n\t * ```typescript\n\t * const queue = new AsyncQueue();\n\t * async function request(url, options) {\n\t * await queue.wait();\n\t * try {\n\t * const result = await fetch(url, options);\n\t * // Do some operations with 'result'\n\t * } finally {\n\t * // Remove first entry from the queue and resolve for the next entry\n\t * queue.shift();\n\t * }\n\t * }\n\t *\n\t * request(someUrl1, someOptions1); // Will call fetch() immediately\n\t * request(someUrl2, someOptions2); // Will call fetch() after the first finished\n\t * request(someUrl3, someOptions3); // Will call fetch() after the second finished\n\t * ```\n\t */\n\tpublic wait(): Promise<void> {\n\t\tconst next = this.promises.length ? this.promises[this.promises.length - 1].promise : Promise.resolve();\n\t\tlet resolve: () => void;\n\t\tconst promise = new Promise<void>((res) => {\n\t\t\tresolve = res;\n\t\t});\n\n\t\tthis.promises.push({\n\t\t\tresolve: resolve!,\n\t\t\tpromise\n\t\t});\n\n\t\treturn next;\n\t}\n\n\t/**\n\t * Frees the queue's lock for the next item to process\n\t */\n\tpublic shift(): void {\n\t\tconst deferred = this.promises.shift();\n\t\tif (typeof deferred !== 'undefined') deferred.resolve();\n\t}\n}\n\n/**\n * @internal\n */\ninterface InternalAsyncQueueDeferredPromise {\n\tresolve(): void;\n\tpromise: Promise<void>;\n}\n"],"names":[],"mappings":";;;;;;CAAA;;;OAGa,UAAU;KAAvB;;;;SAWC;;;;oBAAwD,EAAE;YAAC;MA6C3D;;;;KApDA,IAAW,SAAS;SACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;MAC5B;;;;;;;;;;;;;;;;;;;;;;KA4BM,IAAI;SACV,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;SACxG,IAAI,OAAmB,CAAC;SACxB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,GAAG;aACrC,OAAO,GAAG,GAAG,CAAC;UACd,CAAC,CAAC;SAEH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;aAClB,OAAO,EAAE,OAAQ;aACjB,OAAO;UACP,CAAC,CAAC;SAEH,OAAO,IAAI,CAAC;MACZ;;;;KAKM,KAAK;SACX,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;SACvC,IAAI,OAAO,QAAQ,KAAK,WAAW;aAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;MACxD;;;;;;;;;;;"}
|
40
node_modules/@sapphire/async-queue/dist/lib/AsyncQueue.d.ts
generated
vendored
40
node_modules/@sapphire/async-queue/dist/lib/AsyncQueue.d.ts
generated
vendored
|
@ -1,40 +0,0 @@
|
|||
/**
|
||||
* The AsyncQueue class used to sequentialize burst requests
|
||||
*/
|
||||
export declare class AsyncQueue {
|
||||
/**
|
||||
* The remaining amount of queued promises
|
||||
*/
|
||||
get remaining(): number;
|
||||
/**
|
||||
* The promises array
|
||||
*/
|
||||
private promises;
|
||||
/**
|
||||
* Waits for last promise and queues a new one
|
||||
* @example
|
||||
* ```typescript
|
||||
* const queue = new AsyncQueue();
|
||||
* async function request(url, options) {
|
||||
* await queue.wait();
|
||||
* try {
|
||||
* const result = await fetch(url, options);
|
||||
* // Do some operations with 'result'
|
||||
* } finally {
|
||||
* // Remove first entry from the queue and resolve for the next entry
|
||||
* queue.shift();
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* request(someUrl1, someOptions1); // Will call fetch() immediately
|
||||
* request(someUrl2, someOptions2); // Will call fetch() after the first finished
|
||||
* request(someUrl3, someOptions3); // Will call fetch() after the second finished
|
||||
* ```
|
||||
*/
|
||||
wait(): Promise<void>;
|
||||
/**
|
||||
* Frees the queue's lock for the next item to process
|
||||
*/
|
||||
shift(): void;
|
||||
}
|
||||
//# sourceMappingURL=AsyncQueue.d.ts.map
|
1
node_modules/@sapphire/async-queue/dist/lib/AsyncQueue.d.ts.map
generated
vendored
1
node_modules/@sapphire/async-queue/dist/lib/AsyncQueue.d.ts.map
generated
vendored
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"AsyncQueue.d.ts","sourceRoot":"","sources":["../../src/lib/AsyncQueue.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,UAAU;IACtB;;OAEG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;OAEG;IACH,OAAO,CAAC,QAAQ,CAA2C;IAE3D;;;;;;;;;;;;;;;;;;;;OAoBG;IACI,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAe5B;;OAEG;IACI,KAAK,IAAI,IAAI;CAIpB"}
|
119
node_modules/@sapphire/async-queue/package.json
generated
vendored
119
node_modules/@sapphire/async-queue/package.json
generated
vendored
|
@ -1,56 +1,65 @@
|
|||
{
|
||||
"name": "@sapphire/async-queue",
|
||||
"version": "1.1.9",
|
||||
"description": "Sequential asynchronous lock-based queue for promises",
|
||||
"author": "@sapphire",
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.mjs",
|
||||
"browser": "dist/index.umd.js",
|
||||
"unpkg": "dist/index.umd.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"typedocMain": "src/index.ts",
|
||||
"exports": {
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/async-queue",
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
|
||||
"build": "rollup -c",
|
||||
"start": "yarn build -w",
|
||||
"prepublishOnly": "yarn build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sapphiredev/utilities.git",
|
||||
"directory": "packages/async-queue"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"!dist/*.tsbuildinfo"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=v14.0.0",
|
||||
"npm": ">=7.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"@sapphire/async-queue",
|
||||
"bot",
|
||||
"typescript",
|
||||
"ts",
|
||||
"yarn",
|
||||
"discord",
|
||||
"sapphire",
|
||||
"standalone"
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/sapphiredev/utilities/issues"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "4889ea35a0b081021981ff3d73e5005dd1e922ce"
|
||||
}
|
||||
"name": "@sapphire/async-queue",
|
||||
"version": "1.5.0",
|
||||
"description": "Sequential asynchronous lock-based queue for promises",
|
||||
"author": "@sapphire",
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.mjs",
|
||||
"browser": "dist/index.global.js",
|
||||
"unpkg": "dist/index.global.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/async-queue",
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
|
||||
"build": "tsup",
|
||||
"prepack": "yarn build",
|
||||
"bump": "cliff-jumper",
|
||||
"check-update": "cliff-jumper --dry-run"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sapphiredev/utilities.git",
|
||||
"directory": "packages/async-queue"
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*.js*",
|
||||
"dist/**/*.mjs*",
|
||||
"dist/**/*.d*"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=v14.0.0",
|
||||
"npm": ">=7.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"@sapphire/async-queue",
|
||||
"bot",
|
||||
"typescript",
|
||||
"ts",
|
||||
"yarn",
|
||||
"discord",
|
||||
"sapphire",
|
||||
"standalone"
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/sapphiredev/utilities/issues"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@favware/cliff-jumper": "^1.8.6",
|
||||
"@vitest/coverage-c8": "^0.22.0",
|
||||
"c8": "^7.12.0",
|
||||
"tsup": "^6.2.2",
|
||||
"typescript": "^4.7.4",
|
||||
"vitest": "^0.22.0"
|
||||
}
|
||||
}
|
21
node_modules/@sindresorhus/is/dist/index.d.ts
generated
vendored
21
node_modules/@sindresorhus/is/dist/index.d.ts
generated
vendored
|
@ -1,8 +1,8 @@
|
|||
/// <reference types="node" />
|
||||
/// <reference lib="es2018" />
|
||||
/// <reference lib="dom" />
|
||||
import { Class, TypedArray, ObservableLike, Primitive } from './types';
|
||||
declare const objectTypeNames: readonly ["Function", "Generator", "AsyncGenerator", "GeneratorFunction", "AsyncGeneratorFunction", "AsyncFunction", "Observable", "Array", "Buffer", "Object", "RegExp", "Date", "Error", "Map", "Set", "WeakMap", "WeakSet", "ArrayBuffer", "SharedArrayBuffer", "DataView", "Promise", "URL", "FormData", "URLSearchParams", "HTMLElement", ...("Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array")[]];
|
||||
import { Class, Falsy, TypedArray, ObservableLike, Primitive } from './types';
|
||||
declare const objectTypeNames: readonly ["Function", "Generator", "AsyncGenerator", "GeneratorFunction", "AsyncGeneratorFunction", "AsyncFunction", "Observable", "Array", "Buffer", "Blob", "Object", "RegExp", "Date", "Error", "Map", "Set", "WeakMap", "WeakSet", "ArrayBuffer", "SharedArrayBuffer", "DataView", "Promise", "URL", "FormData", "URLSearchParams", "HTMLElement", ...("Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array")[]];
|
||||
declare type ObjectTypeName = typeof objectTypeNames[number];
|
||||
declare const primitiveTypeNames: readonly ["null", "undefined", "string", "number", "bigint", "boolean", "symbol"];
|
||||
declare type PrimitiveTypeName = typeof primitiveTypeNames[number];
|
||||
|
@ -21,6 +21,7 @@ declare namespace is {
|
|||
var numericString: (value: unknown) => value is string;
|
||||
var array: <T = unknown>(value: unknown, assertion?: ((value: T) => value is T) | undefined) => value is T[];
|
||||
var buffer: (value: unknown) => value is Buffer;
|
||||
var blob: (value: unknown) => value is Blob;
|
||||
var nullOrUndefined: (value: unknown) => value is null | undefined;
|
||||
var object: (value: unknown) => value is object;
|
||||
var iterable: <T = unknown>(value: unknown) => value is Iterable<T>;
|
||||
|
@ -54,11 +55,12 @@ declare namespace is {
|
|||
var arrayBuffer: (value: unknown) => value is ArrayBuffer;
|
||||
var sharedArrayBuffer: (value: unknown) => value is SharedArrayBuffer;
|
||||
var dataView: (value: unknown) => value is DataView;
|
||||
var enumCase: <T = unknown>(value: unknown, targetEnum: T) => boolean;
|
||||
var directInstanceOf: <T>(instance: unknown, class_: Class<T, any[]>) => instance is T;
|
||||
var urlInstance: (value: unknown) => value is URL;
|
||||
var urlString: (value: unknown) => value is string;
|
||||
var truthy: (value: unknown) => boolean;
|
||||
var falsy: (value: unknown) => boolean;
|
||||
var truthy: <T>(value: false | "" | 0 | 0n | T | null | undefined) => value is T;
|
||||
var falsy: <T>(value: false | "" | 0 | 0n | T | null | undefined) => value is Falsy;
|
||||
var nan: (value: unknown) => boolean;
|
||||
var primitive: (value: unknown) => value is Primitive;
|
||||
var integer: (value: unknown) => value is number;
|
||||
|
@ -76,8 +78,9 @@ declare namespace is {
|
|||
var emptyArray: (value: unknown) => value is never[];
|
||||
var nonEmptyArray: (value: unknown) => value is unknown[];
|
||||
var emptyString: (value: unknown) => value is "";
|
||||
var nonEmptyString: (value: unknown) => value is string;
|
||||
var emptyStringOrWhitespace: (value: unknown) => value is string;
|
||||
var nonEmptyString: (value: unknown) => value is string;
|
||||
var nonEmptyStringAndNotWhitespace: (value: unknown) => value is string;
|
||||
var emptyObject: <Key extends string | number | symbol = string>(value: unknown) => value is Record<Key, never>;
|
||||
var nonEmptyObject: <Key extends string | number | symbol = string, Value = unknown>(value: unknown) => value is Record<Key, Value>;
|
||||
var emptySet: (value: unknown) => value is Set<never>;
|
||||
|
@ -123,8 +126,9 @@ export declare const enum AssertionTypeDescription {
|
|||
emptyArray = "empty array",
|
||||
nonEmptyArray = "non-empty array",
|
||||
emptyString = "empty string",
|
||||
nonEmptyString = "non-empty string",
|
||||
emptyStringOrWhitespace = "empty string or whitespace",
|
||||
nonEmptyString = "non-empty string",
|
||||
nonEmptyStringAndNotWhitespace = "non-empty string and not whitespace",
|
||||
emptyObject = "empty object",
|
||||
nonEmptyObject = "non-empty object",
|
||||
emptySet = "empty set",
|
||||
|
@ -151,6 +155,7 @@ interface Assert {
|
|||
numericString: (value: unknown) => asserts value is string;
|
||||
array: <T = unknown>(value: unknown, assertion?: (element: unknown) => asserts element is T) => asserts value is T[];
|
||||
buffer: (value: unknown) => asserts value is Buffer;
|
||||
blob: (value: unknown) => asserts value is Blob;
|
||||
nullOrUndefined: (value: unknown) => asserts value is null | undefined;
|
||||
object: <Key extends keyof any = string, Value = unknown>(value: unknown) => asserts value is Record<Key, Value>;
|
||||
iterable: <T = unknown>(value: unknown) => asserts value is Iterable<T>;
|
||||
|
@ -184,6 +189,7 @@ interface Assert {
|
|||
arrayBuffer: (value: unknown) => asserts value is ArrayBuffer;
|
||||
sharedArrayBuffer: (value: unknown) => asserts value is SharedArrayBuffer;
|
||||
dataView: (value: unknown) => asserts value is DataView;
|
||||
enumCase: <T = unknown>(value: unknown, targetEnum: T) => asserts value is T[keyof T];
|
||||
urlInstance: (value: unknown) => asserts value is URL;
|
||||
urlString: (value: unknown) => asserts value is string;
|
||||
truthy: (value: unknown) => asserts value is unknown;
|
||||
|
@ -202,8 +208,9 @@ interface Assert {
|
|||
emptyArray: (value: unknown) => asserts value is never[];
|
||||
nonEmptyArray: (value: unknown) => asserts value is unknown[];
|
||||
emptyString: (value: unknown) => asserts value is '';
|
||||
nonEmptyString: (value: unknown) => asserts value is string;
|
||||
emptyStringOrWhitespace: (value: unknown) => asserts value is string;
|
||||
nonEmptyString: (value: unknown) => asserts value is string;
|
||||
nonEmptyStringAndNotWhitespace: (value: unknown) => asserts value is string;
|
||||
emptyObject: <Key extends keyof any = string>(value: unknown) => asserts value is Record<Key, never>;
|
||||
nonEmptyObject: <Key extends keyof any = string, Value = unknown>(value: unknown) => asserts value is Record<Key, Value>;
|
||||
emptySet: (value: unknown) => asserts value is Set<never>;
|
||||
|
|
15
node_modules/@sindresorhus/is/dist/index.js
generated
vendored
15
node_modules/@sindresorhus/is/dist/index.js
generated
vendored
|
@ -29,6 +29,7 @@ const objectTypeNames = [
|
|||
'Observable',
|
||||
'Array',
|
||||
'Buffer',
|
||||
'Blob',
|
||||
'Object',
|
||||
'RegExp',
|
||||
'Date',
|
||||
|
@ -139,6 +140,7 @@ is.array = (value, assertion) => {
|
|||
return value.every(assertion);
|
||||
};
|
||||
is.buffer = (value) => { var _a, _b, _c, _d; return (_d = (_c = (_b = (_a = value) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.isBuffer) === null || _c === void 0 ? void 0 : _c.call(_b, value)) !== null && _d !== void 0 ? _d : false; };
|
||||
is.blob = (value) => isObjectOfType('Blob')(value);
|
||||
is.nullOrUndefined = (value) => is.null_(value) || is.undefined(value);
|
||||
is.object = (value) => !is.null_(value) && (typeof value === 'object' || is.function_(value));
|
||||
is.iterable = (value) => { var _a; return is.function_((_a = value) === null || _a === void 0 ? void 0 : _a[Symbol.iterator]); };
|
||||
|
@ -178,6 +180,7 @@ is.bigUint64Array = isObjectOfType('BigUint64Array');
|
|||
is.arrayBuffer = isObjectOfType('ArrayBuffer');
|
||||
is.sharedArrayBuffer = isObjectOfType('SharedArrayBuffer');
|
||||
is.dataView = isObjectOfType('DataView');
|
||||
is.enumCase = (value, targetEnum) => Object.values(targetEnum).includes(value);
|
||||
is.directInstanceOf = (instance, class_) => Object.getPrototypeOf(instance) === class_.prototype;
|
||||
is.urlInstance = (value) => isObjectOfType('URL')(value);
|
||||
is.urlString = (value) => {
|
||||
|
@ -192,7 +195,6 @@ is.urlString = (value) => {
|
|||
return false;
|
||||
}
|
||||
};
|
||||
// TODO: Use the `not` operator with a type guard here when it's available.
|
||||
// Example: `is.truthy = (value: unknown): value is (not false | not 0 | not '' | not undefined | not null) => Boolean(value);`
|
||||
is.truthy = (value) => Boolean(value);
|
||||
// Example: `is.falsy = (value: unknown): value is (not true | 0 | '' | undefined | null) => Boolean(value);`
|
||||
|
@ -258,10 +260,12 @@ is.oddInteger = isAbsoluteMod2(1);
|
|||
is.emptyArray = (value) => is.array(value) && value.length === 0;
|
||||
is.nonEmptyArray = (value) => is.array(value) && value.length > 0;
|
||||
is.emptyString = (value) => is.string(value) && value.length === 0;
|
||||
// TODO: Use `not ''` when the `not` operator is available.
|
||||
is.nonEmptyString = (value) => is.string(value) && value.length > 0;
|
||||
const isWhiteSpaceString = (value) => is.string(value) && !/\S/.test(value);
|
||||
is.emptyStringOrWhitespace = (value) => is.emptyString(value) || isWhiteSpaceString(value);
|
||||
// TODO: Use `not ''` when the `not` operator is available.
|
||||
is.nonEmptyString = (value) => is.string(value) && value.length > 0;
|
||||
// TODO: Use `not ''` when the `not` operator is available.
|
||||
is.nonEmptyStringAndNotWhitespace = (value) => is.string(value) && !is.emptyStringOrWhitespace(value);
|
||||
is.emptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length === 0;
|
||||
// TODO: Use `not` operator here to remove `Map` and `Set` from type guard:
|
||||
// - https://github.com/Microsoft/TypeScript/pull/29317
|
||||
|
@ -320,6 +324,7 @@ exports.assert = {
|
|||
}
|
||||
},
|
||||
buffer: (value) => assertType(is.buffer(value), 'Buffer', value),
|
||||
blob: (value) => assertType(is.blob(value), 'Blob', value),
|
||||
nullOrUndefined: (value) => assertType(is.nullOrUndefined(value), "null or undefined" /* nullOrUndefined */, value),
|
||||
object: (value) => assertType(is.object(value), 'Object', value),
|
||||
iterable: (value) => assertType(is.iterable(value), "Iterable" /* iterable */, value),
|
||||
|
@ -355,6 +360,7 @@ exports.assert = {
|
|||
arrayBuffer: (value) => assertType(is.arrayBuffer(value), 'ArrayBuffer', value),
|
||||
sharedArrayBuffer: (value) => assertType(is.sharedArrayBuffer(value), 'SharedArrayBuffer', value),
|
||||
dataView: (value) => assertType(is.dataView(value), 'DataView', value),
|
||||
enumCase: (value, targetEnum) => assertType(is.enumCase(value, targetEnum), 'EnumCase', value),
|
||||
urlInstance: (value) => assertType(is.urlInstance(value), 'URL', value),
|
||||
urlString: (value) => assertType(is.urlString(value), "string with a URL" /* urlString */, value),
|
||||
truthy: (value) => assertType(is.truthy(value), "truthy" /* truthy */, value),
|
||||
|
@ -373,8 +379,9 @@ exports.assert = {
|
|||
emptyArray: (value) => assertType(is.emptyArray(value), "empty array" /* emptyArray */, value),
|
||||
nonEmptyArray: (value) => assertType(is.nonEmptyArray(value), "non-empty array" /* nonEmptyArray */, value),
|
||||
emptyString: (value) => assertType(is.emptyString(value), "empty string" /* emptyString */, value),
|
||||
nonEmptyString: (value) => assertType(is.nonEmptyString(value), "non-empty string" /* nonEmptyString */, value),
|
||||
emptyStringOrWhitespace: (value) => assertType(is.emptyStringOrWhitespace(value), "empty string or whitespace" /* emptyStringOrWhitespace */, value),
|
||||
nonEmptyString: (value) => assertType(is.nonEmptyString(value), "non-empty string" /* nonEmptyString */, value),
|
||||
nonEmptyStringAndNotWhitespace: (value) => assertType(is.nonEmptyStringAndNotWhitespace(value), "non-empty string and not whitespace" /* nonEmptyStringAndNotWhitespace */, value),
|
||||
emptyObject: (value) => assertType(is.emptyObject(value), "empty object" /* emptyObject */, value),
|
||||
nonEmptyObject: (value) => assertType(is.nonEmptyObject(value), "non-empty object" /* nonEmptyObject */, value),
|
||||
emptySet: (value) => assertType(is.emptySet(value), "empty set" /* emptySet */, value),
|
||||
|
|
1
node_modules/@sindresorhus/is/dist/types.d.ts
generated
vendored
1
node_modules/@sindresorhus/is/dist/types.d.ts
generated
vendored
|
@ -22,3 +22,4 @@ export interface ObservableLike {
|
|||
subscribe(observer: (value: unknown) => void): void;
|
||||
[Symbol.observable](): ObservableLike;
|
||||
}
|
||||
export declare type Falsy = false | 0 | 0n | '' | null | undefined;
|
||||
|
|
2
node_modules/@sindresorhus/is/package.json
generated
vendored
2
node_modules/@sindresorhus/is/package.json
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@sindresorhus/is",
|
||||
"version": "4.2.1",
|
||||
"version": "4.6.0",
|
||||
"description": "Type check values",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/is",
|
||||
|
|
45
node_modules/@sindresorhus/is/readme.md
generated
vendored
45
node_modules/@sindresorhus/is/readme.md
generated
vendored
|
@ -17,8 +17,8 @@ For example, `is.string('🦄') //=> true`
|
|||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install @sindresorhus/is
|
||||
```sh
|
||||
npm install @sindresorhus/is
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
@ -82,6 +82,9 @@ All the below methods accept a value and returns a boolean for whether the value
|
|||
|
||||
##### .undefined(value)
|
||||
##### .null(value)
|
||||
|
||||
**Note:** TypeScript users must use `.null_()` because of a TypeScript naming limitation.
|
||||
|
||||
##### .string(value)
|
||||
##### .number(value)
|
||||
|
||||
|
@ -103,7 +106,11 @@ is.array(value, is.number); // Validate `value` is an array and all of its items
|
|||
```
|
||||
|
||||
##### .function(value)
|
||||
|
||||
**Note:** TypeScript users must use `.function_()` because of a TypeScript naming limitation.
|
||||
|
||||
##### .buffer(value)
|
||||
##### .blob(value)
|
||||
##### .object(value)
|
||||
|
||||
Keep in mind that [functions are objects too](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions).
|
||||
|
@ -212,19 +219,47 @@ is.boundFunction(function () {});
|
|||
##### .sharedArrayBuffer(value)
|
||||
##### .dataView(value)
|
||||
|
||||
##### .enumCase(value, enum)
|
||||
|
||||
TypeScript-only. Returns `true` if `value` is a member of `enum`.
|
||||
|
||||
```ts
|
||||
enum Direction {
|
||||
Ascending = 'ascending',
|
||||
Descending = 'descending'
|
||||
}
|
||||
|
||||
is.enumCase('ascending', Direction);
|
||||
//=> true
|
||||
|
||||
is.enumCase('other', Direction);
|
||||
//=> false
|
||||
```
|
||||
|
||||
#### Emptiness
|
||||
|
||||
##### .emptyString(value)
|
||||
|
||||
Returns `true` if the value is a `string` and the `.length` is 0.
|
||||
|
||||
##### .emptyStringOrWhitespace(value)
|
||||
|
||||
Returns `true` if `is.emptyString(value)` or if it's a `string` that is all whitespace.
|
||||
|
||||
##### .nonEmptyString(value)
|
||||
|
||||
Returns `true` if the value is a `string` and the `.length` is more than 0.
|
||||
|
||||
##### .emptyStringOrWhitespace(value)
|
||||
##### .nonEmptyStringAndNotWhitespace(value)
|
||||
|
||||
Returns `true` if `is.emptyString(value)` or if it's a `string` that is all whitespace.
|
||||
Returns `true` if the value is a `string` that is not empty and not whitespace.
|
||||
|
||||
```js
|
||||
const values = ['property1', '', null, 'property2', ' ', undefined];
|
||||
|
||||
values.filter(is.nonEmptyStringAndNotWhitespace);
|
||||
//=> ['property1', 'property2']
|
||||
```
|
||||
|
||||
##### .emptyArray(value)
|
||||
|
||||
|
@ -355,6 +390,8 @@ An object is plain if it's created by either `{}`, `new Object()`, or `Object.cr
|
|||
|
||||
Returns `true` for instances created by a class.
|
||||
|
||||
**Note:** TypeScript users must use `.class_()` because of a TypeScript naming limitation.
|
||||
|
||||
##### .typedArray(value)
|
||||
|
||||
##### .arrayLike(value)
|
||||
|
|
4
node_modules/@types/node-fetch/README.md
generated
vendored
4
node_modules/@types/node-fetch/README.md
generated
vendored
|
@ -8,9 +8,9 @@ This package contains type definitions for node-fetch (https://github.com/bitinn
|
|||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-fetch.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Thu, 22 Jul 2021 21:01:36 GMT
|
||||
* Last updated: Tue, 16 May 2023 01:03:00 GMT
|
||||
* Dependencies: [@types/form-data](https://npmjs.com/package/@types/form-data), [@types/node](https://npmjs.com/package/@types/node)
|
||||
* Global values: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [Torsten Werner](https://github.com/torstenwerner), [Niklas Lindgren](https://github.com/nikcorg), [Vinay Bedre](https://github.com/vinaybedre), [Antonio Román](https://github.com/kyranet), [Andrew Leedham](https://github.com/AndrewLeedham), [Jason Li](https://github.com/JasonLi914), [Steve Faulkner](https://github.com/southpolesteve), [ExE Boss](https://github.com/ExE-Boss), [Alex Savin](https://github.com/alexandrusavin), [Alexis Tyler](https://github.com/OmgImAlexis), and [Jakub Kisielewski](https://github.com/kbkk).
|
||||
These definitions were written by [Torsten Werner](https://github.com/torstenwerner), [Niklas Lindgren](https://github.com/nikcorg), [Vinay Bedre](https://github.com/vinaybedre), [Antonio Román](https://github.com/kyranet), [Andrew Leedham](https://github.com/AndrewLeedham), [Jason Li](https://github.com/JasonLi914), [Steve Faulkner](https://github.com/southpolesteve), [ExE Boss](https://github.com/ExE-Boss), [Alex Savin](https://github.com/alexandrusavin), [Alexis Tyler](https://github.com/OmgImAlexis), [Jakub Kisielewski](https://github.com/kbkk), and [David Glasser](https://github.com/glasser).
|
||||
|
|
5
node_modules/@types/node-fetch/externals.d.ts
generated
vendored
5
node_modules/@types/node-fetch/externals.d.ts
generated
vendored
|
@ -4,6 +4,7 @@
|
|||
|
||||
export interface AbortSignal {
|
||||
aborted: boolean;
|
||||
reason: any;
|
||||
|
||||
addEventListener: (type: "abort", listener: ((this: AbortSignal, event: any) => any), options?: boolean | {
|
||||
capture?: boolean | undefined,
|
||||
|
@ -17,5 +18,7 @@ export interface AbortSignal {
|
|||
|
||||
dispatchEvent: (event: any) => boolean;
|
||||
|
||||
onabort: null | ((this: AbortSignal, event: any) => void);
|
||||
onabort: null | ((this: AbortSignal, event: any) => any);
|
||||
|
||||
throwIfAborted(): void;
|
||||
}
|
||||
|
|
9
node_modules/@types/node-fetch/index.d.ts
generated
vendored
9
node_modules/@types/node-fetch/index.d.ts
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
// Type definitions for node-fetch 2.5
|
||||
// Type definitions for node-fetch 2.6
|
||||
// Project: https://github.com/bitinn/node-fetch
|
||||
// Definitions by: Torsten Werner <https://github.com/torstenwerner>
|
||||
// Niklas Lindgren <https://github.com/nikcorg>
|
||||
|
@ -11,12 +11,13 @@
|
|||
// Alex Savin <https://github.com/alexandrusavin>
|
||||
// Alexis Tyler <https://github.com/OmgImAlexis>
|
||||
// Jakub Kisielewski <https://github.com/kbkk>
|
||||
// David Glasser <https://github.com/glasser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import FormData = require('form-data');
|
||||
import { Agent } from "http";
|
||||
import { RequestOptions } from "http";
|
||||
import { URLSearchParams, URL } from "url";
|
||||
import { AbortSignal } from "./externals";
|
||||
|
||||
|
@ -31,7 +32,7 @@ export class Request extends Body {
|
|||
url: string;
|
||||
|
||||
// node-fetch extensions to the whatwg/fetch spec
|
||||
agent?: Agent | ((parsedUrl: URL) => Agent) | undefined;
|
||||
agent?: RequestOptions['agent'] | ((parsedUrl: URL) => RequestOptions['agent']);
|
||||
compress: boolean;
|
||||
counter: number;
|
||||
follow: number;
|
||||
|
@ -51,7 +52,7 @@ export interface RequestInit {
|
|||
signal?: AbortSignal | null | undefined;
|
||||
|
||||
// node-fetch extensions
|
||||
agent?: Agent | ((parsedUrl: URL) => Agent) | undefined; // =null http.Agent instance, allows custom proxy, certificate etc.
|
||||
agent?: RequestOptions['agent'] | ((parsedUrl: URL) => RequestOptions['agent']); // =null http.Agent instance, allows custom proxy, certificate etc.
|
||||
compress?: boolean | undefined; // =true support gzip/deflate content encoding. false to disable
|
||||
follow?: number | undefined; // =20 maximum redirect count. 0 to not follow redirect
|
||||
size?: number | undefined; // =0 maximum response body size in bytes. 0 to disable
|
||||
|
|
11
node_modules/@types/node-fetch/package.json
generated
vendored
11
node_modules/@types/node-fetch/package.json
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@types/node-fetch",
|
||||
"version": "2.5.12",
|
||||
"version": "2.6.4",
|
||||
"description": "TypeScript definitions for node-fetch",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-fetch",
|
||||
"license": "MIT",
|
||||
|
@ -59,6 +59,11 @@
|
|||
"name": "Jakub Kisielewski",
|
||||
"url": "https://github.com/kbkk",
|
||||
"githubUsername": "kbkk"
|
||||
},
|
||||
{
|
||||
"name": "David Glasser",
|
||||
"url": "https://github.com/glasser",
|
||||
"githubUsername": "glasser"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
|
@ -73,6 +78,6 @@
|
|||
"@types/node": "*",
|
||||
"form-data": "^3.0.0"
|
||||
},
|
||||
"typesPublisherContentHash": "cb95d0ddf740cecae06afa5d31c7c25945a352c24620ceb89c3b0da970a3d5e0",
|
||||
"typeScriptVersion": "3.6"
|
||||
"typesPublisherContentHash": "e1a69a7824613c58f845f6ae006edeb89add0e29c8ab4f75627b67dcd35f045d",
|
||||
"typeScriptVersion": "4.3"
|
||||
}
|
6
node_modules/@types/node/README.md
generated
vendored
6
node_modules/@types/node/README.md
generated
vendored
|
@ -8,9 +8,9 @@ This package contains type definitions for Node.js (https://nodejs.org/).
|
|||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Tue, 04 Jan 2022 18:31:31 GMT
|
||||
* Last updated: Sat, 02 Sep 2023 20:02:59 GMT
|
||||
* Dependencies: none
|
||||
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`
|
||||
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
|
||||
|
||||
# Credits
|
||||
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [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), [Seth Westphal](https://github.com/westy92), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Surasak Chaisurin](https://github.com/Ryan-Willpower), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [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), and [wafuwafu13](https://github.com/wafuwafu13).
|
||||
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [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).
|
||||
|
|
210
node_modules/@types/node/assert.d.ts
generated
vendored
210
node_modules/@types/node/assert.d.ts
generated
vendored
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* The `assert` module provides a set of assertion functions for verifying
|
||||
* The `node:assert` module provides a set of assertion functions for verifying
|
||||
* invariants.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/assert.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/assert.js)
|
||||
*/
|
||||
declare module 'assert' {
|
||||
/**
|
||||
|
@ -12,14 +12,28 @@ 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 `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 {
|
||||
/**
|
||||
* 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. */
|
||||
|
@ -36,9 +50,10 @@ declare module 'assert' {
|
|||
});
|
||||
}
|
||||
/**
|
||||
* This feature is currently experimental and behavior might still change.
|
||||
* 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
|
||||
* @experimental
|
||||
* @deprecated Deprecated
|
||||
*/
|
||||
class CallTracker {
|
||||
/**
|
||||
|
@ -47,7 +62,7 @@ declare module 'assert' {
|
|||
* error.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert';
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* // Creates call tracker.
|
||||
* const tracker = new assert.CallTracker();
|
||||
|
@ -65,26 +80,44 @@ declare module 'assert' {
|
|||
*/
|
||||
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 'assert';
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* // Creates call tracker.
|
||||
* const tracker = new assert.CallTracker();
|
||||
*
|
||||
* function func() {}
|
||||
*
|
||||
* function foo() {}
|
||||
*
|
||||
* // 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()
|
||||
* tracker.report();
|
||||
* console.log(tracker.report());
|
||||
* // [
|
||||
* // {
|
||||
* // message: 'Expected the func function to be executed 2 time(s) but was
|
||||
|
@ -97,15 +130,39 @@ declare module 'assert' {
|
|||
* // ]
|
||||
* ```
|
||||
* @since v14.2.0, v12.19.0
|
||||
* @return of objects containing information about the wrapper functions returned by `calls`.
|
||||
* @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 'assert';
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* // Creates call tracker.
|
||||
* const tracker = new assert.CallTracker();
|
||||
|
@ -125,6 +182,10 @@ declare module 'assert' {
|
|||
*/
|
||||
verify(): void;
|
||||
}
|
||||
interface CallTrackerCall {
|
||||
thisArg: object;
|
||||
arguments: unknown[];
|
||||
}
|
||||
interface CallTrackerReportInformation {
|
||||
message: string;
|
||||
/** The actual number of times the function was called. */
|
||||
|
@ -143,7 +204,7 @@ declare module 'assert' {
|
|||
* it will be thrown instead of the `AssertionError`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.fail();
|
||||
* // AssertionError [ERR_ASSERTION]: Failed
|
||||
|
@ -181,7 +242,7 @@ declare module 'assert' {
|
|||
* thrown in a file! See below for further details.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.ok(true);
|
||||
* // OK
|
||||
|
@ -216,7 +277,7 @@ declare module 'assert' {
|
|||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* // Using `assert()` works the same:
|
||||
* assert(0);
|
||||
|
@ -237,11 +298,11 @@ declare module 'assert' {
|
|||
* > Stability: 3 - Legacy: Use {@link strictEqual} instead.
|
||||
*
|
||||
* Tests shallow, coercive equality between the `actual` and `expected` parameters
|
||||
* using the [Abstract Equality Comparison](https://tc39.github.io/ecma262/#sec-abstract-equality-comparison) ( `==` ). `NaN` is special handled
|
||||
* and treated as being identical in case both sides are `NaN`.
|
||||
* 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 'assert';
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* assert.equal(1, 1);
|
||||
* // OK, 1 == 1
|
||||
|
@ -270,12 +331,11 @@ declare module 'assert' {
|
|||
*
|
||||
* > Stability: 3 - Legacy: Use {@link notStrictEqual} instead.
|
||||
*
|
||||
* Tests shallow, coercive inequality with the [Abstract Equality Comparison](https://tc39.github.io/ecma262/#sec-abstract-equality-comparison)(`!=` ). `NaN` is special handled and treated as
|
||||
* being identical in case both
|
||||
* sides are `NaN`.
|
||||
* 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 'assert';
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* assert.notEqual(1, 2);
|
||||
* // OK
|
||||
|
@ -322,24 +382,24 @@ declare module 'assert' {
|
|||
* Tests for any deep inequality. Opposite of {@link deepEqual}.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert';
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* const obj1 = {
|
||||
* a: {
|
||||
* b: 1
|
||||
* }
|
||||
* b: 1,
|
||||
* },
|
||||
* };
|
||||
* const obj2 = {
|
||||
* a: {
|
||||
* b: 2
|
||||
* }
|
||||
* b: 2,
|
||||
* },
|
||||
* };
|
||||
* const obj3 = {
|
||||
* a: {
|
||||
* b: 1
|
||||
* }
|
||||
* b: 1,
|
||||
* },
|
||||
* };
|
||||
* const obj4 = Object.create(obj1);
|
||||
* const obj4 = { __proto__: obj1 };
|
||||
*
|
||||
* assert.notDeepEqual(obj1, obj1);
|
||||
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
||||
|
@ -362,10 +422,10 @@ declare module 'assert' {
|
|||
function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* Tests strict equality between the `actual` and `expected` parameters as
|
||||
* determined by the [SameValue Comparison](https://tc39.github.io/ecma262/#sec-samevalue).
|
||||
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.strictEqual(1, 2);
|
||||
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
||||
|
@ -400,10 +460,10 @@ declare module 'assert' {
|
|||
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 the [SameValue Comparison](https://tc39.github.io/ecma262/#sec-samevalue).
|
||||
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.notStrictEqual(1, 2);
|
||||
* // OK
|
||||
|
@ -434,7 +494,7 @@ declare module 'assert' {
|
|||
* Tests for deep strict inequality. Opposite of {@link deepStrictEqual}.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
|
||||
* // OK
|
||||
|
@ -465,14 +525,14 @@ declare module 'assert' {
|
|||
* Custom validation object/error instance:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* const err = new TypeError('Wrong value');
|
||||
* err.code = 404;
|
||||
* err.foo = 'bar';
|
||||
* err.info = {
|
||||
* nested: true,
|
||||
* baz: 'text'
|
||||
* baz: 'text',
|
||||
* };
|
||||
* err.reg = /abc/i;
|
||||
*
|
||||
|
@ -485,16 +545,16 @@ declare module 'assert' {
|
|||
* message: 'Wrong value',
|
||||
* info: {
|
||||
* nested: true,
|
||||
* baz: 'text'
|
||||
* }
|
||||
* 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:
|
||||
* throws(
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw err;
|
||||
* },
|
||||
|
@ -508,17 +568,17 @@ declare module 'assert' {
|
|||
* info: {
|
||||
* nested: true,
|
||||
* // It is not possible to use regular expressions for nested properties!
|
||||
* baz: 'text'
|
||||
* 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
|
||||
* }
|
||||
* reg: /abc/i,
|
||||
* },
|
||||
* );
|
||||
*
|
||||
* // Fails due to the different `message` and `name` properties:
|
||||
* throws(
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* const otherErr = new Error('Not found');
|
||||
* // Copy all enumerable properties from `err` to `otherErr`.
|
||||
|
@ -529,20 +589,20 @@ declare module 'assert' {
|
|||
* },
|
||||
* // The error's `message` and `name` properties will also be checked when using
|
||||
* // an error as validation object.
|
||||
* err
|
||||
* err,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* Validate instanceof using constructor:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw new Error('Wrong value');
|
||||
* },
|
||||
* Error
|
||||
* Error,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
|
@ -552,13 +612,13 @@ declare module 'assert' {
|
|||
* therefore also include the error name.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw new Error('Wrong value');
|
||||
* },
|
||||
* /^Error: Wrong value$/
|
||||
* /^Error: Wrong value$/,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
|
@ -568,7 +628,7 @@ declare module 'assert' {
|
|||
* It will otherwise fail with an `AssertionError`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
|
@ -584,7 +644,7 @@ declare module 'assert' {
|
|||
* // possible.
|
||||
* return true;
|
||||
* },
|
||||
* 'unexpected error'
|
||||
* 'unexpected error',
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
|
@ -594,7 +654,7 @@ declare module 'assert' {
|
|||
* a string as the second argument gets considered:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* function throwingFirst() {
|
||||
* throw new Error('First');
|
||||
|
@ -650,20 +710,20 @@ declare module 'assert' {
|
|||
* 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
|
||||
* [`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 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotThrow(
|
||||
* () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* SyntaxError
|
||||
* SyntaxError,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
|
@ -671,27 +731,27 @@ declare module 'assert' {
|
|||
* 'Got unwanted exception...':
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotThrow(
|
||||
* () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* TypeError
|
||||
* 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 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotThrow(
|
||||
* () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* /Wrong value/,
|
||||
* 'Whoops'
|
||||
* 'Whoops',
|
||||
* );
|
||||
* // Throws: AssertionError: Got unwanted exception: Whoops
|
||||
* ```
|
||||
|
@ -705,7 +765,7 @@ declare module 'assert' {
|
|||
* from the error passed to `ifError()` including the potential new frames for`ifError()` itself.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.ifError(null);
|
||||
* // OK
|
||||
|
@ -751,7 +811,7 @@ declare module 'assert' {
|
|||
* If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* await assert.rejects(
|
||||
* async () => {
|
||||
|
@ -759,13 +819,13 @@ declare module 'assert' {
|
|||
* },
|
||||
* {
|
||||
* name: 'TypeError',
|
||||
* message: 'Wrong value'
|
||||
* }
|
||||
* message: 'Wrong value',
|
||||
* },
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* await assert.rejects(
|
||||
* async () => {
|
||||
|
@ -775,16 +835,16 @@ declare module 'assert' {
|
|||
* assert.strictEqual(err.name, 'TypeError');
|
||||
* assert.strictEqual(err.message, 'Wrong value');
|
||||
* return true;
|
||||
* }
|
||||
* },
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.rejects(
|
||||
* Promise.reject(new Error('Wrong value')),
|
||||
* Error
|
||||
* Error,
|
||||
* ).then(() => {
|
||||
* // ...
|
||||
* });
|
||||
|
@ -814,24 +874,24 @@ declare module 'assert' {
|
|||
* 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
|
||||
* [`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 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* await assert.doesNotReject(
|
||||
* async () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* SyntaxError
|
||||
* SyntaxError,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotReject(Promise.reject(new TypeError('Wrong value')))
|
||||
* .then(() => {
|
||||
|
@ -846,7 +906,7 @@ declare module 'assert' {
|
|||
* Expects the `string` input to match the regular expression.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.match('I will fail', /pass/);
|
||||
* // AssertionError [ERR_ASSERTION]: The input did not match the regular ...
|
||||
|
@ -869,7 +929,7 @@ declare module 'assert' {
|
|||
* Expects the `string` input not to match the regular expression.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'assert/strict';
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotMatch('I will fail', /fail/);
|
||||
* // AssertionError [ERR_ASSERTION]: The input was expected to not match the ...
|
||||
|
|
108
node_modules/@types/node/async_hooks.d.ts
generated
vendored
108
node_modules/@types/node/async_hooks.d.ts
generated
vendored
|
@ -1,17 +1,24 @@
|
|||
/**
|
||||
* The `async_hooks` module provides an API to track asynchronous resources. It
|
||||
* can be accessed using:
|
||||
* 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 'async_hooks';
|
||||
* import async_hooks from 'node:async_hooks';
|
||||
* ```
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/async_hooks.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/async_hooks.js)
|
||||
*/
|
||||
declare module 'async_hooks' {
|
||||
/**
|
||||
* ```js
|
||||
* import { executionAsyncId } from 'async_hooks';
|
||||
* import { executionAsyncId } from 'node:async_hooks';
|
||||
* import fs from 'node:fs';
|
||||
*
|
||||
* console.log(executionAsyncId()); // 1 - bootstrap
|
||||
* fs.open(path, 'r', (err, fd) => {
|
||||
|
@ -51,8 +58,8 @@ declare module 'async_hooks' {
|
|||
* but having an object representing the top-level can be helpful.
|
||||
*
|
||||
* ```js
|
||||
* import { open } from 'fs';
|
||||
* import { executionAsyncId, executionAsyncResource } from 'async_hooks';
|
||||
* 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) => {
|
||||
|
@ -64,11 +71,11 @@ declare module 'async_hooks' {
|
|||
* use of a tracking `Map` to store the metadata:
|
||||
*
|
||||
* ```js
|
||||
* import { createServer } from 'http';
|
||||
* import { createServer } from 'node:http';
|
||||
* import {
|
||||
* executionAsyncId,
|
||||
* executionAsyncResource,
|
||||
* createHook
|
||||
* createHook,
|
||||
* } from 'async_hooks';
|
||||
* const sym = Symbol('state'); // Private symbol to avoid pollution
|
||||
*
|
||||
|
@ -78,7 +85,7 @@ declare module 'async_hooks' {
|
|||
* if (cr) {
|
||||
* resource[sym] = cr[sym];
|
||||
* }
|
||||
* }
|
||||
* },
|
||||
* }).enable();
|
||||
*
|
||||
* const server = createServer((req, res) => {
|
||||
|
@ -167,11 +174,11 @@ declare module 'async_hooks' {
|
|||
* specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section.
|
||||
*
|
||||
* ```js
|
||||
* import { createHook } from 'async_hooks';
|
||||
* import { createHook } from 'node:async_hooks';
|
||||
*
|
||||
* const asyncHook = createHook({
|
||||
* init(asyncId, type, triggerAsyncId, resource) { },
|
||||
* destroy(asyncId) { }
|
||||
* destroy(asyncId) { },
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
|
@ -223,13 +230,13 @@ declare module 'async_hooks' {
|
|||
* The following is an overview of the `AsyncResource` API.
|
||||
*
|
||||
* ```js
|
||||
* import { AsyncResource, executionAsyncId } from 'async_hooks';
|
||||
* 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 }
|
||||
* type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false },
|
||||
* );
|
||||
*
|
||||
* // Run a function in the execution context of the resource. This will
|
||||
|
@ -258,38 +265,22 @@ declare module 'async_hooks' {
|
|||
* @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 9.3)
|
||||
* AsyncResourceOptions object (since v9.3.0)
|
||||
*/
|
||||
constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
|
||||
/**
|
||||
* Binds the given function to the current execution context.
|
||||
*
|
||||
* The returned function will have an `asyncResource` property referencing
|
||||
* the `AsyncResource` to which the function is bound.
|
||||
* @since v14.8.0, v12.19.0
|
||||
* @param fn The function to bind to the current execution context.
|
||||
* @param type An optional name to associate with the underlying `AsyncResource`.
|
||||
*/
|
||||
static bind<Func extends (this: ThisArg, ...args: any[]) => any, ThisArg>(
|
||||
fn: Func,
|
||||
type?: string,
|
||||
thisArg?: ThisArg
|
||||
): Func & {
|
||||
asyncResource: AsyncResource;
|
||||
};
|
||||
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.
|
||||
*
|
||||
* The returned function will have an `asyncResource` property referencing
|
||||
* the `AsyncResource` to which the function is bound.
|
||||
* @since v14.8.0, v12.19.0
|
||||
* @param fn The function to bind to the current `AsyncResource`.
|
||||
*/
|
||||
bind<Func extends (...args: any[]) => any>(
|
||||
fn: Func
|
||||
): Func & {
|
||||
asyncResource: AsyncResource;
|
||||
};
|
||||
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
|
||||
|
@ -322,17 +313,17 @@ 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 `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.
|
||||
* 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 'http';
|
||||
* import { AsyncLocalStorage } from 'async_hooks';
|
||||
* import http from 'node:http';
|
||||
* import { AsyncLocalStorage } from 'node:async_hooks';
|
||||
*
|
||||
* const asyncLocalStorage = new AsyncLocalStorage();
|
||||
*
|
||||
|
@ -364,10 +355,48 @@ declare module 'async_hooks' {
|
|||
*
|
||||
* Each instance of `AsyncLocalStorage` maintains an independent storage context.
|
||||
* Multiple instances can safely exist simultaneously without risk of interfering
|
||||
* with each other data.
|
||||
* 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.
|
||||
|
@ -423,6 +452,7 @@ declare module 'async_hooks' {
|
|||
* ```
|
||||
* @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
|
||||
|
|
426
node_modules/@types/node/buffer.d.ts
generated
vendored
426
node_modules/@types/node/buffer.d.ts
generated
vendored
File diff suppressed because it is too large
Load diff
150
node_modules/@types/node/child_process.d.ts
generated
vendored
150
node_modules/@types/node/child_process.d.ts
generated
vendored
|
@ -1,10 +1,10 @@
|
|||
/**
|
||||
* The `child_process` module provides the ability to spawn subprocesses in
|
||||
* The `node:child_process` module provides the ability to spawn subprocesses in
|
||||
* a manner that is similar, but not identical, to [`popen(3)`](http://man7.org/linux/man-pages/man3/popen.3.html). This capability
|
||||
* is primarily provided by the {@link spawn} function:
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('child_process');
|
||||
* const { spawn } = require('node:child_process');
|
||||
* const ls = spawn('ls', ['-lh', '/usr']);
|
||||
*
|
||||
* ls.stdout.on('data', (data) => {
|
||||
|
@ -28,8 +28,11 @@
|
|||
* 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 it is in the `options` object. Otherwise, `process.env.PATH` is
|
||||
* used.
|
||||
* variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is
|
||||
* used. If `options.env` is set without `PATH`, lookup on Unix is performed
|
||||
* on a default search path search of `/usr/bin:/bin` (see your operating system's
|
||||
* manual for execvpe/execvp), on Windows the current processes environment
|
||||
* variable `PATH` is used.
|
||||
*
|
||||
* On Windows, environment variables are case-insensitive. Node.js
|
||||
* lexicographically sorts the `env` keys and uses the first one that
|
||||
|
@ -41,8 +44,8 @@
|
|||
* without blocking the Node.js event loop. The {@link spawnSync} function provides equivalent functionality in a synchronous manner that blocks
|
||||
* the event loop until the spawned process either exits or is terminated.
|
||||
*
|
||||
* For convenience, the `child_process` module provides a handful of synchronous
|
||||
* and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on
|
||||
* For convenience, the `node:child_process` module provides a handful of
|
||||
* synchronous and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on
|
||||
* top of {@link spawn} or {@link spawnSync}.
|
||||
*
|
||||
* * {@link exec}: spawns a shell and runs a command within that
|
||||
|
@ -60,7 +63,7 @@
|
|||
* 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/v17.0.0/lib/child_process.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/child_process.js)
|
||||
*/
|
||||
declare module 'child_process' {
|
||||
import { ObjectEncodingOptions } from 'node:fs';
|
||||
|
@ -91,8 +94,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 `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;
|
||||
|
@ -106,7 +108,7 @@ declare module 'child_process' {
|
|||
* refer to the same value.
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('child_process');
|
||||
* const { spawn } = require('node:child_process');
|
||||
*
|
||||
* const subprocess = spawn('ls');
|
||||
*
|
||||
|
@ -115,8 +117,7 @@ declare module 'child_process' {
|
|||
* });
|
||||
* ```
|
||||
*
|
||||
* The `subprocess.stdout` property can be `null` 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;
|
||||
|
@ -129,14 +130,13 @@ 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` 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;
|
||||
/**
|
||||
* The `subprocess.channel` property is a reference to the child's IPC channel. If
|
||||
* no IPC channel currently exists, this property is `undefined`.
|
||||
* no IPC channel exists, this property is `undefined`.
|
||||
* @since v7.1.0
|
||||
*/
|
||||
readonly channel?: Pipe | null | undefined;
|
||||
|
@ -151,16 +151,16 @@ declare module 'child_process' {
|
|||
* in the array are `null`.
|
||||
*
|
||||
* ```js
|
||||
* const assert = require('assert');
|
||||
* const fs = require('fs');
|
||||
* const child_process = require('child_process');
|
||||
* const assert = require('node:assert');
|
||||
* const fs = require('node:fs');
|
||||
* const child_process = require('node:child_process');
|
||||
*
|
||||
* const subprocess = child_process.spawn('ls', {
|
||||
* stdio: [
|
||||
* 0, // Use parent's stdin for child.
|
||||
* 'pipe', // Pipe child's stdout to parent.
|
||||
* fs.openSync('err.out', 'w'), // Direct child's stderr to a file.
|
||||
* ]
|
||||
* ],
|
||||
* });
|
||||
*
|
||||
* assert.strictEqual(subprocess.stdio[0], null);
|
||||
|
@ -201,7 +201,7 @@ declare module 'child_process' {
|
|||
* emitted.
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('child_process');
|
||||
* const { spawn } = require('node:child_process');
|
||||
* const grep = spawn('grep', ['ssh']);
|
||||
*
|
||||
* console.log(`Spawned child pid: ${grep.pid}`);
|
||||
|
@ -248,7 +248,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('child_process');
|
||||
* const { spawn } = require('node:child_process');
|
||||
* const grep = spawn('grep', ['ssh']);
|
||||
*
|
||||
* grep.on('close', (code, signal) => {
|
||||
|
@ -281,7 +281,7 @@ declare module 'child_process' {
|
|||
*
|
||||
* ```js
|
||||
* 'use strict';
|
||||
* const { spawn } = require('child_process');
|
||||
* const { spawn } = require('node:child_process');
|
||||
*
|
||||
* const subprocess = spawn(
|
||||
* 'sh',
|
||||
|
@ -291,8 +291,8 @@ declare module 'child_process' {
|
|||
* console.log(process.pid, 'is alive')
|
||||
* }, 500);"`,
|
||||
* ], {
|
||||
* stdio: ['inherit', 'inherit', 'inherit']
|
||||
* }
|
||||
* stdio: ['inherit', 'inherit', 'inherit'],
|
||||
* },
|
||||
* );
|
||||
*
|
||||
* setTimeout(() => {
|
||||
|
@ -302,6 +302,11 @@ declare module 'child_process' {
|
|||
* @since v0.1.90
|
||||
*/
|
||||
kill(signal?: NodeJS.Signals | number): boolean;
|
||||
/**
|
||||
* Calls {@link ChildProcess.kill} with `'SIGTERM'`.
|
||||
* @since v20.5.0
|
||||
*/
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* When an IPC channel has been established between the parent and child (
|
||||
* i.e. when using {@link fork}), the `subprocess.send()` method can
|
||||
|
@ -314,7 +319,7 @@ declare module 'child_process' {
|
|||
* For example, in the parent script:
|
||||
*
|
||||
* ```js
|
||||
* const cp = require('child_process');
|
||||
* const cp = require('node:child_process');
|
||||
* const n = cp.fork(`${__dirname}/sub.js`);
|
||||
*
|
||||
* n.on('message', (m) => {
|
||||
|
@ -368,10 +373,10 @@ declare module 'child_process' {
|
|||
* a TCP server object to the child process as illustrated in the example below:
|
||||
*
|
||||
* ```js
|
||||
* const subprocess = require('child_process').fork('subprocess.js');
|
||||
* const subprocess = require('node:child_process').fork('subprocess.js');
|
||||
*
|
||||
* // Open up the server object and send the handle.
|
||||
* const server = require('net').createServer();
|
||||
* const server = require('node:net').createServer();
|
||||
* server.on('connection', (socket) => {
|
||||
* socket.end('handled by parent');
|
||||
* });
|
||||
|
@ -395,10 +400,9 @@ 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 `net` module, `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, currently only supported on Unix
|
||||
* platforms.
|
||||
* 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
|
||||
*
|
||||
|
@ -407,13 +411,13 @@ declare module 'child_process' {
|
|||
* handle connections with "normal" or "special" priority:
|
||||
*
|
||||
* ```js
|
||||
* const { fork } = require('child_process');
|
||||
* const { fork } = require('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('net').createServer({ pauseOnConnect: true });
|
||||
* const server = require('node:net').createServer({ pauseOnConnect: true });
|
||||
* server.on('connection', (socket) => {
|
||||
*
|
||||
* // If this is special priority...
|
||||
|
@ -479,11 +483,11 @@ declare module 'child_process' {
|
|||
* the child and the parent.
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('child_process');
|
||||
* const { spawn } = require('node:child_process');
|
||||
*
|
||||
* const subprocess = spawn(process.argv[0], ['child_program.js'], {
|
||||
* detached: true,
|
||||
* stdio: 'ignore'
|
||||
* stdio: 'ignore',
|
||||
* });
|
||||
*
|
||||
* subprocess.unref();
|
||||
|
@ -497,11 +501,11 @@ declare module 'child_process' {
|
|||
* to wait for the child to exit before exiting itself.
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('child_process');
|
||||
* const { spawn } = require('node:child_process');
|
||||
*
|
||||
* const subprocess = spawn(process.argv[0], ['child_program.js'], {
|
||||
* detached: true,
|
||||
* stdio: 'ignore'
|
||||
* stdio: 'ignore',
|
||||
* });
|
||||
*
|
||||
* subprocess.unref();
|
||||
|
@ -621,7 +625,7 @@ declare module 'child_process' {
|
|||
}
|
||||
interface CommonOptions extends ProcessEnvOptions {
|
||||
/**
|
||||
* @default true
|
||||
* @default false
|
||||
*/
|
||||
windowsHide?: boolean | undefined;
|
||||
/**
|
||||
|
@ -631,6 +635,15 @@ declare module 'child_process' {
|
|||
}
|
||||
interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable {
|
||||
argv0?: string | undefined;
|
||||
/**
|
||||
* Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings.
|
||||
* If passed as an array, the first element is used for `stdin`, the second for
|
||||
* `stdout`, and the third for `stderr`. A fourth element can be used to
|
||||
* specify the `stdio` behavior beyond the standard streams. See
|
||||
* {@link ChildProcess.stdio} for more information.
|
||||
*
|
||||
* @default 'pipe'
|
||||
*/
|
||||
stdio?: StdioOptions | undefined;
|
||||
shell?: boolean | string | undefined;
|
||||
windowsVerbatimArguments?: boolean | undefined;
|
||||
|
@ -660,7 +673,7 @@ declare module 'child_process' {
|
|||
* ```js
|
||||
* const defaults = {
|
||||
* cwd: undefined,
|
||||
* env: process.env
|
||||
* env: process.env,
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
|
@ -679,7 +692,7 @@ declare module 'child_process' {
|
|||
* exit code:
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('child_process');
|
||||
* const { spawn } = require('node:child_process');
|
||||
* const ls = spawn('ls', ['-lh', '/usr']);
|
||||
*
|
||||
* ls.stdout.on('data', (data) => {
|
||||
|
@ -698,7 +711,7 @@ declare module 'child_process' {
|
|||
* Example: A very elaborate way to run `ps ax | grep ssh`
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('child_process');
|
||||
* const { spawn } = require('node:child_process');
|
||||
* const ps = spawn('ps', ['ax']);
|
||||
* const grep = spawn('grep', ['ssh']);
|
||||
*
|
||||
|
@ -735,7 +748,7 @@ declare module 'child_process' {
|
|||
* Example of checking for failed `spawn`:
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('child_process');
|
||||
* const { spawn } = require('node:child_process');
|
||||
* const subprocess = spawn('bad_command');
|
||||
*
|
||||
* subprocess.on('error', (err) => {
|
||||
|
@ -746,14 +759,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 currently 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
|
||||
* the error passed to the callback will be an `AbortError`:
|
||||
*
|
||||
* ```js
|
||||
* const { spawn } = require('child_process');
|
||||
* const { spawn } = require('node:child_process');
|
||||
* const controller = new AbortController();
|
||||
* const { signal } = controller;
|
||||
* const grep = spawn('grep', ['ssh'], { signal });
|
||||
|
@ -812,7 +825,7 @@ declare module 'child_process' {
|
|||
* need to be dealt with accordingly:
|
||||
*
|
||||
* ```js
|
||||
* const { exec } = require('child_process');
|
||||
* const { exec } = require('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
|
||||
|
@ -838,7 +851,7 @@ declare module 'child_process' {
|
|||
* encoding, `Buffer` objects will be passed to the callback instead.
|
||||
*
|
||||
* ```js
|
||||
* const { exec } = require('child_process');
|
||||
* const { exec } = require('node:child_process');
|
||||
* exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
|
||||
* if (error) {
|
||||
* console.error(`exec error: ${error}`);
|
||||
|
@ -863,8 +876,8 @@ declare module 'child_process' {
|
|||
* callback, but with two additional properties `stdout` and `stderr`.
|
||||
*
|
||||
* ```js
|
||||
* const util = require('util');
|
||||
* const exec = util.promisify(require('child_process').exec);
|
||||
* const util = require('node:util');
|
||||
* const exec = util.promisify(require('node:child_process').exec);
|
||||
*
|
||||
* async function lsExample() {
|
||||
* const { stdout, stderr } = await exec('ls');
|
||||
|
@ -878,11 +891,11 @@ declare module 'child_process' {
|
|||
* the error passed to the callback will be an `AbortError`:
|
||||
*
|
||||
* ```js
|
||||
* const { exec } = require('child_process');
|
||||
* const { exec } = require('node:child_process');
|
||||
* const controller = new AbortController();
|
||||
* const { signal } = controller;
|
||||
* const child = exec('grep ssh', { signal }, (error) => {
|
||||
* console.log(error); // an AbortError
|
||||
* console.error(error); // an AbortError
|
||||
* });
|
||||
* controller.abort();
|
||||
* ```
|
||||
|
@ -981,7 +994,10 @@ declare module 'child_process' {
|
|||
interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {
|
||||
encoding: BufferEncoding;
|
||||
}
|
||||
type ExecFileException = ExecException & NodeJS.ErrnoException;
|
||||
type ExecFileException =
|
||||
& Omit<ExecException, 'code'>
|
||||
& Omit<NodeJS.ErrnoException, 'code'>
|
||||
& { code?: string | number | undefined | null };
|
||||
/**
|
||||
* The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified
|
||||
* executable `file` is spawned directly as a new process making it slightly more
|
||||
|
@ -992,7 +1008,7 @@ declare module 'child_process' {
|
|||
* supported.
|
||||
*
|
||||
* ```js
|
||||
* const { execFile } = require('child_process');
|
||||
* const { execFile } = require('node:child_process');
|
||||
* const child = execFile('node', ['--version'], (error, stdout, stderr) => {
|
||||
* if (error) {
|
||||
* throw error;
|
||||
|
@ -1015,8 +1031,8 @@ declare module 'child_process' {
|
|||
* callback, but with two additional properties `stdout` and `stderr`.
|
||||
*
|
||||
* ```js
|
||||
* const util = require('util');
|
||||
* const execFile = util.promisify(require('child_process').execFile);
|
||||
* const util = require('node:util');
|
||||
* const execFile = util.promisify(require('node:child_process').execFile);
|
||||
* async function getVersion() {
|
||||
* const { stdout } = await execFile('node', ['--version']);
|
||||
* console.log(stdout);
|
||||
|
@ -1032,11 +1048,11 @@ declare module 'child_process' {
|
|||
* the error passed to the callback will be an `AbortError`:
|
||||
*
|
||||
* ```js
|
||||
* const { execFile } = require('child_process');
|
||||
* const { execFile } = require('node:child_process');
|
||||
* const controller = new AbortController();
|
||||
* const { signal } = controller;
|
||||
* const child = execFile('node', ['--version'], { signal }, (error) => {
|
||||
* console.log(error); // an AbortError
|
||||
* console.error(error); // an AbortError
|
||||
* });
|
||||
* controller.abort();
|
||||
* ```
|
||||
|
@ -1189,6 +1205,15 @@ declare module 'child_process' {
|
|||
execPath?: string | undefined;
|
||||
execArgv?: string[] | undefined;
|
||||
silent?: boolean | undefined;
|
||||
/**
|
||||
* Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings.
|
||||
* If passed as an array, the first element is used for `stdin`, the second for
|
||||
* `stdout`, and the third for `stderr`. A fourth element can be used to
|
||||
* specify the `stdio` behavior beyond the standard streams. See
|
||||
* {@link ChildProcess.stdio} for more information.
|
||||
*
|
||||
* @default 'pipe'
|
||||
*/
|
||||
stdio?: StdioOptions | undefined;
|
||||
detached?: boolean | undefined;
|
||||
windowsVerbatimArguments?: boolean | undefined;
|
||||
|
@ -1228,7 +1253,7 @@ declare module 'child_process' {
|
|||
* console.log(`Hello from ${process.argv[2]}!`);
|
||||
* }, 1_000);
|
||||
* } else {
|
||||
* const { fork } = require('child_process');
|
||||
* const { fork } = require('node:child_process');
|
||||
* const controller = new AbortController();
|
||||
* const { signal } = controller;
|
||||
* const child = fork(__filename, ['child'], { signal });
|
||||
|
@ -1289,6 +1314,15 @@ declare module 'child_process' {
|
|||
function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptions): SpawnSyncReturns<string | Buffer>;
|
||||
interface CommonExecOptions extends CommonOptions {
|
||||
input?: string | NodeJS.ArrayBufferView | undefined;
|
||||
/**
|
||||
* Can be set to 'pipe', 'inherit, or 'ignore', or an array of these strings.
|
||||
* If passed as an array, the first element is used for `stdin`, the second for
|
||||
* `stdout`, and the third for `stderr`. A fourth element can be used to
|
||||
* specify the `stdio` behavior beyond the standard streams. See
|
||||
* {@link ChildProcess.stdio} for more information.
|
||||
*
|
||||
* @default 'pipe'
|
||||
*/
|
||||
stdio?: StdioOptions | undefined;
|
||||
killSignal?: NodeJS.Signals | number | undefined;
|
||||
maxBuffer?: number | undefined;
|
||||
|
|
58
node_modules/@types/node/cluster.d.ts
generated
vendored
58
node_modules/@types/node/cluster.d.ts
generated
vendored
|
@ -1,18 +1,19 @@
|
|||
/**
|
||||
* A single instance of Node.js runs in a single thread. To take advantage of
|
||||
* multi-core systems, the user will sometimes want to launch a cluster of Node.js
|
||||
* processes to handle the load.
|
||||
* 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 'cluster';
|
||||
* import http from 'http';
|
||||
* import { cpus } from 'os';
|
||||
* import process from 'process';
|
||||
* import cluster from 'node:cluster';
|
||||
* import http from 'node:http';
|
||||
* import { availableParallelism } from 'node:os';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* const numCPUs = cpus().length;
|
||||
* const numCPUs = availableParallelism();
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* console.log(`Primary ${process.pid} is running`);
|
||||
|
@ -49,12 +50,13 @@
|
|||
* ```
|
||||
*
|
||||
* 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/v17.0.0/lib/cluster.js)
|
||||
* @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;
|
||||
|
@ -64,6 +66,9 @@ declare module 'cluster' {
|
|||
uid?: number | undefined;
|
||||
gid?: number | undefined;
|
||||
inspectPort?: number | (() => number) | undefined;
|
||||
serialization?: SerializationType | undefined;
|
||||
cwd?: string | undefined;
|
||||
windowsHide?: boolean | undefined;
|
||||
}
|
||||
export interface Address {
|
||||
address: string;
|
||||
|
@ -99,9 +104,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()`.
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
|
@ -123,19 +128,13 @@ declare module 'cluster' {
|
|||
send(message: child.Serializable, sendHandle: child.SendHandle, callback?: (error: Error | null) => void): boolean;
|
||||
send(message: child.Serializable, sendHandle: child.SendHandle, options?: child.MessageOptions, callback?: (error: Error | null) => void): boolean;
|
||||
/**
|
||||
* This function will kill the worker. In the primary, it does this
|
||||
* by disconnecting the `worker.process`, and once disconnected, killing
|
||||
* with `signal`. In the worker, it does it by disconnecting the channel,
|
||||
* and then exiting with code `0`.
|
||||
* 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`.
|
||||
*
|
||||
* Because `kill()` attempts to gracefully disconnect the worker process, it is
|
||||
* susceptible to waiting indefinitely for the disconnect to complete. For example,
|
||||
* if the worker enters an infinite loop, a graceful disconnect will never occur.
|
||||
* If the graceful disconnect behavior is not needed, use `worker.process.kill()`.
|
||||
* The `kill()` function kills the worker process without waiting for a graceful
|
||||
* disconnect, it has the same behavior as `worker.process.kill()`.
|
||||
*
|
||||
* Causes `.exitedAfterDisconnect` to be set.
|
||||
*
|
||||
* This method is aliased as `worker.destroy()` for backward compatibility.
|
||||
* 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()`.
|
||||
|
@ -188,7 +187,7 @@ declare module 'cluster' {
|
|||
* });
|
||||
*
|
||||
* } else if (cluster.isWorker) {
|
||||
* const net = require('net');
|
||||
* const net = require('node:net');
|
||||
* const server = net.createServer((socket) => {
|
||||
* // Connections never end
|
||||
* });
|
||||
|
@ -218,12 +217,12 @@ declare module 'cluster' {
|
|||
* because of exiting or being signaled). Otherwise, it returns `false`.
|
||||
*
|
||||
* ```js
|
||||
* import cluster from 'cluster';
|
||||
* import http from 'http';
|
||||
* import { cpus } from 'os';
|
||||
* import process from 'process';
|
||||
* import cluster from 'node:cluster';
|
||||
* import http from 'node:http';
|
||||
* import { availableParallelism } from 'node:os';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* const numCPUs = cpus().length;
|
||||
* const numCPUs = availableParallelism();
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* console.log(`Primary ${process.pid} is running`);
|
||||
|
@ -253,7 +252,8 @@ declare module 'cluster' {
|
|||
*/
|
||||
isDead(): boolean;
|
||||
/**
|
||||
* This property is `true` if the worker exited due to `.kill()` or`.disconnect()`. If the worker exited any other way, it is `false`. If the
|
||||
* 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
|
||||
|
|
10
node_modules/@types/node/console.d.ts
generated
vendored
10
node_modules/@types/node/console.d.ts
generated
vendored
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* The `console` module provides a simple debugging console that is similar to the
|
||||
* JavaScript console mechanism provided by web browsers.
|
||||
* 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('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` 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
|
||||
|
@ -53,7 +53,7 @@
|
|||
* myConsole.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to err
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/console.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/console.js)
|
||||
*/
|
||||
declare module 'console' {
|
||||
import console = require('node:console');
|
||||
|
|
1197
node_modules/@types/node/crypto.d.ts
generated
vendored
1197
node_modules/@types/node/crypto.d.ts
generated
vendored
File diff suppressed because it is too large
Load diff
37
node_modules/@types/node/dgram.d.ts
generated
vendored
37
node_modules/@types/node/dgram.d.ts
generated
vendored
|
@ -1,13 +1,13 @@
|
|||
/**
|
||||
* The `dgram` module provides an implementation of UDP datagram sockets.
|
||||
* The `node:dgram` module provides an implementation of UDP datagram sockets.
|
||||
*
|
||||
* ```js
|
||||
* import dgram from 'dgram';
|
||||
* import dgram from 'node:dgram';
|
||||
*
|
||||
* const server = dgram.createSocket('udp4');
|
||||
*
|
||||
* server.on('error', (err) => {
|
||||
* console.log(`server error:\n${err.stack}`);
|
||||
* console.error(`server error:\n${err.stack}`);
|
||||
* server.close();
|
||||
* });
|
||||
*
|
||||
|
@ -23,7 +23,7 @@
|
|||
* server.bind(41234);
|
||||
* // Prints: server listening 0.0.0.0:41234
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/dgram.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dgram.js)
|
||||
*/
|
||||
declare module 'dgram' {
|
||||
import { AddressInfo } from 'node:net';
|
||||
|
@ -98,8 +98,8 @@ declare module 'dgram' {
|
|||
* 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 'cluster';
|
||||
* import dgram from 'dgram';
|
||||
* import cluster from 'node:cluster';
|
||||
* import dgram from 'node:dgram';
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* cluster.fork(); // Works ok.
|
||||
|
@ -116,7 +116,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
|
||||
|
@ -142,12 +142,12 @@ declare module 'dgram' {
|
|||
* Example of a UDP server listening on port 41234:
|
||||
*
|
||||
* ```js
|
||||
* import dgram from 'dgram';
|
||||
* import dgram from 'node:dgram';
|
||||
*
|
||||
* const server = dgram.createSocket('udp4');
|
||||
*
|
||||
* server.on('error', (err) => {
|
||||
* console.log(`server error:\n${err.stack}`);
|
||||
* console.error(`server error:\n${err.stack}`);
|
||||
* server.close();
|
||||
* });
|
||||
*
|
||||
|
@ -284,8 +284,8 @@ declare module 'dgram' {
|
|||
* Example of sending a UDP packet to a port on `localhost`;
|
||||
*
|
||||
* ```js
|
||||
* import dgram from 'dgram';
|
||||
* import { Buffer } from 'buffer';
|
||||
* import dgram from 'node:dgram';
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const message = Buffer.from('Some bytes');
|
||||
* const client = dgram.createSocket('udp4');
|
||||
|
@ -297,8 +297,8 @@ declare module 'dgram' {
|
|||
* Example of sending a UDP packet composed of multiple buffers to a port on`127.0.0.1`;
|
||||
*
|
||||
* ```js
|
||||
* import dgram from 'dgram';
|
||||
* import { Buffer } from 'buffer';
|
||||
* import dgram from 'node:dgram';
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf1 = Buffer.from('Some ');
|
||||
* const buf2 = Buffer.from('bytes');
|
||||
|
@ -316,8 +316,8 @@ declare module 'dgram' {
|
|||
* Example of sending a UDP packet using a socket connected to a port on`localhost`:
|
||||
*
|
||||
* ```js
|
||||
* import dgram from 'dgram';
|
||||
* import { Buffer } from 'buffer';
|
||||
* import dgram from 'node:dgram';
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const message = Buffer.from('Some bytes');
|
||||
* const client = dgram.createSocket('udp4');
|
||||
|
@ -451,7 +451,7 @@ declare module 'dgram' {
|
|||
* TTL. If the TTL is decremented to 0 by a router, it will not be forwarded.
|
||||
* Changing TTL values is typically done for network probes or when multicasting.
|
||||
*
|
||||
* The `ttl` argument may be between between 1 and 255\. The default on most systems
|
||||
* 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.
|
||||
|
@ -538,6 +538,11 @@ declare module 'dgram' {
|
|||
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' {
|
||||
|
|
89
node_modules/@types/node/diagnostics_channel.d.ts
generated
vendored
89
node_modules/@types/node/diagnostics_channel.d.ts
generated
vendored
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* The `diagnostics_channel` module provides an API to create named channels
|
||||
* 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 'diagnostics_channel';
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
* ```
|
||||
*
|
||||
* It is intended that a module writer wanting to report diagnostics messages
|
||||
|
@ -19,8 +19,8 @@
|
|||
* channels are used along with the shape of the message data. Channel names
|
||||
* should generally include the module name to avoid collisions with data from
|
||||
* other modules.
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/diagnostics_channel.js)
|
||||
* @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' {
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ declare module 'diagnostics_channel' {
|
|||
* performance-sensitive code.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'diagnostics_channel';
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* if (diagnostics_channel.hasSubscribers('my-channel')) {
|
||||
* // There are subscribers, prepare and publish message
|
||||
|
@ -41,14 +41,14 @@ declare module 'diagnostics_channel' {
|
|||
* @param name The channel name
|
||||
* @return If there are active subscribers
|
||||
*/
|
||||
function hasSubscribers(name: string): boolean;
|
||||
function hasSubscribers(name: string | symbol): boolean;
|
||||
/**
|
||||
* This is the primary entry-point for anyone wanting to interact with a named
|
||||
* 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 'diagnostics_channel';
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
* ```
|
||||
|
@ -56,11 +56,48 @@ declare module 'diagnostics_channel' {
|
|||
* @param name The channel name
|
||||
* @return The named channel object
|
||||
*/
|
||||
function channel(name: string): Channel;
|
||||
type ChannelListener = (name: string, message: unknown) => void;
|
||||
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 use to track subscribers and to publish messages when there
|
||||
* 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
|
||||
|
@ -68,7 +105,7 @@ declare module 'diagnostics_channel' {
|
|||
* @since v15.1.0, v14.17.0
|
||||
*/
|
||||
class Channel {
|
||||
readonly name: string;
|
||||
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.
|
||||
|
@ -77,7 +114,7 @@ declare module 'diagnostics_channel' {
|
|||
* performance-sensitive code.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'diagnostics_channel';
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
*
|
||||
|
@ -88,14 +125,31 @@ declare module 'diagnostics_channel' {
|
|||
* @since v15.1.0, v14.17.0
|
||||
*/
|
||||
readonly hasSubscribers: boolean;
|
||||
private constructor(name: string);
|
||||
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 'diagnostics_channel';
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
*
|
||||
|
@ -104,6 +158,7 @@ declare module 'diagnostics_channel' {
|
|||
* });
|
||||
* ```
|
||||
* @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;
|
||||
|
@ -111,7 +166,7 @@ declare module 'diagnostics_channel' {
|
|||
* Remove a message handler previously registered to this channel with `channel.subscribe(onMessage)`.
|
||||
*
|
||||
* ```js
|
||||
* import diagnostics_channel from 'diagnostics_channel';
|
||||
* import diagnostics_channel from 'node:diagnostics_channel';
|
||||
*
|
||||
* const channel = diagnostics_channel.channel('my-channel');
|
||||
*
|
||||
|
@ -124,7 +179,9 @@ declare module 'diagnostics_channel' {
|
|||
* 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;
|
||||
}
|
||||
|
|
45
node_modules/@types/node/dns.d.ts
generated
vendored
45
node_modules/@types/node/dns.d.ts
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* The `dns` module enables name resolution. For example, use it to look up IP
|
||||
* 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
|
||||
|
@ -9,7 +9,7 @@
|
|||
* system do, use {@link lookup}.
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('dns');
|
||||
* const dns = require('node:dns');
|
||||
*
|
||||
* dns.lookup('example.org', (err, address, family) => {
|
||||
* console.log('address: %j family: IPv%s', address, family);
|
||||
|
@ -17,13 +17,13 @@
|
|||
* // address: "93.184.216.34" family: IPv4
|
||||
* ```
|
||||
*
|
||||
* All other functions in the `dns` module connect to an actual DNS server to
|
||||
* 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('dns');
|
||||
* const dns = require('node:dns');
|
||||
*
|
||||
* dns.resolve4('archive.org', (err, addresses) => {
|
||||
* if (err) throw err;
|
||||
|
@ -42,7 +42,7 @@
|
|||
* ```
|
||||
*
|
||||
* See the `Implementation considerations section` for more information.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/dns.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dns.js)
|
||||
*/
|
||||
declare module 'dns' {
|
||||
import * as dnsPromises from 'node:dns/promises';
|
||||
|
@ -76,8 +76,8 @@ declare module 'dns' {
|
|||
/**
|
||||
* 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.
|
||||
* 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`.
|
||||
|
@ -89,14 +89,14 @@ declare module 'dns' {
|
|||
*
|
||||
* `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
|
||||
* with addresses and vice versa. This implementation can have subtle but
|
||||
* important consequences on the behavior of any Node.js program. Please take some
|
||||
* time to consult the `Implementation considerations section` before using`dns.lookup()`.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('dns');
|
||||
* const dns = require('node:dns');
|
||||
* const options = {
|
||||
* family: 6,
|
||||
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
||||
|
@ -135,7 +135,7 @@ declare module 'dns' {
|
|||
* On an error, `err` is an `Error` object, where `err.code` is the error code.
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('dns');
|
||||
* const dns = require('node:dns');
|
||||
* dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
|
||||
* console.log(hostname, service);
|
||||
* // Prints: localhost ssh
|
||||
|
@ -174,7 +174,7 @@ declare module 'dns' {
|
|||
type: 'AAAA';
|
||||
}
|
||||
export interface CaaRecord {
|
||||
critial: number;
|
||||
critical: number;
|
||||
issue?: string | undefined;
|
||||
issuewild?: string | undefined;
|
||||
iodef?: string | undefined;
|
||||
|
@ -244,7 +244,7 @@ declare module 'dns' {
|
|||
*
|
||||
* <omitted>
|
||||
*
|
||||
* On error, `err` is an `Error` object, where `err.code` is one of theDNS error codes.
|
||||
* 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.
|
||||
|
@ -291,7 +291,7 @@ declare module 'dns' {
|
|||
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
||||
}
|
||||
/**
|
||||
* Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
||||
* 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.
|
||||
|
@ -333,7 +333,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`
|
||||
|
@ -484,6 +484,14 @@ declare module 'dns' {
|
|||
* @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
|
||||
|
@ -535,7 +543,7 @@ declare module 'dns' {
|
|||
* * `ipv4first`: sets default `verbatim` `false`.
|
||||
* * `verbatim`: sets default `verbatim` `true`.
|
||||
*
|
||||
* The default is `ipv4first` and {@link setDefaultResultOrder} have higher
|
||||
* 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
|
||||
|
@ -582,7 +590,7 @@ declare module 'dns' {
|
|||
* other resolvers:
|
||||
*
|
||||
* ```js
|
||||
* const { Resolver } = require('dns');
|
||||
* const { Resolver } = require('node:dns');
|
||||
* const resolver = new Resolver();
|
||||
* resolver.setServers(['4.4.4.4']);
|
||||
*
|
||||
|
@ -592,7 +600,7 @@ declare module 'dns' {
|
|||
* });
|
||||
* ```
|
||||
*
|
||||
* The following methods from the `dns` module are available:
|
||||
* The following methods from the `node:dns` module are available:
|
||||
*
|
||||
* * `resolver.getServers()`
|
||||
* * `resolver.resolve()`
|
||||
|
@ -625,6 +633,7 @@ declare module 'dns' {
|
|||
resolve4: typeof resolve4;
|
||||
resolve6: typeof resolve6;
|
||||
resolveAny: typeof resolveAny;
|
||||
resolveCaa: typeof resolveCaa;
|
||||
resolveCname: typeof resolveCname;
|
||||
resolveMx: typeof resolveMx;
|
||||
resolveNaptr: typeof resolveNaptr;
|
||||
|
@ -639,7 +648,7 @@ declare module 'dns' {
|
|||
* 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
|
||||
* 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
|
||||
|
|
60
node_modules/@types/node/dns/promises.d.ts
generated
vendored
60
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('dns').promises` or `require('dns/promises')`.
|
||||
* via `require('node:dns').promises` or `require('node:dns/promises')`.
|
||||
* @since v10.6.0
|
||||
*/
|
||||
declare module 'dns/promises' {
|
||||
|
@ -52,7 +52,7 @@ declare module 'dns/promises' {
|
|||
*
|
||||
* `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
|
||||
* 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()`.
|
||||
|
@ -60,7 +60,7 @@ declare module 'dns/promises' {
|
|||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('dns');
|
||||
* const dns = require('node:dns');
|
||||
* const dnsPromises = dns.promises;
|
||||
* const options = {
|
||||
* family: 6,
|
||||
|
@ -96,7 +96,7 @@ declare module 'dns/promises' {
|
|||
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
|
||||
*
|
||||
* ```js
|
||||
* const dnsPromises = require('dns').promises;
|
||||
* const dnsPromises = require('node:dns').promises;
|
||||
* dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
|
||||
* console.log(result.hostname, result.service);
|
||||
* // Prints: localhost ssh
|
||||
|
@ -119,7 +119,7 @@ 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` 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.
|
||||
|
@ -206,7 +206,7 @@ declare module 'dns/promises' {
|
|||
*/
|
||||
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`
|
||||
|
@ -300,7 +300,7 @@ 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` object, where `err.code`is one of the `DNS error codes`.
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function reverse(ip: string): Promise<string[]>;
|
||||
|
@ -337,13 +337,56 @@ declare module 'dns/promises' {
|
|||
* * `ipv4first`: sets default `verbatim` `false`.
|
||||
* * `verbatim`: sets default `verbatim` `true`.
|
||||
*
|
||||
* The default is `ipv4first` and `dnsPromises.setDefaultResultOrder()` have
|
||||
* 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;
|
||||
|
@ -352,6 +395,7 @@ declare module 'dns/promises' {
|
|||
resolve4: typeof resolve4;
|
||||
resolve6: typeof resolve6;
|
||||
resolveAny: typeof resolveAny;
|
||||
resolveCaa: typeof resolveCaa;
|
||||
resolveCname: typeof resolveCname;
|
||||
resolveMx: typeof resolveMx;
|
||||
resolveNaptr: typeof resolveNaptr;
|
||||
|
|
126
node_modules/@types/node/dom-events.d.ts
generated
vendored
Executable file
126
node_modules/@types/node/dom-events.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,126 @@
|
|||
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;
|
||||
};
|
||||
}
|
11
node_modules/@types/node/domain.d.ts
generated
vendored
11
node_modules/@types/node/domain.d.ts
generated
vendored
|
@ -1,6 +1,7 @@
|
|||
/**
|
||||
* **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
|
||||
* 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.
|
||||
|
@ -11,7 +12,7 @@
|
|||
* 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/v17.0.0/lib/domain.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/domain.js)
|
||||
*/
|
||||
declare module 'domain' {
|
||||
import EventEmitter = require('node:events');
|
||||
|
@ -55,15 +56,15 @@ declare module 'domain' {
|
|||
exit(): void;
|
||||
/**
|
||||
* Run the supplied function in the context of the domain, implicitly
|
||||
* binding all event emitters, timers, and lowlevel requests that are
|
||||
* 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('domain');
|
||||
* const fs = require('fs');
|
||||
* const domain = require('node:domain');
|
||||
* const fs = require('node:fs');
|
||||
* const d = domain.create();
|
||||
* d.on('error', (er) => {
|
||||
* console.error('Caught error!', er);
|
||||
|
|
297
node_modules/@types/node/events.d.ts
generated
vendored
297
node_modules/@types/node/events.d.ts
generated
vendored
|
@ -22,7 +22,7 @@
|
|||
* the `eventEmitter.emit()` method is used to trigger the event.
|
||||
*
|
||||
* ```js
|
||||
* const EventEmitter = require('events');
|
||||
* import { EventEmitter } from 'node:events';
|
||||
*
|
||||
* class MyEmitter extends EventEmitter {}
|
||||
*
|
||||
|
@ -32,19 +32,54 @@
|
|||
* });
|
||||
* myEmitter.emit('event');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/events.js)
|
||||
* @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;
|
||||
}
|
||||
interface NodeEventTarget {
|
||||
// Any EventTarget with a Node-style `once` function
|
||||
interface _NodeEventTarget {
|
||||
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
interface DOMEventTarget {
|
||||
// Any EventTarget with a DOM-style `addEventListener`
|
||||
interface _DOMEventTarget {
|
||||
addEventListener(
|
||||
eventName: string,
|
||||
listener: (...args: any[]) => void,
|
||||
|
@ -58,10 +93,10 @@ declare module 'events' {
|
|||
}
|
||||
interface EventEmitter extends NodeJS.EventEmitter {}
|
||||
/**
|
||||
* The `EventEmitter` class is defined and exposed by the `events` module:
|
||||
* The `EventEmitter` class is defined and exposed by the `node:events` module:
|
||||
*
|
||||
* ```js
|
||||
* const EventEmitter = require('events');
|
||||
* import { EventEmitter } from 'node:events';
|
||||
* ```
|
||||
*
|
||||
* All `EventEmitter`s emit the event `'newListener'` when new listeners are
|
||||
|
@ -82,31 +117,28 @@ declare module 'events' {
|
|||
* semantics and does not listen to the `'error'` event.
|
||||
*
|
||||
* ```js
|
||||
* const { once, EventEmitter } = require('events');
|
||||
* import { once, EventEmitter } from 'node:events';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* async function run() {
|
||||
* const ee = new EventEmitter();
|
||||
* const ee = new EventEmitter();
|
||||
*
|
||||
* process.nextTick(() => {
|
||||
* ee.emit('myevent', 42);
|
||||
* });
|
||||
* process.nextTick(() => {
|
||||
* ee.emit('myevent', 42);
|
||||
* });
|
||||
*
|
||||
* const [value] = await once(ee, 'myevent');
|
||||
* console.log(value);
|
||||
* const [value] = await once(ee, 'myevent');
|
||||
* console.log(value);
|
||||
*
|
||||
* const err = new Error('kaboom');
|
||||
* process.nextTick(() => {
|
||||
* ee.emit('error', err);
|
||||
* });
|
||||
* const err = new Error('kaboom');
|
||||
* process.nextTick(() => {
|
||||
* ee.emit('error', err);
|
||||
* });
|
||||
*
|
||||
* try {
|
||||
* await once(ee, 'myevent');
|
||||
* } catch (err) {
|
||||
* console.log('error happened', err);
|
||||
* }
|
||||
* try {
|
||||
* await once(ee, 'myevent');
|
||||
* } catch (err) {
|
||||
* console.error('error happened', err);
|
||||
* }
|
||||
*
|
||||
* run();
|
||||
* ```
|
||||
*
|
||||
* 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
|
||||
|
@ -114,13 +146,13 @@ declare module 'events' {
|
|||
* special handling:
|
||||
*
|
||||
* ```js
|
||||
* const { EventEmitter, once } = require('events');
|
||||
* import { EventEmitter, once } from 'node:events';
|
||||
*
|
||||
* const ee = new EventEmitter();
|
||||
*
|
||||
* once(ee, 'error')
|
||||
* .then(([err]) => console.log('ok', err.message))
|
||||
* .catch((err) => console.log('error', err.message));
|
||||
* .catch((err) => console.error('error', err.message));
|
||||
*
|
||||
* ee.emit('error', new Error('boom'));
|
||||
*
|
||||
|
@ -130,7 +162,7 @@ declare module 'events' {
|
|||
* An `AbortSignal` can be used to cancel waiting for the event:
|
||||
*
|
||||
* ```js
|
||||
* const { EventEmitter, once } = require('events');
|
||||
* import { EventEmitter, once } from 'node:events';
|
||||
*
|
||||
* const ee = new EventEmitter();
|
||||
* const ac = new AbortController();
|
||||
|
@ -154,29 +186,28 @@ declare module 'events' {
|
|||
* ```
|
||||
* @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[]>;
|
||||
static once(emitter: _NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||
static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
||||
/**
|
||||
* ```js
|
||||
* const { on, EventEmitter } = require('events');
|
||||
* import { on, EventEmitter } from 'node:events';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* (async () => {
|
||||
* const ee = new EventEmitter();
|
||||
* const ee = new EventEmitter();
|
||||
*
|
||||
* // Emit later on
|
||||
* process.nextTick(() => {
|
||||
* ee.emit('foo', 'bar');
|
||||
* ee.emit('foo', 42);
|
||||
* });
|
||||
* // 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
|
||||
* })();
|
||||
* 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
|
||||
|
@ -187,7 +218,9 @@ declare module 'events' {
|
|||
* An `AbortSignal` can be used to cancel waiting on events:
|
||||
*
|
||||
* ```js
|
||||
* const { on, EventEmitter } = require('events');
|
||||
* import { on, EventEmitter } from 'node:events';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* const ac = new AbortController();
|
||||
*
|
||||
* (async () => {
|
||||
|
@ -219,7 +252,8 @@ declare module 'events' {
|
|||
* A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
|
||||
*
|
||||
* ```js
|
||||
* const { EventEmitter, listenerCount } = require('events');
|
||||
* import { EventEmitter, listenerCount } from 'node:events';
|
||||
*
|
||||
* const myEmitter = new EventEmitter();
|
||||
* myEmitter.on('event', () => {});
|
||||
* myEmitter.on('event', () => {});
|
||||
|
@ -242,40 +276,161 @@ declare module 'events' {
|
|||
* event target. This is useful for debugging and diagnostic purposes.
|
||||
*
|
||||
* ```js
|
||||
* const { getEventListeners, EventEmitter } = require('events');
|
||||
* import { getEventListeners, EventEmitter } from 'node:events';
|
||||
*
|
||||
* {
|
||||
* const ee = new EventEmitter();
|
||||
* const listener = () => console.log('Events are fun');
|
||||
* ee.on('foo', listener);
|
||||
* getEventListeners(ee, 'foo'); // [listener]
|
||||
* console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
|
||||
* }
|
||||
* {
|
||||
* const et = new EventTarget();
|
||||
* const listener = () => console.log('Events are fun');
|
||||
* et.addEventListener('foo', listener);
|
||||
* getEventListeners(et, '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[];
|
||||
static getEventListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
||||
/**
|
||||
* This symbol shall be used to install a listener for only monitoring `'error'`
|
||||
* events. Listeners installed using this symbol are called before the regular
|
||||
* `'error'` listeners are called.
|
||||
* Returns the currently set max amount of listeners.
|
||||
*
|
||||
* 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
|
||||
* 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;
|
||||
/**
|
||||
* Sets or gets the default captureRejection value for all emitters.
|
||||
* 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
|
||||
*/
|
||||
// TODO: These should be described using static getter/setter pairs:
|
||||
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');
|
||||
|
@ -315,6 +470,7 @@ declare module 'events' {
|
|||
* 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'));
|
||||
|
@ -344,6 +500,7 @@ declare module 'events' {
|
|||
* 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'));
|
||||
|
@ -375,10 +532,12 @@ 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 will
|
||||
* not remove them from`emit()` in progress. Subsequent events behave as expected.
|
||||
* 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 = () => {
|
||||
|
@ -419,6 +578,7 @@ declare module 'events' {
|
|||
* recently added instance. In the example the `once('ping')`listener is removed:
|
||||
*
|
||||
* ```js
|
||||
* import { EventEmitter } from 'node:events';
|
||||
* const ee = new EventEmitter();
|
||||
*
|
||||
* function pong() {
|
||||
|
@ -487,6 +647,7 @@ declare module 'events' {
|
|||
* 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'));
|
||||
*
|
||||
|
@ -519,7 +680,7 @@ declare module 'events' {
|
|||
* Returns `true` if the event had listeners, `false` otherwise.
|
||||
*
|
||||
* ```js
|
||||
* const EventEmitter = require('events');
|
||||
* import { EventEmitter } from 'node:events';
|
||||
* const myEmitter = new EventEmitter();
|
||||
*
|
||||
* // First listener
|
||||
|
@ -554,11 +715,14 @@ declare module 'events' {
|
|||
*/
|
||||
emit(eventName: string | symbol, ...args: any[]): boolean;
|
||||
/**
|
||||
* Returns the number of listeners listening to the event named `eventName`.
|
||||
* 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): number;
|
||||
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
|
||||
|
@ -578,7 +742,7 @@ declare module 'events' {
|
|||
*/
|
||||
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
|
||||
* 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
|
||||
|
@ -598,7 +762,8 @@ declare module 'events' {
|
|||
* listeners. The values in the array are strings or `Symbol`s.
|
||||
*
|
||||
* ```js
|
||||
* const EventEmitter = require('events');
|
||||
* import { EventEmitter } from 'node:events';
|
||||
*
|
||||
* const myEE = new EventEmitter();
|
||||
* myEE.on('foo', () => {});
|
||||
* myEE.on('bar', () => {});
|
||||
|
|
523
node_modules/@types/node/fs.d.ts
generated
vendored
523
node_modules/@types/node/fs.d.ts
generated
vendored
File diff suppressed because it is too large
Load diff
251
node_modules/@types/node/fs/promises.d.ts
generated
vendored
251
node_modules/@types/node/fs/promises.d.ts
generated
vendored
|
@ -11,32 +11,39 @@
|
|||
declare module 'fs/promises' {
|
||||
import { Abortable } from 'node:events';
|
||||
import { Stream } from 'node:stream';
|
||||
import { ReadableStream } from 'node:stream/web';
|
||||
import {
|
||||
Stats,
|
||||
BigIntStats,
|
||||
StatOptions,
|
||||
WriteVResult,
|
||||
ReadVResult,
|
||||
BigIntStatsFs,
|
||||
BufferEncodingOption,
|
||||
constants as fsConstants,
|
||||
CopyOptions,
|
||||
Dir,
|
||||
Dirent,
|
||||
MakeDirectoryOptions,
|
||||
Mode,
|
||||
ObjectEncodingOptions,
|
||||
OpenDirOptions,
|
||||
OpenMode,
|
||||
PathLike,
|
||||
ReadStream,
|
||||
ReadVResult,
|
||||
RmDirOptions,
|
||||
RmOptions,
|
||||
MakeDirectoryOptions,
|
||||
Dirent,
|
||||
OpenDirOptions,
|
||||
Dir,
|
||||
ObjectEncodingOptions,
|
||||
BufferEncodingOption,
|
||||
OpenMode,
|
||||
Mode,
|
||||
WatchOptions,
|
||||
StatOptions,
|
||||
StatFsOptions,
|
||||
Stats,
|
||||
StatsFs,
|
||||
TimeLike,
|
||||
WatchEventType,
|
||||
CopyOptions,
|
||||
ReadStream,
|
||||
WatchOptions,
|
||||
WriteStream,
|
||||
WriteVResult,
|
||||
} from 'node:fs';
|
||||
import { Interface as ReadlineInterface } from 'node:readline';
|
||||
interface FileChangeInfo<T extends string | Buffer> {
|
||||
eventType: WatchEventType;
|
||||
filename: T;
|
||||
filename: T | null;
|
||||
}
|
||||
interface FlagAndOpenMode {
|
||||
mode?: Mode | undefined;
|
||||
|
@ -75,6 +82,13 @@ declare module 'fs/promises' {
|
|||
emitClose?: boolean | undefined;
|
||||
start?: number | undefined;
|
||||
}
|
||||
interface ReadableWebStreamOptions {
|
||||
/**
|
||||
* Whether to open a normal or a `'bytes'` stream.
|
||||
* @since v20.0.0
|
||||
*/
|
||||
type?: 'bytes' | undefined;
|
||||
}
|
||||
// TODO: Add `EventEmitter` close
|
||||
interface FileHandle {
|
||||
/**
|
||||
|
@ -107,8 +121,8 @@ declare module 'fs/promises' {
|
|||
*/
|
||||
chmod(mode: Mode): Promise<void>;
|
||||
/**
|
||||
* Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream
|
||||
* returned by this method has a default `highWaterMark` of 64 kb.
|
||||
* Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream
|
||||
* returned by this method has a default `highWaterMark` of 64 KiB.
|
||||
*
|
||||
* `options` can include `start` and `end` values to read a range of bytes from
|
||||
* the file instead of the entire file. Both `start` and `end` are inclusive and
|
||||
|
@ -126,7 +140,7 @@ declare module 'fs/promises' {
|
|||
* destroyed. Set the `emitClose` option to `false` to change this behavior.
|
||||
*
|
||||
* ```js
|
||||
* import { open } from 'fs/promises';
|
||||
* import { open } from 'node:fs/promises';
|
||||
*
|
||||
* const fd = await open('/dev/input/event0');
|
||||
* // Create a stream from some character device.
|
||||
|
@ -152,7 +166,7 @@ declare module 'fs/promises' {
|
|||
* An example to read the last 10 bytes of a file which is 100 bytes long:
|
||||
*
|
||||
* ```js
|
||||
* import { open } from 'fs/promises';
|
||||
* import { open } from 'node:fs/promises';
|
||||
*
|
||||
* const fd = await open('sample.txt');
|
||||
* fd.createReadStream({ start: 90, end: 99 });
|
||||
|
@ -163,9 +177,9 @@ declare module 'fs/promises' {
|
|||
/**
|
||||
* `options` may also include a `start` option to allow writing data at some
|
||||
* position past the beginning of the file, allowed values are in the
|
||||
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than 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`.
|
||||
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than
|
||||
* 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,
|
||||
* then the file descriptor won't be closed, even if there's an error.
|
||||
|
@ -191,7 +205,7 @@ declare module 'fs/promises' {
|
|||
* device. The specific implementation is operating system and device specific.
|
||||
* Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail.
|
||||
* @since v10.0.0
|
||||
* @return Fufills with `undefined` upon success.
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
sync(): Promise<void>;
|
||||
/**
|
||||
|
@ -209,6 +223,31 @@ declare module 'fs/promises' {
|
|||
*/
|
||||
read<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number | null, length?: number | null, position?: number | null): Promise<FileReadResult<T>>;
|
||||
read<T extends NodeJS.ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
|
||||
/**
|
||||
* Returns a `ReadableStream` that may be used to read the files data.
|
||||
*
|
||||
* An error will be thrown if this method is called more than once or is called
|
||||
* after the `FileHandle` is closed or closing.
|
||||
*
|
||||
* ```js
|
||||
* import {
|
||||
* open,
|
||||
* } from 'node:fs/promises';
|
||||
*
|
||||
* const file = await open('./some/file/to/read');
|
||||
*
|
||||
* for await (const chunk of file.readableWebStream())
|
||||
* console.log(chunk);
|
||||
*
|
||||
* await file.close();
|
||||
* ```
|
||||
*
|
||||
* While the `ReadableStream` will read the file to completion, it will not
|
||||
* close the `FileHandle` automatically. User code must still call the`fileHandle.close()` method.
|
||||
* @since v17.0.0
|
||||
* @experimental
|
||||
*/
|
||||
readableWebStream(options?: ReadableWebStreamOptions): ReadableStream;
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file.
|
||||
*
|
||||
|
@ -257,6 +296,22 @@ declare module 'fs/promises' {
|
|||
| BufferEncoding
|
||||
| null
|
||||
): Promise<string | Buffer>;
|
||||
/**
|
||||
* Convenience method to create a `readline` interface and stream over the file.
|
||||
* See `filehandle.createReadStream()` for the options.
|
||||
*
|
||||
* ```js
|
||||
* import { open } from 'node:fs/promises';
|
||||
*
|
||||
* const file = await open('./some/file/to/read');
|
||||
*
|
||||
* for await (const line of file.readLines()) {
|
||||
* console.log(line);
|
||||
* }
|
||||
* ```
|
||||
* @since v18.11.0
|
||||
*/
|
||||
readLines(options?: CreateReadStreamOptions): ReadlineInterface;
|
||||
/**
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with an {fs.Stats} for the file.
|
||||
|
@ -281,7 +336,7 @@ declare module 'fs/promises' {
|
|||
* The following example retains only the first four bytes of the file:
|
||||
*
|
||||
* ```js
|
||||
* import { open } from 'fs/promises';
|
||||
* import { open } from 'node:fs/promises';
|
||||
*
|
||||
* let filehandle = null;
|
||||
* try {
|
||||
|
@ -305,13 +360,12 @@ declare module 'fs/promises' {
|
|||
* Change the file system timestamps of the object referenced by the `FileHandle` then resolves the promise with no arguments upon success.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
utimes(atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
||||
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
|
||||
* [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or
|
||||
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object, or an
|
||||
* object with an own `toString` function
|
||||
* property. The promise is resolved with no arguments upon success.
|
||||
* [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.
|
||||
*
|
||||
* If `options` is a string, then it specifies the `encoding`.
|
||||
*
|
||||
|
@ -329,22 +383,20 @@ declare module 'fs/promises' {
|
|||
/**
|
||||
* Write `buffer` to the file.
|
||||
*
|
||||
* If `buffer` is a plain object, it must have an own (not inherited) `toString`function property.
|
||||
*
|
||||
* The promise is resolved with an object containing two properties:
|
||||
*
|
||||
* It is unsafe to use `filehandle.write()` multiple times on the same file
|
||||
* without waiting for the promise to be resolved (or rejected). For this
|
||||
* scenario, use `fs.createWriteStream()`.
|
||||
* scenario, use `filehandle.createWriteStream()`.
|
||||
*
|
||||
* On Linux, positional writes do not work when the file is opened in append mode.
|
||||
* The kernel ignores the position argument and always appends the data to
|
||||
* the end of the file.
|
||||
* @since v10.0.0
|
||||
* @param [offset=0] The start position from within `buffer` where the data to write begins.
|
||||
* @param [length=buffer.byteLength] The number of bytes from `buffer` to write.
|
||||
* @param position The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current position.
|
||||
* See the POSIX pwrite(2) documentation for more detail.
|
||||
* @param offset The start position from within `buffer` where the data to write begins.
|
||||
* @param [length=buffer.byteLength - offset] The number of bytes from `buffer` to write.
|
||||
* @param [position='null'] The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current
|
||||
* position. See the POSIX pwrite(2) documentation for more detail.
|
||||
*/
|
||||
write<TBuffer extends Uint8Array>(
|
||||
buffer: TBuffer,
|
||||
|
@ -375,14 +427,14 @@ declare module 'fs/promises' {
|
|||
* The kernel ignores the position argument and always appends the data to
|
||||
* the end of the file.
|
||||
* @since v12.9.0
|
||||
* @param position The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current
|
||||
* @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>;
|
||||
/**
|
||||
* Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s
|
||||
* @since v13.13.0, v12.17.0
|
||||
* @param position The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position.
|
||||
* @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>;
|
||||
|
@ -391,7 +443,7 @@ declare module 'fs/promises' {
|
|||
* complete.
|
||||
*
|
||||
* ```js
|
||||
* import { open } from 'fs/promises';
|
||||
* import { open } from 'node:fs/promises';
|
||||
*
|
||||
* let filehandle;
|
||||
* try {
|
||||
|
@ -404,13 +456,19 @@ declare module 'fs/promises' {
|
|||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
/**
|
||||
* An alias for {@link FileHandle.close()}.
|
||||
* @since v20.4.0
|
||||
*/
|
||||
[Symbol.asyncDispose](): Promise<void>;
|
||||
}
|
||||
const constants: typeof fsConstants;
|
||||
/**
|
||||
* Tests a user's permissions for the file or directory specified by `path`.
|
||||
* The `mode` argument is an optional integer that specifies the accessibility
|
||||
* checks to be performed. Check `File access constants` for possible values
|
||||
* of `mode`. It is possible to create a mask consisting of the bitwise OR of
|
||||
* two or more values (e.g. `fs.constants.W_OK | fs.constants.R_OK`).
|
||||
* 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
|
||||
* value. If any of the accessibility checks fail, the promise is rejected
|
||||
|
@ -418,8 +476,7 @@ declare module 'fs/promises' {
|
|||
* written by the current process.
|
||||
*
|
||||
* ```js
|
||||
* import { access } from 'fs/promises';
|
||||
* import { constants } from 'fs';
|
||||
* import { access, constants } from 'node:fs/promises';
|
||||
*
|
||||
* try {
|
||||
* await access('/etc/passwd', constants.R_OK | constants.W_OK);
|
||||
|
@ -448,14 +505,13 @@ declare module 'fs/promises' {
|
|||
* will be made to remove the destination.
|
||||
*
|
||||
* ```js
|
||||
* import { constants } from 'fs';
|
||||
* import { copyFile } from 'fs/promises';
|
||||
* import { copyFile, constants } from 'node:fs/promises';
|
||||
*
|
||||
* try {
|
||||
* await copyFile('source.txt', 'destination.txt');
|
||||
* console.log('source.txt was copied to destination.txt');
|
||||
* } catch {
|
||||
* console.log('The file could not be copied');
|
||||
* console.error('The file could not be copied');
|
||||
* }
|
||||
*
|
||||
* // By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
|
||||
|
@ -463,7 +519,7 @@ declare module 'fs/promises' {
|
|||
* await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL);
|
||||
* console.log('source.txt was copied to destination.txt');
|
||||
* } catch {
|
||||
* console.log('The file could not be copied');
|
||||
* console.error('The file could not be copied');
|
||||
* }
|
||||
* ```
|
||||
* @since v10.0.0
|
||||
|
@ -487,7 +543,7 @@ declare module 'fs/promises' {
|
|||
* @param [mode=0o666] Sets the file mode (permission and sticky bits) if the file is created.
|
||||
* @return Fulfills with a {FileHandle} object.
|
||||
*/
|
||||
function open(path: PathLike, flags: string | number, mode?: Mode): Promise<FileHandle>;
|
||||
function open(path: PathLike, flags?: string | number, mode?: Mode): Promise<FileHandle>;
|
||||
/**
|
||||
* Renames `oldPath` to `newPath`.
|
||||
* @since v10.0.0
|
||||
|
@ -525,6 +581,19 @@ declare module 'fs/promises' {
|
|||
* 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.
|
||||
*
|
||||
* ```js
|
||||
* import { mkdir } from 'node:fs/promises';
|
||||
*
|
||||
* try {
|
||||
* const projectFolder = new URL('./test/project/', import.meta.url);
|
||||
* const createDir = await mkdir(projectFolder, { recursive: true });
|
||||
*
|
||||
* console.log(`created ${createDir}`);
|
||||
* } catch (err) {
|
||||
* console.error(err.message);
|
||||
* }
|
||||
* ```
|
||||
* @since v10.0.0
|
||||
* @return Upon success, fulfills with `undefined` if `recursive` is `false`, or the first directory path created if `recursive` is `true`.
|
||||
*/
|
||||
|
@ -567,7 +636,7 @@ declare module 'fs/promises' {
|
|||
* If `options.withFileTypes` is set to `true`, the resolved array will contain `fs.Dirent` objects.
|
||||
*
|
||||
* ```js
|
||||
* import { readdir } from 'fs/promises';
|
||||
* import { readdir } from 'node:fs/promises';
|
||||
*
|
||||
* try {
|
||||
* const files = await readdir(path);
|
||||
|
@ -585,6 +654,7 @@ declare module 'fs/promises' {
|
|||
options?:
|
||||
| (ObjectEncodingOptions & {
|
||||
withFileTypes?: false | undefined;
|
||||
recursive?: boolean | undefined;
|
||||
})
|
||||
| BufferEncoding
|
||||
| null
|
||||
|
@ -600,6 +670,7 @@ declare module 'fs/promises' {
|
|||
| {
|
||||
encoding: 'buffer';
|
||||
withFileTypes?: false | undefined;
|
||||
recursive?: boolean | undefined;
|
||||
}
|
||||
| 'buffer'
|
||||
): Promise<Buffer[]>;
|
||||
|
@ -613,6 +684,7 @@ declare module 'fs/promises' {
|
|||
options?:
|
||||
| (ObjectEncodingOptions & {
|
||||
withFileTypes?: false | undefined;
|
||||
recursive?: boolean | undefined;
|
||||
})
|
||||
| BufferEncoding
|
||||
| null
|
||||
|
@ -626,6 +698,7 @@ declare module 'fs/promises' {
|
|||
path: PathLike,
|
||||
options: ObjectEncodingOptions & {
|
||||
withFileTypes: true;
|
||||
recursive?: boolean | undefined;
|
||||
}
|
||||
): Promise<Dirent[]>;
|
||||
/**
|
||||
|
@ -655,11 +728,14 @@ 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'`. Windows junction points require the destination path
|
||||
* to be absolute. When using `'junction'`, the `target` argument will
|
||||
* automatically be normalized to absolute path.
|
||||
* 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
|
||||
* automatically be normalized to absolute path. Junction points on NTFS volumes
|
||||
* can only point to directories.
|
||||
* @since v10.0.0
|
||||
* @param [type='file']
|
||||
* @param [type='null']
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function symlink(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
|
||||
|
@ -700,6 +776,23 @@ declare module 'fs/promises' {
|
|||
}
|
||||
): Promise<BigIntStats>;
|
||||
function stat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
|
||||
/**
|
||||
* @since v19.6.0, v18.15.0
|
||||
* @return Fulfills with the {fs.StatFs} object for the given `path`.
|
||||
*/
|
||||
function statfs(
|
||||
path: PathLike,
|
||||
opts?: StatFsOptions & {
|
||||
bigint?: false | undefined;
|
||||
}
|
||||
): Promise<StatsFs>;
|
||||
function statfs(
|
||||
path: PathLike,
|
||||
opts: StatFsOptions & {
|
||||
bigint: true;
|
||||
}
|
||||
): Promise<BigIntStatsFs>;
|
||||
function statfs(path: PathLike, opts?: StatFsOptions): Promise<StatsFs | BigIntStatsFs>;
|
||||
/**
|
||||
* Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail.
|
||||
* @since v10.0.0
|
||||
|
@ -741,7 +834,7 @@ declare module 'fs/promises' {
|
|||
* @since v14.5.0, v12.19.0
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function lutimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
||||
function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
|
||||
/**
|
||||
* Changes the ownership of a file.
|
||||
* @since v10.0.0
|
||||
|
@ -755,11 +848,11 @@ 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: string | number | Date, mtime: string | number | Date): Promise<void>;
|
||||
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.
|
||||
*
|
||||
|
@ -800,10 +893,12 @@ declare module 'fs/promises' {
|
|||
* object with an `encoding` property specifying the character encoding to use.
|
||||
*
|
||||
* ```js
|
||||
* import { mkdtemp } from 'fs/promises';
|
||||
* import { mkdtemp } from 'node:fs/promises';
|
||||
* import { join } from 'node:path';
|
||||
* import { tmpdir } from 'node:os';
|
||||
*
|
||||
* try {
|
||||
* await mkdtemp(path.join(os.tmpdir(), 'foo-'));
|
||||
* await mkdtemp(join(tmpdir(), 'foo-'));
|
||||
* } catch (err) {
|
||||
* console.error(err);
|
||||
* }
|
||||
|
@ -812,9 +907,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
|
||||
* platform-specific path separator
|
||||
* (`require('path').sep`).
|
||||
* (`require('node:path').sep`).
|
||||
* @since v10.0.0
|
||||
* @return Fulfills with a string containing the filesystem path of the newly created temporary directory.
|
||||
* @return Fulfills with a string containing the file system path of the newly created temporary directory.
|
||||
*/
|
||||
function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
||||
/**
|
||||
|
@ -830,7 +925,9 @@ 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`, or, an object with an own (not inherited)`toString` function property.
|
||||
* 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 `encoding` option is ignored if `data` is a buffer.
|
||||
*
|
||||
|
@ -845,15 +942,15 @@ declare module 'fs/promises' {
|
|||
*
|
||||
* Similarly to `fsPromises.readFile` \- `fsPromises.writeFile` is a convenience
|
||||
* method that performs multiple `write` calls internally to write the buffer
|
||||
* passed to it. For performance sensitive code consider using `fs.createWriteStream()`.
|
||||
* passed to it. For performance sensitive code consider using `fs.createWriteStream()` or `filehandle.createWriteStream()`.
|
||||
*
|
||||
* It is possible to use an `AbortSignal` to cancel an `fsPromises.writeFile()`.
|
||||
* Cancelation is "best effort", and some amount of data is likely still
|
||||
* to be written.
|
||||
*
|
||||
* ```js
|
||||
* import { writeFile } from 'fs/promises';
|
||||
* import { Buffer } from 'buffer';
|
||||
* import { writeFile } from 'node:fs/promises';
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* try {
|
||||
* const controller = new AbortController();
|
||||
|
@ -916,11 +1013,25 @@ declare module 'fs/promises' {
|
|||
* with an error. On FreeBSD, a representation of the directory's contents will be
|
||||
* returned.
|
||||
*
|
||||
* An example of reading a `package.json` file located in the same directory of the
|
||||
* running code:
|
||||
*
|
||||
* ```js
|
||||
* import { readFile } from 'node:fs/promises';
|
||||
* try {
|
||||
* const filePath = new URL('./package.json', import.meta.url);
|
||||
* const contents = await readFile(filePath, { encoding: 'utf8' });
|
||||
* console.log(contents);
|
||||
* } catch (err) {
|
||||
* console.error(err.message);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* It is possible to abort an ongoing `readFile` using an `AbortSignal`. If a
|
||||
* request is aborted the promise returned is rejected with an `AbortError`:
|
||||
*
|
||||
* ```js
|
||||
* import { readFile } from 'fs/promises';
|
||||
* import { readFile } from 'node:fs/promises';
|
||||
*
|
||||
* try {
|
||||
* const controller = new AbortController();
|
||||
|
@ -999,7 +1110,7 @@ declare module 'fs/promises' {
|
|||
* Example using async iteration:
|
||||
*
|
||||
* ```js
|
||||
* import { opendir } from 'fs/promises';
|
||||
* import { opendir } from 'node:fs/promises';
|
||||
*
|
||||
* try {
|
||||
* const dir = await opendir('./');
|
||||
|
@ -1020,7 +1131,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('fs/promises');
|
||||
* const { watch } = require('node:fs/promises');
|
||||
*
|
||||
* const ac = new AbortController();
|
||||
* const { signal } = ac;
|
||||
|
@ -1084,7 +1195,7 @@ declare module 'fs/promises' {
|
|||
* @param dest destination path to copy to.
|
||||
* @return Fulfills with `undefined` upon success.
|
||||
*/
|
||||
function cp(source: string, destination: string, opts?: CopyOptions): Promise<void>;
|
||||
function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise<void>;
|
||||
}
|
||||
declare module 'node:fs/promises' {
|
||||
export * from 'fs/promises';
|
||||
|
|
69
node_modules/@types/node/globals.d.ts
generated
vendored
69
node_modules/@types/node/globals.d.ts
generated
vendored
|
@ -53,29 +53,59 @@ interface AbortController {
|
|||
/**
|
||||
* 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(): void;
|
||||
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 {
|
||||
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: {
|
||||
prototype: AbortController;
|
||||
new(): AbortController;
|
||||
};
|
||||
declare var AbortController: typeof globalThis extends {onmessage: any; AbortController: infer T}
|
||||
? T
|
||||
: {
|
||||
prototype: AbortController;
|
||||
new(): AbortController;
|
||||
};
|
||||
|
||||
declare var AbortSignal: {
|
||||
prototype: AbortSignal;
|
||||
new(): AbortSignal;
|
||||
// TODO: Add abort() static
|
||||
};
|
||||
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> {
|
||||
/**
|
||||
|
@ -87,6 +117,7 @@ interface RelativeIndexable<T> {
|
|||
}
|
||||
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> {}
|
||||
|
@ -100,6 +131,16 @@ 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 *
|
||||
|
@ -141,7 +182,7 @@ declare namespace NodeJS {
|
|||
/**
|
||||
* Name of the script [if this function was defined in a script]
|
||||
*/
|
||||
getFileName(): string | null;
|
||||
getFileName(): string | undefined;
|
||||
|
||||
/**
|
||||
* Current line number [if this function was defined in a script]
|
||||
|
@ -262,11 +303,11 @@ declare namespace NodeJS {
|
|||
id: string;
|
||||
filename: string;
|
||||
loaded: boolean;
|
||||
/** @deprecated since 14.6.0 Please use `require.main` and `module.children` instead. */
|
||||
/** @deprecated since v14.6.0 Please use `require.main` and `module.children` instead. */
|
||||
parent: Module | null | undefined;
|
||||
children: Module[];
|
||||
/**
|
||||
* @since 11.14.0
|
||||
* @since v11.14.0
|
||||
*
|
||||
* The directory name of the module. This is usually the same as the path.dirname() of the module.id.
|
||||
*/
|
||||
|
|
586
node_modules/@types/node/http.d.ts
generated
vendored
586
node_modules/@types/node/http.d.ts
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* To use the HTTP server and client one must `require('http')`.
|
||||
* To use the HTTP server and client one must `require('node:http')`.
|
||||
*
|
||||
* The HTTP interfaces in Node.js are designed to support many features
|
||||
* of the protocol which have been traditionally difficult to use.
|
||||
|
@ -13,7 +13,7 @@
|
|||
* { 'content-length': '123',
|
||||
* 'content-type': 'text/plain',
|
||||
* 'connection': 'keep-alive',
|
||||
* 'host': 'mysite.com',
|
||||
* 'host': 'example.com',
|
||||
* 'accept': '*' }
|
||||
* ```
|
||||
*
|
||||
|
@ -34,14 +34,16 @@
|
|||
* 'content-LENGTH', '123',
|
||||
* 'content-type', 'text/plain',
|
||||
* 'CONNECTION', 'keep-alive',
|
||||
* 'Host', 'mysite.com',
|
||||
* 'Host', 'example.com',
|
||||
* 'accepT', '*' ]
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/http.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http.js)
|
||||
*/
|
||||
declare module 'http' {
|
||||
import * as stream from 'node:stream';
|
||||
import { URL } from 'node:url';
|
||||
import { LookupOptions } from 'node:dns';
|
||||
import { EventEmitter } from 'node:events';
|
||||
import { TcpSocketConnectOpts, Socket, Server as NetServer, LookupFunction } from 'node:net';
|
||||
// incoming headers will never contain number
|
||||
interface IncomingHttpHeaders extends NodeJS.Dict<string | string[]> {
|
||||
|
@ -113,56 +115,136 @@ declare module 'http' {
|
|||
type OutgoingHttpHeader = number | string | string[];
|
||||
interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> {}
|
||||
interface ClientRequestArgs {
|
||||
signal?: AbortSignal | undefined;
|
||||
protocol?: string | null | undefined;
|
||||
_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)
|
||||
| undefined;
|
||||
defaultPort?: number | string | undefined;
|
||||
family?: number | undefined;
|
||||
headers?: OutgoingHttpHeaders | undefined;
|
||||
hints?: LookupOptions['hints'];
|
||||
host?: string | null | undefined;
|
||||
hostname?: string | null | undefined;
|
||||
family?: number | undefined;
|
||||
port?: number | string | null | undefined;
|
||||
defaultPort?: number | string | undefined;
|
||||
insecureHTTPParser?: boolean | undefined;
|
||||
localAddress?: string | undefined;
|
||||
socketPath?: string | undefined;
|
||||
localPort?: number | undefined;
|
||||
lookup?: LookupFunction | undefined;
|
||||
/**
|
||||
* @default 8192
|
||||
* @default 16384
|
||||
*/
|
||||
maxHeaderSize?: number | undefined;
|
||||
method?: string | undefined;
|
||||
path?: string | null | undefined;
|
||||
headers?: OutgoingHttpHeaders | undefined;
|
||||
auth?: string | null | undefined;
|
||||
agent?: Agent | boolean | undefined;
|
||||
_defaultAgent?: Agent | undefined;
|
||||
timeout?: number | undefined;
|
||||
port?: number | string | null | undefined;
|
||||
protocol?: string | null | undefined;
|
||||
setHost?: boolean | undefined;
|
||||
// https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278
|
||||
createConnection?: ((options: ClientRequestArgs, oncreate: (err: Error, socket: Socket) => void) => Socket) | undefined;
|
||||
lookup?: LookupFunction | undefined;
|
||||
signal?: AbortSignal | undefined;
|
||||
socketPath?: string | undefined;
|
||||
timeout?: number | undefined;
|
||||
uniqueHeaders?: Array<string | string[]> | undefined;
|
||||
joinDuplicateHeaders?: boolean;
|
||||
}
|
||||
interface ServerOptions {
|
||||
IncomingMessage?: typeof IncomingMessage | undefined;
|
||||
ServerResponse?: typeof ServerResponse | undefined;
|
||||
interface ServerOptions<
|
||||
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
||||
Response extends typeof ServerResponse = typeof ServerResponse,
|
||||
> {
|
||||
/**
|
||||
* 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 8192
|
||||
* Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`.
|
||||
*/
|
||||
maxHeaderSize?: number | undefined;
|
||||
IncomingMessage?: Request | undefined;
|
||||
/**
|
||||
* Use an insecure HTTP parser that accepts invalid HTTP headers when true.
|
||||
* Specifies the `ServerResponse` class to be used. Useful for extending the original `ServerResponse`.
|
||||
*/
|
||||
ServerResponse?: Response | undefined;
|
||||
/**
|
||||
* Sets the timeout value in milliseconds for receiving the entire request from the client.
|
||||
* @see Server.requestTimeout for more information.
|
||||
* @default 300000
|
||||
* @since v18.0.0
|
||||
*/
|
||||
requestTimeout?: number | undefined;
|
||||
/**
|
||||
* It joins the field line values of multiple headers in a request with `, ` instead of discarding the duplicates.
|
||||
* @default false
|
||||
* @since v18.14.0
|
||||
*/
|
||||
joinDuplicateHeaders?: boolean;
|
||||
/**
|
||||
* 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.
|
||||
* @see Server.keepAliveTimeout for more information.
|
||||
* @default 5000
|
||||
* @since v18.0.0
|
||||
*/
|
||||
keepAliveTimeout?: number | undefined;
|
||||
/**
|
||||
* Sets the interval value in milliseconds to check for request and headers timeout in incomplete requests.
|
||||
* @default 30000
|
||||
*/
|
||||
connectionsCheckingInterval?: number | undefined;
|
||||
/**
|
||||
* Optionally overrides all `socket`s' `readableHighWaterMark` and `writableHighWaterMark`.
|
||||
* This affects `highWaterMark` property of both `IncomingMessage` and `ServerResponse`.
|
||||
* Default: @see stream.getDefaultHighWaterMark().
|
||||
* @since v20.1.0
|
||||
*/
|
||||
highWaterMark?: number | undefined;
|
||||
/**
|
||||
* Use an insecure HTTP parser that accepts invalid HTTP headers when `true`.
|
||||
* Using the insecure parser should be avoided.
|
||||
* See --insecure-http-parser for more information.
|
||||
* @default false
|
||||
*/
|
||||
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.
|
||||
* @default 16384
|
||||
* @since v13.3.0
|
||||
*/
|
||||
maxHeaderSize?: number | undefined;
|
||||
/**
|
||||
* If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received.
|
||||
* @default true
|
||||
* @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;
|
||||
/**
|
||||
* A list of response headers that should be sent only once.
|
||||
* If the header's value is an array, the items will be joined using `; `.
|
||||
*/
|
||||
uniqueHeaders?: Array<string | string[]> | undefined;
|
||||
}
|
||||
type RequestListener = (req: IncomingMessage, res: ServerResponse) => void;
|
||||
type RequestListener<
|
||||
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
||||
Response extends typeof ServerResponse = typeof ServerResponse,
|
||||
> = (req: InstanceType<Request>, res: InstanceType<Response> & { req: InstanceType<Request> }) => void;
|
||||
/**
|
||||
* @since v0.1.17
|
||||
*/
|
||||
class Server extends NetServer {
|
||||
constructor(requestListener?: RequestListener);
|
||||
constructor(options: ServerOptions, requestListener?: RequestListener);
|
||||
class Server<
|
||||
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
||||
Response extends typeof ServerResponse = typeof ServerResponse,
|
||||
> extends NetServer {
|
||||
constructor(requestListener?: RequestListener<Request, Response>);
|
||||
constructor(options: ServerOptions<Request, Response>, requestListener?: RequestListener<Request, Response>);
|
||||
/**
|
||||
* Sets the timeout value for sockets, and emits a `'timeout'` event on
|
||||
* the Server object, passing the socket as an argument, if a timeout
|
||||
|
@ -211,14 +293,12 @@ declare module 'http' {
|
|||
* Limit the amount of time the parser will wait to receive the complete HTTP
|
||||
* headers.
|
||||
*
|
||||
* In case of inactivity, the rules defined in `server.timeout` apply. However,
|
||||
* that inactivity based timeout would still allow the connection to be kept open
|
||||
* if the headers are being sent very slowly (by default, up to a byte per 2
|
||||
* minutes). In order to prevent this, whenever header data arrives an additional
|
||||
* check is made that more than `server.headersTimeout` milliseconds has not
|
||||
* passed since the connection was established. If the check fails, a `'timeout'`event is emitted on the server object, and (by default) the socket is destroyed.
|
||||
* See `server.timeout` for more information on how timeout behavior can be
|
||||
* customized.
|
||||
* If the timeout expires, the server responds with status 408 without
|
||||
* forwarding the request to the request listener and then closes the connection.
|
||||
*
|
||||
* It must be set to a non-zero value (e.g. 120 seconds) to protect against
|
||||
* potential Denial-of-Service attacks in case the server is deployed without a
|
||||
* reverse proxy in front.
|
||||
* @since v11.3.0, v10.14.0
|
||||
*/
|
||||
headersTimeout: number;
|
||||
|
@ -251,80 +331,109 @@ declare module 'http' {
|
|||
* @since v14.11.0
|
||||
*/
|
||||
requestTimeout: number;
|
||||
/**
|
||||
* 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: '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: 'checkContinue', listener: RequestListener): this;
|
||||
addListener(event: 'checkExpectation', listener: RequestListener): this;
|
||||
addListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
|
||||
addListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
|
||||
addListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
|
||||
addListener(event: 'connect', listener: (req: IncomingMessage, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
addListener(event: 'request', listener: RequestListener): this;
|
||||
addListener(event: 'upgrade', listener: (req: IncomingMessage, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
addListener(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
addListener(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
|
||||
addListener(event: 'request', listener: RequestListener<Request, Response>): this;
|
||||
addListener(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
emit(event: 'close'): boolean;
|
||||
emit(event: 'connection', socket: Socket): boolean;
|
||||
emit(event: 'error', err: Error): boolean;
|
||||
emit(event: 'listening'): boolean;
|
||||
emit(event: 'checkContinue', req: IncomingMessage, res: ServerResponse): boolean;
|
||||
emit(event: 'checkExpectation', req: IncomingMessage, res: ServerResponse): 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: stream.Duplex): boolean;
|
||||
emit(event: 'connect', req: IncomingMessage, socket: stream.Duplex, head: Buffer): boolean;
|
||||
emit(event: 'request', req: IncomingMessage, res: ServerResponse): boolean;
|
||||
emit(event: 'upgrade', req: IncomingMessage, socket: stream.Duplex, head: Buffer): boolean;
|
||||
emit(event: 'connect', req: InstanceType<Request>, socket: stream.Duplex, head: Buffer): boolean;
|
||||
emit(event: 'dropRequest', req: InstanceType<Request>, socket: stream.Duplex): boolean;
|
||||
emit(
|
||||
event: 'request',
|
||||
req: InstanceType<Request>,
|
||||
res: InstanceType<Response> & { req: InstanceType<Request> },
|
||||
): boolean;
|
||||
emit(event: 'upgrade', req: InstanceType<Request>, socket: stream.Duplex, head: Buffer): 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: 'checkContinue', listener: RequestListener): this;
|
||||
on(event: 'checkExpectation', listener: RequestListener): this;
|
||||
on(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
|
||||
on(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
|
||||
on(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
|
||||
on(event: 'connect', listener: (req: IncomingMessage, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
on(event: 'request', listener: RequestListener): this;
|
||||
on(event: 'upgrade', listener: (req: IncomingMessage, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
on(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
on(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
|
||||
on(event: 'request', listener: RequestListener<Request, Response>): this;
|
||||
on(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => 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: 'checkContinue', listener: RequestListener): this;
|
||||
once(event: 'checkExpectation', listener: RequestListener): this;
|
||||
once(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
|
||||
once(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
|
||||
once(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
|
||||
once(event: 'connect', listener: (req: IncomingMessage, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
once(event: 'request', listener: RequestListener): this;
|
||||
once(event: 'upgrade', listener: (req: IncomingMessage, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
once(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
once(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
|
||||
once(event: 'request', listener: RequestListener<Request, Response>): this;
|
||||
once(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => 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: 'checkContinue', listener: RequestListener): this;
|
||||
prependListener(event: 'checkExpectation', listener: RequestListener): this;
|
||||
prependListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
|
||||
prependListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
|
||||
prependListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
|
||||
prependListener(event: 'connect', listener: (req: IncomingMessage, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
prependListener(event: 'request', listener: RequestListener): this;
|
||||
prependListener(event: 'upgrade', listener: (req: IncomingMessage, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
prependListener(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
prependListener(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
|
||||
prependListener(event: 'request', listener: RequestListener<Request, Response>): this;
|
||||
prependListener(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => 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: 'checkContinue', listener: RequestListener): this;
|
||||
prependOnceListener(event: 'checkExpectation', listener: RequestListener): this;
|
||||
prependOnceListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
|
||||
prependOnceListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
|
||||
prependOnceListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
|
||||
prependOnceListener(event: 'connect', listener: (req: IncomingMessage, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
prependOnceListener(event: 'request', listener: RequestListener): this;
|
||||
prependOnceListener(event: 'upgrade', listener: (req: IncomingMessage, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
prependOnceListener(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
prependOnceListener(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
|
||||
prependOnceListener(event: 'request', listener: RequestListener<Request, Response>): this;
|
||||
prependOnceListener(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
|
||||
}
|
||||
/**
|
||||
* This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract of outgoing message from
|
||||
* the perspective of the participants of HTTP transaction.
|
||||
* This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract outgoing message from
|
||||
* the perspective of the participants of an HTTP transaction.
|
||||
* @since v0.1.17
|
||||
*/
|
||||
class OutgoingMessage extends stream.Writable {
|
||||
readonly req: IncomingMessage;
|
||||
class OutgoingMessage<Request extends IncomingMessage = IncomingMessage> extends stream.Writable {
|
||||
readonly req: Request;
|
||||
chunkedEncoding: boolean;
|
||||
shouldKeepAlive: boolean;
|
||||
useChunkedEncodingByDefault: boolean;
|
||||
|
@ -339,7 +448,7 @@ declare module 'http' {
|
|||
*/
|
||||
readonly headersSent: boolean;
|
||||
/**
|
||||
* Aliases of `outgoingMessage.socket`
|
||||
* Alias of `outgoingMessage.socket`.
|
||||
* @since v0.3.0
|
||||
* @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead.
|
||||
*/
|
||||
|
@ -360,15 +469,33 @@ declare module 'http' {
|
|||
*/
|
||||
setTimeout(msecs: number, callback?: () => void): this;
|
||||
/**
|
||||
* Sets a single header value for the header object.
|
||||
* Sets a single header value. If the header already exists in the to-be-sent
|
||||
* headers, its value will be replaced. Use an array of strings to send multiple
|
||||
* headers with the same name.
|
||||
* @since v0.4.0
|
||||
* @param name Header name
|
||||
* @param value Header value
|
||||
*/
|
||||
setHeader(name: string, value: number | string | ReadonlyArray<string>): this;
|
||||
/**
|
||||
* Gets the value of HTTP header with the given name. If such a name doesn't
|
||||
* exist in message, it will be `undefined`.
|
||||
* Append a single header value for the header object.
|
||||
*
|
||||
* If the value is an array, this is equivalent of calling this method multiple
|
||||
* times.
|
||||
*
|
||||
* If there were no previous value for the header, this is equivalent of 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
|
||||
* a single time with values joined using `; `.
|
||||
* @since v18.3.0, v16.17.0
|
||||
* @param name Header name
|
||||
* @param value Header value
|
||||
*/
|
||||
appendHeader(name: string, value: string | ReadonlyArray<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`.
|
||||
* @since v0.4.0
|
||||
* @param name Name of header
|
||||
*/
|
||||
|
@ -381,8 +508,8 @@ declare module 'http' {
|
|||
* values. All header names are lowercase.
|
||||
*
|
||||
* The object returned by the `outgoingMessage.getHeaders()` method does
|
||||
* not prototypically inherit from the JavaScript Object. This means that
|
||||
* typical Object methods such as `obj.toString()`, `obj.hasOwnProperty()`,
|
||||
* 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.
|
||||
*
|
||||
* ```js
|
||||
|
@ -392,13 +519,13 @@ declare module 'http' {
|
|||
* const headers = outgoingMessage.getHeaders();
|
||||
* // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
|
||||
* ```
|
||||
* @since v8.0.0
|
||||
* @since v7.7.0
|
||||
*/
|
||||
getHeaders(): OutgoingHttpHeaders;
|
||||
/**
|
||||
* Returns an array of names of headers of the outgoing outgoingMessage. All
|
||||
* names are lowercase.
|
||||
* @since v8.0.0
|
||||
* Returns an array containing the unique names of the current outgoing headers.
|
||||
* All names are lowercase.
|
||||
* @since v7.7.0
|
||||
*/
|
||||
getHeaderNames(): string[];
|
||||
/**
|
||||
|
@ -408,7 +535,7 @@ declare module 'http' {
|
|||
* ```js
|
||||
* const hasContentType = outgoingMessage.hasHeader('content-type');
|
||||
* ```
|
||||
* @since v8.0.0
|
||||
* @since v7.7.0
|
||||
*/
|
||||
hasHeader(name: string): boolean;
|
||||
/**
|
||||
|
@ -418,16 +545,17 @@ declare module 'http' {
|
|||
* outgoingMessage.removeHeader('Content-Encoding');
|
||||
* ```
|
||||
* @since v0.4.0
|
||||
* @param name Header name
|
||||
*/
|
||||
removeHeader(name: string): void;
|
||||
/**
|
||||
* Adds HTTP trailers (headers but at the end of the message) to the message.
|
||||
*
|
||||
* Trailers are **only** be emitted if the message is chunked encoded. If not,
|
||||
* the trailer will be silently discarded.
|
||||
* Trailers will **only** be emitted if the message is chunked encoded. If not,
|
||||
* the trailers will be silently discarded.
|
||||
*
|
||||
* HTTP requires the `Trailer` header to be sent to emit trailers,
|
||||
* with a list of header fields in its value, e.g.
|
||||
* with a list of header field names in its value, e.g.
|
||||
*
|
||||
* ```js
|
||||
* message.writeHead(200, { 'Content-Type': 'text/plain',
|
||||
|
@ -443,7 +571,7 @@ declare module 'http' {
|
|||
*/
|
||||
addTrailers(headers: OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void;
|
||||
/**
|
||||
* Compulsorily flushes the message headers
|
||||
* Flushes the message headers.
|
||||
*
|
||||
* For efficiency reason, Node.js normally buffers the message headers
|
||||
* until `outgoingMessage.end()` is called or the first chunk of message data
|
||||
|
@ -451,7 +579,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 request.
|
||||
* data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the message.
|
||||
* @since v1.6.0
|
||||
*/
|
||||
flushHeaders(): void;
|
||||
|
@ -461,7 +589,7 @@ declare module 'http' {
|
|||
* passed as the second parameter to the `'request'` event.
|
||||
* @since v0.1.17
|
||||
*/
|
||||
class ServerResponse extends OutgoingMessage {
|
||||
class ServerResponse<Request extends IncomingMessage = IncomingMessage> extends OutgoingMessage<Request> {
|
||||
/**
|
||||
* When using implicit headers (not calling `response.writeHead()` explicitly),
|
||||
* this property controls the status code that will be sent to the client when
|
||||
|
@ -491,15 +619,56 @@ declare module 'http' {
|
|||
* @since v0.11.8
|
||||
*/
|
||||
statusMessage: string;
|
||||
constructor(req: IncomingMessage);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
strictContentLength: boolean;
|
||||
constructor(req: Request);
|
||||
assignSocket(socket: Socket): void;
|
||||
detachSocket(socket: Socket): void;
|
||||
/**
|
||||
* Sends a HTTP/1.1 100 Continue message to the client, indicating that
|
||||
* 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`.
|
||||
* @since v0.3.0
|
||||
*/
|
||||
writeContinue(callback?: () => void): void;
|
||||
/**
|
||||
* Sends an HTTP/1.1 103 Early Hints message to the client with a Link header,
|
||||
* indicating that the user agent can preload/preconnect the linked resources.
|
||||
* The `hints` is an object containing the values of headers to be sent with
|
||||
* early hints message. The optional `callback` argument will be called when
|
||||
* the response message has been written.
|
||||
*
|
||||
* **Example**
|
||||
*
|
||||
* ```js
|
||||
* const earlyHintsLink = '</styles.css>; rel=preload; as=style';
|
||||
* response.writeEarlyHints({
|
||||
* 'link': earlyHintsLink,
|
||||
* });
|
||||
*
|
||||
* const earlyHintsLinks = [
|
||||
* '</styles.css>; rel=preload; as=style',
|
||||
* '</scripts.js>; rel=preload; as=script',
|
||||
* ];
|
||||
* response.writeEarlyHints({
|
||||
* 'link': earlyHintsLinks,
|
||||
* 'x-trace-id': 'id for diagnostics',
|
||||
* });
|
||||
*
|
||||
* const earlyHintsCallback = () => console.log('early hints message sent');
|
||||
* response.writeEarlyHints({
|
||||
* 'link': earlyHintsLinks,
|
||||
* }, earlyHintsCallback);
|
||||
* ```
|
||||
* @since v18.11.0
|
||||
* @param hints An object containing the values of headers
|
||||
* @param callback Will be called when the response message has been written
|
||||
*/
|
||||
writeEarlyHints(hints: Record<string, string | string[]>, callback?: () => void): void;
|
||||
/**
|
||||
* Sends a response header to the request. The status code is a 3-digit HTTP
|
||||
* status code, like `404`. The last argument, `headers`, are the response headers.
|
||||
|
@ -518,7 +687,7 @@ declare module 'http' {
|
|||
* response
|
||||
* .writeHead(200, {
|
||||
* 'Content-Length': Buffer.byteLength(body),
|
||||
* 'Content-Type': 'text/plain'
|
||||
* 'Content-Type': 'text/plain',
|
||||
* })
|
||||
* .end(body);
|
||||
* ```
|
||||
|
@ -549,15 +718,19 @@ declare module 'http' {
|
|||
* });
|
||||
* ```
|
||||
*
|
||||
* `Content-Length` is given in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js
|
||||
* does not check whether `Content-Length` and the length of the body which has
|
||||
* `Content-Length` is read in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js
|
||||
* will check whether `Content-Length` and the length of the body which has
|
||||
* been transmitted are equal or not.
|
||||
*
|
||||
* Attempting to set a header field name or value that contains invalid characters
|
||||
* will result in a `TypeError` being thrown.
|
||||
* will result in a \[`Error`\]\[\] being thrown.
|
||||
* @since v0.1.30
|
||||
*/
|
||||
writeHead(statusCode: number, statusMessage?: string, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[]): this;
|
||||
writeHead(
|
||||
statusCode: number,
|
||||
statusMessage?: string,
|
||||
headers?: OutgoingHttpHeaders | OutgoingHttpHeader[],
|
||||
): this;
|
||||
writeHead(statusCode: number, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[]): this;
|
||||
/**
|
||||
* Sends a HTTP/1.1 102 Processing message to the client, indicating that
|
||||
|
@ -599,8 +772,11 @@ declare module 'http' {
|
|||
*
|
||||
* For backward compatibility, `res` will only emit `'error'` if there is an`'error'` listener registered.
|
||||
*
|
||||
* Node.js does not check whether Content-Length and the length of the
|
||||
* body which has been transmitted are equal or not.
|
||||
* 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,
|
||||
* 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.
|
||||
* @since v0.1.17
|
||||
*/
|
||||
class ClientRequest extends OutgoingMessage {
|
||||
|
@ -608,7 +784,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 - Check `destroyed` instead.
|
||||
* @deprecated Since v17.0.0,v16.12.0 - Check `destroyed` instead.
|
||||
*/
|
||||
aborted: boolean;
|
||||
/**
|
||||
|
@ -621,6 +797,61 @@ declare module 'http' {
|
|||
* @since v14.5.0, v12.19.0
|
||||
*/
|
||||
protocol: string;
|
||||
/**
|
||||
* When sending request through a keep-alive enabled agent, the underlying socket
|
||||
* might be reused. But if server closes connection at unfortunate time, client
|
||||
* may run into a 'ECONNRESET' error.
|
||||
*
|
||||
* ```js
|
||||
* const http = require('node:http');
|
||||
*
|
||||
* // Server has a 5 seconds keep-alive timeout by default
|
||||
* http
|
||||
* .createServer((req, res) => {
|
||||
* res.write('hello\n');
|
||||
* res.end();
|
||||
* })
|
||||
* .listen(3000);
|
||||
*
|
||||
* setInterval(() => {
|
||||
* // Adapting a keep-alive agent
|
||||
* http.get('http://localhost:3000', { agent }, (res) => {
|
||||
* res.on('data', (data) => {
|
||||
* // Do nothing
|
||||
* });
|
||||
* });
|
||||
* }, 5000); // Sending request on 5s interval so it's easy to hit idle timeout
|
||||
* ```
|
||||
*
|
||||
* By marking a request whether it reused socket or not, we can do
|
||||
* automatic error retry base on it.
|
||||
*
|
||||
* ```js
|
||||
* const http = require('node:http');
|
||||
* const agent = new http.Agent({ keepAlive: true });
|
||||
*
|
||||
* function retriableRequest() {
|
||||
* const req = http
|
||||
* .get('http://localhost:3000', { agent }, (res) => {
|
||||
* // ...
|
||||
* })
|
||||
* .on('error', (err) => {
|
||||
* // Check if retry is needed
|
||||
* if (req.reusedSocket && err.code === 'ECONNRESET') {
|
||||
* retriableRequest();
|
||||
* }
|
||||
* });
|
||||
* }
|
||||
*
|
||||
* retriableRequest();
|
||||
* ```
|
||||
* @since v13.0.0, v12.16.0
|
||||
*/
|
||||
reusedSocket: boolean;
|
||||
/**
|
||||
* Limits maximum response headers count. If set to 0, no limit will be applied.
|
||||
*/
|
||||
maxHeadersCount: number;
|
||||
constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void);
|
||||
/**
|
||||
* The request method.
|
||||
|
@ -765,7 +996,7 @@ declare module 'http' {
|
|||
/**
|
||||
* An `IncomingMessage` object is created by {@link Server} or {@link ClientRequest} and passed as the first argument to the `'request'` and `'response'` event respectively. It may be used to
|
||||
* access response
|
||||
* status, headers and data.
|
||||
* 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
|
||||
* parse and emit the incoming HTTP headers and payload, as the underlying socket
|
||||
|
@ -778,7 +1009,7 @@ declare module 'http' {
|
|||
* The `message.aborted` property will be `true` if the request has
|
||||
* been aborted.
|
||||
* @since v10.1.0
|
||||
* @deprecated Since v17.0.0 - Check `message.destroyed` from [stream.Readable](https://nodejs.org/dist/latest-v17.x/docs/api/stream.html#class-streamreadable).
|
||||
* @deprecated Since v17.0.0,v16.12.0 - Check `message.destroyed` from <a href="stream.html#class-streamreadable" class="type">stream.Readable</a>.
|
||||
*/
|
||||
aborted: boolean;
|
||||
/**
|
||||
|
@ -803,7 +1034,7 @@ declare module 'http' {
|
|||
* const req = http.request({
|
||||
* host: '127.0.0.1',
|
||||
* port: 8080,
|
||||
* method: 'POST'
|
||||
* method: 'POST',
|
||||
* }, (res) => {
|
||||
* res.resume();
|
||||
* res.on('end', () => {
|
||||
|
@ -830,7 +1061,7 @@ declare module 'http' {
|
|||
*
|
||||
* This property is guaranteed to be an instance of the `net.Socket` class,
|
||||
* a subclass of `stream.Duplex`, unless the user specified a socket
|
||||
* type other than `net.Socket`.
|
||||
* type other than `net.Socket` or internally nulled.
|
||||
* @since v0.3.0
|
||||
*/
|
||||
socket: Socket;
|
||||
|
@ -853,12 +1084,30 @@ declare module 'http' {
|
|||
*
|
||||
* * 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.
|
||||
* * `set-cookie` is always an array. Duplicates are added to the array.
|
||||
* * For duplicate `cookie` headers, the values are joined together with '; '.
|
||||
* * For all other headers, the values are joined together with ', '.
|
||||
* * For duplicate `cookie` headers, the values are joined together with `; `.
|
||||
* * For all other headers, the values are joined together with `, `.
|
||||
* @since v0.1.5
|
||||
*/
|
||||
headers: IncomingHttpHeaders;
|
||||
/**
|
||||
* Similar to `message.headers`, but there is no join logic and the values are
|
||||
* always arrays of strings, even for headers received just once.
|
||||
*
|
||||
* ```js
|
||||
* // Prints something like:
|
||||
* //
|
||||
* // { 'user-agent': ['curl/7.22.0'],
|
||||
* // host: ['127.0.0.1:8000'],
|
||||
* // accept: ['*'] }
|
||||
* console.log(request.headersDistinct);
|
||||
* ```
|
||||
* @since v18.3.0, v16.17.0
|
||||
*/
|
||||
headersDistinct: NodeJS.Dict<string[]>;
|
||||
/**
|
||||
* The raw request/response headers list exactly as they were received.
|
||||
*
|
||||
|
@ -889,6 +1138,13 @@ declare module 'http' {
|
|||
* @since v0.3.0
|
||||
*/
|
||||
trailers: NodeJS.Dict<string>;
|
||||
/**
|
||||
* Similar to `message.trailers`, but there is no join logic and the values are
|
||||
* always arrays of strings, even for headers received just once.
|
||||
* Only populated at the `'end'` event.
|
||||
* @since v18.3.0, v16.17.0
|
||||
*/
|
||||
trailersDistinct: NodeJS.Dict<string[]>;
|
||||
/**
|
||||
* The raw request/response trailer keys and values exactly as they were
|
||||
* received. Only populated at the `'end'` event.
|
||||
|
@ -924,7 +1180,7 @@ declare module 'http' {
|
|||
* new URL(request.url, `http://${request.headers.host}`);
|
||||
* ```
|
||||
*
|
||||
* When `request.url` is `'/status?name=ryan'` and`request.headers.host` is `'localhost:3000'`:
|
||||
* When `request.url` is `'/status?name=ryan'` and `request.headers.host` is`'localhost:3000'`:
|
||||
*
|
||||
* ```console
|
||||
* $ node
|
||||
|
@ -1048,16 +1304,16 @@ declare module 'http' {
|
|||
* hostname: 'localhost',
|
||||
* port: 80,
|
||||
* path: '/',
|
||||
* agent: false // Create a new agent just for this one request
|
||||
* agent: false, // Create a new agent just for this one request
|
||||
* }, (res) => {
|
||||
* // Do stuff with response
|
||||
* });
|
||||
* ```
|
||||
* @since v0.3.4
|
||||
*/
|
||||
class Agent {
|
||||
class Agent extends EventEmitter {
|
||||
/**
|
||||
* By default set to 256\. For agents with `keepAlive` enabled, this
|
||||
* By default set to 256. For agents with `keepAlive` enabled, this
|
||||
* sets the maximum number of sockets that will be left open in the free
|
||||
* state.
|
||||
* @since v0.11.7
|
||||
|
@ -1121,12 +1377,23 @@ declare module 'http' {
|
|||
* added to the `'request'` event.
|
||||
* @since v0.1.13
|
||||
*/
|
||||
function createServer(requestListener?: RequestListener): Server;
|
||||
function createServer(options: ServerOptions, requestListener?: RequestListener): Server;
|
||||
function createServer<
|
||||
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
||||
Response extends typeof ServerResponse = typeof ServerResponse,
|
||||
>(requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
|
||||
function createServer<
|
||||
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
||||
Response extends typeof ServerResponse = typeof ServerResponse,
|
||||
>(
|
||||
options: ServerOptions<Request, Response>,
|
||||
requestListener?: RequestListener<Request, Response>,
|
||||
): Server<Request, Response>;
|
||||
// although RequestOptions are passed as ClientRequestArgs to ClientRequest directly,
|
||||
// create interface RequestOptions would make the naming more clear to developers
|
||||
interface RequestOptions extends ClientRequestArgs {}
|
||||
/**
|
||||
* `options` in `socket.connect()` are also supported.
|
||||
*
|
||||
* Node.js maintains several connections per server to make HTTP requests.
|
||||
* This function allows one to transparently issue requests.
|
||||
*
|
||||
|
@ -1142,10 +1409,10 @@ declare module 'http' {
|
|||
* upload a file with a POST request, then write to the `ClientRequest` object.
|
||||
*
|
||||
* ```js
|
||||
* const http = require('http');
|
||||
* const http = require('node:http');
|
||||
*
|
||||
* const postData = JSON.stringify({
|
||||
* 'msg': 'Hello World!'
|
||||
* 'msg': 'Hello World!',
|
||||
* });
|
||||
*
|
||||
* const options = {
|
||||
|
@ -1155,8 +1422,8 @@ declare module 'http' {
|
|||
* method: 'POST',
|
||||
* headers: {
|
||||
* 'Content-Type': 'application/json',
|
||||
* 'Content-Length': Buffer.byteLength(postData)
|
||||
* }
|
||||
* 'Content-Length': Buffer.byteLength(postData),
|
||||
* },
|
||||
* };
|
||||
*
|
||||
* const req = http.request(options, (res) => {
|
||||
|
@ -1243,7 +1510,7 @@ 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'`.
|
||||
* * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`
|
||||
* * `'close'`
|
||||
* * `'close'` on the `res` object
|
||||
*
|
||||
|
@ -1251,7 +1518,7 @@ declare module 'http' {
|
|||
* 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'`
|
||||
* * `'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
|
||||
|
@ -1259,7 +1526,7 @@ declare module 'http' {
|
|||
*
|
||||
* * `'socket'`
|
||||
* * (`req.destroy()` called here)
|
||||
* * `'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'`, or the error with which `req.destroy()` was called
|
||||
* * `'close'`
|
||||
*
|
||||
* If `req.destroy()` is called after the response is received, the following
|
||||
|
@ -1270,7 +1537,7 @@ 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'`.
|
||||
* * `'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'`
|
||||
* * `'close'` on the `res` object
|
||||
*
|
||||
|
@ -1306,8 +1573,9 @@ declare module 'http' {
|
|||
* 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
|
||||
* request itself.
|
||||
* 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.
|
||||
* @since v0.3.6
|
||||
*/
|
||||
function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
|
||||
|
@ -1363,7 +1631,7 @@ declare module 'http' {
|
|||
* const server = http.createServer((req, res) => {
|
||||
* res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
* res.end(JSON.stringify({
|
||||
* data: 'Hello World!'
|
||||
* data: 'Hello World!',
|
||||
* }));
|
||||
* });
|
||||
*
|
||||
|
@ -1374,6 +1642,76 @@ 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.
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* ```js
|
||||
* const { validateHeaderName } = require('node:http');
|
||||
*
|
||||
* try {
|
||||
* validateHeaderName('');
|
||||
* } catch (err) {
|
||||
* console.error(err instanceof TypeError); // --> true
|
||||
* console.error(err.code); // --> 'ERR_INVALID_HTTP_TOKEN'
|
||||
* console.error(err.message); // --> 'Header name must be a valid HTTP token [""]'
|
||||
* }
|
||||
* ```
|
||||
* @since v14.3.0
|
||||
* @param [label='Header name'] Label for error message.
|
||||
*/
|
||||
function validateHeaderName(name: string): void;
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* * Undefined value error is identified by `code: 'ERR_HTTP_INVALID_HEADER_VALUE'`.
|
||||
* * Invalid value character error is identified by `code: 'ERR_INVALID_CHAR'`.
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* ```js
|
||||
* const { validateHeaderValue } = require('node:http');
|
||||
*
|
||||
* try {
|
||||
* validateHeaderValue('x-my-header', undefined);
|
||||
* } catch (err) {
|
||||
* console.error(err instanceof TypeError); // --> true
|
||||
* console.error(err.code === 'ERR_HTTP_INVALID_HEADER_VALUE'); // --> true
|
||||
* console.error(err.message); // --> 'Invalid value "undefined" for header "x-my-header"'
|
||||
* }
|
||||
*
|
||||
* try {
|
||||
* validateHeaderValue('x-my-header', 'oʊmɪɡə');
|
||||
* } catch (err) {
|
||||
* console.error(err instanceof TypeError); // --> true
|
||||
* console.error(err.code === 'ERR_INVALID_CHAR'); // --> true
|
||||
* console.error(err.message); // --> 'Invalid character in header content ["x-my-header"]'
|
||||
* }
|
||||
* ```
|
||||
* @since v14.3.0
|
||||
* @param name Header name
|
||||
* @param value Header value
|
||||
*/
|
||||
function validateHeaderValue(name: string, value: string): void;
|
||||
/**
|
||||
* Set the maximum number of idle HTTP parsers.
|
||||
* @since v18.8.0, v16.18.0
|
||||
* @param [max=1000]
|
||||
*/
|
||||
function setMaxIdleHTTPParsers(max: number): void;
|
||||
let globalAgent: Agent;
|
||||
/**
|
||||
* Read-only property specifying the maximum allowed size of HTTP headers in bytes.
|
||||
|
|
123
node_modules/@types/node/http2.d.ts
generated
vendored
123
node_modules/@types/node/http2.d.ts
generated
vendored
|
@ -1,12 +1,12 @@
|
|||
/**
|
||||
* The `http2` module provides an implementation of the [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol. It
|
||||
* can be accessed using:
|
||||
* The `node:http2` module provides an implementation of the [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol.
|
||||
* It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* ```
|
||||
* @since v8.4.0
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/http2.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http2.js)
|
||||
*/
|
||||
declare module 'http2' {
|
||||
import EventEmitter = require('node:events');
|
||||
|
@ -83,7 +83,7 @@ declare module 'http2' {
|
|||
*/
|
||||
readonly destroyed: boolean;
|
||||
/**
|
||||
* Set the `true` if the `END_STREAM` flag was set in the request or response
|
||||
* Set to `true` if the `END_STREAM` flag was set in the request or response
|
||||
* HEADERS frame received, indicating that no additional data should be received
|
||||
* and the readable side of the `Http2Stream` will be closed.
|
||||
* @since v10.11.0
|
||||
|
@ -128,7 +128,7 @@ declare module 'http2' {
|
|||
* value will be `undefined` after the `Http2Stream` instance is destroyed.
|
||||
* @since v8.4.0
|
||||
*/
|
||||
readonly session: Http2Session;
|
||||
readonly session: Http2Session | undefined;
|
||||
/**
|
||||
* Provides miscellaneous information about the current state of the`Http2Stream`.
|
||||
*
|
||||
|
@ -151,7 +151,7 @@ declare module 'http2' {
|
|||
priority(options: StreamPriorityOptions): void;
|
||||
/**
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* const client = http2.connect('http://example.org:8000');
|
||||
* const { NGHTTP2_CANCEL } = http2.constants;
|
||||
* const req = client.request({ ':path': '/' });
|
||||
|
@ -171,7 +171,7 @@ declare module 'http2' {
|
|||
* trailers can be sent.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* const server = http2.createServer();
|
||||
* server.on('stream', (stream) => {
|
||||
* stream.respond(undefined, { waitForTrailers: true });
|
||||
|
@ -332,7 +332,7 @@ declare module 'http2' {
|
|||
* Initiates a push stream. The callback is invoked with the new `Http2Stream`instance created for the push stream passed as the second argument, or an`Error` passed as the first argument.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* const server = http2.createServer();
|
||||
* server.on('stream', (stream) => {
|
||||
* stream.respond({ ':status': 200 });
|
||||
|
@ -357,7 +357,7 @@ declare module 'http2' {
|
|||
pushStream(headers: OutgoingHttpHeaders, options?: StreamPriorityOptions, callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void): void;
|
||||
/**
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* const server = http2.createServer();
|
||||
* server.on('stream', (stream) => {
|
||||
* stream.respond({ ':status': 200 });
|
||||
|
@ -365,16 +365,15 @@ declare module 'http2' {
|
|||
* });
|
||||
* ```
|
||||
*
|
||||
* When the `options.waitForTrailers` option is set, the `'wantTrailers'` event
|
||||
* will be emitted immediately after queuing the last chunk of payload data to be
|
||||
* sent. The `http2stream.sendTrailers()` method can then be used to sent trailing
|
||||
* header fields to the peer.
|
||||
* Initiates a response. When the `options.waitForTrailers` option is set, the`'wantTrailers'` event will be emitted immediately after queuing the last chunk
|
||||
* of payload data to be sent. The `http2stream.sendTrailers()` method can then be
|
||||
* used to sent trailing header fields to the peer.
|
||||
*
|
||||
* When `options.waitForTrailers` is set, the `Http2Stream` will not automatically
|
||||
* close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* const server = http2.createServer();
|
||||
* server.on('stream', (stream) => {
|
||||
* stream.respond({ ':status': 200 }, { waitForTrailers: true });
|
||||
|
@ -397,8 +396,8 @@ declare module 'http2' {
|
|||
* automatically.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const fs = require('fs');
|
||||
* const http2 = require('node:http2');
|
||||
* const fs = require('node:fs');
|
||||
*
|
||||
* const server = http2.createServer();
|
||||
* server.on('stream', (stream) => {
|
||||
|
@ -408,7 +407,7 @@ declare module 'http2' {
|
|||
* const headers = {
|
||||
* 'content-length': stat.size,
|
||||
* 'last-modified': stat.mtime.toUTCString(),
|
||||
* 'content-type': 'text/plain; charset=utf-8'
|
||||
* 'content-type': 'text/plain; charset=utf-8',
|
||||
* };
|
||||
* stream.respondWithFD(fd, headers);
|
||||
* stream.on('close', () => fs.closeSync(fd));
|
||||
|
@ -439,8 +438,8 @@ declare module 'http2' {
|
|||
* close when the final `DATA` frame is transmitted. User code _must_ call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const fs = require('fs');
|
||||
* const http2 = require('node:http2');
|
||||
* const fs = require('node:fs');
|
||||
*
|
||||
* const server = http2.createServer();
|
||||
* server.on('stream', (stream) => {
|
||||
|
@ -450,7 +449,7 @@ declare module 'http2' {
|
|||
* const headers = {
|
||||
* 'content-length': stat.size,
|
||||
* 'last-modified': stat.mtime.toUTCString(),
|
||||
* 'content-type': 'text/plain; charset=utf-8'
|
||||
* 'content-type': 'text/plain; charset=utf-8',
|
||||
* };
|
||||
* stream.respondWithFD(fd, headers, { waitForTrailers: true });
|
||||
* stream.on('wantTrailers', () => {
|
||||
|
@ -482,7 +481,7 @@ declare module 'http2' {
|
|||
* Example using a file path:
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* const server = http2.createServer();
|
||||
* server.on('stream', (stream) => {
|
||||
* function statCheck(stat, headers) {
|
||||
|
@ -500,7 +499,7 @@ declare module 'http2' {
|
|||
* }
|
||||
* } catch (err) {
|
||||
* // Perform actual error handling.
|
||||
* console.log(err);
|
||||
* console.error(err);
|
||||
* }
|
||||
* stream.end();
|
||||
* }
|
||||
|
@ -516,7 +515,7 @@ declare module 'http2' {
|
|||
* results to determine if the file has been modified to return an appropriate`304` response:
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* const server = http2.createServer();
|
||||
* server.on('stream', (stream) => {
|
||||
* function statCheck(stat, headers) {
|
||||
|
@ -549,7 +548,7 @@ declare module 'http2' {
|
|||
* close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* const server = http2.createServer();
|
||||
* server.on('stream', (stream) => {
|
||||
* stream.respondWithFile('/some/file',
|
||||
|
@ -580,6 +579,7 @@ declare module 'http2' {
|
|||
parent?: number | undefined;
|
||||
weight?: number | undefined;
|
||||
waitForTrailers?: boolean | undefined;
|
||||
signal?: AbortSignal | undefined;
|
||||
}
|
||||
export interface SessionState {
|
||||
effectiveLocalWindowSize?: number | undefined;
|
||||
|
@ -747,7 +747,7 @@ declare module 'http2' {
|
|||
* the delta.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
*
|
||||
* const server = http2.createServer();
|
||||
* const expectedWindowSize = 2 ** 20;
|
||||
|
@ -779,7 +779,7 @@ declare module 'http2' {
|
|||
* @since v8.4.0
|
||||
* @param callback Callback that is called once the session is connected or right away if the session is already connected.
|
||||
*/
|
||||
settings(settings: Settings): void;
|
||||
settings(settings: Settings, callback?: (err: Error | null, settings: Settings, duration: number) => void): void;
|
||||
/**
|
||||
* Calls `unref()` on this `Http2Session`instance's underlying `net.Socket`.
|
||||
* @since v9.4.0
|
||||
|
@ -845,14 +845,19 @@ declare module 'http2' {
|
|||
* For HTTP/2 Client `Http2Session` instances only, the `http2session.request()`creates and returns an `Http2Stream` instance that can be used to send an
|
||||
* HTTP/2 request to the connected server.
|
||||
*
|
||||
* When a `ClientHttp2Session` is first created, the socket may not yet be
|
||||
* connected. if `clienthttp2session.request()` is called during this time, the
|
||||
* actual request will be deferred until the socket is ready to go.
|
||||
* If the `session` is closed before the actual request be executed, an`ERR_HTTP2_GOAWAY_SESSION` is thrown.
|
||||
*
|
||||
* This method is only available if `http2session.type` is equal to`http2.constants.NGHTTP2_SESSION_CLIENT`.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* const clientSession = http2.connect('https://localhost:1234');
|
||||
* const {
|
||||
* HTTP2_HEADER_PATH,
|
||||
* HTTP2_HEADER_STATUS
|
||||
* HTTP2_HEADER_STATUS,
|
||||
* } = http2.constants;
|
||||
*
|
||||
* const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' });
|
||||
|
@ -922,7 +927,7 @@ declare module 'http2' {
|
|||
* Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
*
|
||||
* const server = http2.createServer();
|
||||
* server.on('session', (session) => {
|
||||
|
@ -963,7 +968,7 @@ declare module 'http2' {
|
|||
* authoritative responses.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* const options = getSecureOptionsSomehow();
|
||||
* const server = http2.createSecureServer(options);
|
||||
* server.on('stream', (stream) => {
|
||||
|
@ -989,7 +994,7 @@ declare module 'http2' {
|
|||
* server using the `http2.createSecureServer()` method:
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* const options = getSecureOptionsSomehow();
|
||||
* options.origins = ['https://example.com', 'https://example.org'];
|
||||
* const server = http2.createSecureServer(options);
|
||||
|
@ -1047,7 +1052,6 @@ declare module 'http2' {
|
|||
*/
|
||||
unknownProtocolTimeout?: number | undefined;
|
||||
selectPadding?(frameLen: number, maxFrameLen: number): number;
|
||||
createConnection?(authority: url.URL, option: SessionOptions): stream.Duplex;
|
||||
}
|
||||
export interface ClientSessionOptions extends SessionOptions {
|
||||
maxReservedRemoteStreams?: number | undefined;
|
||||
|
@ -1431,7 +1435,7 @@ declare module 'http2' {
|
|||
*/
|
||||
readonly headersSent: boolean;
|
||||
/**
|
||||
* A reference to the original HTTP2 request object.
|
||||
* A reference to the original HTTP2 `request` object.
|
||||
* @since v15.7.0
|
||||
*/
|
||||
readonly req: Http2ServerRequest;
|
||||
|
@ -1452,7 +1456,7 @@ declare module 'http2' {
|
|||
* All other interactions will be routed directly to the socket.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* const server = http2.createServer((req, res) => {
|
||||
* const ip = req.socket.remoteAddress;
|
||||
* const port = req.socket.remotePort;
|
||||
|
@ -1635,8 +1639,8 @@ declare module 'http2' {
|
|||
* This sends a chunk of the response body. This method may
|
||||
* be called multiple times to provide successive parts of the body.
|
||||
*
|
||||
* In the `http` module, the response body is omitted when the
|
||||
* request is a HEAD request. Similarly, the `204` and `304` responses_must not_ include a message body.
|
||||
* In the `node:http` module, the response body is omitted when the
|
||||
* request is a HEAD request. Similarly, the `204` and `304` responses _must not_ include a message body.
|
||||
*
|
||||
* `chunk` can be a string or a buffer. If `chunk` is a string,
|
||||
* the second parameter specifies how to encode it into a byte stream.
|
||||
|
@ -1664,6 +1668,31 @@ declare module 'http2' {
|
|||
* @since v8.4.0
|
||||
*/
|
||||
writeContinue(): void;
|
||||
/**
|
||||
* Sends a status `103 Early Hints` to the client with a Link header,
|
||||
* indicating that the user agent can preload/preconnect the linked resources.
|
||||
* The `hints` is an object containing the values of headers to be sent with
|
||||
* early hints message.
|
||||
*
|
||||
* **Example**
|
||||
*
|
||||
* ```js
|
||||
* const earlyHintsLink = '</styles.css>; rel=preload; as=style';
|
||||
* response.writeEarlyHints({
|
||||
* 'link': earlyHintsLink,
|
||||
* });
|
||||
*
|
||||
* const earlyHintsLinks = [
|
||||
* '</styles.css>; rel=preload; as=style',
|
||||
* '</scripts.js>; rel=preload; as=script',
|
||||
* ];
|
||||
* response.writeEarlyHints({
|
||||
* 'link': earlyHintsLinks,
|
||||
* });
|
||||
* ```
|
||||
* @since v18.11.0
|
||||
*/
|
||||
writeEarlyHints(hints: Record<string, string | string[]>): void;
|
||||
/**
|
||||
* Sends a response header to the request. The status code is a 3-digit HTTP
|
||||
* status code, like `404`. The last argument, `headers`, are the response headers.
|
||||
|
@ -1994,7 +2023,7 @@ declare module 'http2' {
|
|||
* for use with the `HTTP2-Settings` header field.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
*
|
||||
* const packed = http2.getPackedSettings({ enablePush: false });
|
||||
*
|
||||
|
@ -2019,7 +2048,7 @@ declare module 'http2' {
|
|||
* with browser clients.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
*
|
||||
* // Create an unencrypted HTTP/2 server.
|
||||
* // Since there are no browsers known that support
|
||||
|
@ -2030,12 +2059,12 @@ declare module 'http2' {
|
|||
* server.on('stream', (stream, headers) => {
|
||||
* stream.respond({
|
||||
* 'content-type': 'text/html; charset=utf-8',
|
||||
* ':status': 200
|
||||
* ':status': 200,
|
||||
* });
|
||||
* stream.end('<h1>Hello World</h1>');
|
||||
* });
|
||||
*
|
||||
* server.listen(80);
|
||||
* server.listen(8000);
|
||||
* ```
|
||||
* @since v8.4.0
|
||||
* @param onRequestHandler See `Compatibility API`
|
||||
|
@ -2046,12 +2075,12 @@ declare module 'http2' {
|
|||
* Returns a `tls.Server` instance that creates and manages `Http2Session`instances.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const fs = require('fs');
|
||||
* const http2 = require('node:http2');
|
||||
* const fs = require('node:fs');
|
||||
*
|
||||
* const options = {
|
||||
* key: fs.readFileSync('server-key.pem'),
|
||||
* cert: fs.readFileSync('server-cert.pem')
|
||||
* cert: fs.readFileSync('server-cert.pem'),
|
||||
* };
|
||||
*
|
||||
* // Create a secure HTTP/2 server
|
||||
|
@ -2060,12 +2089,12 @@ declare module 'http2' {
|
|||
* server.on('stream', (stream, headers) => {
|
||||
* stream.respond({
|
||||
* 'content-type': 'text/html; charset=utf-8',
|
||||
* ':status': 200
|
||||
* ':status': 200,
|
||||
* });
|
||||
* stream.end('<h1>Hello World</h1>');
|
||||
* });
|
||||
*
|
||||
* server.listen(80);
|
||||
* server.listen(8443);
|
||||
* ```
|
||||
* @since v8.4.0
|
||||
* @param onRequestHandler See `Compatibility API`
|
||||
|
@ -2076,7 +2105,7 @@ declare module 'http2' {
|
|||
* Returns a `ClientHttp2Session` instance.
|
||||
*
|
||||
* ```js
|
||||
* const http2 = require('http2');
|
||||
* const http2 = require('node:http2');
|
||||
* const client = http2.connect('https://localhost:1234');
|
||||
*
|
||||
* // Use the client
|
||||
|
|
156
node_modules/@types/node/https.d.ts
generated
vendored
156
node_modules/@types/node/https.d.ts
generated
vendored
|
@ -1,16 +1,20 @@
|
|||
/**
|
||||
* 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/v17.0.0/lib/https.js)
|
||||
* @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 = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions;
|
||||
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
|
||||
};
|
||||
|
@ -26,14 +30,33 @@ declare module 'https' {
|
|||
constructor(options?: AgentOptions);
|
||||
options: AgentOptions;
|
||||
}
|
||||
interface Server extends http.Server {}
|
||||
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 extends tls.Server {
|
||||
constructor(requestListener?: http.RequestListener);
|
||||
constructor(options: ServerOptions, requestListener?: http.RequestListener);
|
||||
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;
|
||||
|
@ -45,12 +68,12 @@ declare module 'https' {
|
|||
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): this;
|
||||
addListener(event: 'checkExpectation', listener: http.RequestListener): 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: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
addListener(event: 'request', listener: http.RequestListener): this;
|
||||
addListener(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => 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;
|
||||
|
@ -62,12 +85,30 @@ declare module 'https' {
|
|||
emit(event: 'connection', socket: Duplex): boolean;
|
||||
emit(event: 'error', err: Error): boolean;
|
||||
emit(event: 'listening'): boolean;
|
||||
emit(event: 'checkContinue', req: http.IncomingMessage, res: http.ServerResponse): boolean;
|
||||
emit(event: 'checkExpectation', req: http.IncomingMessage, res: http.ServerResponse): 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: http.IncomingMessage, socket: Duplex, head: Buffer): boolean;
|
||||
emit(event: 'request', req: http.IncomingMessage, res: http.ServerResponse): boolean;
|
||||
emit(event: 'upgrade', req: http.IncomingMessage, socket: Duplex, head: Buffer): 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;
|
||||
|
@ -79,12 +120,12 @@ declare module 'https' {
|
|||
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): this;
|
||||
on(event: 'checkExpectation', listener: http.RequestListener): 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: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
on(event: 'request', listener: http.RequestListener): this;
|
||||
on(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => 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;
|
||||
|
@ -96,12 +137,12 @@ declare module 'https' {
|
|||
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): this;
|
||||
once(event: 'checkExpectation', listener: http.RequestListener): 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: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
once(event: 'request', listener: http.RequestListener): this;
|
||||
once(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => 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;
|
||||
|
@ -113,12 +154,12 @@ declare module 'https' {
|
|||
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): this;
|
||||
prependListener(event: 'checkExpectation', listener: http.RequestListener): 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: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
prependListener(event: 'request', listener: http.RequestListener): this;
|
||||
prependListener(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => 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;
|
||||
|
@ -130,22 +171,22 @@ declare module 'https' {
|
|||
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): this;
|
||||
prependOnceListener(event: 'checkExpectation', listener: http.RequestListener): 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: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
prependOnceListener(event: 'request', listener: http.RequestListener): this;
|
||||
prependOnceListener(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => 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('https');
|
||||
* const fs = require('fs');
|
||||
* 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')
|
||||
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
|
||||
* };
|
||||
*
|
||||
* https.createServer(options, (req, res) => {
|
||||
|
@ -157,12 +198,12 @@ declare module 'https' {
|
|||
* Or
|
||||
*
|
||||
* ```js
|
||||
* const https = require('https');
|
||||
* const fs = require('fs');
|
||||
* const https = require('node:https');
|
||||
* const fs = require('node:fs');
|
||||
*
|
||||
* const options = {
|
||||
* pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
|
||||
* passphrase: 'sample'
|
||||
* passphrase: 'sample',
|
||||
* };
|
||||
*
|
||||
* https.createServer(options, (req, res) => {
|
||||
|
@ -174,8 +215,17 @@ declare module 'https' {
|
|||
* @param options Accepts `options` from `createServer`, `createSecureContext` and `createServer`.
|
||||
* @param requestListener A listener to be added to the `'request'` event.
|
||||
*/
|
||||
function createServer(requestListener?: http.RequestListener): Server;
|
||||
function createServer(options: ServerOptions, requestListener?: http.RequestListener): Server;
|
||||
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.
|
||||
*
|
||||
|
@ -189,13 +239,13 @@ declare module 'https' {
|
|||
* upload a file with a POST request, then write to the `ClientRequest` object.
|
||||
*
|
||||
* ```js
|
||||
* const https = require('https');
|
||||
* const https = require('node:https');
|
||||
*
|
||||
* const options = {
|
||||
* hostname: 'encrypted.google.com',
|
||||
* port: 443,
|
||||
* path: '/',
|
||||
* method: 'GET'
|
||||
* method: 'GET',
|
||||
* };
|
||||
*
|
||||
* const req = https.request(options, (res) => {
|
||||
|
@ -222,7 +272,7 @@ declare module 'https' {
|
|||
* path: '/',
|
||||
* method: 'GET',
|
||||
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
||||
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
|
||||
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
|
||||
* };
|
||||
* options.agent = new https.Agent(options);
|
||||
*
|
||||
|
@ -241,7 +291,7 @@ declare module 'https' {
|
|||
* method: 'GET',
|
||||
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
||||
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
|
||||
* agent: false
|
||||
* agent: false,
|
||||
* };
|
||||
*
|
||||
* const req = https.request(options, (res) => {
|
||||
|
@ -262,9 +312,9 @@ declare module 'https' {
|
|||
* Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`):
|
||||
*
|
||||
* ```js
|
||||
* const tls = require('tls');
|
||||
* const https = require('https');
|
||||
* const crypto = require('crypto');
|
||||
* 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');
|
||||
|
@ -281,7 +331,7 @@ declare module 'https' {
|
|||
* return err;
|
||||
* }
|
||||
*
|
||||
* // Pin the public key, similar to HPKP pin-sha25 pinning
|
||||
* // 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: ' +
|
||||
|
@ -365,7 +415,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('https');
|
||||
* const https = require('node:https');
|
||||
*
|
||||
* https.get('https://encrypted.google.com/', (res) => {
|
||||
* console.log('statusCode:', res.statusCode);
|
||||
|
|
12
node_modules/@types/node/index.d.ts
generated
vendored
12
node_modules/@types/node/index.d.ts
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
// Type definitions for non-npm package Node.js 17.0
|
||||
// Type definitions for non-npm package Node.js 20.5
|
||||
// Project: https://nodejs.org/
|
||||
// Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
|
||||
// DefinitelyTyped <https://github.com/DefinitelyTyped>
|
||||
|
@ -21,8 +21,6 @@
|
|||
// Nikita Galkin <https://github.com/galkin>
|
||||
// Parambir Singh <https://github.com/parambirs>
|
||||
// Sebastian Silbermann <https://github.com/eps1lon>
|
||||
// Seth Westphal <https://github.com/westy92>
|
||||
// Simon Schick <https://github.com/SimonSchick>
|
||||
// Thomas den Hollander <https://github.com/ThomasdenH>
|
||||
// Wilco Bakker <https://github.com/WilcoBakker>
|
||||
// wwwy3y3 <https://github.com/wwwy3y3>
|
||||
|
@ -34,7 +32,6 @@
|
|||
// Junxiao Shi <https://github.com/yoursunny>
|
||||
// Ilia Baryshnikov <https://github.com/qwelias>
|
||||
// ExE Boss <https://github.com/ExE-Boss>
|
||||
// Surasak Chaisurin <https://github.com/Ryan-Willpower>
|
||||
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// Anna Henningsen <https://github.com/addaleax>
|
||||
// Victor Perin <https://github.com/victorperin>
|
||||
|
@ -42,6 +39,8 @@
|
|||
// NodeJS Contributors <https://github.com/NodeJS>
|
||||
// Linus Unnebäck <https://github.com/LinusU>
|
||||
// wafuwafu13 <https://github.com/wafuwafu13>
|
||||
// Matteo Collina <https://github.com/mcollina>
|
||||
// Dmitry Semigradsky <https://github.com/Semigradsky>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
|
@ -68,7 +67,7 @@
|
|||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// NOTE: These definitions support NodeJS and TypeScript 3.7+.
|
||||
// NOTE: These definitions support NodeJS and TypeScript 4.9+.
|
||||
|
||||
// Reference required types from the default lib:
|
||||
/// <reference lib="es2020" />
|
||||
|
@ -93,6 +92,7 @@
|
|||
/// <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" />
|
||||
|
@ -109,12 +109,14 @@
|
|||
/// <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" />
|
||||
|
|
37
node_modules/@types/node/inspector.d.ts
generated
vendored
37
node_modules/@types/node/inspector.d.ts
generated
vendored
|
@ -1,21 +1,27 @@
|
|||
// tslint:disable-next-line:dt-header
|
||||
// eslint-disable-next-line @definitelytyped/dt-header
|
||||
// Type definitions for inspector
|
||||
|
||||
// These definitions are auto-generated.
|
||||
// Please see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/19330
|
||||
// for more information.
|
||||
|
||||
// tslint:disable:max-line-length
|
||||
|
||||
/**
|
||||
* The `inspector` module provides an API for interacting with the V8 inspector.
|
||||
* The `node:inspector` module provides an API for interacting with the V8
|
||||
* inspector.
|
||||
*
|
||||
* It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const inspector = require('inspector');
|
||||
* import * as inspector from 'node:inspector/promises';
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/inspector.js)
|
||||
*
|
||||
* or
|
||||
*
|
||||
* ```js
|
||||
* import * as inspector from 'node:inspector';
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/inspector.js)
|
||||
*/
|
||||
declare module 'inspector' {
|
||||
import EventEmitter = require('node:events');
|
||||
|
@ -1688,7 +1694,7 @@ declare module 'inspector' {
|
|||
/**
|
||||
* Controls how the trace buffer stores data.
|
||||
*/
|
||||
recordMode?: string;
|
||||
recordMode?: string | undefined;
|
||||
/**
|
||||
* Included category filters.
|
||||
*/
|
||||
|
@ -1778,12 +1784,6 @@ declare module 'inspector' {
|
|||
* @since v8.0.0
|
||||
*/
|
||||
connect(): void;
|
||||
/**
|
||||
* Connects a session to the main thread inspector back-end. An exception will
|
||||
* be thrown if this API was not called on a Worker thread.
|
||||
* @since v12.11.0
|
||||
*/
|
||||
connectToMainThread(): void;
|
||||
/**
|
||||
* Immediately close the session. All pending message callbacks will be called
|
||||
* with an error. `session.connect()` will need to be called to be able to send
|
||||
|
@ -2695,7 +2695,7 @@ declare module 'inspector' {
|
|||
prependOnceListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this;
|
||||
}
|
||||
/**
|
||||
* Activate inspector on host and port. Equivalent to `node --inspect=[[host:]port]`, but can be done programmatically after node has
|
||||
* Activate inspector on host and port. Equivalent to`node --inspect=[[host:]port]`, but can be done programmatically after node has
|
||||
* started.
|
||||
*
|
||||
* If wait is `true`, will block until a client has connected to the inspect port
|
||||
|
@ -2717,12 +2717,12 @@ declare module 'inspector' {
|
|||
* ```console
|
||||
* $ node --inspect -p 'inspector.url()'
|
||||
* Debugger listening on ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34
|
||||
* For help see https://nodejs.org/en/docs/inspector
|
||||
* For help, see: https://nodejs.org/en/docs/inspector
|
||||
* ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34
|
||||
*
|
||||
* $ node --inspect=localhost:3000 -p 'inspector.url()'
|
||||
* Debugger listening on ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a
|
||||
* For help see https://nodejs.org/en/docs/inspector
|
||||
* For help, see: https://nodejs.org/en/docs/inspector
|
||||
* ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a
|
||||
*
|
||||
* $ node -p 'inspector.url()'
|
||||
|
@ -2738,7 +2738,10 @@ declare module 'inspector' {
|
|||
*/
|
||||
function waitForDebugger(): void;
|
||||
}
|
||||
/**
|
||||
* The inspector module provides an API for interacting with the V8 inspector.
|
||||
*/
|
||||
declare module 'node:inspector' {
|
||||
import EventEmitter = require('inspector');
|
||||
export = EventEmitter;
|
||||
import inspector = require('inspector');
|
||||
export = inspector;
|
||||
}
|
||||
|
|
134
node_modules/@types/node/module.d.ts
generated
vendored
134
node_modules/@types/node/module.d.ts
generated
vendored
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
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
|
||||
|
@ -10,9 +11,9 @@ declare module 'module' {
|
|||
* does not add or remove exported names from the `ES Modules`.
|
||||
*
|
||||
* ```js
|
||||
* const fs = require('fs');
|
||||
* const assert = require('assert');
|
||||
* const { syncBuiltinESMExports } = require('module');
|
||||
* const fs = require('node:fs');
|
||||
* const assert = require('node:assert');
|
||||
* const { syncBuiltinESMExports } = require('node:module');
|
||||
*
|
||||
* fs.readFile = newAPI;
|
||||
*
|
||||
|
@ -26,7 +27,7 @@ declare module 'module' {
|
|||
*
|
||||
* syncBuiltinESMExports();
|
||||
*
|
||||
* import('fs').then((esmFS) => {
|
||||
* 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
|
||||
|
@ -44,6 +45,7 @@ declare module 'module' {
|
|||
* `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 {
|
||||
|
@ -72,12 +74,127 @@ declare module 'module' {
|
|||
readonly payload: SourceMapPayload;
|
||||
constructor(payload: SourceMapPayload);
|
||||
/**
|
||||
* Given a line number and column number in the generated source file, returns
|
||||
* an object representing the position in the original file. The object returned
|
||||
* consists of the following keys:
|
||||
* 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(line: number, column: number): SourceMapping;
|
||||
findEntry(lineOffset: number, columnOffset: number): SourceMapping;
|
||||
}
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
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 Module extends NodeModule {}
|
||||
class Module {
|
||||
|
@ -85,6 +202,7 @@ declare module 'module' {
|
|||
static wrap(code: string): string;
|
||||
static createRequire(path: string | URL): NodeRequire;
|
||||
static builtinModules: string[];
|
||||
static isBuiltin(moduleName: string): boolean;
|
||||
static Module: typeof Module;
|
||||
constructor(id: string, parent?: Module);
|
||||
}
|
||||
|
|
151
node_modules/@types/node/net.d.ts
generated
vendored
151
node_modules/@types/node/net.d.ts
generated
vendored
|
@ -1,22 +1,22 @@
|
|||
/**
|
||||
* > Stability: 2 - Stable
|
||||
*
|
||||
* The `net` module provides an asynchronous network API for creating stream-based
|
||||
* 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('net');
|
||||
* const net = require('node:net');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/net.js)
|
||||
* @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.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
|
||||
type LookupFunction = (hostname: string, options: dns.LookupAllOptions, callback: (err: NodeJS.ErrnoException | null, addresses: dns.LookupAddress[]) => void) => void;
|
||||
interface AddressInfo {
|
||||
address: string;
|
||||
family: string;
|
||||
|
@ -54,11 +54,23 @@ declare module 'net' {
|
|||
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
|
||||
|
@ -127,6 +139,14 @@ declare module 'net' {
|
|||
* @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.
|
||||
|
@ -204,7 +224,7 @@ declare module 'net' {
|
|||
*/
|
||||
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).
|
||||
* 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.
|
||||
|
@ -246,6 +266,12 @@ declare module 'net' {
|
|||
* @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.
|
||||
*/
|
||||
|
@ -262,6 +288,21 @@ declare module 'net' {
|
|||
* @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).
|
||||
|
@ -269,15 +310,23 @@ declare module 'net' {
|
|||
*/
|
||||
readonly remoteAddress?: string | undefined;
|
||||
/**
|
||||
* The string representation of the remote IP family. `'IPv4'` or `'IPv6'`.
|
||||
* 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`.
|
||||
* 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.
|
||||
|
@ -300,7 +349,8 @@ declare module 'net' {
|
|||
* 5. end
|
||||
* 6. error
|
||||
* 7. lookup
|
||||
* 8. timeout
|
||||
* 8. ready
|
||||
* 9. timeout
|
||||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: 'close', listener: (hadError: boolean) => void): this;
|
||||
|
@ -387,6 +437,33 @@ declare module 'net' {
|
|||
* @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.
|
||||
|
@ -427,7 +504,7 @@ declare module 'net' {
|
|||
* ```js
|
||||
* server.on('error', (e) => {
|
||||
* if (e.code === 'EADDRINUSE') {
|
||||
* console.log('Address in use, retrying...');
|
||||
* console.error('Address in use, retrying...');
|
||||
* setTimeout(() => {
|
||||
* server.close();
|
||||
* server.listen(PORT, HOST);
|
||||
|
@ -492,7 +569,7 @@ declare module 'net' {
|
|||
*/
|
||||
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).
|
||||
* 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
|
||||
*/
|
||||
|
@ -524,37 +601,49 @@ declare module 'net' {
|
|||
* 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';
|
||||
/**
|
||||
|
@ -638,11 +727,11 @@ declare module 'net' {
|
|||
*
|
||||
* The server can be a TCP server or an `IPC` server, depending on what it `listen()` to.
|
||||
*
|
||||
* Here is an example of an TCP echo server which listens for connections
|
||||
* Here is an example of a TCP echo server which listens for connections
|
||||
* on port 8124:
|
||||
*
|
||||
* ```js
|
||||
* const net = require('net');
|
||||
* const net = require('node:net');
|
||||
* const server = net.createServer((c) => {
|
||||
* // 'connection' listener.
|
||||
* console.log('client connected');
|
||||
|
@ -662,8 +751,8 @@ declare module 'net' {
|
|||
*
|
||||
* Test this by using `telnet`:
|
||||
*
|
||||
* ```console
|
||||
* $ telnet localhost 8124
|
||||
* ```bash
|
||||
* telnet localhost 8124
|
||||
* ```
|
||||
*
|
||||
* To listen on the socket `/tmp/echo.sock`:
|
||||
|
@ -676,8 +765,8 @@ declare module 'net' {
|
|||
*
|
||||
* Use `nc` to connect to a Unix domain socket server:
|
||||
*
|
||||
* ```console
|
||||
* $ nc -U /tmp/echo.sock
|
||||
* ```bash
|
||||
* nc -U /tmp/echo.sock
|
||||
* ```
|
||||
* @since v0.5.0
|
||||
* @param connectionListener Automatically set as a listener for the {@link 'connection'} event.
|
||||
|
@ -717,19 +806,39 @@ declare module 'net' {
|
|||
function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
|
||||
function createConnection(path: string, connectionListener?: () => void): Socket;
|
||||
/**
|
||||
* Tests if input is an IP address. Returns `0` for invalid strings,
|
||||
* returns `4` for IP version 4 addresses, and returns `6` for IP version 6
|
||||
* addresses.
|
||||
* 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 a version 4 IP address, otherwise returns `false`.
|
||||
* 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 a version 6 IP address, otherwise returns `false`.
|
||||
* 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;
|
||||
|
|
50
node_modules/@types/node/os.d.ts
generated
vendored
50
node_modules/@types/node/os.d.ts
generated
vendored
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* The `os` module provides operating system-related utility methods and
|
||||
* The `node:os` module provides operating system-related utility methods and
|
||||
* properties. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const os = require('os');
|
||||
* const os = require('node:os');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/os.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/os.js)
|
||||
*/
|
||||
declare module 'os' {
|
||||
interface CpuInfo {
|
||||
|
@ -28,6 +28,7 @@ declare module 'os' {
|
|||
}
|
||||
interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
|
||||
family: 'IPv4';
|
||||
scopeid?: undefined;
|
||||
}
|
||||
interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
|
||||
family: 'IPv6';
|
||||
|
@ -74,6 +75,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 properties included on each object include:
|
||||
*
|
||||
|
@ -87,8 +89,8 @@ declare module 'os' {
|
|||
* nice: 0,
|
||||
* sys: 30340,
|
||||
* idle: 1070356870,
|
||||
* irq: 0
|
||||
* }
|
||||
* irq: 0,
|
||||
* },
|
||||
* },
|
||||
* {
|
||||
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
||||
|
@ -98,8 +100,8 @@ declare module 'os' {
|
|||
* nice: 0,
|
||||
* sys: 26980,
|
||||
* idle: 1071569080,
|
||||
* irq: 0
|
||||
* }
|
||||
* irq: 0,
|
||||
* },
|
||||
* },
|
||||
* {
|
||||
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
||||
|
@ -109,8 +111,8 @@ declare module 'os' {
|
|||
* nice: 0,
|
||||
* sys: 21750,
|
||||
* idle: 1070919370,
|
||||
* irq: 0
|
||||
* }
|
||||
* irq: 0,
|
||||
* },
|
||||
* },
|
||||
* {
|
||||
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
||||
|
@ -120,17 +122,28 @@ declare module 'os' {
|
|||
* nice: 0,
|
||||
* sys: 19430,
|
||||
* idle: 1070905480,
|
||||
* irq: 20
|
||||
* }
|
||||
* 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.
|
||||
|
@ -387,7 +400,7 @@ declare module 'os' {
|
|||
const EOL: string;
|
||||
/**
|
||||
* Returns the operating system CPU architecture for which the Node.js binary was
|
||||
* compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, `'x32'`, and `'x64'`.
|
||||
* compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, and `'x64'`.
|
||||
*
|
||||
* The return value is equivalent to `process.arch`.
|
||||
* @since v0.5.0
|
||||
|
@ -402,8 +415,9 @@ declare module 'os' {
|
|||
*/
|
||||
function version(): string;
|
||||
/**
|
||||
* Returns a string identifying the operating system platform. The value is set
|
||||
* at compile time. Possible values are `'aix'`, `'darwin'`, `'freebsd'`,`'linux'`, `'openbsd'`, `'sunos'`, and `'win32'`.
|
||||
* 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`.
|
||||
*
|
||||
|
@ -412,6 +426,14 @@ declare module '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.
|
||||
|
|
38
node_modules/@types/node/package.json
generated
vendored
38
node_modules/@types/node/package.json
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@types/node",
|
||||
"version": "17.0.8",
|
||||
"version": "20.5.9",
|
||||
"description": "TypeScript definitions for Node.js",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
||||
"license": "MIT",
|
||||
|
@ -110,16 +110,6 @@
|
|||
"url": "https://github.com/eps1lon",
|
||||
"githubUsername": "eps1lon"
|
||||
},
|
||||
{
|
||||
"name": "Seth Westphal",
|
||||
"url": "https://github.com/westy92",
|
||||
"githubUsername": "westy92"
|
||||
},
|
||||
{
|
||||
"name": "Simon Schick",
|
||||
"url": "https://github.com/SimonSchick",
|
||||
"githubUsername": "SimonSchick"
|
||||
},
|
||||
{
|
||||
"name": "Thomas den Hollander",
|
||||
"url": "https://github.com/ThomasdenH",
|
||||
|
@ -175,11 +165,6 @@
|
|||
"url": "https://github.com/ExE-Boss",
|
||||
"githubUsername": "ExE-Boss"
|
||||
},
|
||||
{
|
||||
"name": "Surasak Chaisurin",
|
||||
"url": "https://github.com/Ryan-Willpower",
|
||||
"githubUsername": "Ryan-Willpower"
|
||||
},
|
||||
{
|
||||
"name": "Piotr Błażejewicz",
|
||||
"url": "https://github.com/peterblazejewicz",
|
||||
|
@ -214,10 +199,27 @@
|
|||
"name": "wafuwafu13",
|
||||
"url": "https://github.com/wafuwafu13",
|
||||
"githubUsername": "wafuwafu13"
|
||||
},
|
||||
{
|
||||
"name": "Matteo Collina",
|
||||
"url": "https://github.com/mcollina",
|
||||
"githubUsername": "mcollina"
|
||||
},
|
||||
{
|
||||
"name": "Dmitry Semigradsky",
|
||||
"url": "https://github.com/Semigradsky",
|
||||
"githubUsername": "Semigradsky"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"typesVersions": {
|
||||
"<=4.8": {
|
||||
"*": [
|
||||
"ts4.8/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
|
@ -225,6 +227,6 @@
|
|||
},
|
||||
"scripts": {},
|
||||
"dependencies": {},
|
||||
"typesPublisherContentHash": "133a958e0122898f222d66bf1e776d90a38ee878a694bbe229cf5e02db71deef",
|
||||
"typeScriptVersion": "3.8"
|
||||
"typesPublisherContentHash": "b81b4a667392c6db4f92b6520158fccbce2770eefa3b0e03de5624b811f81649",
|
||||
"typeScriptVersion": "4.3"
|
||||
}
|
63
node_modules/@types/node/path.d.ts
generated
vendored
63
node_modules/@types/node/path.d.ts
generated
vendored
|
@ -7,13 +7,13 @@ declare module 'path/win32' {
|
|||
export = path;
|
||||
}
|
||||
/**
|
||||
* The `path` module provides utilities for working with file and directory paths.
|
||||
* It can be accessed using:
|
||||
* The `node:path` module provides utilities for working with file and directory
|
||||
* paths. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const path = require('path');
|
||||
* const path = require('node:path');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/path.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/path.js)
|
||||
*/
|
||||
declare module 'path' {
|
||||
namespace path {
|
||||
|
@ -69,18 +69,19 @@ declare module 'path' {
|
|||
* Normalize a string path, reducing '..' and '.' parts.
|
||||
* When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
|
||||
*
|
||||
* @param p string path to normalize.
|
||||
* @param path string path to normalize.
|
||||
* @throws {TypeError} if `path` is not a string.
|
||||
*/
|
||||
normalize(p: string): string;
|
||||
normalize(path: string): string;
|
||||
/**
|
||||
* Join all arguments together and normalize the resulting path.
|
||||
* Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
|
||||
*
|
||||
* @param paths 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}.
|
||||
* 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.
|
||||
*
|
||||
|
@ -89,61 +90,71 @@ declare module 'path' {
|
|||
* the current working directory is used as well. The resulting path is normalized,
|
||||
* and trailing slashes are removed unless the path gets resolved to the root directory.
|
||||
*
|
||||
* @param pathSegments string paths to join. Non-string arguments are ignored.
|
||||
* @param paths A sequence of paths or path segments.
|
||||
* @throws {TypeError} if any of the arguments is not a string.
|
||||
*/
|
||||
resolve(...pathSegments: string[]): 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(p: string): boolean;
|
||||
isAbsolute(path: string): boolean;
|
||||
/**
|
||||
* Solve the relative path from {from} to {to}.
|
||||
* 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 p the path to evaluate.
|
||||
* @param path the path to evaluate.
|
||||
* @throws {TypeError} if `path` is not a string.
|
||||
*/
|
||||
dirname(p: string): 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 p the path to evaluate.
|
||||
* @param ext optionally, an extension to remove from the result.
|
||||
* @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(p: string, ext?: string): 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
|
||||
* If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string.
|
||||
*
|
||||
* @param p the path to evaluate.
|
||||
* @param path the path to evaluate.
|
||||
* @throws {TypeError} if `path` is not a string.
|
||||
*/
|
||||
extname(p: string): string;
|
||||
extname(path: string): string;
|
||||
/**
|
||||
* The platform-specific file separator. '\\' or '/'.
|
||||
*/
|
||||
readonly sep: string;
|
||||
readonly sep: '\\' | '/';
|
||||
/**
|
||||
* The platform-specific file delimiter. ';' or ':'.
|
||||
*/
|
||||
readonly delimiter: string;
|
||||
readonly delimiter: ';' | ':';
|
||||
/**
|
||||
* Returns an object from a path string - the opposite of format().
|
||||
*
|
||||
* @param pathString path to evaluate.
|
||||
* @param path path to evaluate.
|
||||
* @throws {TypeError} if `path` is not a string.
|
||||
*/
|
||||
parse(p: string): ParsedPath;
|
||||
parse(path: string): ParsedPath;
|
||||
/**
|
||||
* Returns a path string from an object - the opposite of parse().
|
||||
*
|
||||
* @param pathString path to evaluate.
|
||||
* @param pathObject path to evaluate.
|
||||
*/
|
||||
format(pP: FormatInputPathObject): string;
|
||||
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.
|
||||
|
|
113
node_modules/@types/node/perf_hooks.d.ts
generated
vendored
113
node_modules/@types/node/perf_hooks.d.ts
generated
vendored
|
@ -7,9 +7,10 @@
|
|||
* * [High Resolution Time](https://www.w3.org/TR/hr-time-2)
|
||||
* * [Performance Timeline](https://w3c.github.io/performance-timeline/)
|
||||
* * [User Timing](https://www.w3.org/TR/user-timing/)
|
||||
* * [Resource Timing](https://www.w3.org/TR/resource-timing-2/)
|
||||
*
|
||||
* ```js
|
||||
* const { PerformanceObserver, performance } = require('perf_hooks');
|
||||
* const { PerformanceObserver, performance } = require('node:perf_hooks');
|
||||
*
|
||||
* const obs = new PerformanceObserver((items) => {
|
||||
* console.log(items.getEntries()[0].duration);
|
||||
|
@ -26,11 +27,11 @@
|
|||
* performance.measure('A to B', 'A', 'B');
|
||||
* });
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/perf_hooks.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/perf_hooks.js)
|
||||
*/
|
||||
declare module 'perf_hooks' {
|
||||
import { AsyncResource } from 'node:async_hooks';
|
||||
type EntryType = 'node' | 'mark' | 'measure' | 'gc' | 'function' | 'http2' | 'http';
|
||||
type EntryType = 'node' | 'mark' | 'measure' | 'gc' | 'function' | 'http2' | 'http' | 'dns';
|
||||
interface NodeGCPerformanceDetail {
|
||||
/**
|
||||
* When `performanceEntry.entryType` is equal to 'gc', `the performance.kind` property identifies
|
||||
|
@ -46,6 +47,7 @@ declare module 'perf_hooks' {
|
|||
readonly flags?: number | undefined;
|
||||
}
|
||||
/**
|
||||
* The constructor of this class is not exposed to users directly.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
class PerformanceEntry {
|
||||
|
@ -85,6 +87,24 @@ declare module 'perf_hooks' {
|
|||
* @since v16.0.0
|
||||
*/
|
||||
readonly detail?: NodeGCPerformanceDetail | unknown | undefined; // TODO: Narrow this based on entry type.
|
||||
toJSON(): any;
|
||||
}
|
||||
/**
|
||||
* Exposes marks created via the `Performance.mark()` method.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
class PerformanceMark extends PerformanceEntry {
|
||||
readonly duration: 0;
|
||||
readonly entryType: 'mark';
|
||||
}
|
||||
/**
|
||||
* Exposes measures created via the `Performance.measure()` method.
|
||||
*
|
||||
* The constructor of this class is not exposed to users directly.
|
||||
* @since v18.2.0, v16.17.0
|
||||
*/
|
||||
class PerformanceMeasure extends PerformanceEntry {
|
||||
readonly entryType: 'measure';
|
||||
}
|
||||
/**
|
||||
* _This property is an extension by Node.js. It is not available in Web browsers._
|
||||
|
@ -191,14 +211,44 @@ declare module 'perf_hooks' {
|
|||
* @param name
|
||||
*/
|
||||
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
|
||||
* @since v16.7.0
|
||||
*/
|
||||
clearMeasures(name?: string): void;
|
||||
/**
|
||||
* 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
|
||||
* `performance.getEntriesByType()` and `performance.getEntriesByName()`.
|
||||
* @since v16.7.0
|
||||
*/
|
||||
getEntries(): PerformanceEntry[];
|
||||
/**
|
||||
* Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime`
|
||||
* whose `performanceEntry.name` is equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to `type`.
|
||||
* @param name
|
||||
* @param type
|
||||
* @since v16.7.0
|
||||
*/
|
||||
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`.
|
||||
* @param type
|
||||
* @since v16.7.0
|
||||
*/
|
||||
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.
|
||||
* Performance marks are used to mark specific significant moments in the Performance Timeline.
|
||||
* @param name
|
||||
* @return The PerformanceMark entry that was created
|
||||
*/
|
||||
mark(name?: string, options?: MarkOptions): void;
|
||||
mark(name?: string, options?: MarkOptions): PerformanceMark;
|
||||
/**
|
||||
* Creates a new PerformanceMeasure entry in the Performance Timeline.
|
||||
* A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
|
||||
|
@ -213,9 +263,10 @@ declare module 'perf_hooks' {
|
|||
* @param name
|
||||
* @param startMark
|
||||
* @param endMark
|
||||
* @return The PerformanceMeasure entry that was created
|
||||
*/
|
||||
measure(name: string, startMark?: string, endMark?: string): void;
|
||||
measure(name: string, options: MeasureOptions): void;
|
||||
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.
|
||||
*/
|
||||
|
@ -249,8 +300,8 @@ declare module 'perf_hooks' {
|
|||
* ```js
|
||||
* const {
|
||||
* performance,
|
||||
* PerformanceObserver
|
||||
* } = require('perf_hooks');
|
||||
* PerformanceObserver,
|
||||
* } = require('node:perf_hooks');
|
||||
*
|
||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
||||
* console.log(perfObserverList.getEntries());
|
||||
|
@ -270,6 +321,9 @@ declare module 'perf_hooks' {
|
|||
* * }
|
||||
* * ]
|
||||
*
|
||||
*
|
||||
* performance.clearMarks();
|
||||
* performance.clearMeasures();
|
||||
* observer.disconnect();
|
||||
* });
|
||||
* obs.observe({ type: 'mark' });
|
||||
|
@ -288,8 +342,8 @@ declare module 'perf_hooks' {
|
|||
* ```js
|
||||
* const {
|
||||
* performance,
|
||||
* PerformanceObserver
|
||||
* } = require('perf_hooks');
|
||||
* PerformanceObserver,
|
||||
* } = require('node:perf_hooks');
|
||||
*
|
||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
||||
* console.log(perfObserverList.getEntriesByName('meow'));
|
||||
|
@ -317,6 +371,9 @@ declare module 'perf_hooks' {
|
|||
* * ]
|
||||
*
|
||||
* console.log(perfObserverList.getEntriesByName('test', 'measure')); // []
|
||||
*
|
||||
* performance.clearMarks();
|
||||
* performance.clearMeasures();
|
||||
* observer.disconnect();
|
||||
* });
|
||||
* obs.observe({ entryTypes: ['mark', 'measure'] });
|
||||
|
@ -334,8 +391,8 @@ declare module 'perf_hooks' {
|
|||
* ```js
|
||||
* const {
|
||||
* performance,
|
||||
* PerformanceObserver
|
||||
* } = require('perf_hooks');
|
||||
* PerformanceObserver,
|
||||
* } = require('node:perf_hooks');
|
||||
*
|
||||
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
||||
* console.log(perfObserverList.getEntriesByType('mark'));
|
||||
|
@ -355,6 +412,8 @@ declare module 'perf_hooks' {
|
|||
* * }
|
||||
* * ]
|
||||
*
|
||||
* performance.clearMarks();
|
||||
* performance.clearMeasures();
|
||||
* observer.disconnect();
|
||||
* });
|
||||
* obs.observe({ type: 'mark' });
|
||||
|
@ -367,6 +426,9 @@ declare module 'perf_hooks' {
|
|||
getEntriesByType(type: EntryType): PerformanceEntry[];
|
||||
}
|
||||
type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void;
|
||||
/**
|
||||
* @since v8.5.0
|
||||
*/
|
||||
class PerformanceObserver extends AsyncResource {
|
||||
constructor(callback: PerformanceObserverCallback);
|
||||
/**
|
||||
|
@ -380,11 +442,11 @@ declare module 'perf_hooks' {
|
|||
* ```js
|
||||
* const {
|
||||
* performance,
|
||||
* PerformanceObserver
|
||||
* } = require('perf_hooks');
|
||||
* PerformanceObserver,
|
||||
* } = require('node:perf_hooks');
|
||||
*
|
||||
* const obs = new PerformanceObserver((list, observer) => {
|
||||
* // Called three times synchronously. `list` contains one item.
|
||||
* // Called once asynchronously. `list` contains three items.
|
||||
* });
|
||||
* obs.observe({ type: 'mark' });
|
||||
*
|
||||
|
@ -499,6 +561,11 @@ declare module 'perf_hooks' {
|
|||
* @since v15.9.0, v14.18.0
|
||||
*/
|
||||
recordDelta(): void;
|
||||
/**
|
||||
* Adds the values from `other` to this histogram.
|
||||
* @since v17.4.0, v16.14.0
|
||||
*/
|
||||
add(other: RecordableHistogram): void;
|
||||
}
|
||||
/**
|
||||
* _This property is an extension by Node.js. It is not available in Web browsers._
|
||||
|
@ -513,7 +580,7 @@ declare module 'perf_hooks' {
|
|||
* detect.
|
||||
*
|
||||
* ```js
|
||||
* const { monitorEventLoopDelay } = require('perf_hooks');
|
||||
* const { monitorEventLoopDelay } = require('node:perf_hooks');
|
||||
* const h = monitorEventLoopDelay({ resolution: 20 });
|
||||
* h.enable();
|
||||
* // Do something.
|
||||
|
@ -551,6 +618,20 @@ declare module 'perf_hooks' {
|
|||
* @since v15.9.0, v14.18.0
|
||||
*/
|
||||
function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
|
||||
import { performance as _performance } from 'perf_hooks';
|
||||
global {
|
||||
/**
|
||||
* `performance` is a global reference for `require('perf_hooks').performance`
|
||||
* https://nodejs.org/api/globals.html#performance
|
||||
* @since v16.0.0
|
||||
*/
|
||||
var performance: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
performance: infer T;
|
||||
}
|
||||
? T
|
||||
: typeof _performance;
|
||||
}
|
||||
}
|
||||
declare module 'node:perf_hooks' {
|
||||
export * from 'perf_hooks';
|
||||
|
|
179
node_modules/@types/node/process.d.ts
generated
vendored
179
node_modules/@types/node/process.d.ts
generated
vendored
|
@ -49,6 +49,7 @@ declare module 'process' {
|
|||
openssl: string;
|
||||
}
|
||||
type Platform = 'aix' | 'android' | 'darwin' | 'freebsd' | 'haiku' | 'linux' | 'openbsd' | 'sunos' | 'win32' | 'cygwin' | 'netbsd';
|
||||
type Architecture = 'arm' | 'arm64' | 'ia32' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 's390' | 's390x' | 'x64';
|
||||
type Signals =
|
||||
| 'SIGABRT'
|
||||
| 'SIGALRM'
|
||||
|
@ -96,7 +97,7 @@ declare module 'process' {
|
|||
type UncaughtExceptionListener = (error: Error, origin: UncaughtExceptionOrigin) => void;
|
||||
/**
|
||||
* Most of the time the unhandledRejection will be an Error, but this should not be relied upon
|
||||
* as *anything* can be thrown/rejected, it is therefore unsafe to assume the the value is an Error.
|
||||
* as *anything* can be thrown/rejected, it is therefore unsafe to assume that the value is an Error.
|
||||
*/
|
||||
type UnhandledRejectionListener = (reason: unknown, promise: Promise<unknown>) => void;
|
||||
type WarningListener = (warning: Error) => void;
|
||||
|
@ -249,7 +250,7 @@ declare module 'process' {
|
|||
* For example, to copy `process.stdin` to `process.stdout`:
|
||||
*
|
||||
* ```js
|
||||
* import { stdin, stdout } from 'process';
|
||||
* import { stdin, stdout } from 'node:process';
|
||||
*
|
||||
* stdin.pipe(stdout);
|
||||
* ```
|
||||
|
@ -296,7 +297,7 @@ declare module 'process' {
|
|||
* For example, assuming the following script for `process-args.js`:
|
||||
*
|
||||
* ```js
|
||||
* import { argv } from 'process';
|
||||
* import { argv } from 'node:process';
|
||||
*
|
||||
* // print process.argv
|
||||
* argv.forEach((val, index) => {
|
||||
|
@ -306,8 +307,8 @@ declare module 'process' {
|
|||
*
|
||||
* Launching the Node.js process as:
|
||||
*
|
||||
* ```console
|
||||
* $ node process-args.js one two=three four
|
||||
* ```bash
|
||||
* node process-args.js one two=three four
|
||||
* ```
|
||||
*
|
||||
* Would generate the output:
|
||||
|
@ -343,8 +344,8 @@ declare module 'process' {
|
|||
* the script name. These options are useful in order to spawn child processes with
|
||||
* the same execution environment as the parent.
|
||||
*
|
||||
* ```console
|
||||
* $ node --harmony script.js --version
|
||||
* ```bash
|
||||
* node --harmony script.js --version
|
||||
* ```
|
||||
*
|
||||
* Results in `process.execArgv`:
|
||||
|
@ -388,7 +389,7 @@ declare module 'process' {
|
|||
* the specified `directory` does not exist).
|
||||
*
|
||||
* ```js
|
||||
* import { chdir, cwd } from 'process';
|
||||
* import { chdir, cwd } from 'node:process';
|
||||
*
|
||||
* console.log(`Starting directory: ${cwd()}`);
|
||||
* try {
|
||||
|
@ -408,7 +409,7 @@ declare module 'process' {
|
|||
* process.
|
||||
*
|
||||
* ```js
|
||||
* import { cwd } from 'process';
|
||||
* import { cwd } from 'node:process';
|
||||
*
|
||||
* console.log(`Current directory: ${cwd()}`);
|
||||
* ```
|
||||
|
@ -419,7 +420,7 @@ declare module 'process' {
|
|||
* The port used by the Node.js debugger when enabled.
|
||||
*
|
||||
* ```js
|
||||
* import process from 'process';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* process.debugPort = 5858;
|
||||
* ```
|
||||
|
@ -431,12 +432,12 @@ declare module 'process' {
|
|||
* specific process warnings. These can be listened for by adding a handler to the `'warning'` event.
|
||||
*
|
||||
* ```js
|
||||
* import { emitWarning } from 'process';
|
||||
* 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'
|
||||
* detail: 'This is some additional information',
|
||||
* });
|
||||
* // Emits:
|
||||
* // (node:56338) [MY_WARNING] Warning: Something happened!
|
||||
|
@ -446,7 +447,7 @@ declare module 'process' {
|
|||
* In this example, an `Error` object is generated internally by`process.emitWarning()` and passed through to the `'warning'` handler.
|
||||
*
|
||||
* ```js
|
||||
* import process from 'process';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* process.on('warning', (warning) => {
|
||||
* console.warn(warning.name); // 'Warning'
|
||||
|
@ -491,14 +492,14 @@ declare module 'process' {
|
|||
* to other `Worker` threads.
|
||||
* In other words, the following example would not work:
|
||||
*
|
||||
* ```console
|
||||
* $ node -e 'process.env.foo = "bar"' && echo $foo
|
||||
* ```bash
|
||||
* node -e 'process.env.foo = "bar"' && echo $foo
|
||||
* ```
|
||||
*
|
||||
* While the following will:
|
||||
*
|
||||
* ```js
|
||||
* import { env } from 'process';
|
||||
* import { env } from 'node:process';
|
||||
*
|
||||
* env.foo = 'bar';
|
||||
* console.log(env.foo);
|
||||
|
@ -509,7 +510,7 @@ declare module 'process' {
|
|||
* throw an error when the value is not a string, number, or boolean.
|
||||
*
|
||||
* ```js
|
||||
* import { env } from 'process';
|
||||
* import { env } from 'node:process';
|
||||
*
|
||||
* env.test = null;
|
||||
* console.log(env.test);
|
||||
|
@ -522,7 +523,7 @@ declare module 'process' {
|
|||
* Use `delete` to delete a property from `process.env`.
|
||||
*
|
||||
* ```js
|
||||
* import { env } from 'process';
|
||||
* import { env } from 'node:process';
|
||||
*
|
||||
* env.TEST = 1;
|
||||
* delete env.TEST;
|
||||
|
@ -533,7 +534,7 @@ declare module 'process' {
|
|||
* On Windows operating systems, environment variables are case-insensitive.
|
||||
*
|
||||
* ```js
|
||||
* import { env } from 'process';
|
||||
* import { env } from 'node:process';
|
||||
*
|
||||
* env.TEST = 1;
|
||||
* console.log(env.test);
|
||||
|
@ -542,7 +543,7 @@ declare module 'process' {
|
|||
*
|
||||
* Unless explicitly specified when creating a `Worker` instance,
|
||||
* each `Worker` thread has its own copy of `process.env`, based on its
|
||||
* parent thread’s `process.env`, or whatever was specified as the `env` option
|
||||
* 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.
|
||||
|
@ -559,7 +560,7 @@ declare module 'process' {
|
|||
* To exit with a 'failure' code:
|
||||
*
|
||||
* ```js
|
||||
* import { exit } from 'process';
|
||||
* import { exit } from 'node:process';
|
||||
*
|
||||
* exit(1);
|
||||
* ```
|
||||
|
@ -578,7 +579,7 @@ declare module 'process' {
|
|||
* truncated and lost:
|
||||
*
|
||||
* ```js
|
||||
* import { exit } from 'process';
|
||||
* import { exit } from 'node:process';
|
||||
*
|
||||
* // This is an example of what *not* to do:
|
||||
* if (someConditionNotMet()) {
|
||||
|
@ -589,13 +590,13 @@ declare module 'process' {
|
|||
*
|
||||
* The reason this is problematic is because writes to `process.stdout` in Node.js
|
||||
* 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.
|
||||
* 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
|
||||
* scheduling any additional work for the event loop:
|
||||
*
|
||||
* ```js
|
||||
* import process from 'process';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* // How to properly set the exit code while letting
|
||||
* // the process exit gracefully.
|
||||
|
@ -612,7 +613,7 @@ declare module 'process' {
|
|||
* In `Worker` threads, this function stops the current thread rather
|
||||
* than the current process.
|
||||
* @since v0.1.13
|
||||
* @param [code=0] The exit code.
|
||||
* @param [code=0] The exit code. For string type, only integer strings (e.g.,'1') are allowed.
|
||||
*/
|
||||
exit(code?: number): never;
|
||||
/**
|
||||
|
@ -641,7 +642,7 @@ declare module 'process' {
|
|||
* Android).
|
||||
* @since v0.1.31
|
||||
*/
|
||||
getgid(): number;
|
||||
getgid?: () => number;
|
||||
/**
|
||||
* The `process.setgid()` method sets the group identity of the process. (See [`setgid(2)`](http://man7.org/linux/man-pages/man2/setgid.2.html).) The `id` can be passed as either a
|
||||
* numeric ID or a group name
|
||||
|
@ -668,7 +669,7 @@ declare module 'process' {
|
|||
* @since v0.1.31
|
||||
* @param id The group name or ID
|
||||
*/
|
||||
setgid(id: number | string): void;
|
||||
setgid?: (id: number | string) => void;
|
||||
/**
|
||||
* The `process.getuid()` method returns the numeric user identity of the process.
|
||||
* (See [`getuid(2)`](http://man7.org/linux/man-pages/man2/getuid.2.html).)
|
||||
|
@ -685,7 +686,7 @@ declare module 'process' {
|
|||
* Android).
|
||||
* @since v0.1.28
|
||||
*/
|
||||
getuid(): number;
|
||||
getuid?: () => number;
|
||||
/**
|
||||
* The `process.setuid(id)` method sets the user identity of the process. (See [`setuid(2)`](http://man7.org/linux/man-pages/man2/setuid.2.html).) The `id` can be passed as either a
|
||||
* numeric ID or a username string.
|
||||
|
@ -711,7 +712,7 @@ declare module 'process' {
|
|||
* This feature is not available in `Worker` threads.
|
||||
* @since v0.1.28
|
||||
*/
|
||||
setuid(id: number | string): void;
|
||||
setuid?: (id: number | string) => void;
|
||||
/**
|
||||
* The `process.geteuid()` method returns the numerical effective user identity of
|
||||
* the process. (See [`geteuid(2)`](http://man7.org/linux/man-pages/man2/geteuid.2.html).)
|
||||
|
@ -728,7 +729,7 @@ declare module 'process' {
|
|||
* Android).
|
||||
* @since v2.0.0
|
||||
*/
|
||||
geteuid(): number;
|
||||
geteuid?: () => number;
|
||||
/**
|
||||
* The `process.seteuid()` method sets the effective user identity of the process.
|
||||
* (See [`seteuid(2)`](http://man7.org/linux/man-pages/man2/seteuid.2.html).) The `id` can be passed as either a numeric ID or a username
|
||||
|
@ -755,7 +756,7 @@ declare module 'process' {
|
|||
* @since v2.0.0
|
||||
* @param id A user name or ID
|
||||
*/
|
||||
seteuid(id: number | string): void;
|
||||
seteuid?: (id: number | string) => void;
|
||||
/**
|
||||
* The `process.getegid()` method returns the numerical effective group identity
|
||||
* of the Node.js process. (See [`getegid(2)`](http://man7.org/linux/man-pages/man2/getegid.2.html).)
|
||||
|
@ -772,7 +773,7 @@ declare module 'process' {
|
|||
* Android).
|
||||
* @since v2.0.0
|
||||
*/
|
||||
getegid(): number;
|
||||
getegid?: () => number;
|
||||
/**
|
||||
* The `process.setegid()` method sets the effective group identity of the process.
|
||||
* (See [`setegid(2)`](http://man7.org/linux/man-pages/man2/setegid.2.html).) The `id` can be passed as either a numeric ID or a group
|
||||
|
@ -799,7 +800,7 @@ declare module 'process' {
|
|||
* @since v2.0.0
|
||||
* @param id A group name or ID
|
||||
*/
|
||||
setegid(id: number | string): void;
|
||||
setegid?: (id: number | string) => void;
|
||||
/**
|
||||
* The `process.getgroups()` method returns an array with the supplementary group
|
||||
* IDs. POSIX leaves it unspecified if the effective group ID is included but
|
||||
|
@ -817,7 +818,7 @@ declare module 'process' {
|
|||
* Android).
|
||||
* @since v0.9.4
|
||||
*/
|
||||
getgroups(): number[];
|
||||
getgroups?: () => number[];
|
||||
/**
|
||||
* The `process.setgroups()` method sets the supplementary group IDs for the
|
||||
* Node.js process. This is a privileged operation that requires the Node.js
|
||||
|
@ -843,7 +844,7 @@ declare module 'process' {
|
|||
* This feature is not available in `Worker` threads.
|
||||
* @since v0.9.4
|
||||
*/
|
||||
setgroups(groups: ReadonlyArray<string | number>): void;
|
||||
setgroups?: (groups: ReadonlyArray<string | number>) => void;
|
||||
/**
|
||||
* The `process.setUncaughtExceptionCaptureCallback()` function sets a function
|
||||
* that will be invoked when an uncaught exception occurs, which will receive the
|
||||
|
@ -872,7 +873,7 @@ declare module 'process' {
|
|||
* The `process.version` property contains the Node.js version string.
|
||||
*
|
||||
* ```js
|
||||
* import { version } from 'process';
|
||||
* import { version } from 'node:process';
|
||||
*
|
||||
* console.log(`Version: ${version}`);
|
||||
* // Version: v14.8.0
|
||||
|
@ -889,7 +890,7 @@ declare module 'process' {
|
|||
* to load modules that were compiled against a different module ABI version.
|
||||
*
|
||||
* ```js
|
||||
* import { versions } from 'process';
|
||||
* import { versions } from 'node:process';
|
||||
*
|
||||
* console.log(versions);
|
||||
* ```
|
||||
|
@ -897,30 +898,39 @@ declare module 'process' {
|
|||
* Will generate an object similar to:
|
||||
*
|
||||
* ```console
|
||||
* { node: '11.13.0',
|
||||
* v8: '7.0.276.38-node.18',
|
||||
* uv: '1.27.0',
|
||||
* zlib: '1.2.11',
|
||||
* brotli: '1.0.7',
|
||||
* ares: '1.15.0',
|
||||
* modules: '67',
|
||||
* nghttp2: '1.34.0',
|
||||
* napi: '4',
|
||||
* llhttp: '1.1.1',
|
||||
* openssl: '1.1.1b',
|
||||
* cldr: '34.0',
|
||||
* icu: '63.1',
|
||||
* tz: '2018e',
|
||||
* unicode: '11.0' }
|
||||
* { node: '20.2.0',
|
||||
* acorn: '8.8.2',
|
||||
* ada: '2.4.0',
|
||||
* ares: '1.19.0',
|
||||
* base64: '0.5.0',
|
||||
* brotli: '1.0.9',
|
||||
* cjs_module_lexer: '1.2.2',
|
||||
* cldr: '43.0',
|
||||
* icu: '73.1',
|
||||
* llhttp: '8.1.0',
|
||||
* modules: '115',
|
||||
* napi: '8',
|
||||
* nghttp2: '1.52.0',
|
||||
* nghttp3: '0.7.0',
|
||||
* ngtcp2: '0.8.1',
|
||||
* openssl: '3.0.8+quic',
|
||||
* simdutf: '3.2.9',
|
||||
* tz: '2023c',
|
||||
* undici: '5.22.0',
|
||||
* unicode: '15.0',
|
||||
* uv: '1.44.2',
|
||||
* uvwasi: '0.0.16',
|
||||
* v8: '11.3.244.8-node.9',
|
||||
* zlib: '1.2.13' }
|
||||
* ```
|
||||
* @since v0.2.0
|
||||
*/
|
||||
readonly versions: ProcessVersions;
|
||||
/**
|
||||
* The `process.config` property returns an `Object` containing the JavaScript
|
||||
* representation of the configure options used to compile the current Node.js
|
||||
* executable. This is the same as the `config.gypi` file that was produced when
|
||||
* running the `./configure` script.
|
||||
* The `process.config` property returns a frozen `Object` containing the
|
||||
* JavaScript representation of the configure options used to compile the current
|
||||
* Node.js executable. This is the same as the `config.gypi` file that was produced
|
||||
* when running the `./configure` script.
|
||||
*
|
||||
* An example of the possible output looks like:
|
||||
*
|
||||
|
@ -942,7 +952,6 @@ declare module 'process' {
|
|||
* node_shared_http_parser: 'false',
|
||||
* node_shared_libuv: 'false',
|
||||
* node_shared_zlib: 'false',
|
||||
* node_use_dtrace: 'false',
|
||||
* node_use_openssl: 'true',
|
||||
* node_shared_openssl: 'false',
|
||||
* strict_aliasing: 'true',
|
||||
|
@ -951,13 +960,6 @@ declare module 'process' {
|
|||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* The `process.config` property is **not** read-only and there are existing
|
||||
* modules in the ecosystem that are known to extend, modify, or entirely replace
|
||||
* the value of `process.config`.
|
||||
*
|
||||
* Modifying the `process.config` property, or any child-property of the`process.config` object has been deprecated. The `process.config` will be made
|
||||
* read-only in a future release.
|
||||
* @since v0.7.7
|
||||
*/
|
||||
readonly config: ProcessConfig;
|
||||
|
@ -976,7 +978,7 @@ declare module 'process' {
|
|||
* other than kill the target process.
|
||||
*
|
||||
* ```js
|
||||
* import process, { kill } from 'process';
|
||||
* import process, { kill } from 'node:process';
|
||||
*
|
||||
* process.on('SIGHUP', () => {
|
||||
* console.log('Got SIGHUP signal.');
|
||||
|
@ -1001,7 +1003,7 @@ declare module 'process' {
|
|||
* The `process.pid` property returns the PID of the process.
|
||||
*
|
||||
* ```js
|
||||
* import { pid } from 'process';
|
||||
* import { pid } from 'node:process';
|
||||
*
|
||||
* console.log(`This process is pid ${pid}`);
|
||||
* ```
|
||||
|
@ -1013,7 +1015,7 @@ declare module 'process' {
|
|||
* current process.
|
||||
*
|
||||
* ```js
|
||||
* import { ppid } from 'process';
|
||||
* import { ppid } from 'node:process';
|
||||
*
|
||||
* console.log(`The parent process is pid ${ppid}`);
|
||||
* ```
|
||||
|
@ -1040,19 +1042,19 @@ 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'`, `'s390'`, `'s390x'`, `'x32'`, and `'x64'`.
|
||||
* Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`,`'ppc64'`, `'s390'`, `'s390x'`, and `'x64'`.
|
||||
*
|
||||
* ```js
|
||||
* import { arch } from 'process';
|
||||
* import { arch } from 'node:process';
|
||||
*
|
||||
* console.log(`This processor architecture is ${arch}`);
|
||||
* ```
|
||||
* @since v0.5.0
|
||||
*/
|
||||
readonly arch: string;
|
||||
readonly arch: Architecture;
|
||||
/**
|
||||
* The `process.platform` property returns a string identifying the operating
|
||||
* system platform on which the Node.js process is running.
|
||||
* system platform for which the Node.js binary was compiled.
|
||||
*
|
||||
* Currently possible values are:
|
||||
*
|
||||
|
@ -1065,7 +1067,7 @@ declare module 'process' {
|
|||
* * `'win32'`
|
||||
*
|
||||
* ```js
|
||||
* import { platform } from 'process';
|
||||
* import { platform } from 'node:process';
|
||||
*
|
||||
* console.log(`This platform is ${platform}`);
|
||||
* ```
|
||||
|
@ -1088,6 +1090,17 @@ declare module 'process' {
|
|||
*/
|
||||
mainModule?: Module | undefined;
|
||||
memoryUsage: MemoryUsageFn;
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* 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;
|
||||
/**
|
||||
* 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
|
||||
|
@ -1099,7 +1112,7 @@ declare module 'process' {
|
|||
* argument to the function, to get a diff reading.
|
||||
*
|
||||
* ```js
|
||||
* import { cpuUsage } from 'process';
|
||||
* import { cpuUsage } from 'node:process';
|
||||
*
|
||||
* const startUsage = cpuUsage();
|
||||
* // { user: 38579, system: 6986 }
|
||||
|
@ -1123,7 +1136,7 @@ declare module 'process' {
|
|||
* See the [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#process-nexttick) guide for more background.
|
||||
*
|
||||
* ```js
|
||||
* import { nextTick } from 'process';
|
||||
* import { nextTick } from 'node:process';
|
||||
*
|
||||
* console.log('start');
|
||||
* nextTick(() => {
|
||||
|
@ -1141,7 +1154,7 @@ declare module 'process' {
|
|||
* I/O has occurred:
|
||||
*
|
||||
* ```js
|
||||
* import { nextTick } from 'process';
|
||||
* import { nextTick } from 'node:process';
|
||||
*
|
||||
* function MyThing(options) {
|
||||
* this.setupOptions(options);
|
||||
|
@ -1189,7 +1202,7 @@ declare module 'process' {
|
|||
* The following approach is much better:
|
||||
*
|
||||
* ```js
|
||||
* import { nextTick } from 'process';
|
||||
* import { nextTick } from 'node:process';
|
||||
*
|
||||
* function definitelyAsync(arg, cb) {
|
||||
* if (arg) {
|
||||
|
@ -1214,10 +1227,10 @@ declare module 'process' {
|
|||
* ```js
|
||||
* {
|
||||
* name: 'node',
|
||||
* lts: 'Erbium',
|
||||
* sourceUrl: 'https://nodejs.org/download/release/v12.18.1/node-v12.18.1.tar.gz',
|
||||
* headersUrl: 'https://nodejs.org/download/release/v12.18.1/node-v12.18.1-headers.tar.gz',
|
||||
* libUrl: 'https://nodejs.org/download/release/v12.18.1/win-x64/node.lib'
|
||||
* lts: 'Hydrogen',
|
||||
* sourceUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0.tar.gz',
|
||||
* headersUrl: 'https://nodejs.org/download/release/v18.12.0/node-v18.12.0-headers.tar.gz',
|
||||
* libUrl: 'https://nodejs.org/download/release/v18.12.0/win-x64/node.lib'
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
|
@ -1321,7 +1334,7 @@ declare module 'process' {
|
|||
* dashes:
|
||||
*
|
||||
* ```js
|
||||
* import { allowedNodeEnvironmentFlags } from 'process';
|
||||
* import { allowedNodeEnvironmentFlags } from 'node:process';
|
||||
*
|
||||
* allowedNodeEnvironmentFlags.forEach((flag) => {
|
||||
* // -r
|
||||
|
@ -1347,7 +1360,7 @@ declare module 'process' {
|
|||
report?: ProcessReport | undefined;
|
||||
/**
|
||||
* ```js
|
||||
* import { resourceUsage } from 'process';
|
||||
* import { resourceUsage } from 'node:process';
|
||||
*
|
||||
* console.log(resourceUsage());
|
||||
* /*
|
||||
|
@ -1405,7 +1418,7 @@ declare module 'process' {
|
|||
emit(event: 'unhandledRejection', reason: unknown, promise: Promise<unknown>): boolean;
|
||||
emit(event: 'warning', warning: Error): boolean;
|
||||
emit(event: 'message', message: unknown, sendHandle: unknown): this;
|
||||
emit(event: Signals, signal: Signals): boolean;
|
||||
emit(event: Signals, signal?: Signals): boolean;
|
||||
emit(event: 'multipleResolves', type: MultipleResolveType, promise: Promise<unknown>, value: unknown): this;
|
||||
emit(event: 'worker', listener: WorkerListener): this;
|
||||
on(event: 'beforeExit', listener: BeforeExitListener): this;
|
||||
|
|
2
node_modules/@types/node/punycode.d.ts
generated
vendored
2
node_modules/@types/node/punycode.d.ts
generated
vendored
|
@ -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/v17.0.0/lib/punycode.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/punycode.js)
|
||||
*/
|
||||
declare module 'punycode' {
|
||||
/**
|
||||
|
|
12
node_modules/@types/node/querystring.d.ts
generated
vendored
12
node_modules/@types/node/querystring.d.ts
generated
vendored
|
@ -1,15 +1,15 @@
|
|||
/**
|
||||
* The `querystring` module provides utilities for parsing and formatting URL
|
||||
* The `node:querystring` module provides utilities for parsing and formatting URL
|
||||
* query strings. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const querystring = require('querystring');
|
||||
* const querystring = require('node:querystring');
|
||||
* ```
|
||||
*
|
||||
* The `querystring` API is considered Legacy. While it is still maintained,
|
||||
* new code should use the `URLSearchParams` API instead.
|
||||
* @deprecated Legacy
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/querystring.js)
|
||||
* `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)
|
||||
*/
|
||||
declare module 'querystring' {
|
||||
interface StringifyOptions {
|
||||
|
|
226
node_modules/@types/node/readline.d.ts
generated
vendored
226
node_modules/@types/node/readline.d.ts
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* The `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` stream (such as `process.stdin`) one line at a time.
|
||||
*
|
||||
* To use the promise-based APIs:
|
||||
*
|
||||
|
@ -13,11 +13,11 @@
|
|||
* import * as readline from 'node:readline';
|
||||
* ```
|
||||
*
|
||||
* The following simple example illustrates the basic use of the `readline` module.
|
||||
* The following simple example illustrates the basic use of the `node:readline`module.
|
||||
*
|
||||
* ```js
|
||||
* import * as readline from 'node:readline/promises';
|
||||
* import { stdin as input, stdout as output } from 'process';
|
||||
* import { stdin as input, stdout as output } from 'node:process';
|
||||
*
|
||||
* const rl = readline.createInterface({ input, output });
|
||||
*
|
||||
|
@ -30,11 +30,13 @@
|
|||
*
|
||||
* 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/v17.0.0/lib/readline.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/readline.js)
|
||||
*/
|
||||
declare module 'readline' {
|
||||
import { Abortable, EventEmitter } from 'node:events';
|
||||
interface Key {
|
||||
import * as promises from 'node:readline/promises';
|
||||
export { promises };
|
||||
export interface Key {
|
||||
sequence?: string | undefined;
|
||||
name?: string | undefined;
|
||||
ctrl?: boolean | undefined;
|
||||
|
@ -48,7 +50,7 @@ declare module 'readline' {
|
|||
* and is read from, the `input` stream.
|
||||
* @since v0.1.104
|
||||
*/
|
||||
class Interface extends EventEmitter {
|
||||
export class Interface extends EventEmitter {
|
||||
readonly terminal: boolean;
|
||||
/**
|
||||
* The current input data being processed by node.
|
||||
|
@ -71,7 +73,7 @@ declare module 'readline' {
|
|||
* const showResults = debounce(() => {
|
||||
* console.log(
|
||||
* '\n',
|
||||
* values.filter((val) => val.startsWith(rl.line)).join(' ')
|
||||
* values.filter((val) => val.startsWith(rl.line)).join(' '),
|
||||
* );
|
||||
* }, 300);
|
||||
* process.stdin.on('keypress', (c, k) => {
|
||||
|
@ -97,7 +99,7 @@ declare module 'readline' {
|
|||
* > Instances of the `readline.Interface` class are constructed using the
|
||||
* > `readline.createInterface()` method.
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor
|
||||
*/
|
||||
protected constructor(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean);
|
||||
/**
|
||||
|
@ -106,12 +108,12 @@ declare module 'readline' {
|
|||
* > Instances of the `readline.Interface` class are constructed using the
|
||||
* > `readline.createInterface()` method.
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor
|
||||
*/
|
||||
protected constructor(options: ReadLineOptions);
|
||||
/**
|
||||
* The `rl.getPrompt()` method returns the current prompt used by `rl.prompt()`.
|
||||
* @since v15.3.0
|
||||
* @since v15.3.0, v14.17.0
|
||||
* @return the current prompt string
|
||||
*/
|
||||
getPrompt(): string;
|
||||
|
@ -121,13 +123,13 @@ declare module 'readline' {
|
|||
*/
|
||||
setPrompt(prompt: string): void;
|
||||
/**
|
||||
* The `rl.prompt()` method writes the `readline.Interface` instances configured`prompt` to a new line in `output` in order to provide a user with a new
|
||||
* The `rl.prompt()` method writes the `Interface` instances configured`prompt` to a new line in `output` in order to provide a user with a new
|
||||
* location at which to provide input.
|
||||
*
|
||||
* When called, `rl.prompt()` will resume the `input` stream if it has been
|
||||
* paused.
|
||||
*
|
||||
* If the `readline.Interface` was created with `output` set to `null` or`undefined` the prompt is not written.
|
||||
* 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`.
|
||||
*/
|
||||
|
@ -139,12 +141,14 @@ declare module 'readline' {
|
|||
* When called, `rl.question()` will resume the `input` stream if it has been
|
||||
* paused.
|
||||
*
|
||||
* If the `readline.Interface` was created with `output` set to `null` or`undefined` the `query` is not written.
|
||||
* 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.
|
||||
* The `callback` is called with the provided answer as the only argument.
|
||||
*
|
||||
* An error will be thrown if calling `rl.question()` after `rl.close()`.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
|
@ -169,25 +173,6 @@ declare module 'readline' {
|
|||
*
|
||||
* setTimeout(() => ac.abort(), 10000);
|
||||
* ```
|
||||
*
|
||||
* If this method is invoked as it's util.promisify()ed version, it returns a
|
||||
* Promise that fulfills with the answer. If the question is canceled using
|
||||
* an `AbortController` it will reject with an `AbortError`.
|
||||
*
|
||||
* ```js
|
||||
* const util = require('util');
|
||||
* const question = util.promisify(rl.question).bind(rl);
|
||||
*
|
||||
* async function questionExample() {
|
||||
* try {
|
||||
* const answer = await question('What is you favorite food? ');
|
||||
* console.log(`Oh, so your favorite food is ${answer}`);
|
||||
* } catch (err) {
|
||||
* console.error('Question rejected', err);
|
||||
* }
|
||||
* }
|
||||
* questionExample();
|
||||
* ```
|
||||
* @since v0.3.3
|
||||
* @param query A statement or query to write to `output`, prepended to the prompt.
|
||||
* @param callback A callback function that is invoked with the user's input in response to the `query`.
|
||||
|
@ -198,7 +183,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 `readline.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;
|
||||
|
@ -208,12 +193,12 @@ declare module 'readline' {
|
|||
*/
|
||||
resume(): this;
|
||||
/**
|
||||
* The `rl.close()` method closes the `readline.Interface` instance and
|
||||
* The `rl.close()` method closes the `Interface` instance and
|
||||
* relinquishes control over the `input` and `output` streams. When called,
|
||||
* the `'close'` event will be emitted.
|
||||
*
|
||||
* Calling `rl.close()` does not immediately stop other events (including `'line'`)
|
||||
* from being emitted by the `readline.Interface` instance.
|
||||
* from being emitted by the `Interface` instance.
|
||||
* @since v0.1.98
|
||||
*/
|
||||
close(): void;
|
||||
|
@ -228,7 +213,7 @@ declare module 'readline' {
|
|||
* When called, `rl.write()` will resume the `input` stream if it has been
|
||||
* paused.
|
||||
*
|
||||
* If the `readline.Interface` was created with `output` set to `null` or`undefined` the `data` and `key` are not written.
|
||||
* If the `Interface` was created with `output` set to `null` or`undefined` the `data` and `key` are not written.
|
||||
*
|
||||
* ```js
|
||||
* rl.write('Delete this!');
|
||||
|
@ -315,11 +300,11 @@ declare module 'readline' {
|
|||
prependOnceListener(event: 'history', listener: (history: string[]) => void): this;
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<string>;
|
||||
}
|
||||
type ReadLine = Interface; // type forwarded for backwards compatibility
|
||||
type Completer = (line: string) => CompleterResult;
|
||||
type AsyncCompleter = (line: string, callback: (err?: null | Error, result?: CompleterResult) => void) => void;
|
||||
type CompleterResult = [string[], string];
|
||||
interface ReadLineOptions {
|
||||
export type ReadLine = Interface; // type forwarded for backwards compatibility
|
||||
export type Completer = (line: string) => CompleterResult;
|
||||
export type AsyncCompleter = (line: string, callback: (err?: null | Error, result?: CompleterResult) => void) => void;
|
||||
export type CompleterResult = [string[], string];
|
||||
export interface ReadLineOptions {
|
||||
input: NodeJS.ReadableStream;
|
||||
output?: NodeJS.WritableStream | undefined;
|
||||
completer?: Completer | AsyncCompleter | undefined;
|
||||
|
@ -348,10 +333,10 @@ declare module 'readline' {
|
|||
* The `readline.createInterface()` method creates a new `readline.Interface`instance.
|
||||
*
|
||||
* ```js
|
||||
* const readline = require('readline');
|
||||
* const readline = require('node:readline');
|
||||
* const rl = readline.createInterface({
|
||||
* input: process.stdin,
|
||||
* output: process.stdout
|
||||
* output: process.stdout,
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
|
@ -370,18 +355,12 @@ declare module 'readline' {
|
|||
* (`process.stdout` does this automatically when it is a TTY).
|
||||
*
|
||||
* When creating a `readline.Interface` using `stdin` as input, the program
|
||||
* will not terminate until it receives `EOF` (Ctrl+D on
|
||||
* Linux/macOS, Ctrl+Z followed by Return on
|
||||
* Windows).
|
||||
* If you want your application to exit without waiting for user input, you can `unref()` the standard input stream:
|
||||
*
|
||||
* ```js
|
||||
* process.stdin.unref();
|
||||
* ```
|
||||
* will not terminate until it receives an [EOF character](https://en.wikipedia.org/wiki/End-of-file#EOF_character). To exit without
|
||||
* waiting for user input, call `process.stdin.unref()`.
|
||||
* @since v0.1.98
|
||||
*/
|
||||
function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface;
|
||||
function createInterface(options: ReadLineOptions): Interface;
|
||||
export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface;
|
||||
export function createInterface(options: ReadLineOptions): Interface;
|
||||
/**
|
||||
* The `readline.emitKeypressEvents()` method causes the given `Readable` stream to begin emitting `'keypress'` events corresponding to received input.
|
||||
*
|
||||
|
@ -405,11 +384,11 @@ declare module 'readline' {
|
|||
* implement a small command-line interface:
|
||||
*
|
||||
* ```js
|
||||
* const readline = require('readline');
|
||||
* const readline = require('node:readline');
|
||||
* const rl = readline.createInterface({
|
||||
* input: process.stdin,
|
||||
* output: process.stdout,
|
||||
* prompt: 'OHAI> '
|
||||
* prompt: 'OHAI> ',
|
||||
* });
|
||||
*
|
||||
* rl.prompt();
|
||||
|
@ -437,15 +416,15 @@ declare module 'readline' {
|
|||
* well as a `for await...of` loop:
|
||||
*
|
||||
* ```js
|
||||
* const fs = require('fs');
|
||||
* const readline = require('readline');
|
||||
* const fs = require('node:fs');
|
||||
* const readline = require('node:readline');
|
||||
*
|
||||
* async function processLineByLine() {
|
||||
* const fileStream = fs.createReadStream('input.txt');
|
||||
*
|
||||
* const rl = readline.createInterface({
|
||||
* input: fileStream,
|
||||
* crlfDelay: Infinity
|
||||
* crlfDelay: Infinity,
|
||||
* });
|
||||
* // Note: we use the crlfDelay option to recognize all instances of CR LF
|
||||
* // ('\r\n') in input.txt as a single line break.
|
||||
|
@ -462,12 +441,12 @@ declare module 'readline' {
|
|||
* Alternatively, one could use the `'line'` event:
|
||||
*
|
||||
* ```js
|
||||
* const fs = require('fs');
|
||||
* const readline = require('readline');
|
||||
* const fs = require('node:fs');
|
||||
* const readline = require('node:readline');
|
||||
*
|
||||
* const rl = readline.createInterface({
|
||||
* input: fs.createReadStream('sample.txt'),
|
||||
* crlfDelay: Infinity
|
||||
* crlfDelay: Infinity,
|
||||
* });
|
||||
*
|
||||
* rl.on('line', (line) => {
|
||||
|
@ -478,15 +457,15 @@ 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:
|
||||
*
|
||||
* ```js
|
||||
* const { once } = require('events');
|
||||
* const { createReadStream } = require('fs');
|
||||
* const { createInterface } = require('readline');
|
||||
* const { once } = require('node:events');
|
||||
* const { createReadStream } = require('node:fs');
|
||||
* const { createInterface } = require('node:readline');
|
||||
*
|
||||
* (async function processLineByLine() {
|
||||
* try {
|
||||
* const rl = createInterface({
|
||||
* input: createReadStream('big-file.txt'),
|
||||
* crlfDelay: Infinity
|
||||
* crlfDelay: Infinity,
|
||||
* });
|
||||
*
|
||||
* rl.on('line', (line) => {
|
||||
|
@ -503,9 +482,9 @@ declare module 'readline' {
|
|||
* ```
|
||||
* @since v0.7.7
|
||||
*/
|
||||
function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
|
||||
type Direction = -1 | 0 | 1;
|
||||
interface CursorPos {
|
||||
export function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
|
||||
export type Direction = -1 | 0 | 1;
|
||||
export interface CursorPos {
|
||||
rows: number;
|
||||
cols: number;
|
||||
}
|
||||
|
@ -516,7 +495,7 @@ declare module 'readline' {
|
|||
* @param callback Invoked once the operation completes.
|
||||
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
||||
*/
|
||||
function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
|
||||
export function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
|
||||
/**
|
||||
* The `readline.clearScreenDown()` method clears the given `TTY` stream from
|
||||
* the current position of the cursor down.
|
||||
|
@ -524,7 +503,7 @@ declare module 'readline' {
|
|||
* @param callback Invoked once the operation completes.
|
||||
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
||||
*/
|
||||
function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
|
||||
export function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
|
||||
/**
|
||||
* The `readline.cursorTo()` method moves cursor to the specified position in a
|
||||
* given `TTY` `stream`.
|
||||
|
@ -532,118 +511,15 @@ declare module 'readline' {
|
|||
* @param callback Invoked once the operation completes.
|
||||
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
||||
*/
|
||||
function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean;
|
||||
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`.
|
||||
*
|
||||
* ## Example: Tiny CLI
|
||||
*
|
||||
* The following example illustrates the use of `readline.Interface` class to
|
||||
* implement a small command-line interface:
|
||||
*
|
||||
* ```js
|
||||
* const readline = require('readline');
|
||||
* const rl = readline.createInterface({
|
||||
* input: process.stdin,
|
||||
* output: process.stdout,
|
||||
* prompt: 'OHAI> '
|
||||
* });
|
||||
*
|
||||
* rl.prompt();
|
||||
*
|
||||
* rl.on('line', (line) => {
|
||||
* switch (line.trim()) {
|
||||
* case 'hello':
|
||||
* console.log('world!');
|
||||
* break;
|
||||
* default:
|
||||
* console.log(`Say what? I might have heard '${line.trim()}'`);
|
||||
* break;
|
||||
* }
|
||||
* rl.prompt();
|
||||
* }).on('close', () => {
|
||||
* console.log('Have a great day!');
|
||||
* process.exit(0);
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* ## Example: Read file stream line-by-Line
|
||||
*
|
||||
* A common use case for `readline` is to consume an input file one line at a
|
||||
* time. The easiest way to do so is leveraging the `fs.ReadStream` API as
|
||||
* well as a `for await...of` loop:
|
||||
*
|
||||
* ```js
|
||||
* const fs = require('fs');
|
||||
* const readline = require('readline');
|
||||
*
|
||||
* async function processLineByLine() {
|
||||
* const fileStream = fs.createReadStream('input.txt');
|
||||
*
|
||||
* const rl = readline.createInterface({
|
||||
* input: fileStream,
|
||||
* crlfDelay: Infinity
|
||||
* });
|
||||
* // Note: we use the crlfDelay option to recognize all instances of CR LF
|
||||
* // ('\r\n') in input.txt as a single line break.
|
||||
*
|
||||
* for await (const line of rl) {
|
||||
* // Each line in input.txt will be successively available here as `line`.
|
||||
* console.log(`Line from file: ${line}`);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* processLineByLine();
|
||||
* ```
|
||||
*
|
||||
* Alternatively, one could use the `'line'` event:
|
||||
*
|
||||
* ```js
|
||||
* const fs = require('fs');
|
||||
* const readline = require('readline');
|
||||
*
|
||||
* const rl = readline.createInterface({
|
||||
* input: fs.createReadStream('sample.txt'),
|
||||
* crlfDelay: Infinity
|
||||
* });
|
||||
*
|
||||
* rl.on('line', (line) => {
|
||||
* console.log(`Line from file: ${line}`);
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Currently, `for await...of` loop can be a bit slower. If `async` / `await`flow and speed are both essential, a mixed approach can be applied:
|
||||
*
|
||||
* ```js
|
||||
* const { once } = require('events');
|
||||
* const { createReadStream } = require('fs');
|
||||
* const { createInterface } = require('readline');
|
||||
*
|
||||
* (async function processLineByLine() {
|
||||
* try {
|
||||
* const rl = createInterface({
|
||||
* input: createReadStream('big-file.txt'),
|
||||
* crlfDelay: Infinity
|
||||
* });
|
||||
*
|
||||
* rl.on('line', (line) => {
|
||||
* // Process the line.
|
||||
* });
|
||||
*
|
||||
* await once(rl, 'close');
|
||||
*
|
||||
* console.log('File processed.');
|
||||
* } catch (err) {
|
||||
* console.error(err);
|
||||
* }
|
||||
* })();
|
||||
* ```
|
||||
* @since v0.7.7
|
||||
* @param callback Invoked once the operation completes.
|
||||
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
||||
*/
|
||||
function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean;
|
||||
export function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean;
|
||||
}
|
||||
declare module 'node:readline' {
|
||||
export * from 'readline';
|
||||
|
|
145
node_modules/@types/node/readline/promises.d.ts
generated
vendored
Executable file
145
node_modules/@types/node/readline/promises.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,145 @@
|
|||
/**
|
||||
* @since v17.0.0
|
||||
* @experimental
|
||||
*/
|
||||
declare module 'readline/promises' {
|
||||
import { Interface as _Interface, ReadLineOptions, Completer, AsyncCompleter, Direction } from 'node:readline';
|
||||
import { Abortable } from 'node:events';
|
||||
/**
|
||||
* 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.
|
||||
* @since v17.0.0
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* 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 question is called after `rl.close()`, it returns a rejected promise.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
* const answer = await rl.question('What is your favorite food? ');
|
||||
* console.log(`Oh, so your favorite food is ${answer}`);
|
||||
* ```
|
||||
*
|
||||
* Using an `AbortSignal` to cancel a question.
|
||||
*
|
||||
* ```js
|
||||
* const signal = AbortSignal.timeout(10_000);
|
||||
*
|
||||
* signal.addEventListener('abort', () => {
|
||||
* console.log('The food question timed out');
|
||||
* }, { once: true });
|
||||
*
|
||||
* const answer = await rl.question('What is your favorite food? ', { signal });
|
||||
* console.log(`Oh, so your favorite food is ${answer}`);
|
||||
* ```
|
||||
* @since v17.0.0
|
||||
* @param query A statement or query to write to `output`, prepended to the prompt.
|
||||
* @return A promise that is fulfilled with the user's input in response to the `query`.
|
||||
*/
|
||||
question(query: string): Promise<string>;
|
||||
question(query: string, options: Abortable): Promise<string>;
|
||||
}
|
||||
/**
|
||||
* @since v17.0.0
|
||||
*/
|
||||
class Readline {
|
||||
/**
|
||||
* @param stream A TTY stream.
|
||||
*/
|
||||
constructor(
|
||||
stream: NodeJS.WritableStream,
|
||||
options?: {
|
||||
autoCommit?: boolean;
|
||||
}
|
||||
);
|
||||
/**
|
||||
* 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.
|
||||
* @since v17.0.0
|
||||
* @return this
|
||||
*/
|
||||
clearLine(dir: Direction): this;
|
||||
/**
|
||||
* 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.
|
||||
* @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.
|
||||
* @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.
|
||||
* @since v17.0.0
|
||||
* @return this
|
||||
*/
|
||||
cursorTo(x: number, y?: number): this;
|
||||
/**
|
||||
* 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.
|
||||
* @since v17.0.0
|
||||
* @return this
|
||||
*/
|
||||
moveCursor(dx: number, dy: number): this;
|
||||
/**
|
||||
* The `rl.rollback` methods clears the internal list of pending actions without
|
||||
* sending it to the associated `stream`.
|
||||
* @since v17.0.0
|
||||
* @return this
|
||||
*/
|
||||
rollback(): this;
|
||||
}
|
||||
/**
|
||||
* The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface`instance.
|
||||
*
|
||||
* ```js
|
||||
* const readlinePromises = require('node:readline/promises');
|
||||
* const rl = readlinePromises.createInterface({
|
||||
* input: process.stdin,
|
||||
* output: process.stdout,
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Once the `readlinePromises.Interface` instance is created, the most common case
|
||||
* is to listen for the `'line'` event:
|
||||
*
|
||||
* ```js
|
||||
* rl.on('line', (line) => {
|
||||
* console.log(`Received: ${line}`);
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* If `terminal` is `true` for this instance then the `output` stream will get
|
||||
* the best compatibility if it defines an `output.columns` property and emits
|
||||
* a `'resize'` event on the `output` if or when the columns ever change
|
||||
* (`process.stdout` does this automatically when it is a TTY).
|
||||
* @since v17.0.0
|
||||
*/
|
||||
function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface;
|
||||
function createInterface(options: ReadLineOptions): Interface;
|
||||
}
|
||||
declare module 'node:readline/promises' {
|
||||
export * from 'readline/promises';
|
||||
}
|
42
node_modules/@types/node/repl.d.ts
generated
vendored
42
node_modules/@types/node/repl.d.ts
generated
vendored
|
@ -1,12 +1,12 @@
|
|||
/**
|
||||
* The `repl` module provides a Read-Eval-Print-Loop (REPL) implementation that
|
||||
* is available both as a standalone program or includible in other applications.
|
||||
* It can be accessed using:
|
||||
* The `node:repl` module provides a Read-Eval-Print-Loop (REPL) implementation
|
||||
* that is available both as a standalone program or includible in other
|
||||
* applications. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const repl = require('repl');
|
||||
* const repl = require('node:repl');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/repl.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/repl.js)
|
||||
*/
|
||||
declare module 'repl' {
|
||||
import { Interface, Completer, AsyncCompleter } from 'node:readline';
|
||||
|
@ -41,8 +41,8 @@ declare module 'repl' {
|
|||
* error with `repl.Recoverable` to indicate the input was incomplete and prompt for
|
||||
* additional lines.
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_default_evaluation
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_custom_evaluation_functions
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_default_evaluation
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_custom_evaluation_functions
|
||||
*/
|
||||
eval?: REPLEval | undefined;
|
||||
/**
|
||||
|
@ -74,13 +74,13 @@ declare module 'repl' {
|
|||
* The function to invoke to format the output of each command before writing to `output`.
|
||||
* Default: a wrapper for `util.inspect`.
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_customizing_repl_output
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_customizing_repl_output
|
||||
*/
|
||||
writer?: REPLWriter | undefined;
|
||||
/**
|
||||
* An optional function used for custom Tab auto completion.
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v11.x/docs/api/readline.html#readline_use_of_the_completer_function
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#readline_use_of_the_completer_function
|
||||
*/
|
||||
completer?: Completer | AsyncCompleter | undefined;
|
||||
/**
|
||||
|
@ -124,7 +124,7 @@ declare module 'repl' {
|
|||
* or directly using the JavaScript `new` keyword.
|
||||
*
|
||||
* ```js
|
||||
* const repl = require('repl');
|
||||
* const repl = require('node:repl');
|
||||
*
|
||||
* const options = { useColors: true };
|
||||
*
|
||||
|
@ -162,33 +162,33 @@ declare module 'repl' {
|
|||
/**
|
||||
* A value indicating whether the REPL is currently in "editor mode".
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_commands_and_special_keys
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_commands_and_special_keys
|
||||
*/
|
||||
readonly editorMode: boolean;
|
||||
/**
|
||||
* A value indicating whether the `_` variable has been assigned.
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
|
||||
*/
|
||||
readonly underscoreAssigned: boolean;
|
||||
/**
|
||||
* The last evaluation result from the REPL (assigned to the `_` variable inside of the REPL).
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
|
||||
*/
|
||||
readonly last: any;
|
||||
/**
|
||||
* A value indicating whether the `_error` variable has been assigned.
|
||||
*
|
||||
* @since v9.8.0
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
|
||||
*/
|
||||
readonly underscoreErrAssigned: boolean;
|
||||
/**
|
||||
* The last error raised inside the REPL (assigned to the `_error` variable inside of the REPL).
|
||||
*
|
||||
* @since v9.8.0
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
|
||||
*/
|
||||
readonly lastError: any;
|
||||
/**
|
||||
|
@ -240,7 +240,7 @@ declare module 'repl' {
|
|||
*
|
||||
* `REPLServer` cannot be subclassed due to implementation specifics in NodeJS.
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_class_replserver
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_class_replserver
|
||||
*/
|
||||
private constructor();
|
||||
/**
|
||||
|
@ -251,7 +251,7 @@ declare module 'repl' {
|
|||
* The following example shows two new commands added to the REPL instance:
|
||||
*
|
||||
* ```js
|
||||
* const repl = require('repl');
|
||||
* const repl = require('node:repl');
|
||||
*
|
||||
* const replServer = repl.start({ prompt: '> ' });
|
||||
* replServer.defineCommand('sayhello', {
|
||||
|
@ -260,7 +260,7 @@ declare module 'repl' {
|
|||
* this.clearBufferedCommand();
|
||||
* console.log(`Hello, ${name}!`);
|
||||
* this.displayPrompt();
|
||||
* }
|
||||
* },
|
||||
* });
|
||||
* replServer.defineCommand('saybye', function saybye() {
|
||||
* console.log('Goodbye!');
|
||||
|
@ -277,7 +277,7 @@ declare module 'repl' {
|
|||
* Goodbye!
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
* @param keyword The command keyword (*without* a leading `.` character).
|
||||
* @param keyword The command keyword (_without_ a leading `.` character).
|
||||
* @param cmd The function to invoke when the command is processed.
|
||||
*/
|
||||
defineCommand(keyword: string, cmd: REPLCommandAction | REPLCommand): void;
|
||||
|
@ -401,7 +401,7 @@ declare module 'repl' {
|
|||
* If `options` is a string, then it specifies the input prompt:
|
||||
*
|
||||
* ```js
|
||||
* const repl = require('repl');
|
||||
* const repl = require('node:repl');
|
||||
*
|
||||
* // a Unix style prompt
|
||||
* repl.start('$ ');
|
||||
|
@ -412,7 +412,7 @@ declare module 'repl' {
|
|||
/**
|
||||
* Indicates a recoverable error that a `REPLServer` can use to support multi-line input.
|
||||
*
|
||||
* @see https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_recoverable_errors
|
||||
* @see https://nodejs.org/dist/latest-v20.x/docs/api/repl.html#repl_recoverable_errors
|
||||
*/
|
||||
class Recoverable extends SyntaxError {
|
||||
err: Error;
|
||||
|
|
1943
node_modules/@types/node/stream.d.ts
generated
vendored
1943
node_modules/@types/node/stream.d.ts
generated
vendored
File diff suppressed because it is too large
Load diff
16
node_modules/@types/node/stream/consumers.d.ts
generated
vendored
16
node_modules/@types/node/stream/consumers.d.ts
generated
vendored
|
@ -1,22 +1,10 @@
|
|||
// Duplicates of interface in lib.dom.ts.
|
||||
// Duplicated here rather than referencing lib.dom.ts because doing so causes lib.dom.ts to be loaded for "test-all"
|
||||
// Which in turn causes tests to pass that shouldn't pass.
|
||||
//
|
||||
// This interface is not, and should not be, exported.
|
||||
interface Blob {
|
||||
readonly size: number;
|
||||
readonly type: string;
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
slice(start?: number, end?: number, contentType?: string): Blob;
|
||||
stream(): NodeJS.ReadableStream;
|
||||
text(): Promise<string>;
|
||||
}
|
||||
declare module 'stream/consumers' {
|
||||
import { Blob as NodeBlob } from 'node:buffer';
|
||||
import { Readable } from 'node:stream';
|
||||
function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<Buffer>;
|
||||
function text(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<string>;
|
||||
function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<ArrayBuffer>;
|
||||
function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<Blob>;
|
||||
function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<NodeBlob>;
|
||||
function json(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<unknown>;
|
||||
}
|
||||
declare module 'node:stream/consumers' {
|
||||
|
|
3
node_modules/@types/node/stream/web.d.ts
generated
vendored
3
node_modules/@types/node/stream/web.d.ts
generated
vendored
|
@ -139,7 +139,8 @@ declare module 'stream/web' {
|
|||
pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
|
||||
pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
|
||||
tee(): [ReadableStream<R>, ReadableStream<R>];
|
||||
[Symbol.asyncIterator](options?: { preventCancel?: boolean }): AsyncIterableIterator<R>;
|
||||
values(options?: { preventCancel?: boolean }): AsyncIterableIterator<R>;
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<R>;
|
||||
}
|
||||
const ReadableStream: {
|
||||
prototype: ReadableStream;
|
||||
|
|
12
node_modules/@types/node/string_decoder.d.ts
generated
vendored
12
node_modules/@types/node/string_decoder.d.ts
generated
vendored
|
@ -1,16 +1,16 @@
|
|||
/**
|
||||
* The `string_decoder` module provides an API for decoding `Buffer` objects into
|
||||
* strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16
|
||||
* The `node:string_decoder` module provides an API for decoding `Buffer` objects
|
||||
* into strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16
|
||||
* characters. It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const { StringDecoder } = require('string_decoder');
|
||||
* const { StringDecoder } = require('node:string_decoder');
|
||||
* ```
|
||||
*
|
||||
* The following example shows the basic use of the `StringDecoder` class.
|
||||
*
|
||||
* ```js
|
||||
* const { StringDecoder } = require('string_decoder');
|
||||
* const { StringDecoder } = require('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('string_decoder');
|
||||
* const { StringDecoder } = require('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])));
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/string_decoder.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/string_decoder.js)
|
||||
*/
|
||||
declare module 'string_decoder' {
|
||||
class StringDecoder {
|
||||
|
|
1461
node_modules/@types/node/test.d.ts
generated
vendored
Executable file
1461
node_modules/@types/node/test.d.ts
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
149
node_modules/@types/node/timers.d.ts
generated
vendored
149
node_modules/@types/node/timers.d.ts
generated
vendored
|
@ -1,12 +1,12 @@
|
|||
/**
|
||||
* 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('timers')` to use the API.
|
||||
* globals, there is no need to call `require('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/v17.0.0/lib/timers.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/timers.js)
|
||||
*/
|
||||
declare module 'timers' {
|
||||
import { Abortable } from 'node:events';
|
||||
|
@ -33,15 +33,74 @@ declare module 'timers' {
|
|||
refresh(): this;
|
||||
[Symbol.toPrimitive](): number;
|
||||
}
|
||||
interface Immediate extends RefCounted {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
class Immediate implements RefCounted {
|
||||
/**
|
||||
* 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`
|
||||
*/
|
||||
ref(): this;
|
||||
/**
|
||||
* When called, the active `Immediate` 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 `Immediate` object's callback is
|
||||
* invoked. Calling `immediate.unref()` multiple times will have no effect.
|
||||
* @since v9.7.0
|
||||
* @return 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
|
||||
*/
|
||||
[Symbol.dispose](): void;
|
||||
}
|
||||
interface Timeout extends Timer {
|
||||
/**
|
||||
* 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
|
||||
* 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 {
|
||||
/**
|
||||
* 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
|
||||
* @return 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;
|
||||
/**
|
||||
* If true, the `Timeout` object will keep the Node.js event loop active.
|
||||
* @since v11.0.0
|
||||
|
@ -60,8 +119,32 @@ declare module 'timers' {
|
|||
*/
|
||||
refresh(): this;
|
||||
[Symbol.toPrimitive](): number;
|
||||
/**
|
||||
* Cancels the timeout.
|
||||
* @since v20.5.0
|
||||
*/
|
||||
[Symbol.dispose](): 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
|
||||
|
@ -69,15 +152,58 @@ declare module 'timers' {
|
|||
namespace setTimeout {
|
||||
const __promisify__: typeof setTimeoutPromise;
|
||||
}
|
||||
function clearTimeout(timeoutId: NodeJS.Timeout): void;
|
||||
function setInterval<TArgs extends any[]>(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timer;
|
||||
/**
|
||||
* 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.Timer;
|
||||
function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timeout;
|
||||
namespace setInterval {
|
||||
const __promisify__: typeof setIntervalPromise;
|
||||
}
|
||||
function clearInterval(intervalId: NodeJS.Timeout): void;
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* When multiple calls to `setImmediate()` are made, the `callback` functions are
|
||||
* queued for execution in the order in which they are created. The entire callback
|
||||
* queue is processed every event loop iteration. If an immediate timer is queued
|
||||
* from inside an executing callback, that timer will not be triggered until the
|
||||
* next event loop iteration.
|
||||
*
|
||||
* 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()`.
|
||||
* @since v0.9.1
|
||||
* @param callback The function to call at the end of this turn of the Node.js `Event Loop`
|
||||
* @param args Optional arguments to pass when the `callback` is called.
|
||||
* @return for use with {@link 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
|
||||
|
@ -85,7 +211,12 @@ declare module 'timers' {
|
|||
namespace setImmediate {
|
||||
const __promisify__: typeof setImmediatePromise;
|
||||
}
|
||||
function clearImmediate(immediateId: NodeJS.Immediate): void;
|
||||
/**
|
||||
* Cancels an `Immediate` object created by `setImmediate()`.
|
||||
* @since v0.9.1
|
||||
* @param immediate An `Immediate` object as returned by {@link setImmediate}.
|
||||
*/
|
||||
function clearImmediate(immediateId: NodeJS.Immediate | undefined): void;
|
||||
function queueMicrotask(callback: () => void): void;
|
||||
}
|
||||
}
|
||||
|
|
27
node_modules/@types/node/timers/promises.d.ts
generated
vendored
27
node_modules/@types/node/timers/promises.d.ts
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* The `timers/promises` API provides an alternative set of timer functions
|
||||
* that return `Promise` objects. The API is accessible via`require('timers/promises')`.
|
||||
* that return `Promise` objects. The API is accessible via`require('node:timers/promises')`.
|
||||
*
|
||||
* ```js
|
||||
* import {
|
||||
|
@ -44,6 +44,8 @@ declare module 'timers/promises' {
|
|||
function setImmediate<T = void>(value?: T, options?: TimerOptions): Promise<T>;
|
||||
/**
|
||||
* Returns an async iterator that generates values in an interval of `delay` ms.
|
||||
* If `ref` is `true`, you need to call `next()` of async iterator explicitly
|
||||
* or implicitly to keep the event loop alive.
|
||||
*
|
||||
* ```js
|
||||
* import {
|
||||
|
@ -62,6 +64,29 @@ declare module 'timers/promises' {
|
|||
* @since v15.9.0
|
||||
*/
|
||||
function setInterval<T = void>(delay?: number, value?: T, options?: TimerOptions): AsyncIterable<T>;
|
||||
interface Scheduler {
|
||||
/**
|
||||
* ```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
|
||||
* @experimental
|
||||
* @param [delay=1] The number of milliseconds to wait before fulfilling the promise.
|
||||
*/
|
||||
wait: (delay?: number, options?: TimerOptions) => 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
|
||||
* @experimental
|
||||
*/
|
||||
yield: () => Promise<void>;
|
||||
}
|
||||
const scheduler: Scheduler;
|
||||
}
|
||||
declare module 'node:timers/promises' {
|
||||
export * from 'timers/promises';
|
||||
|
|
222
node_modules/@types/node/tls.d.ts
generated
vendored
222
node_modules/@types/node/tls.d.ts
generated
vendored
|
@ -1,12 +1,12 @@
|
|||
/**
|
||||
* The `tls` module provides an implementation of the Transport Layer Security
|
||||
* The `node:tls` module provides an implementation of the Transport Layer Security
|
||||
* (TLS) and Secure Socket Layer (SSL) protocols that is built on top of OpenSSL.
|
||||
* The module can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* const tls = require('tls');
|
||||
* const tls = require('node:tls');
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/tls.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/tls.js)
|
||||
*/
|
||||
declare module 'tls' {
|
||||
import { X509Certificate } from 'node:crypto';
|
||||
|
@ -41,21 +41,100 @@ declare module 'tls' {
|
|||
CN: string;
|
||||
}
|
||||
interface PeerCertificate {
|
||||
subject: Certificate;
|
||||
issuer: Certificate;
|
||||
subjectaltname: string;
|
||||
infoAccess: NodeJS.Dict<string[]>;
|
||||
modulus: string;
|
||||
exponent: string;
|
||||
valid_from: string;
|
||||
valid_to: string;
|
||||
fingerprint: string;
|
||||
fingerprint256: string;
|
||||
ext_key_usage: string[];
|
||||
serialNumber: string;
|
||||
/**
|
||||
* `true` if a Certificate Authority (CA), `false` otherwise.
|
||||
* @since v18.13.0
|
||||
*/
|
||||
ca: boolean;
|
||||
/**
|
||||
* The DER encoded X.509 certificate data.
|
||||
*/
|
||||
raw: Buffer;
|
||||
/**
|
||||
* The certificate subject.
|
||||
*/
|
||||
subject: Certificate;
|
||||
/**
|
||||
* The certificate issuer, described in the same terms as the `subject`.
|
||||
*/
|
||||
issuer: Certificate;
|
||||
/**
|
||||
* The date-time the certificate is valid from.
|
||||
*/
|
||||
valid_from: string;
|
||||
/**
|
||||
* The date-time the certificate is valid to.
|
||||
*/
|
||||
valid_to: string;
|
||||
/**
|
||||
* The certificate serial number, as a hex string.
|
||||
*/
|
||||
serialNumber: string;
|
||||
/**
|
||||
* The SHA-1 digest of the DER encoded certificate.
|
||||
* It is returned as a `:` separated hexadecimal string.
|
||||
*/
|
||||
fingerprint: string;
|
||||
/**
|
||||
* The SHA-256 digest of the DER encoded certificate.
|
||||
* It is returned as a `:` separated hexadecimal string.
|
||||
*/
|
||||
fingerprint256: string;
|
||||
/**
|
||||
* The SHA-512 digest of the DER encoded certificate.
|
||||
* It is returned as a `:` separated hexadecimal string.
|
||||
*/
|
||||
fingerprint512: string;
|
||||
/**
|
||||
* The extended key usage, a set of OIDs.
|
||||
*/
|
||||
ext_key_usage?: string[];
|
||||
/**
|
||||
* A string containing concatenated names for the subject,
|
||||
* an alternative to the `subject` names.
|
||||
*/
|
||||
subjectaltname?: string;
|
||||
/**
|
||||
* An array describing the AuthorityInfoAccess, used with OCSP.
|
||||
*/
|
||||
infoAccess?: NodeJS.Dict<string[]>;
|
||||
/**
|
||||
* For RSA keys: The RSA bit size.
|
||||
*
|
||||
* For EC keys: The key size in bits.
|
||||
*/
|
||||
bits?: number;
|
||||
/**
|
||||
* The RSA exponent, as a string in hexadecimal number notation.
|
||||
*/
|
||||
exponent?: string;
|
||||
/**
|
||||
* The RSA modulus, as a hexadecimal string.
|
||||
*/
|
||||
modulus?: string;
|
||||
/**
|
||||
* The public key.
|
||||
*/
|
||||
pubkey?: Buffer;
|
||||
/**
|
||||
* The ASN.1 name of the OID of the elliptic curve.
|
||||
* Well-known curves are identified by an OID.
|
||||
* While it is unusual, it is possible that the curve
|
||||
* is identified by its mathematical properties,
|
||||
* in which case it will not have an OID.
|
||||
*/
|
||||
asn1Curve?: string;
|
||||
/**
|
||||
* The NIST name for the elliptic curve,if it has one
|
||||
* (not all well-known curves have been assigned names by NIST).
|
||||
*/
|
||||
nistCurve?: string;
|
||||
}
|
||||
interface DetailedPeerCertificate extends PeerCertificate {
|
||||
/**
|
||||
* The issuer certificate object.
|
||||
* For self-signed certificates, this may be a circular reference.
|
||||
*/
|
||||
issuerCertificate: DetailedPeerCertificate;
|
||||
}
|
||||
interface CipherNameAndProtocol {
|
||||
|
@ -133,7 +212,7 @@ declare module 'tls' {
|
|||
*
|
||||
* Instances of `tls.TLSSocket` implement the duplex `Stream` interface.
|
||||
*
|
||||
* Methods that return TLS connection metadata (e.g.{@link TLSSocket.getPeerCertificate} will only return data while the
|
||||
* Methods that return TLS connection metadata (e.g.{@link TLSSocket.getPeerCertificate}) will only return data while the
|
||||
* connection is open.
|
||||
* @since v0.11.4
|
||||
*/
|
||||
|
@ -143,8 +222,8 @@ declare module 'tls' {
|
|||
*/
|
||||
constructor(socket: net.Socket, options?: TLSSocketOptions);
|
||||
/**
|
||||
* Returns `true` if the peer certificate was signed by one of the CAs specified
|
||||
* when creating the `tls.TLSSocket` instance, otherwise `false`.
|
||||
* This property is `true` if the peer certificate was signed by one of the CAs
|
||||
* specified when creating the `tls.TLSSocket` instance, otherwise `false`.
|
||||
* @since v0.11.4
|
||||
*/
|
||||
authorized: boolean;
|
||||
|
@ -158,7 +237,7 @@ declare module 'tls' {
|
|||
* Always returns `true`. This may be used to distinguish TLS sockets from regular`net.Socket` instances.
|
||||
* @since v0.11.4
|
||||
*/
|
||||
encrypted: boolean;
|
||||
encrypted: true;
|
||||
/**
|
||||
* String containing the selected ALPN protocol.
|
||||
* Before a handshake has completed, this value is always null.
|
||||
|
@ -180,13 +259,13 @@ declare module 'tls' {
|
|||
/**
|
||||
* Returns an object containing information on the negotiated cipher suite.
|
||||
*
|
||||
* For example:
|
||||
* For example, a TLSv1.2 protocol with AES256-SHA cipher:
|
||||
*
|
||||
* ```json
|
||||
* {
|
||||
* "name": "AES128-SHA256",
|
||||
* "standardName": "TLS_RSA_WITH_AES_128_CBC_SHA256",
|
||||
* "version": "TLSv1.2"
|
||||
* "name": "AES256-SHA",
|
||||
* "standardName": "TLS_RSA_WITH_AES_256_CBC_SHA",
|
||||
* "version": "SSLv3"
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
|
@ -343,9 +422,9 @@ declare module 'tls' {
|
|||
* When enabled, TLS packet trace information is written to `stderr`. This can be
|
||||
* used to debug TLS connection problems.
|
||||
*
|
||||
* Note: The format of the output is identical to the output of `openssl s_client -trace` or `openssl s_server -trace`. While it is produced by OpenSSL's`SSL_trace()` function, the format is
|
||||
* undocumented, can change without notice,
|
||||
* and should not be relied on.
|
||||
* The format of the output is identical to the output of`openssl s_client -trace` or `openssl s_server -trace`. While it is produced by
|
||||
* OpenSSL's `SSL_trace()` function, the format is undocumented, can change
|
||||
* without notice, and should not be relied on.
|
||||
* @since v12.2.0
|
||||
*/
|
||||
enableTrace(): void;
|
||||
|
@ -374,7 +453,7 @@ declare module 'tls' {
|
|||
* 128,
|
||||
* 'client finished');
|
||||
*
|
||||
*
|
||||
* /*
|
||||
* Example return value of keyingMaterial:
|
||||
* <Buffer 76 26 af 99 c5 56 8e 42 09 91 ef 9f 93 cb ad 6c 7b 65 f8 53 f1 d8 d9
|
||||
* 12 5a 33 b8 b5 25 df 7b 37 9f e0 e2 4f b8 67 83 a3 2f cd 5d 41 42 4c 91
|
||||
|
@ -558,7 +637,8 @@ declare module 'tls' {
|
|||
* used.
|
||||
* @since v0.5.3
|
||||
* @param hostname A SNI host name or wildcard (e.g. `'*'`)
|
||||
* @param context An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc).
|
||||
* @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;
|
||||
/**
|
||||
|
@ -598,44 +678,44 @@ declare module 'tls' {
|
|||
*/
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
|
||||
addListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
||||
addListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => 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: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
|
||||
addListener(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
|
||||
addListener(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: 'tlsClientError', err: Error, tlsSocket: TLSSocket): boolean;
|
||||
emit(event: 'newSession', sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void): boolean;
|
||||
emit(event: 'newSession', sessionId: Buffer, sessionData: Buffer, callback: () => 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: 'resumeSession', sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void): boolean;
|
||||
emit(event: 'secureConnection', tlsSocket: TLSSocket): boolean;
|
||||
emit(event: 'keylog', line: Buffer, tlsSocket: TLSSocket): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
|
||||
on(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
||||
on(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => 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: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
|
||||
on(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
|
||||
on(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
|
||||
once(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
||||
once(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => 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: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
|
||||
once(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
|
||||
once(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
|
||||
prependListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
||||
prependListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => 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: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
|
||||
prependListener(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
|
||||
prependListener(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
|
||||
prependOnceListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
||||
prependOnceListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => 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: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
|
||||
prependOnceListener(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
|
||||
prependOnceListener(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
|
||||
}
|
||||
|
@ -648,6 +728,17 @@ declare module 'tls' {
|
|||
}
|
||||
type SecureVersion = 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1';
|
||||
interface SecureContextOptions {
|
||||
/**
|
||||
* If set, this will be called when a client opens a connection using the ALPN extension.
|
||||
* One argument will be passed to the callback: an object containing `servername` and `protocols` fields,
|
||||
* respectively containing the server name from the SNI extension (if any) and an array of
|
||||
* ALPN protocol name strings. The callback must return either one of the strings listed in `protocols`,
|
||||
* which will be returned to the client as the selected ALPN protocol, or `undefined`,
|
||||
* to reject the connection with a fatal alert. If a string is returned that does not match one of
|
||||
* the client's ALPN protocols, an error will be thrown.
|
||||
* 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;
|
||||
/**
|
||||
* Optionally override the trusted CA certificates. Default is to trust
|
||||
* the well-known CAs curated by Mozilla. Mozilla's CAs are completely
|
||||
|
@ -689,12 +780,9 @@ declare module 'tls' {
|
|||
*/
|
||||
crl?: string | Buffer | Array<string | Buffer> | undefined;
|
||||
/**
|
||||
* Diffie Hellman parameters, required for Perfect Forward Secrecy. Use
|
||||
* openssl dhparam to create the parameters. The key length must be
|
||||
* greater than or equal to 1024 bits or else an error will be thrown.
|
||||
* Although 1024 bits is permissible, use 2048 bits or larger for
|
||||
* stronger security. If omitted or invalid, the parameters are
|
||||
* silently discarded and DHE ciphers will not be available.
|
||||
* `'auto'` or custom Diffie-Hellman parameters, required for non-ECDHE perfect forward secrecy.
|
||||
* If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available.
|
||||
* ECDHE-based perfect forward secrecy will still be available.
|
||||
*/
|
||||
dhparam?: string | Buffer | undefined;
|
||||
/**
|
||||
|
@ -723,7 +811,7 @@ declare module 'tls' {
|
|||
* object.passphrase is optional. Encrypted keys will be decrypted with
|
||||
* object.passphrase if provided, or options.passphrase if it is not.
|
||||
*/
|
||||
key?: string | Buffer | Array<Buffer | KeyObject> | undefined;
|
||||
key?: string | Buffer | Array<string | Buffer | KeyObject> | undefined;
|
||||
/**
|
||||
* Name of an OpenSSL engine to get private key from. Should be used
|
||||
* together with privateKeyIdentifier.
|
||||
|
@ -814,13 +902,19 @@ declare module 'tls' {
|
|||
* Returns [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object, populating it with `reason`, `host`, and `cert` on
|
||||
* failure. On success, returns [undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type).
|
||||
*
|
||||
* This function can be overwritten by providing alternative function as part of
|
||||
* the `options.checkServerIdentity` option passed to `tls.connect()`. The
|
||||
* 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
|
||||
* overwriting function can call `tls.checkServerIdentity()` of course, to augment
|
||||
* the checks done with additional verification.
|
||||
*
|
||||
* This function is only called if the certificate passed all other checks, such as
|
||||
* being issued by trusted CA (`options.ca`).
|
||||
*
|
||||
* 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.
|
||||
* @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.
|
||||
|
@ -830,14 +924,14 @@ declare module 'tls' {
|
|||
* Creates a new {@link Server}. The `secureConnectionListener`, if provided, is
|
||||
* automatically set as a listener for the `'secureConnection'` event.
|
||||
*
|
||||
* The `ticketKeys` options is automatically shared between `cluster` module
|
||||
* The `ticketKeys` options is automatically shared between `node:cluster` module
|
||||
* workers.
|
||||
*
|
||||
* The following illustrates a simple echo server:
|
||||
*
|
||||
* ```js
|
||||
* const tls = require('tls');
|
||||
* const fs = require('fs');
|
||||
* const tls = require('node:tls');
|
||||
* const fs = require('node:fs');
|
||||
*
|
||||
* const options = {
|
||||
* key: fs.readFileSync('server-key.pem'),
|
||||
|
@ -847,7 +941,7 @@ declare module 'tls' {
|
|||
* requestCert: true,
|
||||
*
|
||||
* // This is necessary only if the client uses a self-signed certificate.
|
||||
* ca: [ fs.readFileSync('client-cert.pem') ]
|
||||
* ca: [ fs.readFileSync('client-cert.pem') ],
|
||||
* };
|
||||
*
|
||||
* const server = tls.createServer(options, (socket) => {
|
||||
|
@ -882,8 +976,8 @@ declare module 'tls' {
|
|||
*
|
||||
* ```js
|
||||
* // Assumes an echo server that is listening on port 8000.
|
||||
* const tls = require('tls');
|
||||
* const fs = require('fs');
|
||||
* const tls = require('node:tls');
|
||||
* const fs = require('node:fs');
|
||||
*
|
||||
* const options = {
|
||||
* // Necessary only if the server requires client certificate authentication.
|
||||
|
@ -959,12 +1053,19 @@ declare module 'tls' {
|
|||
* APIs that create secure contexts have no default value.
|
||||
*
|
||||
* The `tls.createSecureContext()` method creates a `SecureContext` object. It is
|
||||
* usable as an argument to several `tls` APIs, such as {@link createServer} and `server.addContext()`, but has no public methods.
|
||||
* 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.
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
* permissible, use 2048 bits or larger for stronger security.
|
||||
* @since v0.11.13
|
||||
*/
|
||||
function createSecureContext(options?: SecureContextOptions): SecureContext;
|
||||
|
@ -973,6 +1074,8 @@ declare module 'tls' {
|
|||
* lower-case for historical reasons, but must be uppercased to be used in
|
||||
* the `ciphers` option of {@link createSecureContext}.
|
||||
*
|
||||
* Not all supported ciphers are enabled by default. See `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.
|
||||
*
|
||||
|
@ -1008,6 +1111,13 @@ declare module 'tls' {
|
|||
* are provided, the lowest minimum is used.
|
||||
*/
|
||||
let DEFAULT_MIN_VERSION: SecureVersion;
|
||||
/**
|
||||
* The default value of the ciphers option of tls.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.
|
||||
*/
|
||||
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
|
||||
|
|
39
node_modules/@types/node/trace_events.d.ts
generated
vendored
39
node_modules/@types/node/trace_events.d.ts
generated
vendored
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
* The `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 `trace_events` module. The `--trace-event-categories` flag
|
||||
* or by using the `node:trace_events` module. The `--trace-event-categories` flag
|
||||
* accepts a list of comma-separated category names.
|
||||
*
|
||||
* The available categories are:
|
||||
|
@ -13,9 +13,19 @@
|
|||
* The `async_hooks` events have a unique `asyncId` and a special `triggerId` `triggerAsyncId` property.
|
||||
* * `node.bootstrap`: Enables capture of Node.js bootstrap milestones.
|
||||
* * `node.console`: Enables capture of `console.time()` and `console.count()`output.
|
||||
* * `node.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.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.perf.usertiming`: Enables capture of only Performance API User Timing
|
||||
* measures and marks.
|
||||
|
@ -23,8 +33,9 @@
|
|||
* measurements.
|
||||
* * `node.promises.rejections`: Enables capture of trace data tracking the number
|
||||
* of unhandled Promise rejections and handled-after-rejections.
|
||||
* * `node.vm.script`: Enables capture of trace data for the `vm` module's`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods.
|
||||
* * `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.http`: Enables capture of trace data for http request / response.
|
||||
*
|
||||
* By default the `node`, `node.async_hooks`, and `v8` categories are enabled.
|
||||
*
|
||||
|
@ -43,10 +54,10 @@
|
|||
* node --trace-event-categories v8,node,node.async_hooks
|
||||
* ```
|
||||
*
|
||||
* Alternatively, trace events may be enabled using the `trace_events` module:
|
||||
* Alternatively, trace events may be enabled using the `node:trace_events` module:
|
||||
*
|
||||
* ```js
|
||||
* const trace_events = require('trace_events');
|
||||
* const trace_events = require('node:trace_events');
|
||||
* const tracing = trace_events.createTracing({ categories: ['node.perf'] });
|
||||
* tracing.enable(); // Enable trace event capture for the 'node.perf' category
|
||||
*
|
||||
|
@ -66,6 +77,16 @@
|
|||
* 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
|
||||
* in your code, such as:
|
||||
*
|
||||
* ```js
|
||||
* process.on('SIGINT', function onSigint() {
|
||||
* console.info('Received SIGINT.');
|
||||
* process.exit(130); // Or applicable exit code depending on OS and signal
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* The tracing system uses the same time source
|
||||
* as the one used by `process.hrtime()`.
|
||||
* However the trace-event timestamps are expressed in microseconds,
|
||||
|
@ -73,7 +94,7 @@
|
|||
*
|
||||
* The features from this module are not available in `Worker` threads.
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/trace_events.js)
|
||||
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/trace_events.js)
|
||||
*/
|
||||
declare module 'trace_events' {
|
||||
/**
|
||||
|
@ -122,7 +143,7 @@ declare module 'trace_events' {
|
|||
* Creates and returns a `Tracing` object for the given set of `categories`.
|
||||
*
|
||||
* ```js
|
||||
* const trace_events = require('trace_events');
|
||||
* const trace_events = require('node:trace_events');
|
||||
* const categories = ['node.perf', 'node.async_hooks'];
|
||||
* const tracing = trace_events.createTracing({ categories });
|
||||
* tracing.enable();
|
||||
|
@ -142,7 +163,7 @@ declare module 'trace_events' {
|
|||
* Given the file `test.js` below, the command`node --trace-event-categories node.perf test.js` will print`'node.async_hooks,node.perf'` to the console.
|
||||
*
|
||||
* ```js
|
||||
* const trace_events = require('trace_events');
|
||||
* const trace_events = require('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'] });
|
||||
|
|
972
node_modules/@types/node/ts4.8/assert.d.ts
generated
vendored
Executable file
972
node_modules/@types/node/ts4.8/assert.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,972 @@
|
|||
/**
|
||||
* 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
Executable file
8
node_modules/@types/node/ts4.8/assert/strict.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,8 @@
|
|||
declare module 'assert/strict' {
|
||||
import { strict } from 'node:assert';
|
||||
export = strict;
|
||||
}
|
||||
declare module 'node:assert/strict' {
|
||||
import { strict } from 'node:assert';
|
||||
export = strict;
|
||||
}
|
531
node_modules/@types/node/ts4.8/async_hooks.d.ts
generated
vendored
Executable file
531
node_modules/@types/node/ts4.8/async_hooks.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,531 @@
|
|||
/**
|
||||
* 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
|
||||
* 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';
|
||||
}
|
2354
node_modules/@types/node/ts4.8/buffer.d.ts
generated
vendored
Executable file
2354
node_modules/@types/node/ts4.8/buffer.d.ts
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
1400
node_modules/@types/node/ts4.8/child_process.d.ts
generated
vendored
Executable file
1400
node_modules/@types/node/ts4.8/child_process.d.ts
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
414
node_modules/@types/node/ts4.8/cluster.d.ts
generated
vendored
Executable file
414
node_modules/@types/node/ts4.8/cluster.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,414 @@
|
|||
/**
|
||||
* 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';
|
||||
}
|
412
node_modules/@types/node/ts4.8/console.d.ts
generated
vendored
Executable file
412
node_modules/@types/node/ts4.8/console.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,412 @@
|
|||
/**
|
||||
* 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 The display label for the counter.
|
||||
*/
|
||||
count(label?: string): void;
|
||||
/**
|
||||
* Resets the internal counter specific to `label`.
|
||||
*
|
||||
* ```js
|
||||
* > console.count('abc');
|
||||
* abc: 1
|
||||
* undefined
|
||||
* > console.countReset('abc');
|
||||
* undefined
|
||||
* > console.count('abc');
|
||||
* abc: 1
|
||||
* undefined
|
||||
* >
|
||||
* ```
|
||||
* @since v8.3.0
|
||||
* @param label The display label for the counter.
|
||||
*/
|
||||
countReset(label?: string): void;
|
||||
/**
|
||||
* The `console.debug()` function is an alias for {@link log}.
|
||||
* @since v8.0.0
|
||||
*/
|
||||
debug(message?: any, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* Uses `util.inspect()` on `obj` and prints the resulting string to `stdout`.
|
||||
* This function bypasses any custom `inspect()` function defined on `obj`.
|
||||
* @since v0.1.101
|
||||
*/
|
||||
dir(obj: any, options?: InspectOptions): void;
|
||||
/**
|
||||
* This method calls `console.log()` passing it the arguments received.
|
||||
* This method does not produce any XML formatting.
|
||||
* @since v8.0.0
|
||||
*/
|
||||
dirxml(...data: any[]): void;
|
||||
/**
|
||||
* Prints to `stderr` with newline. Multiple arguments can be passed, with the
|
||||
* first used as the primary message and all additional used as substitution
|
||||
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`).
|
||||
*
|
||||
* ```js
|
||||
* const code = 5;
|
||||
* console.error('error #%d', code);
|
||||
* // Prints: error #5, to stderr
|
||||
* console.error('error', code);
|
||||
* // Prints: error 5, to stderr
|
||||
* ```
|
||||
*
|
||||
* If formatting elements (e.g. `%d`) are not found in the first string then `util.inspect()` is called on each argument and the resulting string
|
||||
* values are concatenated. See `util.format()` for more information.
|
||||
* @since v0.1.100
|
||||
*/
|
||||
error(message?: any, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* Increases indentation of subsequent lines by spaces for `groupIndentation`length.
|
||||
*
|
||||
* If one or more `label`s are provided, those are printed first without the
|
||||
* additional indentation.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
group(...label: any[]): void;
|
||||
/**
|
||||
* An alias for {@link group}.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
groupCollapsed(...label: any[]): void;
|
||||
/**
|
||||
* Decreases indentation of subsequent lines by spaces for `groupIndentation`length.
|
||||
* @since v8.5.0
|
||||
*/
|
||||
groupEnd(): void;
|
||||
/**
|
||||
* The `console.info()` function is an alias for {@link log}.
|
||||
* @since v0.1.100
|
||||
*/
|
||||
info(message?: any, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* Prints to `stdout` with newline. Multiple arguments can be passed, with the
|
||||
* first used as the primary message and all additional used as substitution
|
||||
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`).
|
||||
*
|
||||
* ```js
|
||||
* const count = 5;
|
||||
* console.log('count: %d', count);
|
||||
* // Prints: count: 5, to stdout
|
||||
* console.log('count:', count);
|
||||
* // Prints: count: 5, to stdout
|
||||
* ```
|
||||
*
|
||||
* See `util.format()` for more information.
|
||||
* @since v0.1.100
|
||||
*/
|
||||
log(message?: any, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* Try to construct a table with the columns of the properties of `tabularData`(or use `properties`) and rows of `tabularData` and log it. Falls back to just
|
||||
* logging the argument if it can’t be parsed as tabular.
|
||||
*
|
||||
* ```js
|
||||
* // These can't be parsed as tabular data
|
||||
* console.table(Symbol());
|
||||
* // Symbol()
|
||||
*
|
||||
* console.table(undefined);
|
||||
* // undefined
|
||||
*
|
||||
* console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);
|
||||
* // ┌─────────┬─────┬─────┐
|
||||
* // │ (index) │ a │ b │
|
||||
* // ├─────────┼─────┼─────┤
|
||||
* // │ 0 │ 1 │ 'Y' │
|
||||
* // │ 1 │ 'Z' │ 2 │
|
||||
* // └─────────┴─────┴─────┘
|
||||
*
|
||||
* console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);
|
||||
* // ┌─────────┬─────┐
|
||||
* // │ (index) │ a │
|
||||
* // ├─────────┼─────┤
|
||||
* // │ 0 │ 1 │
|
||||
* // │ 1 │ 'Z' │
|
||||
* // └─────────┴─────┘
|
||||
* ```
|
||||
* @since v10.0.0
|
||||
* @param properties Alternate properties for constructing the table.
|
||||
*/
|
||||
table(tabularData: any, properties?: ReadonlyArray<string>): void;
|
||||
/**
|
||||
* Starts a timer that can be used to compute the duration of an operation. Timers
|
||||
* are identified by a unique `label`. Use the same `label` when calling {@link timeEnd} to stop the timer and output the elapsed time in
|
||||
* suitable time units to `stdout`. For example, if the elapsed
|
||||
* time is 3869ms, `console.timeEnd()` displays "3.869s".
|
||||
* @since v0.1.104
|
||||
*/
|
||||
time(label?: string): void;
|
||||
/**
|
||||
* Stops a timer that was previously started by calling {@link time} and
|
||||
* prints the result to `stdout`:
|
||||
*
|
||||
* ```js
|
||||
* console.time('100-elements');
|
||||
* for (let i = 0; i < 100; i++) {}
|
||||
* console.timeEnd('100-elements');
|
||||
* // prints 100-elements: 225.438ms
|
||||
* ```
|
||||
* @since v0.1.104
|
||||
*/
|
||||
timeEnd(label?: string): void;
|
||||
/**
|
||||
* For a timer that was previously started by calling {@link time}, prints
|
||||
* the elapsed time and other `data` arguments to `stdout`:
|
||||
*
|
||||
* ```js
|
||||
* console.time('process');
|
||||
* const value = expensiveProcess1(); // Returns 42
|
||||
* console.timeLog('process', value);
|
||||
* // Prints "process: 365.227ms 42".
|
||||
* doExpensiveProcess2(value);
|
||||
* console.timeEnd('process');
|
||||
* ```
|
||||
* @since v10.7.0
|
||||
*/
|
||||
timeLog(label?: string, ...data: any[]): void;
|
||||
/**
|
||||
* Prints to `stderr` the string `'Trace: '`, followed by the `util.format()` formatted message and stack trace to the current position in the code.
|
||||
*
|
||||
* ```js
|
||||
* console.trace('Show me');
|
||||
* // Prints: (stack trace will vary based on where trace is called)
|
||||
* // Trace: Show me
|
||||
* // at repl:2:9
|
||||
* // at REPLServer.defaultEval (repl.js:248:27)
|
||||
* // at bound (domain.js:287:14)
|
||||
* // at REPLServer.runBound [as eval] (domain.js:300:12)
|
||||
* // at REPLServer.<anonymous> (repl.js:412:12)
|
||||
* // at emitOne (events.js:82:20)
|
||||
* // at REPLServer.emit (events.js:169:7)
|
||||
* // at REPLServer.Interface._onLine (readline.js:210:10)
|
||||
* // at REPLServer.Interface._line (readline.js:549:8)
|
||||
* // at REPLServer.Interface._ttyWrite (readline.js:826:14)
|
||||
* ```
|
||||
* @since v0.1.104
|
||||
*/
|
||||
trace(message?: any, ...optionalParams: any[]): void;
|
||||
/**
|
||||
* The `console.warn()` function is an alias for {@link error}.
|
||||
* @since v0.1.100
|
||||
*/
|
||||
warn(message?: any, ...optionalParams: any[]): void;
|
||||
// --- Inspector mode only ---
|
||||
/**
|
||||
* This method does not display anything unless used in the inspector.
|
||||
* Starts a JavaScript CPU profile with an optional label.
|
||||
*/
|
||||
profile(label?: string): void;
|
||||
/**
|
||||
* This method does not display anything unless used in the inspector.
|
||||
* Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector.
|
||||
*/
|
||||
profileEnd(label?: string): void;
|
||||
/**
|
||||
* This method does not display anything unless used in the inspector.
|
||||
* Adds an event with the label `label` to the Timeline panel of the inspector.
|
||||
*/
|
||||
timeStamp(label?: string): void;
|
||||
}
|
||||
/**
|
||||
* The `console` module provides a simple debugging console that is similar to the
|
||||
* JavaScript console mechanism provided by web browsers.
|
||||
*
|
||||
* The module exports two specific components:
|
||||
*
|
||||
* * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
|
||||
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
|
||||
*
|
||||
* _**Warning**_: The global console object's methods are neither consistently
|
||||
* synchronous like the browser APIs they resemble, nor are they consistently
|
||||
* asynchronous like all other Node.js streams. See the `note on process I/O` for
|
||||
* more information.
|
||||
*
|
||||
* Example using the global `console`:
|
||||
*
|
||||
* ```js
|
||||
* console.log('hello world');
|
||||
* // Prints: hello world, to stdout
|
||||
* console.log('hello %s', 'world');
|
||||
* // Prints: hello world, to stdout
|
||||
* console.error(new Error('Whoops, something bad happened'));
|
||||
* // Prints error message and stack trace to stderr:
|
||||
* // Error: Whoops, something bad happened
|
||||
* // at [eval]:5:15
|
||||
* // at Script.runInThisContext (node:vm:132:18)
|
||||
* // at Object.runInThisContext (node:vm:309:38)
|
||||
* // at node:internal/process/execution:77:19
|
||||
* // at [eval]-wrapper:6:22
|
||||
* // at evalScript (node:internal/process/execution:76:60)
|
||||
* // at node:internal/main/eval_string:23:3
|
||||
*
|
||||
* const name = 'Will Robinson';
|
||||
* console.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to stderr
|
||||
* ```
|
||||
*
|
||||
* Example using the `Console` class:
|
||||
*
|
||||
* ```js
|
||||
* const out = getStreamSomehow();
|
||||
* const err = getStreamSomehow();
|
||||
* const myConsole = new console.Console(out, err);
|
||||
*
|
||||
* myConsole.log('hello world');
|
||||
* // Prints: hello world, to out
|
||||
* myConsole.log('hello %s', 'world');
|
||||
* // Prints: hello world, to out
|
||||
* myConsole.error(new Error('Whoops, something bad happened'));
|
||||
* // Prints: [Error: Whoops, something bad happened], to err
|
||||
*
|
||||
* const name = 'Will Robinson';
|
||||
* myConsole.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to err
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/console.js)
|
||||
*/
|
||||
namespace console {
|
||||
interface ConsoleConstructorOptions {
|
||||
stdout: NodeJS.WritableStream;
|
||||
stderr?: NodeJS.WritableStream | undefined;
|
||||
ignoreErrors?: boolean | undefined;
|
||||
colorMode?: boolean | 'auto' | undefined;
|
||||
inspectOptions?: InspectOptions | undefined;
|
||||
/**
|
||||
* 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;
|
||||
}
|
18
node_modules/@types/node/ts4.8/constants.d.ts
generated
vendored
Executable file
18
node_modules/@types/node/ts4.8/constants.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,18 @@
|
|||
/** @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;
|
||||
}
|
3977
node_modules/@types/node/ts4.8/crypto.d.ts
generated
vendored
Executable file
3977
node_modules/@types/node/ts4.8/crypto.d.ts
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
550
node_modules/@types/node/ts4.8/dgram.d.ts
generated
vendored
Executable file
550
node_modules/@types/node/ts4.8/dgram.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,550 @@
|
|||
/**
|
||||
* 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 { EventEmitter, Abortable } 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
Executable file
191
node_modules/@types/node/ts4.8/diagnostics_channel.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,191 @@
|
|||
/**
|
||||
* 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';
|
||||
}
|
668
node_modules/@types/node/ts4.8/dns.d.ts
generated
vendored
Executable file
668
node_modules/@types/node/ts4.8/dns.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,668 @@
|
|||
/**
|
||||
* 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';
|
||||
}
|
414
node_modules/@types/node/ts4.8/dns/promises.d.ts
generated
vendored
Executable file
414
node_modules/@types/node/ts4.8/dns/promises.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,414 @@
|
|||
/**
|
||||
* 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 {
|
||||
LookupAddress,
|
||||
LookupOneOptions,
|
||||
LookupAllOptions,
|
||||
LookupOptions,
|
||||
AnyRecord,
|
||||
CaaRecord,
|
||||
MxRecord,
|
||||
NaptrRecord,
|
||||
SoaRecord,
|
||||
SrvRecord,
|
||||
ResolveWithTtlOptions,
|
||||
RecordWithTtl,
|
||||
ResolveOptions,
|
||||
ResolverOptions,
|
||||
} from 'node:dns';
|
||||
/**
|
||||
* Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
|
||||
* that are currently configured for DNS resolution. A string will include a port
|
||||
* section if a custom port is used.
|
||||
*
|
||||
* ```js
|
||||
* [
|
||||
* '4.4.4.4',
|
||||
* '2001:4860:4860::8888',
|
||||
* '4.4.4.4:1053',
|
||||
* '[2001:4860:4860::8888]:1053',
|
||||
* ]
|
||||
* ```
|
||||
* @since v10.6.0
|
||||
*/
|
||||
function getServers(): string[];
|
||||
/**
|
||||
* Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
|
||||
* AAAA (IPv6) record. All `option` properties are optional. If `options` is an
|
||||
* integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
|
||||
* and IPv6 addresses are both returned if found.
|
||||
*
|
||||
* With the `all` option set to `true`, the `Promise` is resolved with `addresses`being an array of objects with the properties `address` and `family`.
|
||||
*
|
||||
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
|
||||
* Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
|
||||
* the host name does not exist but also when the lookup fails in other ways
|
||||
* such as no available file descriptors.
|
||||
*
|
||||
* `dnsPromises.lookup()` does not necessarily have anything to do with the DNS
|
||||
* protocol. The implementation uses an operating system facility that can
|
||||
* associate names with addresses and vice versa. This implementation can have
|
||||
* subtle but important consequences on the behavior of any Node.js program. Please
|
||||
* take some time to consult the `Implementation considerations section` before
|
||||
* using `dnsPromises.lookup()`.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
* const dns = require('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';
|
||||
}
|
126
node_modules/@types/node/ts4.8/dom-events.d.ts
generated
vendored
Executable file
126
node_modules/@types/node/ts4.8/dom-events.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,126 @@
|
|||
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
Executable file
170
node_modules/@types/node/ts4.8/domain.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,170 @@
|
|||
/**
|
||||
* **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';
|
||||
}
|
788
node_modules/@types/node/ts4.8/events.d.ts
generated
vendored
Executable file
788
node_modules/@types/node/ts4.8/events.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,788 @@
|
|||
/**
|
||||
* 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;
|
||||
}
|
4082
node_modules/@types/node/ts4.8/fs.d.ts
generated
vendored
Executable file
4082
node_modules/@types/node/ts4.8/fs.d.ts
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
1202
node_modules/@types/node/ts4.8/fs/promises.d.ts
generated
vendored
Executable file
1202
node_modules/@types/node/ts4.8/fs/promises.d.ts
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
325
node_modules/@types/node/ts4.8/globals.d.ts
generated
vendored
Executable file
325
node_modules/@types/node/ts4.8/globals.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,325 @@
|
|||
// 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;
|
||||
}
|
||||
}
|
1
node_modules/@types/node/ts4.8/globals.global.d.ts
generated
vendored
Executable file
1
node_modules/@types/node/ts4.8/globals.global.d.ts
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
declare var global: typeof globalThis;
|
1724
node_modules/@types/node/ts4.8/http.d.ts
generated
vendored
Executable file
1724
node_modules/@types/node/ts4.8/http.d.ts
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
2129
node_modules/@types/node/ts4.8/http2.d.ts
generated
vendored
Executable file
2129
node_modules/@types/node/ts4.8/http2.d.ts
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
441
node_modules/@types/node/ts4.8/https.d.ts
generated
vendored
Executable file
441
node_modules/@types/node/ts4.8/https.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,441 @@
|
|||
/**
|
||||
* 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
Executable file
88
node_modules/@types/node/ts4.8/index.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
* 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
Executable file
2747
node_modules/@types/node/ts4.8/inspector.d.ts
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
232
node_modules/@types/node/ts4.8/module.d.ts
generated
vendored
Executable file
232
node_modules/@types/node/ts4.8/module.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,232 @@
|
|||
/**
|
||||
* @since v0.3.7
|
||||
*/
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
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 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;
|
||||
constructor(id: string, parent?: Module);
|
||||
}
|
||||
global {
|
||||
interface ImportMeta {
|
||||
url: string;
|
||||
/**
|
||||
* @experimental
|
||||
* This feature is only available with the `--experimental-import-meta-resolve`
|
||||
* command flag enabled.
|
||||
*
|
||||
* Provides a module-relative resolution function scoped to each module, returning
|
||||
* the URL string.
|
||||
*
|
||||
* @param specified The module specifier to resolve relative to `parent`.
|
||||
* @param parent The absolute parent module URL to resolve from. If none
|
||||
* is specified, the value of `import.meta.url` is used as the default.
|
||||
*/
|
||||
resolve?(specified: string, parent?: string | URL): Promise<string>;
|
||||
}
|
||||
}
|
||||
export = Module;
|
||||
}
|
||||
declare module 'node:module' {
|
||||
import module = require('module');
|
||||
export = module;
|
||||
}
|
893
node_modules/@types/node/ts4.8/net.d.ts
generated
vendored
Executable file
893
node_modules/@types/node/ts4.8/net.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,893 @@
|
|||
/**
|
||||
* > 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);
|
||||
/**
|
||||
* 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 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;
|
||||
/**
|
||||
* 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';
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue