Celé som to prerobil
This commit is contained in:
parent
45bd44654c
commit
717473d85b
1298 changed files with 116641 additions and 24519 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.env
|
108
debug.js
Normal file → Executable file
108
debug.js
Normal file → Executable file
|
@ -1,5 +1,13 @@
|
||||||
const Discord = require('discord.js');
|
const { Client, Intents } = require('discord.js');
|
||||||
const client = new Discord.Client();
|
const client = new Client({ intents: [
|
||||||
|
Intents.FLAGS.GUILDS,
|
||||||
|
Intents.FLAGS.GUILD_MESSAGES,
|
||||||
|
Intents.FLAGS.GUILD_MESSAGE_REACTIONS
|
||||||
|
] });
|
||||||
|
/**
|
||||||
|
List of intents
|
||||||
|
https://discord.com/developers/docs/topics/gateway#privileged-intents
|
||||||
|
*/
|
||||||
|
|
||||||
require("dotenv").config()
|
require("dotenv").config()
|
||||||
|
|
||||||
|
@ -11,23 +19,14 @@ var hugGifs =
|
||||||
"https://c.tenor.com/fLxZt7jo1YEAAAAd/loli-dragon.gif",
|
"https://c.tenor.com/fLxZt7jo1YEAAAAd/loli-dragon.gif",
|
||||||
"https://c.tenor.com/qF7mO4nnL0sAAAAd/abra%C3%A7o-hug.gif"]
|
"https://c.tenor.com/qF7mO4nnL0sAAAAd/abra%C3%A7o-hug.gif"]
|
||||||
|
|
||||||
|
|
||||||
client.once('ready', () => {
|
client.once('ready', () => {
|
||||||
console.log('Running');
|
console.log('Running');
|
||||||
let msg = []
|
|
||||||
msg.push(new Discord.MessageAttachment('https://cdn.discordapp.com/attachments/770762334305386556/925041308677074944/mp4.gif'))
|
|
||||||
msg.push(new Discord.MessageAttachment('https://cdn.discordapp.com/attachments/770762334305386556/925041308677074944/mp4.gif'))
|
|
||||||
|
|
||||||
client.channels.cache.get('770748282191740943').send(msg)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('message', gotMessage);
|
client.on("messageCreate", gotMessage);
|
||||||
|
|
||||||
|
|
||||||
function gotMessage(message){
|
function gotMessage(message){
|
||||||
|
|
||||||
// console.log(message)
|
|
||||||
|
|
||||||
if(message.content.includes('https://media.discordapp.net')) {
|
if(message.content.includes('https://media.discordapp.net')) {
|
||||||
if(message.content.includes('webm') || message.content.includes('mov') ||
|
if(message.content.includes('webm') || message.content.includes('mov') ||
|
||||||
message.content.includes('mp4')) {
|
message.content.includes('mp4')) {
|
||||||
|
@ -36,6 +35,8 @@ function gotMessage(message){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let msg = message.content.toLowerCase()
|
||||||
|
|
||||||
let content = message.content.trim()
|
let content = message.content.trim()
|
||||||
|
|
||||||
var msgContentSplit = content.split(/[ ]+/);
|
var msgContentSplit = content.split(/[ ]+/);
|
||||||
|
@ -44,25 +45,32 @@ function gotMessage(message){
|
||||||
move(message, msgContentSplit)
|
move(message, msgContentSplit)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgContentSplit[0] == "henlo") {
|
let isBot = message.author.bot
|
||||||
|
|
||||||
|
if (!isBot){
|
||||||
|
if (msg.includes("henlo")) {
|
||||||
henlo(message)
|
henlo(message)
|
||||||
}
|
}
|
||||||
else if (msgContentSplit[0] == "how ye") {
|
else if (msg.includes("how ye")) {
|
||||||
mood(message)
|
mood(message)
|
||||||
}
|
}
|
||||||
else if (msgContentSplit[0] == "tylko jedno") {
|
else if (msg.includes("tylko jedno")) {
|
||||||
message.channel.send("Koksu pięć gram odlecieć sam");
|
message.channel.send("Koksu pięć gram odlecieć sam");
|
||||||
}
|
}
|
||||||
if (msgContentSplit[0] == "hug") {
|
if (msgContentSplit[0] == "hug") {
|
||||||
hug(message)
|
hug(message)
|
||||||
}
|
}
|
||||||
|
else if (msgContentSplit[0] == "!say") {
|
||||||
|
say(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Responses
|
// Responses
|
||||||
function henlo(message){
|
function henlo(message){
|
||||||
var emojis = ["🥰", "🐄", "🐮", "❤️", "👋", "🤠", "😊"];
|
var emojis = ["🥰", "🐄", "🐮", "❤️", "👋", "🤠", "😊"];
|
||||||
let randomNum = RNG(emojis.length);
|
let randomNum = RNG(emojis.length);
|
||||||
message.channel.send("Henlooo " + message.author.username + " " + emojis[randomNum]);
|
message.reply("Henlooo " + message.author.username + " " + emojis[randomNum]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hug(message){
|
function hug(message){
|
||||||
|
@ -71,10 +79,11 @@ function hug(message){
|
||||||
var mentionedRoles = message.mentions.roles.values()
|
var mentionedRoles = message.mentions.roles.values()
|
||||||
var mentionedRolesSize = message.mentions.roles.size
|
var mentionedRolesSize = message.mentions.roles.size
|
||||||
|
|
||||||
msg = message.content.toLowerCase()
|
var msg = message.content.toLowerCase()
|
||||||
|
|
||||||
let randomNum = RNG(hugGifs.length)
|
let randomNum = RNG(hugGifs.length)
|
||||||
title = message.author.username + " hugs"
|
let title = message.author.username + " hugs"
|
||||||
|
let embed;
|
||||||
if (mentionedUsersSize > 0 || mentionedRolesSize > 0){
|
if (mentionedUsersSize > 0 || mentionedRolesSize > 0){
|
||||||
let allMentions = ""
|
let allMentions = ""
|
||||||
for (let i = 0; i < mentionedUsersSize; i++) {
|
for (let i = 0; i < mentionedUsersSize; i++) {
|
||||||
|
@ -106,7 +115,7 @@ function hug(message){
|
||||||
function mood(message){
|
function mood(message){
|
||||||
var responses = ["Not bad, how yee?", "MOOdy", "A bit sad 😢", "Good, how yee?", "I'm fine, how yee?"];
|
var responses = ["Not bad, how yee?", "MOOdy", "A bit sad 😢", "Good, how yee?", "I'm fine, how yee?"];
|
||||||
let randomNum = RNG(responses.length);
|
let randomNum = RNG(responses.length);
|
||||||
message.channel.send(responses[randomNum]);
|
message.reply(responses[randomNum]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function move(message, splits){
|
function move(message, splits){
|
||||||
|
@ -122,39 +131,53 @@ function move(message, splits){
|
||||||
mentionedChannelId = splits[0].substring(2, splits[0].length - 1);
|
mentionedChannelId = splits[0].substring(2, splits[0].length - 1);
|
||||||
replyChannelId = message.reference.channelID;
|
replyChannelId = message.reference.channelID;
|
||||||
|
|
||||||
var replyChannel = client.channels.cache.find(channel => channel.id === replyChannelId);
|
var replyChannel = client.channels.cache.get(replyChannelId);
|
||||||
|
|
||||||
|
// create embed
|
||||||
|
// add field for every attachment
|
||||||
|
// keď je tam emebed tak možnosť cez emotes či vymazať original post alebo nie
|
||||||
|
// zisti ako sa robia replies ako robia normálny usery
|
||||||
replyChannel.messages.fetch(replyMessageId).then(msg => {
|
replyChannel.messages.fetch(replyMessageId).then(msg => {
|
||||||
|
let newMessage = []
|
||||||
newMessage = new Discord.Message()
|
let allAttachments = msg.attachments.values()
|
||||||
allAttachments = msg.attachments.values()
|
|
||||||
|
|
||||||
att = []
|
|
||||||
for (let i = 0; i < msg.attachments.size; i++){
|
for (let i = 0; i < msg.attachments.size; i++){
|
||||||
currAttachment = allAttachments.next().value
|
let currAttachment = allAttachments.next().value
|
||||||
att.push(new Discord.MessageAttachment(currAttachment.url))
|
newMessage.push(new Discord.MessageAttachment(currAttachment.url))
|
||||||
}
|
}
|
||||||
console.log(att)
|
|
||||||
coll = new Discord.Collection(att)
|
|
||||||
console.log(coll)
|
|
||||||
|
|
||||||
newMessage.attachments = coll
|
|
||||||
// newMessage.attachments = new Discord.MessageAttachment()
|
|
||||||
newMessage.embeds = msg.embeds
|
|
||||||
newMessage.content = "Sent by <@" + msg.author + "> \nmooved <@" + message.author + ">\n"
|
|
||||||
newMessage.content += msg.content
|
|
||||||
|
|
||||||
client.channels.cache.get(mentionedChannelId).send(newMessage)
|
|
||||||
|
|
||||||
|
if (newMessage.length > 0){
|
||||||
|
client.channels.cache.get(mentionedChannelId).send(newMessage).then(msgToEdit => {
|
||||||
|
msgToEdit.edit(`Sent by ${msg.author}\nmooved ${message.author}\n`)
|
||||||
|
})
|
||||||
msg.delete({timeout: 3000});
|
msg.delete({timeout: 3000});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (msg.embeds.length > 0){
|
||||||
|
message.channel.send("Can't really moove embeds, sowwy :c")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let newMsg = new Discord.MessageEmbed()
|
||||||
|
.setColor(randomColor())
|
||||||
|
.addField("MOO", `Sent by ${msg.author}\nmooved ${message.author}`)
|
||||||
|
.addField("Message:", msg.content)
|
||||||
|
client.channels.cache.get(mentionedChannelId).send(newMsg)
|
||||||
|
msg.delete({timeout: 3000})
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
message.delete({timeout: 3000});
|
message.delete({timeout: 3000});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function say(message){
|
||||||
|
let tmp = message.content.split("!say ")
|
||||||
|
let content = tmp[1]
|
||||||
|
message.channel.send(content)
|
||||||
|
message.delete()
|
||||||
|
}
|
||||||
|
|
||||||
function createEmbed(title, img, desc){
|
function createEmbed(title, img, desc){
|
||||||
embed = new Discord.MessageEmbed()
|
let embed = new Discord.MessageEmbed()
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
.setImage(img)
|
.setImage(img)
|
||||||
.setDescription(desc)
|
.setDescription(desc)
|
||||||
|
@ -176,6 +199,9 @@ function RNG(max){
|
||||||
return Math.floor(Math.random() * max)
|
return Math.floor(Math.random() * max)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// narodeniny?
|
||||||
|
// vianoce, novy rok a tak
|
||||||
|
// hug cez tenor
|
||||||
|
// headpat cez tenor
|
||||||
|
// .gif
|
||||||
client.login(process.env.TOKEN)
|
client.login(process.env.TOKEN)
|
9
main.js
Normal file → Executable file
9
main.js
Normal file → Executable file
|
@ -1,5 +1,9 @@
|
||||||
const Discord = require('discord.js');
|
const { Client, Intents } = require('discord.js');
|
||||||
const client = new Discord.Client();
|
const client = new Client({ intents: [
|
||||||
|
Intents.FLAGS.GUILDS,
|
||||||
|
Intents.FLAGS.GUILD_MESSAGES,
|
||||||
|
Intents.FLAGS.GUILD_MESSAGE_REACTIONS
|
||||||
|
] });
|
||||||
|
|
||||||
require("dotenv").config()
|
require("dotenv").config()
|
||||||
|
|
||||||
|
@ -18,7 +22,6 @@ client.once('ready', () => {
|
||||||
|
|
||||||
client.on('message', gotMessage);
|
client.on('message', gotMessage);
|
||||||
|
|
||||||
|
|
||||||
function gotMessage(message){
|
function gotMessage(message){
|
||||||
|
|
||||||
// console.log(message)
|
// console.log(message)
|
||||||
|
|
8
node.js
Normal file → Executable file
8
node.js
Normal file → Executable file
|
@ -1,5 +1,9 @@
|
||||||
const Discord = require('discord.js');
|
const { Client, Intents } = require('discord.js');
|
||||||
const client = new Discord.Client();
|
const client = new Client({ intents: [
|
||||||
|
Intents.FLAGS.GUILDS,
|
||||||
|
Intents.FLAGS.GUILD_MESSAGES,
|
||||||
|
Intents.FLAGS.GUILD_MESSAGE_REACTIONS
|
||||||
|
] });
|
||||||
var author = " ";
|
var author = " ";
|
||||||
var storedLink = " ";
|
var storedLink = " ";
|
||||||
var link;
|
var link;
|
||||||
|
|
275
node_modules/.package-lock.json
generated
vendored
275
node_modules/.package-lock.json
generated
vendored
|
@ -1,18 +1,97 @@
|
||||||
{
|
{
|
||||||
"name": "discord-bot",
|
"name": "moover",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"node_modules/@discordjs/collection": {
|
"node_modules/@discordjs/builders": {
|
||||||
"version": "0.1.6",
|
"version": "0.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.12.0.tgz",
|
||||||
"integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
|
"integrity": "sha512-Vx2MjUZd6QVo1uS2uWt708Fd6cHWGFblAvbpL5EBO+kLl0BADmPwwvts+YJ/VfSywed6Vsk6K2cEooR/Ytjhjw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@sindresorhus/is": "^4.3.0",
|
||||||
|
"discord-api-types": "^0.26.1",
|
||||||
|
"ts-mixer": "^6.0.0",
|
||||||
|
"tslib": "^2.3.1",
|
||||||
|
"zod": "^3.11.6"
|
||||||
},
|
},
|
||||||
"node_modules/@discordjs/form-data": {
|
"engines": {
|
||||||
|
"node": ">=16.9.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@discordjs/collection": {
|
||||||
|
"version": "0.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.4.0.tgz",
|
||||||
|
"integrity": "sha512-zmjq+l/rV35kE6zRrwe8BHqV78JvIh2ybJeZavBi5NySjWXqN3hmmAKg7kYMMXSeiWtSsMoZ/+MQi0DiQWy2lw==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.0.0",
|
||||||
|
"npm": ">=7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@discordjs/rest": {
|
||||||
|
"version": "0.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-0.3.0.tgz",
|
||||||
|
"integrity": "sha512-F9aeP3odlAlllM1ciBZLdd+adiAyBj4VaZBejj4UMj4afE2wfCkNTGvYYiRxrXUE9fN7e/BuDP2ePl0tVA2m7Q==",
|
||||||
|
"dependencies": {
|
||||||
|
"@discordjs/collection": "^0.4.0",
|
||||||
|
"@sapphire/async-queue": "^1.1.9",
|
||||||
|
"@sapphire/snowflake": "^3.0.1",
|
||||||
|
"discord-api-types": "^0.26.1",
|
||||||
|
"form-data": "^4.0.0",
|
||||||
|
"node-fetch": "^2.6.5",
|
||||||
|
"tslib": "^2.3.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.9.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==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=v14.0.0",
|
||||||
|
"npm": ">=7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@sapphire/snowflake": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.0.1.tgz",
|
||||||
"integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
|
"integrity": "sha512-v+wCC2q9DK3OhG7Vcdt/8A/INAYiyhlMD5snakmXGBN1usLBwSGJVJBjDHv4VGI5C9YYl4UdW5Ovr3arvYsJXQ==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=v14.0.0",
|
||||||
|
"npm": ">=7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@sindresorhus/is": {
|
||||||
|
"version": "4.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.3.0.tgz",
|
||||||
|
"integrity": "sha512-wwOvh0eO3PiTEivGJWiZ+b946SlMSb4pe+y+Ur/4S87cwo09pYi+FWHHnbrM3W9W7cBYKDqQXcrFYjYUCOJUEQ==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sindresorhus/is?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/node": {
|
||||||
|
"version": "17.0.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.10.tgz",
|
||||||
|
"integrity": "sha512-S/3xB4KzyFxYGCppyDt68yzBU9ysL88lSdIah4D6cptdcltc4NCPCAMc0+PCpg/lLIyC7IPvj2Z52OJWeIUkog=="
|
||||||
|
},
|
||||||
|
"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==",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*",
|
||||||
|
"form-data": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/node-fetch/node_modules/form-data": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"asynckit": "^0.4.0",
|
"asynckit": "^0.4.0",
|
||||||
"combined-stream": "^1.0.8",
|
"combined-stream": "^1.0.8",
|
||||||
|
@ -22,15 +101,12 @@
|
||||||
"node": ">= 6"
|
"node": ">= 6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/abort-controller": {
|
"node_modules/@types/ws": {
|
||||||
"version": "3.0.0",
|
"version": "8.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz",
|
||||||
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
|
"integrity": "sha512-NOn5eIcgWLOo6qW8AcuLZ7G8PycXu0xTxxkS6Q18VWFxgPUSOwV0pBj2a/4viNZVu25i7RIB7GttdkAIUUXOOg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"event-target-shim": "^5.0.0"
|
"@types/node": "*"
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6.5"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/asynckit": {
|
"node_modules/asynckit": {
|
||||||
|
@ -57,109 +133,144 @@
|
||||||
"node": ">=0.4.0"
|
"node": ">=0.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/discord-api-types": {
|
||||||
|
"version": "0.26.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.26.1.tgz",
|
||||||
|
"integrity": "sha512-T5PdMQ+Y1MEECYMV5wmyi9VEYPagEDEi4S0amgsszpWY0VB9JJ/hEvM6BgLhbdnKky4gfmZEXtEEtojN8ZKJQQ==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/discord.js": {
|
"node_modules/discord.js": {
|
||||||
"version": "12.4.1",
|
"version": "13.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.6.0.tgz",
|
||||||
"integrity": "sha512-KxOB8LOAN3GmrvkD6a6Fr1nlfArIFZ+q7Uqg4T/5duB90GZy9a0/Py2E+Y+eHKP6ZUCR2mbNMLCcHGjahiaNqA==",
|
"integrity": "sha512-tXNR8zgsEPxPBvGk3AQjJ9ljIIC6/LOPjzKwpwz8Y1Q2X66Vi3ZqFgRHYwnHKC0jC0F+l4LzxlhmOJsBZDNg9g==",
|
||||||
"deprecated": "no longer supported",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/collection": "^0.1.6",
|
"@discordjs/builders": "^0.11.0",
|
||||||
"@discordjs/form-data": "^3.0.1",
|
"@discordjs/collection": "^0.4.0",
|
||||||
"abort-controller": "^3.0.0",
|
"@sapphire/async-queue": "^1.1.9",
|
||||||
|
"@types/node-fetch": "^2.5.12",
|
||||||
|
"@types/ws": "^8.2.2",
|
||||||
|
"discord-api-types": "^0.26.0",
|
||||||
|
"form-data": "^4.0.0",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"prism-media": "^1.2.2",
|
"ws": "^8.4.0"
|
||||||
"setimmediate": "^1.0.5",
|
|
||||||
"tweetnacl": "^1.0.3",
|
|
||||||
"ws": "^7.3.1"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.0.0"
|
"node": ">=16.6.0",
|
||||||
|
"npm": ">=7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/discord.js/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==",
|
||||||
|
"dependencies": {
|
||||||
|
"@sindresorhus/is": "^4.2.0",
|
||||||
|
"discord-api-types": "^0.26.0",
|
||||||
|
"ts-mixer": "^6.0.0",
|
||||||
|
"tslib": "^2.3.1",
|
||||||
|
"zod": "^3.11.6"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.0.0",
|
||||||
|
"npm": ">=7.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/dotenv": {
|
"node_modules/dotenv": {
|
||||||
"version": "10.0.0",
|
"version": "14.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-14.2.0.tgz",
|
||||||
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==",
|
"integrity": "sha512-05POuPJyPpO6jqzTNweQFfAyMSD4qa4lvsMOWyTRTdpHKy6nnnN+IYWaXF+lHivhBH/ufDKlR4IWCAN3oPnHuw==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/event-target-shim": {
|
"node_modules/form-data": {
|
||||||
"version": "5.0.1",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||||
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
|
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||||
|
"dependencies": {
|
||||||
|
"asynckit": "^0.4.0",
|
||||||
|
"combined-stream": "^1.0.8",
|
||||||
|
"mime-types": "^2.1.12"
|
||||||
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6"
|
"node": ">= 6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mime-db": {
|
"node_modules/mime-db": {
|
||||||
"version": "1.44.0",
|
"version": "1.51.0",
|
||||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
|
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz",
|
||||||
"integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==",
|
"integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mime-types": {
|
"node_modules/mime-types": {
|
||||||
"version": "2.1.27",
|
"version": "2.1.34",
|
||||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz",
|
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz",
|
||||||
"integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
|
"integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"mime-db": "1.44.0"
|
"mime-db": "1.51.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/node-fetch": {
|
"node_modules/node-fetch": {
|
||||||
"version": "2.6.1",
|
"version": "2.6.7",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
|
||||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"whatwg-url": "^5.0.0"
|
||||||
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "4.x || >=6.0.0"
|
"node": "4.x || >=6.0.0"
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"node_modules/prism-media": {
|
|
||||||
"version": "1.2.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.2.tgz",
|
|
||||||
"integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw==",
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@discordjs/opus": "^0.1.0",
|
"encoding": "^0.1.0"
|
||||||
"ffmpeg-static": "^2.4.0 || ^3.0.0",
|
|
||||||
"node-opus": "^0.3.1",
|
|
||||||
"opusscript": "^0.0.6"
|
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"@discordjs/opus": {
|
"encoding": {
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"ffmpeg-static": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"node-opus": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"opusscript": {
|
|
||||||
"optional": true
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/setimmediate": {
|
"node_modules/tr46": {
|
||||||
"version": "1.0.5",
|
"version": "0.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||||
"integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
|
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
|
||||||
},
|
},
|
||||||
"node_modules/tweetnacl": {
|
"node_modules/ts-mixer": {
|
||||||
"version": "1.0.3",
|
"version": "6.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.0.tgz",
|
||||||
"integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
|
"integrity": "sha512-nXIb1fvdY5CBSrDIblLn73NW0qRDk5yJ0Sk1qPBF560OdJfQp9jhl+0tzcY09OZ9U+6GpeoI9RjwoIKFIoB9MQ=="
|
||||||
|
},
|
||||||
|
"node_modules/tslib": {
|
||||||
|
"version": "2.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||||
|
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||||
|
},
|
||||||
|
"node_modules/webidl-conversions": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||||
|
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
|
||||||
|
},
|
||||||
|
"node_modules/whatwg-url": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||||
|
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
|
||||||
|
"dependencies": {
|
||||||
|
"tr46": "~0.0.3",
|
||||||
|
"webidl-conversions": "^3.0.0"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ws": {
|
"node_modules/ws": {
|
||||||
"version": "7.5.6",
|
"version": "8.4.2",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.6.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-8.4.2.tgz",
|
||||||
"integrity": "sha512-6GLgCqo2cy2A2rjCNFlxQS6ZljG/coZfZXclldI8FB/1G3CCI36Zd8xy2HrFVACi8tfk5XrgLQEk+P0Tnz9UcA==",
|
"integrity": "sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.3.0"
|
"node": ">=10.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"bufferutil": "^4.0.1",
|
"bufferutil": "^4.0.1",
|
||||||
|
@ -173,6 +284,14 @@
|
||||||
"optional": true
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/zod": {
|
||||||
|
"version": "3.11.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/zod/-/zod-3.11.6.tgz",
|
||||||
|
"integrity": "sha512-daZ80A81I3/9lIydI44motWe6n59kRBfNzTuS2bfzVh1nAXi667TOTWWtatxyG+fwgNUiagSj/CWZwRRbevJIg==",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/colinhacks"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
126
node_modules/@discordjs/builders/CHANGELOG.md
generated
vendored
Normal file
126
node_modules/@discordjs/builders/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
# [0.12.0](https://github.com/discordjs/discord.js/compare/@discordjs/builders@0.11.0...@discordjs/builders@0.12.0) (2021-12-08)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
- **builders:** Dont export `Button` component stuff twice (#7289) ([86d9d06](https://github.com/discordjs/discord.js/commit/86d9d0674347c08d056cd054cb4ce4253195bf94))
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
- **SlashCommandSubcommands:** Updating old links from Discord developer portal (#7224) ([bd7a6f2](https://github.com/discordjs/discord.js/commit/bd7a6f265212624199fb0b2ddc8ece39759c63de))
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Add components to /builders (#7195) ([2bb40fd](https://github.com/discordjs/discord.js/commit/2bb40fd767cf5918e3ba422ff73082734bfa05b0))
|
||||||
|
|
||||||
|
## Typings
|
||||||
|
|
||||||
|
- Make `required` a boolean (#7307) ([c10afea](https://github.com/discordjs/discord.js/commit/c10afeadc702ab98bec5e077b3b92494a9596f9c))
|
||||||
|
|
||||||
|
# [0.11.0](https://github.com/discordjs/builders/compare/v0.10.0...v0.11.0) (2021-12-29)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
- **ApplicationCommandOptions:** clean up code for builder options ([#68](https://github.com/discordjs/builders/issues/68)) ([b5d0b15](https://github.com/discordjs/builders/commit/b5d0b157b1262bd01fa011f8e0cf33adb82776e7))
|
||||||
|
|
||||||
|
# [0.10.0](https://github.com/discordjs/builders/compare/v0.9.0...v0.10.0) (2021-12-24)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
- use zod instead of ow for max/min option validation ([#66](https://github.com/discordjs/builders/issues/66)) ([beb35fb](https://github.com/discordjs/builders/commit/beb35fb1f65bd6be2321e17cc792f67e8615fd48))
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- add max/min option for int and number builder options ([#47](https://github.com/discordjs/builders/issues/47)) ([2e1e860](https://github.com/discordjs/builders/commit/2e1e860b46e3453398b20df63dabb6d4325e32d1))
|
||||||
|
|
||||||
|
# [0.9.0](https://github.com/discordjs/builders/compare/v0.8.2...v0.9.0) (2021-12-02)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
- replace ow with zod ([#58](https://github.com/discordjs/builders/issues/58)) ([0b6fb81](https://github.com/discordjs/builders/commit/0b6fb8161b858e42781855fb73aaa873fec58160))
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **SlashCommandBuilder:** add autocomplete ([#53](https://github.com/discordjs/builders/issues/53)) ([05b07a7](https://github.com/discordjs/builders/commit/05b07a7e88848188c27d7380d9f948cba25ef778))
|
||||||
|
|
||||||
|
## [0.8.2](https://github.com/discordjs/builders/compare/v0.8.1...v0.8.2) (2021-10-30)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
- downgrade ow because of esm issues ([#55](https://github.com/discordjs/builders/issues/55)) ([3722d2c](https://github.com/discordjs/builders/commit/3722d2c1109a7a5c0abad63c1a7eb944df6e46c8))
|
||||||
|
|
||||||
|
## [0.8.1](https://github.com/discordjs/builders/compare/v0.8.0...v0.8.1) (2021-10-29)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
- documentation ([e33ec8d](https://github.com/discordjs/builders/commit/e33ec8dfd5785312f82e0afb017a3dac614fd71d))
|
||||||
|
|
||||||
|
# [0.7.0](https://github.com/discordjs/builders/compare/v0.6.0...v0.7.0) (2021-10-18)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
- properly type `toJSON` methods ([#34](https://github.com/discordjs/builders/issues/34)) ([7723ad0](https://github.com/discordjs/builders/commit/7723ad0da169386e638188de220451a97513bc25))
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **ContextMenus:** add context menu command builder ([#29](https://github.com/discordjs/builders/issues/29)) ([f0641e5](https://github.com/discordjs/builders/commit/f0641e55733de8992600f3082bcf054e6f815cf7))
|
||||||
|
- add support for channel types on channel options ([#41](https://github.com/discordjs/builders/issues/41)) ([f6c187e](https://github.com/discordjs/builders/commit/f6c187e0ad6ebe03e65186ece3e95cb1db5aeb50))
|
||||||
|
|
||||||
|
# [0.6.0](https://github.com/discordjs/builders/compare/v0.5.0...v0.6.0) (2021-08-24)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
- **SlashCommandBuilder:** allow subcommands and groups to coexist at the root level ([#26](https://github.com/discordjs/builders/issues/26)) ([0be4daf](https://github.com/discordjs/builders/commit/0be4dafdfc0b5747c880be0078c00ada913eb4fb))
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- create `Embed` builder ([#11](https://github.com/discordjs/builders/issues/11)) ([eb942a4](https://github.com/discordjs/builders/commit/eb942a4d1f3bcec9a4e370b6af602a713ad8f9b7))
|
||||||
|
- **SlashCommandBuilder:** create setDefaultPermission function ([#19](https://github.com/discordjs/builders/issues/19)) ([5d53759](https://github.com/discordjs/builders/commit/5d537593937a8da330153ce4711b7d093a80330e))
|
||||||
|
- **SlashCommands:** add number option type ([#23](https://github.com/discordjs/builders/issues/23)) ([1563991](https://github.com/discordjs/builders/commit/1563991d421bb07bf7a412c87e7613692d770f04))
|
||||||
|
|
||||||
|
# [0.5.0](https://github.com/discordjs/builders/compare/v0.3.0...v0.5.0) (2021-08-10)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Formatters:** add `formatEmoji` ([#20](https://github.com/discordjs/builders/issues/20)) ([c3d8bb5](https://github.com/discordjs/builders/commit/c3d8bb5363a1d46b45c0def4277da6921e2ba209))
|
||||||
|
|
||||||
|
# [0.4.0](https://github.com/discordjs/builders/compare/v0.3.0...v0.4.0) (2021-08-05)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- `sub command` => `subcommand` ([#18](https://github.com/discordjs/builders/pull/18)) ([95599c5](https://github.com/discordjs/builders/commit/95599c5b5366ebd054c4c277c52f1a44cda1209d))
|
||||||
|
|
||||||
|
# [0.3.0](https://github.com/discordjs/builders/compare/v0.2.0...v0.3.0) (2021-08-01)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
- **Shrug:** Update comment ([#14](https://github.com/discordjs/builders/issues/14)) ([6fa6c40](https://github.com/discordjs/builders/commit/6fa6c405f2ea733811677d3d1bfb1e2806d504d5))
|
||||||
|
- shrug face rendering ([#13](https://github.com/discordjs/builders/issues/13)) ([6ad24ec](https://github.com/discordjs/builders/commit/6ad24ecd96c82b0f576e78e9e53fc7bf9c36ef5d))
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **formatters:** mentions ([#9](https://github.com/discordjs/builders/issues/9)) ([f83fe99](https://github.com/discordjs/builders/commit/f83fe99b83188ed999845751ffb005c687dbd60a))
|
||||||
|
- **Formatters:** Add a spoiler function ([#16](https://github.com/discordjs/builders/issues/16)) ([c213a6a](https://github.com/discordjs/builders/commit/c213a6abb114f65653017a4edec4bdba2162d771))
|
||||||
|
- **SlashCommands:** add slash command builders ([#3](https://github.com/discordjs/builders/issues/3)) ([6aa3af0](https://github.com/discordjs/builders/commit/6aa3af07b0ee342fff91f080914bb12b3ab773f8))
|
||||||
|
- shrug, tableflip and unflip strings ([#5](https://github.com/discordjs/builders/issues/5)) ([de5fa82](https://github.com/discordjs/builders/commit/de5fa823cd6f1feba5b2d0a63b2cb1761dfd1814))
|
||||||
|
|
||||||
|
# [0.2.0](https://github.com/discordjs/builders/compare/v0.1.1...v0.2.0) (2021-07-03)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Formatters:** added `hyperlink` and `hideLinkEmbed` ([#4](https://github.com/discordjs/builders/issues/4)) ([c532daf](https://github.com/discordjs/builders/commit/c532daf2ba2feae75bf9668f63462e96a5314cff))
|
||||||
|
|
||||||
|
# [0.1.1](https://github.com/discordjs/builders/compare/v0.1.0...v0.1.1) (2021-06-30)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
- **Deps:** added `tslib` as dependency ([#2](https://github.com/discordjs/builders/issues/2)) ([5576ff3](https://github.com/discordjs/builders/commit/5576ff3b67136b957bed0ab8a4c655d5de322813))
|
||||||
|
|
||||||
|
# 0.1.0 (2021-06-30)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- added message formatters ([#1](https://github.com/discordjs/builders/issues/1)) ([765e46d](https://github.com/discordjs/builders/commit/765e46dac96c4e49d350243e5fad34c2bc738a7c))
|
3
node_modules/prism-media/LICENSE → node_modules/@discordjs/builders/LICENSE
generated
vendored
3
node_modules/prism-media/LICENSE → node_modules/@discordjs/builders/LICENSE
generated
vendored
|
@ -175,7 +175,8 @@
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
Copyright 2019 - 2020 Amish Shah
|
Copyright 2021 Noel Buechler
|
||||||
|
Copyright 2021 Vlad Frangu
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
53
node_modules/@discordjs/builders/README.md
generated
vendored
Normal file
53
node_modules/@discordjs/builders/README.md
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<div align="center">
|
||||||
|
<br />
|
||||||
|
<p>
|
||||||
|
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
||||||
|
</p>
|
||||||
|
<br />
|
||||||
|
<p>
|
||||||
|
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
||||||
|
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/v/@discordjs/builders.svg?maxAge=3600" alt="npm version" /></a>
|
||||||
|
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/dt/@discordjs/builders.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||||
|
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
||||||
|
<a href="https://codecov.io/gh/discordjs/builders"><img src="https://codecov.io/gh/discordjs/builders/branch/main/graph/badge.svg" alt="Code coverage" /></a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
**Node.js 16.9.0 or newer is required.**
|
||||||
|
|
||||||
|
```sh-session
|
||||||
|
npm install @discordjs/builders
|
||||||
|
yarn add @discordjs/builders
|
||||||
|
pnpm add @discordjs/builders
|
||||||
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
Here are some examples for the builders and utilities you can find in this package:
|
||||||
|
|
||||||
|
- [Slash Command Builders](./docs/examples/Slash%20Command%20Builders.md)
|
||||||
|
|
||||||
|
## Links
|
||||||
|
|
||||||
|
- [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website))
|
||||||
|
- [Documentation](https://discord.js.org/#/docs/builders)
|
||||||
|
- [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide))
|
||||||
|
See also the [Update Guide](https://discordjs.guide/additional-info/changes-in-v13.html), including updated and removed items in the library.
|
||||||
|
- [discord.js Discord server](https://discord.gg/djs)
|
||||||
|
- [Discord API Discord server](https://discord.gg/discord-api)
|
||||||
|
- [GitHub](https://github.com/discordjs/discord.js/tree/main/packages/builders)
|
||||||
|
- [npm](https://www.npmjs.com/package/@discordjs/builders)
|
||||||
|
- [Related libraries](https://discord.com/developers/docs/topics/community-resources#libraries)
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
||||||
|
[documentation](https://discord.js.org/#/docs/builders).
|
||||||
|
See [the contribution guide](https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md) if you'd like to submit a PR.
|
||||||
|
|
||||||
|
## Help
|
||||||
|
|
||||||
|
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle
|
||||||
|
nudge in the right direction, please don't hesitate to join our official [discord.js Server](https://discord.gg/djs).
|
1084
node_modules/@discordjs/builders/dist/index.d.ts
generated
vendored
Normal file
1084
node_modules/@discordjs/builders/dist/index.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
4
node_modules/@discordjs/builders/dist/index.js
generated
vendored
Normal file
4
node_modules/@discordjs/builders/dist/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@discordjs/builders/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/builders/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
node_modules/@discordjs/builders/dist/index.mjs
generated
vendored
Normal file
4
node_modules/@discordjs/builders/dist/index.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@discordjs/builders/dist/index.mjs.map
generated
vendored
Normal file
1
node_modules/@discordjs/builders/dist/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@discordjs/builders/docs/README.md
generated
vendored
Normal file
1
node_modules/@discordjs/builders/docs/README.md
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
## [View the documentation here.](https://discord.js.org/#/docs/builders)
|
5
node_modules/@discordjs/builders/docs/index.yml
generated
vendored
Normal file
5
node_modules/@discordjs/builders/docs/index.yml
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
- name: General
|
||||||
|
files:
|
||||||
|
- name: Welcome
|
||||||
|
id: welcome
|
||||||
|
path: ../../README.md
|
88
node_modules/@discordjs/builders/package.json
generated
vendored
Normal file
88
node_modules/@discordjs/builders/package.json
generated
vendored
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
{
|
||||||
|
"name": "@discordjs/builders",
|
||||||
|
"version": "0.12.0",
|
||||||
|
"description": "A set of builders that you can use when creating your bot",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsup",
|
||||||
|
"test": "jest --pass-with-no-tests",
|
||||||
|
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
||||||
|
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
|
||||||
|
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs",
|
||||||
|
"prepublishOnly": "yarn build && yarn lint && yarn test",
|
||||||
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/builders/*'"
|
||||||
|
},
|
||||||
|
"main": "./dist/index.js",
|
||||||
|
"module": "./dist/index.mjs",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"exports": {
|
||||||
|
"import": "./dist/index.mjs",
|
||||||
|
"require": "./dist/index.js"
|
||||||
|
},
|
||||||
|
"directories": {
|
||||||
|
"lib": "src",
|
||||||
|
"test": "__tests__"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"contributors": [
|
||||||
|
"Vlad Frangu <kingdgrizzle@gmail.com>",
|
||||||
|
"Crawl <icrawltogo@gmail.com>",
|
||||||
|
"Amish Shah <amishshah.2k@gmail.com>",
|
||||||
|
"SpaceEEC <spaceeec@yahoo.com>",
|
||||||
|
"Antonio Roman <kyradiscord@gmail.com>"
|
||||||
|
],
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"keywords": [
|
||||||
|
"discord",
|
||||||
|
"api",
|
||||||
|
"bot",
|
||||||
|
"client",
|
||||||
|
"node",
|
||||||
|
"discordapp",
|
||||||
|
"discordjs"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/discordjs/discord.js.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/discordjs/discord.js/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://discord.js.org",
|
||||||
|
"dependencies": {
|
||||||
|
"@sindresorhus/is": "^4.3.0",
|
||||||
|
"discord-api-types": "^0.26.1",
|
||||||
|
"ts-mixer": "^6.0.0",
|
||||||
|
"tslib": "^2.3.1",
|
||||||
|
"zod": "^3.11.6"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.16.12",
|
||||||
|
"@babel/plugin-proposal-decorators": "^7.16.5",
|
||||||
|
"@babel/preset-env": "^7.16.11",
|
||||||
|
"@babel/preset-typescript": "^7.16.5",
|
||||||
|
"@discordjs/ts-docgen": "^0.3.4",
|
||||||
|
"@types/jest": "^27.0.3",
|
||||||
|
"@types/node": "^16.11.6",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
||||||
|
"@typescript-eslint/parser": "^5.10.0",
|
||||||
|
"babel-plugin-transform-typescript-metadata": "^0.3.2",
|
||||||
|
"eslint": "^8.7.0",
|
||||||
|
"eslint-config-marine": "^9.3.2",
|
||||||
|
"eslint-config-prettier": "^8.3.0",
|
||||||
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"jest": "^27.4.7",
|
||||||
|
"prettier": "^2.5.1",
|
||||||
|
"standard-version": "^9.3.2",
|
||||||
|
"tsup": "^5.11.11",
|
||||||
|
"typedoc": "^0.22.11",
|
||||||
|
"typescript": "^4.5.5"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.9.0"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
}
|
||||||
|
}
|
3
node_modules/@discordjs/collection/LICENSE
generated
vendored
3
node_modules/@discordjs/collection/LICENSE
generated
vendored
|
@ -175,7 +175,8 @@
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
Copyright 2015 - 2020 Amish Shah
|
Copyright 2015 - 2021 Noel Buechler
|
||||||
|
Copyright 2015 - 2021 Amish Shah
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|
47
node_modules/@discordjs/collection/README.md
generated
vendored
47
node_modules/@discordjs/collection/README.md
generated
vendored
|
@ -1,3 +1,46 @@
|
||||||
# Collection
|
<div align="center">
|
||||||
|
<br />
|
||||||
|
<p>
|
||||||
|
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
||||||
|
</p>
|
||||||
|
<br />
|
||||||
|
<p>
|
||||||
|
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
||||||
|
<a href="https://www.npmjs.com/package/@discordjs/collection"><img src="https://img.shields.io/npm/v/@discordjs/collection.svg?maxAge=3600" alt="npm version" /></a>
|
||||||
|
<a href="https://www.npmjs.com/package/@discordjs/collection"><img src="https://img.shields.io/npm/dt/@discordjs/collection.svg?maxAge=3600" alt="npm downloads" /></a>
|
||||||
|
<a href="https://github.com/discordjs/collection/actions"><img src="https://github.com/discordjs/collection/workflows/Tests/badge.svg" alt="Build status" /></a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
Utility data structure used in Discord.js.
|
## About
|
||||||
|
|
||||||
|
`@discordjs/collection` is a powerful utility data structure used in discord.js.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
**Node.js 16.0.0 or newer is required.**
|
||||||
|
|
||||||
|
```sh-session
|
||||||
|
npm install @discordjs/collection
|
||||||
|
yarn add @discordjs/collection
|
||||||
|
pnpm add @discordjs/collection
|
||||||
|
```
|
||||||
|
|
||||||
|
## Links
|
||||||
|
|
||||||
|
- [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website))
|
||||||
|
- [Documentation](https://discord.js.org/#/docs/collection)
|
||||||
|
- [discord.js Discord server](https://discord.gg/djs)
|
||||||
|
- [GitHub](https://github.com/discordjs/collection)
|
||||||
|
- [npm](https://www.npmjs.com/package/@discordjs/collection)
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
||||||
|
[documentation](https://discord.js.org/#/docs/collection).
|
||||||
|
See [the contribution guide](https://github.com/discordjs/collection/blob/main/.github/CONTRIBUTING.md) if you'd like to submit a PR.
|
||||||
|
|
||||||
|
## Help
|
||||||
|
|
||||||
|
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle
|
||||||
|
nudge in the right direction, please don't hesitate to join our official [discord.js Server](https://discord.gg/djs).
|
||||||
|
|
374
node_modules/@discordjs/collection/dist/index.d.ts
generated
vendored
374
node_modules/@discordjs/collection/dist/index.d.ts
generated
vendored
|
@ -1,152 +1,170 @@
|
||||||
export interface CollectionConstructor {
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
interface CollectionConstructor {
|
||||||
new (): Collection<unknown, unknown>;
|
new (): Collection<unknown, unknown>;
|
||||||
new <K, V>(entries?: ReadonlyArray<readonly [K, V]> | null): Collection<K, V>;
|
new <K, V>(entries?: ReadonlyArray<readonly [K, V]> | null): Collection<K, V>;
|
||||||
new <K, V>(iterable: Iterable<readonly [K, V]>): Collection<K, V>;
|
new <K, V>(iterable: Iterable<readonly [K, V]>): Collection<K, V>;
|
||||||
readonly prototype: Collection<unknown, unknown>;
|
readonly prototype: Collection<unknown, unknown>;
|
||||||
readonly [Symbol.species]: CollectionConstructor;
|
readonly [Symbol.species]: CollectionConstructor;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
interface Collection<K, V> extends Map<K, V> {
|
||||||
|
constructor: CollectionConstructor;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has
|
* A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has
|
||||||
* an ID, for significantly improved performance and ease-of-use.
|
* an ID, for significantly improved performance and ease-of-use.
|
||||||
* @extends {Map}
|
|
||||||
* @property {number} size - The amount of elements in this collection.
|
|
||||||
*/
|
*/
|
||||||
declare class Collection<K, V> extends Map<K, V> {
|
declare class Collection<K, V> extends Map<K, V> {
|
||||||
private _array;
|
|
||||||
private _keyArray;
|
|
||||||
static readonly default: typeof Collection;
|
static readonly default: typeof Collection;
|
||||||
['constructor']: typeof Collection;
|
|
||||||
constructor(entries?: ReadonlyArray<readonly [K, V]> | null);
|
|
||||||
/**
|
/**
|
||||||
* Identical to [Map.get()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get).
|
* Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
|
||||||
* Gets an element with the specified key, and returns its value, or `undefined` if the element does not exist.
|
*
|
||||||
* @param {*} key - The key to get from this collection
|
* @param key The key to get if it exists, or set otherwise
|
||||||
* @returns {* | undefined}
|
* @param defaultValueGenerator A function that generates the default value
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* collection.ensure(guildId, () => defaultGuildConfig);
|
||||||
*/
|
*/
|
||||||
get(key: K): V | undefined;
|
ensure(key: K, defaultValueGenerator: (key: K, collection: this) => V): V;
|
||||||
/**
|
/**
|
||||||
* Identical to [Map.set()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set).
|
* Checks if all of the elements exist in the collection.
|
||||||
* Sets a new element in the collection with the specified key and value.
|
*
|
||||||
* @param {*} key - The key of the element to add
|
* @param keys - The keys of the elements to check for
|
||||||
* @param {*} value - The value of the element to add
|
*
|
||||||
* @returns {Collection}
|
* @returns `true` if all of the elements exist, `false` if at least one does not exist.
|
||||||
*/
|
*/
|
||||||
set(key: K, value: V): this;
|
hasAll(...keys: K[]): boolean;
|
||||||
/**
|
/**
|
||||||
* Identical to [Map.has()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has).
|
* Checks if any of the elements exist in the collection.
|
||||||
* Checks if an element exists in the collection.
|
*
|
||||||
* @param {*} key - The key of the element to check for
|
* @param keys - The keys of the elements to check for
|
||||||
* @returns {boolean} `true` if the element exists, `false` if it does not exist.
|
*
|
||||||
|
* @returns `true` if any of the elements exist, `false` if none exist.
|
||||||
*/
|
*/
|
||||||
has(key: K): boolean;
|
hasAny(...keys: K[]): boolean;
|
||||||
/**
|
|
||||||
* Identical to [Map.delete()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete).
|
|
||||||
* Deletes an element from the collection.
|
|
||||||
* @param {*} key - The key to delete from the collection
|
|
||||||
* @returns {boolean} `true` if the element was removed, `false` if the element does not exist.
|
|
||||||
*/
|
|
||||||
delete(key: K): boolean;
|
|
||||||
/**
|
|
||||||
* Identical to [Map.clear()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear).
|
|
||||||
* Removes all elements from the collection.
|
|
||||||
* @returns {undefined}
|
|
||||||
*/
|
|
||||||
clear(): void;
|
|
||||||
/**
|
|
||||||
* Creates an ordered array of the values of this collection, and caches it internally. The array will only be
|
|
||||||
* reconstructed if an item is added to or removed from the collection, or if you change the length of the array
|
|
||||||
* itself. If you don't want this caching behavior, use `[...collection.values()]` or
|
|
||||||
* `Array.from(collection.values())` instead.
|
|
||||||
* @returns {Array}
|
|
||||||
*/
|
|
||||||
array(): V[];
|
|
||||||
/**
|
|
||||||
* Creates an ordered array of the keys of this collection, and caches it internally. The array will only be
|
|
||||||
* reconstructed if an item is added to or removed from the collection, or if you change the length of the array
|
|
||||||
* itself. If you don't want this caching behavior, use `[...collection.keys()]` or
|
|
||||||
* `Array.from(collection.keys())` instead.
|
|
||||||
* @returns {Array}
|
|
||||||
*/
|
|
||||||
keyArray(): K[];
|
|
||||||
/**
|
/**
|
||||||
* Obtains the first value(s) in this collection.
|
* Obtains the first value(s) in this collection.
|
||||||
* @param {number} [amount] Amount of values to obtain from the beginning
|
*
|
||||||
* @returns {*|Array<*>} A single value if no amount is provided or an array of values, starting from the end if
|
* @param amount Amount of values to obtain from the beginning
|
||||||
* amount is negative
|
*
|
||||||
|
* @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative
|
||||||
*/
|
*/
|
||||||
first(): V | undefined;
|
first(): V | undefined;
|
||||||
first(amount: number): V[];
|
first(amount: number): V[];
|
||||||
/**
|
/**
|
||||||
* Obtains the first key(s) in this collection.
|
* Obtains the first key(s) in this collection.
|
||||||
* @param {number} [amount] Amount of keys to obtain from the beginning
|
*
|
||||||
* @returns {*|Array<*>} A single key if no amount is provided or an array of keys, starting from the end if
|
* @param amount Amount of keys to obtain from the beginning
|
||||||
|
*
|
||||||
|
* @returns A single key if no amount is provided or an array of keys, starting from the end if
|
||||||
* amount is negative
|
* amount is negative
|
||||||
*/
|
*/
|
||||||
firstKey(): K | undefined;
|
firstKey(): K | undefined;
|
||||||
firstKey(amount: number): K[];
|
firstKey(amount: number): K[];
|
||||||
/**
|
/**
|
||||||
* Obtains the last value(s) in this collection. This relies on {@link Collection#array}, and thus the caching
|
* Obtains the last value(s) in this collection.
|
||||||
* mechanism applies here as well.
|
*
|
||||||
* @param {number} [amount] Amount of values to obtain from the end
|
* @param amount Amount of values to obtain from the end
|
||||||
* @returns {*|Array<*>} A single value if no amount is provided or an array of values, starting from the start if
|
*
|
||||||
|
* @returns A single value if no amount is provided or an array of values, starting from the start if
|
||||||
* amount is negative
|
* amount is negative
|
||||||
*/
|
*/
|
||||||
last(): V | undefined;
|
last(): V | undefined;
|
||||||
last(amount: number): V[];
|
last(amount: number): V[];
|
||||||
/**
|
/**
|
||||||
* Obtains the last key(s) in this collection. This relies on {@link Collection#keyArray}, and thus the caching
|
* Obtains the last key(s) in this collection.
|
||||||
* mechanism applies here as well.
|
*
|
||||||
* @param {number} [amount] Amount of keys to obtain from the end
|
* @param amount Amount of keys to obtain from the end
|
||||||
* @returns {*|Array<*>} A single key if no amount is provided or an array of keys, starting from the start if
|
*
|
||||||
|
* @returns A single key if no amount is provided or an array of keys, starting from the start if
|
||||||
* amount is negative
|
* amount is negative
|
||||||
*/
|
*/
|
||||||
lastKey(): K | undefined;
|
lastKey(): K | undefined;
|
||||||
lastKey(amount: number): K[];
|
lastKey(amount: number): K[];
|
||||||
/**
|
/**
|
||||||
* Obtains unique random value(s) from this collection. This relies on {@link Collection#array}, and thus the caching
|
* Identical to [Array.at()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at).
|
||||||
* mechanism applies here as well.
|
* Returns the item at a given index, allowing for positive and negative integers.
|
||||||
* @param {number} [amount] Amount of values to obtain randomly
|
* Negative integers count back from the last item in the collection.
|
||||||
* @returns {*|Array<*>} A single value if no amount is provided or an array of values
|
*
|
||||||
|
* @param index The index of the element to obtain
|
||||||
*/
|
*/
|
||||||
random(): V;
|
at(index: number): V | undefined;
|
||||||
|
/**
|
||||||
|
* Identical to [Array.at()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at).
|
||||||
|
* Returns the key at a given index, allowing for positive and negative integers.
|
||||||
|
* Negative integers count back from the last item in the collection.
|
||||||
|
*
|
||||||
|
* @param index The index of the key to obtain
|
||||||
|
*/
|
||||||
|
keyAt(index: number): K | undefined;
|
||||||
|
/**
|
||||||
|
* Obtains unique random value(s) from this collection.
|
||||||
|
*
|
||||||
|
* @param amount Amount of values to obtain randomly
|
||||||
|
*
|
||||||
|
* @returns A single value if no amount is provided or an array of values
|
||||||
|
*/
|
||||||
|
random(): V | undefined;
|
||||||
random(amount: number): V[];
|
random(amount: number): V[];
|
||||||
/**
|
/**
|
||||||
* Obtains unique random key(s) from this collection. This relies on {@link Collection#keyArray}, and thus the caching
|
* Obtains unique random key(s) from this collection.
|
||||||
* mechanism applies here as well.
|
*
|
||||||
* @param {number} [amount] Amount of keys to obtain randomly
|
* @param amount Amount of keys to obtain randomly
|
||||||
* @returns {*|Array<*>} A single key if no amount is provided or an array
|
*
|
||||||
|
* @returns A single key if no amount is provided or an array
|
||||||
*/
|
*/
|
||||||
randomKey(): K;
|
randomKey(): K | undefined;
|
||||||
randomKey(amount: number): K[];
|
randomKey(amount: number): K[];
|
||||||
|
/**
|
||||||
|
* Identical to [Array.reverse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)
|
||||||
|
* but returns a Collection instead of an Array.
|
||||||
|
*/
|
||||||
|
reverse(): this;
|
||||||
/**
|
/**
|
||||||
* Searches for a single item where the given function returns a truthy value. This behaves like
|
* Searches for a single item where the given function returns a truthy value. This behaves like
|
||||||
* [Array.find()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
|
* [Array.find()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
|
||||||
* <warn>All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you
|
* <warn>All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you
|
||||||
* should use the `get` method. See
|
* should use the `get` method. See
|
||||||
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) for details.</warn>
|
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) for details.</warn>
|
||||||
* @param {Function} fn The function to test with (should return boolean)
|
*
|
||||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
* @param fn The function to test with (should return boolean)
|
||||||
* @returns {*}
|
* @param thisArg Value to use as `this` when executing function
|
||||||
* @example collection.find(user => user.username === 'Bob');
|
*
|
||||||
|
* @example
|
||||||
|
* collection.find(user => user.username === 'Bob');
|
||||||
*/
|
*/
|
||||||
|
find<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): V2 | undefined;
|
||||||
find(fn: (value: V, key: K, collection: this) => boolean): V | undefined;
|
find(fn: (value: V, key: K, collection: this) => boolean): V | undefined;
|
||||||
find<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): V | undefined;
|
find<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): V2 | undefined;
|
||||||
|
find<This>(fn: (this: This, value: V, key: K, collection: this) => boolean, thisArg: This): V | undefined;
|
||||||
/**
|
/**
|
||||||
* Searches for the key of a single item where the given function returns a truthy value. This behaves like
|
* Searches for the key of a single item where the given function returns a truthy value. This behaves like
|
||||||
* [Array.findIndex()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex),
|
* [Array.findIndex()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex),
|
||||||
* but returns the key rather than the positional index.
|
* but returns the key rather than the positional index.
|
||||||
* @param {Function} fn The function to test with (should return boolean)
|
*
|
||||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
* @param fn The function to test with (should return boolean)
|
||||||
* @returns {*}
|
* @param thisArg Value to use as `this` when executing function
|
||||||
* @example collection.findKey(user => user.username === 'Bob');
|
*
|
||||||
|
* @example
|
||||||
|
* collection.findKey(user => user.username === 'Bob');
|
||||||
*/
|
*/
|
||||||
|
findKey<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): K2 | undefined;
|
||||||
findKey(fn: (value: V, key: K, collection: this) => boolean): K | undefined;
|
findKey(fn: (value: V, key: K, collection: this) => boolean): K | undefined;
|
||||||
findKey<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): K | undefined;
|
findKey<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): K2 | undefined;
|
||||||
|
findKey<This>(fn: (this: This, value: V, key: K, collection: this) => boolean, thisArg: This): K | undefined;
|
||||||
/**
|
/**
|
||||||
* Removes items that satisfy the provided filter function.
|
* Removes items that satisfy the provided filter function.
|
||||||
* @param {Function} fn Function used to test (should return a boolean)
|
*
|
||||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
* @param fn Function used to test (should return a boolean)
|
||||||
* @returns {number} The number of removed entries
|
* @param thisArg Value to use as `this` when executing function
|
||||||
|
*
|
||||||
|
* @returns The number of removed entries
|
||||||
*/
|
*/
|
||||||
sweep(fn: (value: V, key: K, collection: this) => boolean): number;
|
sweep(fn: (value: V, key: K, collection: this) => boolean): number;
|
||||||
sweep<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): number;
|
sweep<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): number;
|
||||||
|
@ -154,90 +172,119 @@ declare class Collection<K, V> extends Map<K, V> {
|
||||||
* Identical to
|
* Identical to
|
||||||
* [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
|
* [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
|
||||||
* but returns a Collection instead of an Array.
|
* but returns a Collection instead of an Array.
|
||||||
* @param {Function} fn The function to test with (should return boolean)
|
*
|
||||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
* @param fn The function to test with (should return boolean)
|
||||||
* @returns {Collection}
|
* @param thisArg Value to use as `this` when executing function
|
||||||
* @example collection.filter(user => user.username === 'Bob');
|
*
|
||||||
|
* @example
|
||||||
|
* collection.filter(user => user.username === 'Bob');
|
||||||
*/
|
*/
|
||||||
filter(fn: (value: V, key: K, collection: this) => boolean): this;
|
filter<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): Collection<K2, V>;
|
||||||
filter<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): this;
|
filter<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): Collection<K, V2>;
|
||||||
|
filter(fn: (value: V, key: K, collection: this) => boolean): Collection<K, V>;
|
||||||
|
filter<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): Collection<K2, V>;
|
||||||
|
filter<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): Collection<K, V2>;
|
||||||
|
filter<This>(fn: (this: This, value: V, key: K, collection: this) => boolean, thisArg: This): Collection<K, V>;
|
||||||
/**
|
/**
|
||||||
* Partitions the collection into two collections where the first collection
|
* Partitions the collection into two collections where the first collection
|
||||||
* contains the items that passed and the second contains the items that failed.
|
* contains the items that passed and the second contains the items that failed.
|
||||||
* @param {Function} fn Function used to test (should return a boolean)
|
*
|
||||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
* @param fn Function used to test (should return a boolean)
|
||||||
* @returns {Collection[]}
|
* @param thisArg Value to use as `this` when executing function
|
||||||
* @example const [big, small] = collection.partition(guild => guild.memberCount > 250);
|
*
|
||||||
|
* @example
|
||||||
|
* const [big, small] = collection.partition(guild => guild.memberCount > 250);
|
||||||
*/
|
*/
|
||||||
partition(fn: (value: V, key: K, collection: this) => boolean): [this, this];
|
partition<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];
|
||||||
partition<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): [this, this];
|
partition<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];
|
||||||
|
partition(fn: (value: V, key: K, collection: this) => boolean): [Collection<K, V>, Collection<K, V>];
|
||||||
|
partition<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];
|
||||||
|
partition<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];
|
||||||
|
partition<This>(fn: (this: This, value: V, key: K, collection: this) => boolean, thisArg: This): [Collection<K, V>, Collection<K, V>];
|
||||||
/**
|
/**
|
||||||
* Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to
|
* Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to
|
||||||
* [Array.flatMap()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).
|
* [Array.flatMap()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).
|
||||||
* @param {Function} fn Function that produces a new Collection
|
*
|
||||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
* @param fn Function that produces a new Collection
|
||||||
* @returns {Collection}
|
* @param thisArg Value to use as `this` when executing function
|
||||||
* @example collection.flatMap(guild => guild.members.cache);
|
*
|
||||||
|
* @example
|
||||||
|
* collection.flatMap(guild => guild.members.cache);
|
||||||
*/
|
*/
|
||||||
flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>): Collection<K, T>;
|
flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>): Collection<K, T>;
|
||||||
flatMap<T, This>(fn: (this: This, value: V, key: K, collection: this) => Collection<K, T>, thisArg: This): Collection<K, T>;
|
flatMap<T, This>(fn: (this: This, value: V, key: K, collection: this) => Collection<K, T>, thisArg: This): Collection<K, T>;
|
||||||
/**
|
/**
|
||||||
* Maps each item to another value into an array. Identical in behavior to
|
* Maps each item to another value into an array. Identical in behavior to
|
||||||
* [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
|
* [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
|
||||||
* @param {Function} fn Function that produces an element of the new array, taking three arguments
|
*
|
||||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
* @param fn Function that produces an element of the new array, taking three arguments
|
||||||
* @returns {Array}
|
* @param thisArg Value to use as `this` when executing function
|
||||||
* @example collection.map(user => user.tag);
|
*
|
||||||
|
* @example
|
||||||
|
* collection.map(user => user.tag);
|
||||||
*/
|
*/
|
||||||
map<T>(fn: (value: V, key: K, collection: this) => T): T[];
|
map<T>(fn: (value: V, key: K, collection: this) => T): T[];
|
||||||
map<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): T[];
|
map<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): T[];
|
||||||
/**
|
/**
|
||||||
* Maps each item to another value into a collection. Identical in behavior to
|
* Maps each item to another value into a collection. Identical in behavior to
|
||||||
* [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
|
* [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
|
||||||
* @param {Function} fn Function that produces an element of the new collection, taking three arguments
|
*
|
||||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
* @param fn Function that produces an element of the new collection, taking three arguments
|
||||||
* @returns {Collection}
|
* @param thisArg Value to use as `this` when executing function
|
||||||
* @example collection.mapValues(user => user.tag);
|
*
|
||||||
|
* @example
|
||||||
|
* collection.mapValues(user => user.tag);
|
||||||
*/
|
*/
|
||||||
mapValues<T>(fn: (value: V, key: K, collection: this) => T): Collection<K, T>;
|
mapValues<T>(fn: (value: V, key: K, collection: this) => T): Collection<K, T>;
|
||||||
mapValues<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): Collection<K, T>;
|
mapValues<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): Collection<K, T>;
|
||||||
/**
|
/**
|
||||||
* Checks if there exists an item that passes a test. Identical in behavior to
|
* Checks if there exists an item that passes a test. Identical in behavior to
|
||||||
* [Array.some()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some).
|
* [Array.some()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some).
|
||||||
* @param {Function} fn Function used to test (should return a boolean)
|
*
|
||||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
* @param fn Function used to test (should return a boolean)
|
||||||
* @returns {boolean}
|
* @param thisArg Value to use as `this` when executing function
|
||||||
* @example collection.some(user => user.discriminator === '0000');
|
*
|
||||||
|
* @example
|
||||||
|
* collection.some(user => user.discriminator === '0000');
|
||||||
*/
|
*/
|
||||||
some(fn: (value: V, key: K, collection: this) => boolean): boolean;
|
some(fn: (value: V, key: K, collection: this) => boolean): boolean;
|
||||||
some<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): boolean;
|
some<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): boolean;
|
||||||
/**
|
/**
|
||||||
* Checks if all items passes a test. Identical in behavior to
|
* Checks if all items passes a test. Identical in behavior to
|
||||||
* [Array.every()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every).
|
* [Array.every()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every).
|
||||||
* @param {Function} fn Function used to test (should return a boolean)
|
*
|
||||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
* @param fn Function used to test (should return a boolean)
|
||||||
* @returns {boolean}
|
* @param thisArg Value to use as `this` when executing function
|
||||||
* @example collection.every(user => !user.bot);
|
*
|
||||||
|
* @example
|
||||||
|
* collection.every(user => !user.bot);
|
||||||
*/
|
*/
|
||||||
|
every<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): this is Collection<K2, V>;
|
||||||
|
every<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): this is Collection<K, V2>;
|
||||||
every(fn: (value: V, key: K, collection: this) => boolean): boolean;
|
every(fn: (value: V, key: K, collection: this) => boolean): boolean;
|
||||||
every<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): boolean;
|
every<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): this is Collection<K2, V>;
|
||||||
|
every<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): this is Collection<K, V2>;
|
||||||
|
every<This>(fn: (this: This, value: V, key: K, collection: this) => boolean, thisArg: This): boolean;
|
||||||
/**
|
/**
|
||||||
* Applies a function to produce a single value. Identical in behavior to
|
* Applies a function to produce a single value. Identical in behavior to
|
||||||
* [Array.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
|
* [Array.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
|
||||||
* @param {Function} fn Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
*
|
||||||
|
* @param fn Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
||||||
* and `collection`
|
* and `collection`
|
||||||
* @param {*} [initialValue] Starting value for the accumulator
|
* @param initialValue Starting value for the accumulator
|
||||||
* @returns {*}
|
*
|
||||||
* @example collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
* @example
|
||||||
|
* collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
||||||
*/
|
*/
|
||||||
reduce<T>(fn: (accumulator: T, value: V, key: K, collection: this) => T, initialValue?: T): T;
|
reduce<T>(fn: (accumulator: T, value: V, key: K, collection: this) => T, initialValue?: T): T;
|
||||||
/**
|
/**
|
||||||
* Identical to
|
* Identical to
|
||||||
* [Map.forEach()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach),
|
* [Map.forEach()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach),
|
||||||
* but returns the collection instead of undefined.
|
* but returns the collection instead of undefined.
|
||||||
* @param {Function} fn Function to execute for each element
|
*
|
||||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
* @param fn Function to execute for each element
|
||||||
* @returns {Collection}
|
* @param thisArg Value to use as `this` when executing function
|
||||||
|
*
|
||||||
* @example
|
* @example
|
||||||
* collection
|
* collection
|
||||||
* .each(user => console.log(user.username))
|
* .each(user => console.log(user.username))
|
||||||
|
@ -248,9 +295,10 @@ declare class Collection<K, V> extends Map<K, V> {
|
||||||
each<T>(fn: (this: T, value: V, key: K, collection: this) => void, thisArg: T): this;
|
each<T>(fn: (this: T, value: V, key: K, collection: this) => void, thisArg: T): this;
|
||||||
/**
|
/**
|
||||||
* Runs a function on the collection and returns the collection.
|
* Runs a function on the collection and returns the collection.
|
||||||
* @param {Function} fn Function to execute
|
*
|
||||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
* @param fn Function to execute
|
||||||
* @returns {Collection}
|
* @param thisArg Value to use as `this` when executing function
|
||||||
|
*
|
||||||
* @example
|
* @example
|
||||||
* collection
|
* collection
|
||||||
* .tap(coll => console.log(coll.size))
|
* .tap(coll => console.log(coll.size))
|
||||||
|
@ -261,59 +309,73 @@ declare class Collection<K, V> extends Map<K, V> {
|
||||||
tap<T>(fn: (this: T, collection: this) => void, thisArg: T): this;
|
tap<T>(fn: (this: T, collection: this) => void, thisArg: T): this;
|
||||||
/**
|
/**
|
||||||
* Creates an identical shallow copy of this collection.
|
* Creates an identical shallow copy of this collection.
|
||||||
* @returns {Collection}
|
*
|
||||||
* @example const newColl = someColl.clone();
|
* @example
|
||||||
|
* const newColl = someColl.clone();
|
||||||
*/
|
*/
|
||||||
clone(): this;
|
clone(): Collection<K, V>;
|
||||||
/**
|
/**
|
||||||
* Combines this collection with others into a new collection. None of the source collections are modified.
|
* Combines this collection with others into a new collection. None of the source collections are modified.
|
||||||
* @param {...Collection} collections Collections to merge
|
*
|
||||||
* @returns {Collection}
|
* @param collections Collections to merge
|
||||||
* @example const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
*
|
||||||
|
* @example
|
||||||
|
* const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
||||||
*/
|
*/
|
||||||
concat(...collections: Collection<K, V>[]): this;
|
concat(...collections: Collection<K, V>[]): Collection<K, V>;
|
||||||
/**
|
/**
|
||||||
* Checks if this collection shares identical items with another.
|
* Checks if this collection shares identical items with another.
|
||||||
* This is different to checking for equality using equal-signs, because
|
* This is different to checking for equality using equal-signs, because
|
||||||
* the collections may be different objects, but contain the same data.
|
* the collections may be different objects, but contain the same data.
|
||||||
* @param {Collection} collection Collection to compare with
|
*
|
||||||
* @returns {boolean} Whether the collections have identical contents
|
* @param collection Collection to compare with
|
||||||
|
*
|
||||||
|
* @returns Whether the collections have identical contents
|
||||||
*/
|
*/
|
||||||
equals(collection: Collection<K, V>): boolean;
|
equals(collection: Collection<K, V>): boolean;
|
||||||
/**
|
/**
|
||||||
* The sort method sorts the items of a collection in place and returns it.
|
* The sort method sorts the items of a collection in place and returns it.
|
||||||
* The sort is not necessarily stable in Node 10 or older.
|
* The sort is not necessarily stable in Node 10 or older.
|
||||||
* The default sort order is according to string Unicode code points.
|
* The default sort order is according to string Unicode code points.
|
||||||
* @param {Function} [compareFunction] Specifies a function that defines the sort order.
|
*
|
||||||
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
* @param compareFunction Specifies a function that defines the sort order.
|
||||||
* according to the string conversion of each element.
|
* If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
|
||||||
* @returns {Collection}
|
*
|
||||||
* @example collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
* @example
|
||||||
|
* collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||||
*/
|
*/
|
||||||
sort(compareFunction?: (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number): this;
|
sort(compareFunction?: Comparator<K, V>): this;
|
||||||
/**
|
/**
|
||||||
* The intersect method returns a new structure containing items where the keys are present in both original structures.
|
* The intersect method returns a new structure containing items where the keys are present in both original structures.
|
||||||
* @param {Collection} other The other Collection to filter against
|
*
|
||||||
* @returns {Collection}
|
* @param other The other Collection to filter against
|
||||||
*/
|
*/
|
||||||
intersect(other: Collection<K, V>): Collection<K, V>;
|
intersect(other: Collection<K, V>): Collection<K, V>;
|
||||||
/**
|
/**
|
||||||
* The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
|
* The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
|
||||||
* @param {Collection} other The other Collection to filter against
|
*
|
||||||
* @returns {Collection}
|
* @param other The other Collection to filter against
|
||||||
*/
|
*/
|
||||||
difference(other: Collection<K, V>): Collection<K, V>;
|
difference(other: Collection<K, V>): Collection<K, V>;
|
||||||
/**
|
/**
|
||||||
* The sorted method sorts the items of a collection and returns it.
|
* The sorted method sorts the items of a collection and returns it.
|
||||||
* The sort is not necessarily stable in Node 10 or older.
|
* The sort is not necessarily stable in Node 10 or older.
|
||||||
* The default sort order is according to string Unicode code points.
|
* The default sort order is according to string Unicode code points.
|
||||||
* @param {Function} [compareFunction] Specifies a function that defines the sort order.
|
*
|
||||||
|
* @param compareFunction Specifies a function that defines the sort order.
|
||||||
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
||||||
* according to the string conversion of each element.
|
* according to the string conversion of each element.
|
||||||
* @returns {Collection}
|
*
|
||||||
* @example collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
* @example
|
||||||
|
* collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||||
*/
|
*/
|
||||||
sorted(compareFunction?: (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number): this;
|
sorted(compareFunction?: Comparator<K, V>): Collection<K, V>;
|
||||||
|
toJSON(): V[];
|
||||||
|
private static defaultSort;
|
||||||
}
|
}
|
||||||
export { Collection };
|
/**
|
||||||
export default Collection;
|
* @internal
|
||||||
|
*/
|
||||||
|
declare type Comparator<K, V> = (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number;
|
||||||
|
|
||||||
|
export { Collection, CollectionConstructor, Comparator, Collection as default };
|
||||||
|
|
394
node_modules/@discordjs/collection/dist/index.js
generated
vendored
394
node_modules/@discordjs/collection/dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
1
node_modules/@discordjs/collection/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/collection/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/@discordjs/collection/dist/index.mjs
generated
vendored
Normal file
2
node_modules/@discordjs/collection/dist/index.mjs
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
var u=Object.defineProperty;var f=(o,e,i)=>e in o?u(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i;var h=(o,e)=>u(o,"name",{value:e,configurable:!0});var a=(o,e,i)=>(f(o,typeof e!="symbol"?e+"":e,i),i);var s=class extends Map{ensure(e,i){if(this.has(e))return this.get(e);let t=i(e,this);return this.set(e,t),t}hasAll(...e){return e.every(i=>super.has(i))}hasAny(...e){return e.some(i=>super.has(i))}first(e){if(typeof e=="undefined")return this.values().next().value;if(e<0)return this.last(e*-1);e=Math.min(this.size,e);let i=this.values();return Array.from({length:e},()=>i.next().value)}firstKey(e){if(typeof e=="undefined")return this.keys().next().value;if(e<0)return this.lastKey(e*-1);e=Math.min(this.size,e);let i=this.keys();return Array.from({length:e},()=>i.next().value)}last(e){let i=[...this.values()];return typeof e=="undefined"?i[i.length-1]:e<0?this.first(e*-1):e?i.slice(-e):[]}lastKey(e){let i=[...this.keys()];return typeof e=="undefined"?i[i.length-1]:e<0?this.firstKey(e*-1):e?i.slice(-e):[]}at(e){return e=Math.floor(e),[...this.values()].at(e)}keyAt(e){return e=Math.floor(e),[...this.keys()].at(e)}random(e){let i=[...this.values()];return typeof e=="undefined"?i[Math.floor(Math.random()*i.length)]:!i.length||!e?[]:Array.from({length:Math.min(e,i.length)},()=>i.splice(Math.floor(Math.random()*i.length),1)[0])}randomKey(e){let i=[...this.keys()];return typeof e=="undefined"?i[Math.floor(Math.random()*i.length)]:!i.length||!e?[]:Array.from({length:Math.min(e,i.length)},()=>i.splice(Math.floor(Math.random()*i.length),1)[0])}reverse(){let e=[...this.entries()].reverse();this.clear();for(let[i,t]of e)this.set(i,t);return this}find(e,i){typeof i!="undefined"&&(e=e.bind(i));for(let[t,n]of this)if(e(n,t,this))return n}findKey(e,i){typeof i!="undefined"&&(e=e.bind(i));for(let[t,n]of this)if(e(n,t,this))return t}sweep(e,i){typeof i!="undefined"&&(e=e.bind(i));let t=this.size;for(let[n,l]of this)e(l,n,this)&&this.delete(n);return t-this.size}filter(e,i){typeof i!="undefined"&&(e=e.bind(i));let t=new this.constructor[Symbol.species];for(let[n,l]of this)e(l,n,this)&&t.set(n,l);return t}partition(e,i){typeof i!="undefined"&&(e=e.bind(i));let t=[new this.constructor[Symbol.species],new this.constructor[Symbol.species]];for(let[n,l]of this)e(l,n,this)?t[0].set(n,l):t[1].set(n,l);return t}flatMap(e,i){let t=this.map(e,i);return new this.constructor[Symbol.species]().concat(...t)}map(e,i){typeof i!="undefined"&&(e=e.bind(i));let t=this.entries();return Array.from({length:this.size},()=>{let[n,l]=t.next().value;return e(l,n,this)})}mapValues(e,i){typeof i!="undefined"&&(e=e.bind(i));let t=new this.constructor[Symbol.species];for(let[n,l]of this)t.set(n,e(l,n,this));return t}some(e,i){typeof i!="undefined"&&(e=e.bind(i));for(let[t,n]of this)if(e(n,t,this))return!0;return!1}every(e,i){typeof i!="undefined"&&(e=e.bind(i));for(let[t,n]of this)if(!e(n,t,this))return!1;return!0}reduce(e,i){let t;if(typeof i!="undefined"){t=i;for(let[l,c]of this)t=e(t,c,l,this);return t}let n=!0;for(let[l,c]of this){if(n){t=c,n=!1;continue}t=e(t,c,l,this)}if(n)throw new TypeError("Reduce of empty collection with no initial value");return t}each(e,i){return this.forEach(e,i),this}tap(e,i){return typeof i!="undefined"&&(e=e.bind(i)),e(this),this}clone(){return new this.constructor[Symbol.species](this)}concat(...e){let i=this.clone();for(let t of e)for(let[n,l]of t)i.set(n,l);return i}equals(e){if(!e)return!1;if(this===e)return!0;if(this.size!==e.size)return!1;for(let[i,t]of this)if(!e.has(i)||t!==e.get(i))return!1;return!0}sort(e=s.defaultSort){let i=[...this.entries()];i.sort((t,n)=>e(t[1],n[1],t[0],n[0])),super.clear();for(let[t,n]of i)super.set(t,n);return this}intersect(e){let i=new this.constructor[Symbol.species];for(let[t,n]of e)this.has(t)&&i.set(t,n);return i}difference(e){let i=new this.constructor[Symbol.species];for(let[t,n]of e)this.has(t)||i.set(t,n);for(let[t,n]of this)e.has(t)||i.set(t,n);return i}sorted(e=s.defaultSort){return new this.constructor[Symbol.species](this).sort((i,t,n,l)=>e(i,t,n,l))}toJSON(){return[...this.values()]}static defaultSort(e,i){return Number(e>i)||Number(e===i)-1}},r=s;h(r,"Collection"),a(r,"default",s);var V=r;export{r as Collection,V as default};
|
||||||
|
//# sourceMappingURL=index.mjs.map
|
1
node_modules/@discordjs/collection/dist/index.mjs.map
generated
vendored
Normal file
1
node_modules/@discordjs/collection/dist/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
131
node_modules/@discordjs/collection/package.json
generated
vendored
131
node_modules/@discordjs/collection/package.json
generated
vendored
|
@ -1,78 +1,85 @@
|
||||||
{
|
{
|
||||||
"_from": "@discordjs/collection@^0.1.6",
|
|
||||||
"_id": "@discordjs/collection@0.1.6",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ==",
|
|
||||||
"_location": "/@discordjs/collection",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "@discordjs/collection@^0.1.6",
|
|
||||||
"name": "@discordjs/collection",
|
"name": "@discordjs/collection",
|
||||||
"escapedName": "@discordjs%2fcollection",
|
"version": "0.4.0",
|
||||||
"scope": "@discordjs",
|
|
||||||
"rawSpec": "^0.1.6",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^0.1.6"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/discord.js"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz",
|
|
||||||
"_shasum": "9e9a7637f4e4e0688fd8b2b5c63133c91607682c",
|
|
||||||
"_spec": "@discordjs/collection@^0.1.6",
|
|
||||||
"_where": "C:\\Users\\hlack\\Desktop\\discord bot\\node_modules\\discord.js",
|
|
||||||
"author": {
|
|
||||||
"name": "Amish Shah",
|
|
||||||
"email": "amishshah.2k@gmail.com"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/discordjs/collection/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Utility data structure used in Discord.js",
|
"description": "Utility data structure used in Discord.js",
|
||||||
"devDependencies": {
|
"scripts": {
|
||||||
"@babel/cli": "^7.8.4",
|
"pretest": "npm run build",
|
||||||
"@babel/core": "^7.8.4",
|
"test": "jest --pass-with-no-tests",
|
||||||
"@babel/preset-env": "^7.8.4",
|
"test:ci": "jest --no-stack-trace --verbose --pass-with-no-tests",
|
||||||
"@babel/preset-typescript": "^7.8.3",
|
"prebuild": "npm run lint",
|
||||||
"@types/node": "^13.7.4",
|
"build": "tsup",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.21.0",
|
"lint": "eslint src --ext mjs,js,ts",
|
||||||
"@typescript-eslint/parser": "^2.21.0",
|
"lint:fix": "eslint src --ext mjs,js,ts --fix",
|
||||||
"discord.js-docgen": "github:discordjs/docgen#ts-patch",
|
"format": "prettier --write **/*.{ts,js,json,yml,yaml}",
|
||||||
"eslint": "^6.8.0",
|
"prepare": "is-ci || husky install",
|
||||||
"eslint-config-marine": "^6.0.0",
|
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs",
|
||||||
"jsdoc-babel": "^0.5.0",
|
"prepublishOnly": "npm run lint && npm run test",
|
||||||
"rimraf": "^3.0.2",
|
"release": "standard-version --preset angular"
|
||||||
"typescript": "^3.8.2"
|
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"main": "./dist/index.js",
|
||||||
"extends": "marine/node"
|
"module": "./dist/index.mjs",
|
||||||
|
"typings": "./dist/index.d.ts",
|
||||||
|
"exports": {
|
||||||
|
"import": "./dist/index.mjs",
|
||||||
|
"require": "./dist/index.js"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/discordjs/collection#readme",
|
"directories": {
|
||||||
|
"lib": "src",
|
||||||
|
"test": "__tests__"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"contributors": [
|
||||||
|
"Crawl <icrawltogo@gmail.com>",
|
||||||
|
"Amish Shah <amishshah.2k@gmail.com>",
|
||||||
|
"SpaceEEC <spaceeec@yahoo.com>",
|
||||||
|
"Vlad Frangu <kingdgrizzle@gmail.com>"
|
||||||
|
],
|
||||||
|
"license": "Apache-2.0",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"map",
|
"map",
|
||||||
"collection",
|
"collection",
|
||||||
"utility"
|
"utility"
|
||||||
],
|
],
|
||||||
"license": "Apache-2.0",
|
|
||||||
"main": "dist/index.js",
|
|
||||||
"name": "@discordjs/collection",
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/discordjs/collection.git"
|
"url": "git+https://github.com/discordjs/collection.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"bugs": {
|
||||||
"build": "rimraf dist/ && tsc",
|
"url": "https://github.com/discordjs/collection/issues"
|
||||||
"docs": "docgen --jsdoc jsdoc.json --source src/*.ts src/**/*.ts --custom docs/index.yml --output docs/docs.json",
|
|
||||||
"docs:test": "docgen --jsdoc jsdoc.json --source src/*.ts src/**/*.ts --custom docs/index.yml",
|
|
||||||
"lint": "eslint src --ext .ts",
|
|
||||||
"prebuild": "npm run lint",
|
|
||||||
"pretest": "npm run build",
|
|
||||||
"test": "node test/index.js"
|
|
||||||
},
|
},
|
||||||
"types": "dist/index.d.ts",
|
"homepage": "https://github.com/discordjs/collection",
|
||||||
"version": "0.1.6"
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.16.5",
|
||||||
|
"@babel/preset-env": "^7.16.5",
|
||||||
|
"@babel/preset-typescript": "^7.16.5",
|
||||||
|
"@commitlint/cli": "^15.0.0",
|
||||||
|
"@commitlint/config-angular": "^15.0.0",
|
||||||
|
"@discordjs/ts-docgen": "^0.3.4",
|
||||||
|
"@types/jest": "^27.0.3",
|
||||||
|
"@types/node": "^16.11.6",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.8.0",
|
||||||
|
"@typescript-eslint/parser": "^5.8.0",
|
||||||
|
"eslint": "^8.5.0",
|
||||||
|
"eslint-config-marine": "^9.1.0",
|
||||||
|
"eslint-config-prettier": "^8.3.0",
|
||||||
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"husky": "^7.0.4",
|
||||||
|
"is-ci": "^3.0.1",
|
||||||
|
"jest": "^27.4.5",
|
||||||
|
"lint-staged": "^12.1.4",
|
||||||
|
"prettier": "^2.5.1",
|
||||||
|
"standard-version": "^9.3.2",
|
||||||
|
"tsup": "^5.11.8",
|
||||||
|
"typedoc": "^0.22.10",
|
||||||
|
"typescript": "^4.5.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.0.0",
|
||||||
|
"npm": ">=7.0.0"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
68
node_modules/@discordjs/rest/CHANGELOG.md
generated
vendored
Normal file
68
node_modules/@discordjs/rest/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
# [0.3.0](https://github.com/discordjs/discord.js/compare/@discordjs/rest@0.2.0...@discordjs/rest@0.3.0) (2021-12-08)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
- **rest:** Don't add empty query (#7308) ([d0fa5aa](https://github.com/discordjs/discord.js/commit/d0fa5aaa26d316608120bca3050e14eefbe2f93b))
|
||||||
|
- **rest:** Use http agent when protocol is not https (#7309) ([d8ea572](https://github.com/discordjs/discord.js/commit/d8ea572fb8a51f2f6a902c4926e814017d115708))
|
||||||
|
- `ref` delay for rate limited requests (#7239) ([ed0cfd9](https://github.com/discordjs/discord.js/commit/ed0cfd91edc3a2b23a34a8ecd9db38baa12b52fa))
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
- Fix a typo and use milliseconds instead of ms (#7251) ([0dd56af](https://github.com/discordjs/discord.js/commit/0dd56afe1cdf16f1e7d9afe1f8c29c31d1833a25))
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Rest hash and handler sweeping (#7255) ([3bb4829](https://github.com/discordjs/discord.js/commit/3bb48298004d292214c6cb8f927c2fea78a42952))
|
||||||
|
- Rest docs (#7281) ([9054f2f](https://github.com/discordjs/discord.js/commit/9054f2f7ad7f246431e5f53403535bf301c27a80))
|
||||||
|
|
||||||
|
## Refactor
|
||||||
|
|
||||||
|
- **files:** File data can be much more than buffer (#7238) ([86ab526](https://github.com/discordjs/discord.js/commit/86ab526d493415b14b79b51d08c3677897d219ee))
|
||||||
|
- **rest:** Rename attachment to file (#7199) ([c969cbf](https://github.com/discordjs/discord.js/commit/c969cbf6524093757d47108b6a55e62dcb210e8b))
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
- **voice:** Fix tests ([62c74b8](https://github.com/discordjs/discord.js/commit/62c74b8333066465e5bd295b8b102b35a506751d))
|
||||||
|
|
||||||
|
# [0.2.0-canary.0](https://github.com/discordjs/discord.js-modules/compare/@discordjs/rest@0.1.1-canary.0...@discordjs/rest@0.2.0-canary.0) (2021-12-08)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
- **CDN#icon:** remove `guild` prefixes ([#67](https://github.com/discordjs/discord.js-modules/issues/67)) ([8882686](https://github.com/discordjs/discord.js-modules/commit/88826869d8ed3695f2b9475bea8d3b851df270bd))
|
||||||
|
- **Cdn:** make parameters immutable ([#84](https://github.com/discordjs/discord.js-modules/issues/84)) ([3105b61](https://github.com/discordjs/discord.js-modules/commit/3105b614da603dd3c8479dea089b5953d3c8b89b))
|
||||||
|
- **CDN:** use correct types ([#86](https://github.com/discordjs/discord.js-modules/issues/86)) ([64b02d4](https://github.com/discordjs/discord.js-modules/commit/64b02d4649a38802dd1a4e7a738ec64c27dea760))
|
||||||
|
- **Rest:** lint errors ([53c0cce](https://github.com/discordjs/discord.js-modules/commit/53c0ccefee80225ca7640cf88f44c68da99f31e7))
|
||||||
|
- use hash instead of animatedHash for default avatar test ([#74](https://github.com/discordjs/discord.js-modules/issues/74)) ([4852838](https://github.com/discordjs/discord.js-modules/commit/485283824cf368874096d59a64131970401218e9))
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **CDN#guildIcon:** implement dynamic logic ([#53](https://github.com/discordjs/discord.js-modules/issues/53)) ([c4b2803](https://github.com/discordjs/discord.js-modules/commit/c4b280366b0c5920c147126ccb9068f16fc898aa))
|
||||||
|
- **CDN:** add role icon endpoint ([#64](https://github.com/discordjs/discord.js-modules/issues/64)) ([4d7d692](https://github.com/discordjs/discord.js-modules/commit/4d7d692b4954c373941d2d8f3e3335a9a8543220))
|
||||||
|
- **CDN:** add sticker endpoints ([#60](https://github.com/discordjs/discord.js-modules/issues/60)) ([3b714ba](https://github.com/discordjs/discord.js-modules/commit/3b714bada415a7987dd6aa50c938751c66dc05be))
|
||||||
|
- **CDN:** guild member avatars ([#68](https://github.com/discordjs/discord.js-modules/issues/68)) ([90c25ad](https://github.com/discordjs/discord.js-modules/commit/90c25ad4afa5ec5906867f431afcaf11fb56355a))
|
||||||
|
- **Errors:** show data sent when an error occurs ([#72](https://github.com/discordjs/discord.js-modules/issues/72)) ([3e2edc8](https://github.com/discordjs/discord.js-modules/commit/3e2edc8974e2c62c324db0c151da4d34c289c40a))
|
||||||
|
- expose https agent options ([#82](https://github.com/discordjs/discord.js-modules/issues/82)) ([7f1c9be](https://github.com/discordjs/discord.js-modules/commit/7f1c9be817bbc6a4a11a726c952580dd3cb7b149))
|
||||||
|
- **RateLimits:** optionally error on ratelimits ([#77](https://github.com/discordjs/discord.js-modules/issues/77)) ([a371f0b](https://github.com/discordjs/discord.js-modules/commit/a371f0bc6c76cffaf048fd0fbf9c64a6c4d6619e))
|
||||||
|
- **RequestManager:** support setting global headers in options ([#70](https://github.com/discordjs/discord.js-modules/issues/70)) ([d1758c7](https://github.com/discordjs/discord.js-modules/commit/d1758c74b00a3f83c39745cd9af147a7f8f2b12b))
|
||||||
|
- **Requests:** add attachment keys and form data for stickers ([#81](https://github.com/discordjs/discord.js-modules/issues/81)) ([7c2b0c0](https://github.com/discordjs/discord.js-modules/commit/7c2b0c0e432b82776bb57c1708f3be6b4affde56))
|
||||||
|
- **Rest:** add response and request events ([#85](https://github.com/discordjs/discord.js-modules/issues/85)) ([c3aba56](https://github.com/discordjs/discord.js-modules/commit/c3aba567572e73548c38cd7c7f9945e9361833de))
|
||||||
|
- **REST:** change api version to v9 ([#62](https://github.com/discordjs/discord.js-modules/issues/62)) ([4c980e6](https://github.com/discordjs/discord.js-modules/commit/4c980e6ad6c0297519ec0f09ec27953764a4a12d))
|
||||||
|
- **Rest:** improve global rate limit and invalid request tracking ([#51](https://github.com/discordjs/discord.js-modules/issues/51)) ([b73cc06](https://github.com/discordjs/discord.js-modules/commit/b73cc060daa701de71815a824ebaccdc9ebf2859))
|
||||||
|
- **Rest:** use native Node.js AbortController ([#66](https://github.com/discordjs/discord.js-modules/issues/66)) ([3b53910](https://github.com/discordjs/discord.js-modules/commit/3b539102f07c413ffd3ee60718ac8e5a709bdd0e))
|
||||||
|
- **SequentialHandler:** add more info to debug when rate limit was hit ([#78](https://github.com/discordjs/discord.js-modules/issues/78)) ([a4e404b](https://github.com/discordjs/discord.js-modules/commit/a4e404b2e6df625a48176b9f1bfac6cfe86c5d66))
|
||||||
|
|
||||||
|
# [0.1.1-canary.0](https://github.com/discordjs/discord.js-modules/compare/@discordjs/rest@0.1.0-canary.0...@discordjs/rest@0.1.1-canary.0) (2021-08-24)
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
- **Rest:** use reference type for DOM ([#55](https://github.com/discordjs/discord.js-modules/issues/55)) ([07f5aa7](https://github.com/discordjs/discord.js-modules/commit/07f5aa744092c16b0f05b05055e5d4bbd49754e7))
|
||||||
|
|
||||||
|
# 0.1.0-canary.0 (2021-06-29)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **rest:** Implement rest module ([#34](https://github.com/discordjs/discord.js-modules/issues/34)) ([6990f0f](https://github.com/discordjs/discord.js-modules/commit/6990f0f7f3ca958a95f9b1b19681b42669743427))
|
192
node_modules/@discordjs/rest/LICENSE
generated
vendored
Normal file
192
node_modules/@discordjs/rest/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,192 @@
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
Copyright 2021 Noel Buechler
|
||||||
|
Copyright 2021 Antonio Román
|
||||||
|
Copyright 2021 Vlad Frangu
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
3
node_modules/@discordjs/rest/README.md
generated
vendored
Normal file
3
node_modules/@discordjs/rest/README.md
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# `@discordjs/rest`
|
||||||
|
|
||||||
|
> The REST API module for Discord.js
|
8
node_modules/@discordjs/rest/dist/index.d.ts
generated
vendored
Normal file
8
node_modules/@discordjs/rest/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
/// <reference lib="dom" />
|
||||||
|
export * from './lib/CDN';
|
||||||
|
export * from './lib/errors/DiscordAPIError';
|
||||||
|
export * from './lib/errors/HTTPError';
|
||||||
|
export * from './lib/errors/RateLimitError';
|
||||||
|
export * from './lib/RequestManager';
|
||||||
|
export * from './lib/REST';
|
||||||
|
export * from './lib/utils/constants';
|
8
node_modules/@discordjs/rest/dist/index.js
generated
vendored
Normal file
8
node_modules/@discordjs/rest/dist/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@discordjs/rest/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
8
node_modules/@discordjs/rest/dist/index.mjs
generated
vendored
Normal file
8
node_modules/@discordjs/rest/dist/index.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@discordjs/rest/dist/index.mjs.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
163
node_modules/@discordjs/rest/dist/lib/CDN.d.ts
generated
vendored
Normal file
163
node_modules/@discordjs/rest/dist/lib/CDN.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
import { ImageExtension, ImageSize, StickerExtension } from './utils/constants';
|
||||||
|
/**
|
||||||
|
* The options used for image URLs
|
||||||
|
*/
|
||||||
|
export interface BaseImageURLOptions {
|
||||||
|
/**
|
||||||
|
* The extension to use for the image URL
|
||||||
|
* @default 'webp'
|
||||||
|
*/
|
||||||
|
extension?: ImageExtension;
|
||||||
|
/**
|
||||||
|
* The size specified in the image URL
|
||||||
|
*/
|
||||||
|
size?: ImageSize;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The options used for image URLs with animated content
|
||||||
|
*/
|
||||||
|
export interface ImageURLOptions extends BaseImageURLOptions {
|
||||||
|
/**
|
||||||
|
* Whether or not to prefer the static version of an image asset.
|
||||||
|
*/
|
||||||
|
forceStatic?: boolean;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The options to use when making a CDN URL
|
||||||
|
*/
|
||||||
|
export interface MakeURLOptions {
|
||||||
|
/**
|
||||||
|
* The extension to use for the image URL
|
||||||
|
* @default 'webp'
|
||||||
|
*/
|
||||||
|
extension?: string | undefined;
|
||||||
|
/**
|
||||||
|
* The size specified in the image URL
|
||||||
|
*/
|
||||||
|
size?: ImageSize;
|
||||||
|
/**
|
||||||
|
* The allowed extensions that can be used
|
||||||
|
*/
|
||||||
|
allowedExtensions?: ReadonlyArray<string>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The CDN link builder
|
||||||
|
*/
|
||||||
|
export declare class CDN {
|
||||||
|
private readonly base;
|
||||||
|
constructor(base?: string);
|
||||||
|
/**
|
||||||
|
* Generates an app asset URL for a client's asset.
|
||||||
|
* @param clientId The client id that has the asset
|
||||||
|
* @param assetHash The hash provided by Discord for this asset
|
||||||
|
* @param options Optional options for the asset
|
||||||
|
*/
|
||||||
|
appAsset(clientId: string, assetHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||||
|
/**
|
||||||
|
* Generates an app icon URL for a client's icon.
|
||||||
|
* @param clientId The client id that has the icon
|
||||||
|
* @param iconHash The hash provided by Discord for this icon
|
||||||
|
* @param options Optional options for the icon
|
||||||
|
*/
|
||||||
|
appIcon(clientId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||||
|
/**
|
||||||
|
* Generates an avatar URL, e.g. for a user or a webhook.
|
||||||
|
* @param id The id that has the icon
|
||||||
|
* @param avatarHash The hash provided by Discord for this avatar
|
||||||
|
* @param options Optional options for the avatar
|
||||||
|
*/
|
||||||
|
avatar(id: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||||
|
/**
|
||||||
|
* Generates a banner URL, e.g. for a user or a guild.
|
||||||
|
* @param id The id that has the banner splash
|
||||||
|
* @param bannerHash The hash provided by Discord for this banner
|
||||||
|
* @param options Optional options for the banner
|
||||||
|
*/
|
||||||
|
banner(id: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||||
|
/**
|
||||||
|
* Generates an icon URL for a channel, e.g. a group DM.
|
||||||
|
* @param channelId The channel id that has the icon
|
||||||
|
* @param iconHash The hash provided by Discord for this channel
|
||||||
|
* @param options Optional options for the icon
|
||||||
|
*/
|
||||||
|
channelIcon(channelId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||||
|
/**
|
||||||
|
* Generates the default avatar URL for a discriminator.
|
||||||
|
* @param discriminator The discriminator modulo 5
|
||||||
|
*/
|
||||||
|
defaultAvatar(discriminator: number): string;
|
||||||
|
/**
|
||||||
|
* Generates a discovery splash URL for a guild's discovery splash.
|
||||||
|
* @param guildId The guild id that has the discovery splash
|
||||||
|
* @param splashHash The hash provided by Discord for this splash
|
||||||
|
* @param options Optional options for the splash
|
||||||
|
*/
|
||||||
|
discoverySplash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||||
|
/**
|
||||||
|
* Generates an emoji's URL for an emoji.
|
||||||
|
* @param emojiId The emoji id
|
||||||
|
* @param extension The extension of the emoji
|
||||||
|
*/
|
||||||
|
emoji(emojiId: string, extension?: ImageExtension): string;
|
||||||
|
/**
|
||||||
|
* Generates a guild member avatar URL.
|
||||||
|
* @param guildId The id of the guild
|
||||||
|
* @param userId The id of the user
|
||||||
|
* @param avatarHash The hash provided by Discord for this avatar
|
||||||
|
* @param options Optional options for the avatar
|
||||||
|
*/
|
||||||
|
guildMemberAvatar(guildId: string, userId: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||||
|
/**
|
||||||
|
* Generates an icon URL, e.g. for a guild.
|
||||||
|
* @param id The id that has the icon splash
|
||||||
|
* @param iconHash The hash provided by Discord for this icon
|
||||||
|
* @param options Optional options for the icon
|
||||||
|
*/
|
||||||
|
icon(id: string, iconHash: string, options?: Readonly<ImageURLOptions>): string;
|
||||||
|
/**
|
||||||
|
* Generates a URL for the icon of a role
|
||||||
|
* @param roleId The id of the role that has the icon
|
||||||
|
* @param roleIconHash The hash provided by Discord for this role icon
|
||||||
|
* @param options Optional options for the role icon
|
||||||
|
*/
|
||||||
|
roleIcon(roleId: string, roleIconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||||
|
/**
|
||||||
|
* Generates a guild invite splash URL for a guild's invite splash.
|
||||||
|
* @param guildId The guild id that has the invite splash
|
||||||
|
* @param splashHash The hash provided by Discord for this splash
|
||||||
|
* @param options Optional options for the splash
|
||||||
|
*/
|
||||||
|
splash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||||
|
/**
|
||||||
|
* Generates a sticker URL.
|
||||||
|
* @param stickerId The sticker id
|
||||||
|
* @param extension The extension of the sticker
|
||||||
|
*/
|
||||||
|
sticker(stickerId: string, extension?: StickerExtension): string;
|
||||||
|
/**
|
||||||
|
* Generates a sticker pack banner URL.
|
||||||
|
* @param bannerId The banner id
|
||||||
|
* @param options Optional options for the banner
|
||||||
|
*/
|
||||||
|
stickerPackBanner(bannerId: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||||
|
/**
|
||||||
|
* Generates a team icon URL for a team's icon.
|
||||||
|
* @param teamId The team id that has the icon
|
||||||
|
* @param iconHash The hash provided by Discord for this icon
|
||||||
|
* @param options Optional options for the icon
|
||||||
|
*/
|
||||||
|
teamIcon(teamId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
||||||
|
/**
|
||||||
|
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
||||||
|
* @param route The base cdn route
|
||||||
|
* @param hash The hash provided by Discord for this icon
|
||||||
|
* @param options Optional options for the link
|
||||||
|
*/
|
||||||
|
private dynamicMakeURL;
|
||||||
|
/**
|
||||||
|
* Constructs the URL for the resource
|
||||||
|
* @param route The base cdn route
|
||||||
|
* @param options The extension/size options for the link
|
||||||
|
*/
|
||||||
|
private makeURL;
|
||||||
|
}
|
237
node_modules/@discordjs/rest/dist/lib/REST.d.ts
generated
vendored
Normal file
237
node_modules/@discordjs/rest/dist/lib/REST.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,237 @@
|
||||||
|
/// <reference types="node" />
|
||||||
|
import { EventEmitter } from 'node:events';
|
||||||
|
import { CDN } from './CDN';
|
||||||
|
import { InternalRequest, RequestData, RequestManager, RouteLike } from './RequestManager';
|
||||||
|
import type { AgentOptions } from 'node:https';
|
||||||
|
import type { RequestInit, Response } from 'node-fetch';
|
||||||
|
import type { HashData } from './RequestManager';
|
||||||
|
import type Collection from '@discordjs/collection';
|
||||||
|
import type { IHandler } from './handlers/IHandler';
|
||||||
|
/**
|
||||||
|
* Options to be passed when creating the REST instance
|
||||||
|
*/
|
||||||
|
export interface RESTOptions {
|
||||||
|
/**
|
||||||
|
* HTTPS Agent options
|
||||||
|
* @default {}
|
||||||
|
*/
|
||||||
|
agent: Omit<AgentOptions, 'keepAlive'>;
|
||||||
|
/**
|
||||||
|
* The base api path, without version
|
||||||
|
* @default 'https://discord.com/api'
|
||||||
|
*/
|
||||||
|
api: string;
|
||||||
|
/**
|
||||||
|
* The cdn path
|
||||||
|
* @default 'https://cdn.discordapp.com'
|
||||||
|
*/
|
||||||
|
cdn: string;
|
||||||
|
/**
|
||||||
|
* Additional headers to send for all API requests
|
||||||
|
* @default {}
|
||||||
|
*/
|
||||||
|
headers: Record<string, string>;
|
||||||
|
/**
|
||||||
|
* The number of invalid REST requests (those that return 401, 403, or 429) in a 10 minute window between emitted warnings (0 for no warnings).
|
||||||
|
* That is, if set to 500, warnings will be emitted at invalid request number 500, 1000, 1500, and so on.
|
||||||
|
* @default 0
|
||||||
|
*/
|
||||||
|
invalidRequestWarningInterval: number;
|
||||||
|
/**
|
||||||
|
* How many requests to allow sending per second (Infinity for unlimited, 50 for the standard global limit used by Discord)
|
||||||
|
* @default 50
|
||||||
|
*/
|
||||||
|
globalRequestsPerSecond: number;
|
||||||
|
/**
|
||||||
|
* The extra offset to add to rate limits in milliseconds
|
||||||
|
* @default 50
|
||||||
|
*/
|
||||||
|
offset: number;
|
||||||
|
/**
|
||||||
|
* Determines how rate limiting and pre-emptive throttling should be handled.
|
||||||
|
* When an array of strings, each element is treated as a prefix for the request route
|
||||||
|
* (e.g. `/channels` to match any route starting with `/channels` such as `/channels/:id/messages`)
|
||||||
|
* for which to throw {@link RateLimitError}s. All other request routes will be queued normally
|
||||||
|
* @default null
|
||||||
|
*/
|
||||||
|
rejectOnRateLimit: string[] | RateLimitQueueFilter | null;
|
||||||
|
/**
|
||||||
|
* The number of retries for errors with the 500 code, or errors
|
||||||
|
* that timeout
|
||||||
|
* @default 3
|
||||||
|
*/
|
||||||
|
retries: number;
|
||||||
|
/**
|
||||||
|
* The time to wait in milliseconds before a request is aborted
|
||||||
|
* @default 15_000
|
||||||
|
*/
|
||||||
|
timeout: number;
|
||||||
|
/**
|
||||||
|
* Extra information to add to the user agent
|
||||||
|
* @default `Node.js ${process.version}`
|
||||||
|
*/
|
||||||
|
userAgentAppendix: string;
|
||||||
|
/**
|
||||||
|
* The version of the API to use
|
||||||
|
* @default '9'
|
||||||
|
*/
|
||||||
|
version: string;
|
||||||
|
/**
|
||||||
|
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 4h)
|
||||||
|
* @default 14_400_000
|
||||||
|
*/
|
||||||
|
hashSweepInterval: number;
|
||||||
|
/**
|
||||||
|
* The maximum amount of time a hash can exist in milliseconds without being hit with a request (defaults to 24h)
|
||||||
|
* @default 86_400_000
|
||||||
|
*/
|
||||||
|
hashLifetime: number;
|
||||||
|
/**
|
||||||
|
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 1h)
|
||||||
|
* @default 3_600_000
|
||||||
|
*/
|
||||||
|
handlerSweepInterval: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Data emitted on `RESTEvents.RateLimited`
|
||||||
|
*/
|
||||||
|
export interface RateLimitData {
|
||||||
|
/**
|
||||||
|
* The time, in milliseconds, until the request-lock is reset
|
||||||
|
*/
|
||||||
|
timeToReset: number;
|
||||||
|
/**
|
||||||
|
* The amount of requests we can perform before locking requests
|
||||||
|
*/
|
||||||
|
limit: number;
|
||||||
|
/**
|
||||||
|
* The HTTP method being performed
|
||||||
|
*/
|
||||||
|
method: string;
|
||||||
|
/**
|
||||||
|
* The bucket hash for this request
|
||||||
|
*/
|
||||||
|
hash: string;
|
||||||
|
/**
|
||||||
|
* The full URL for this request
|
||||||
|
*/
|
||||||
|
url: string;
|
||||||
|
/**
|
||||||
|
* The route being hit in this request
|
||||||
|
*/
|
||||||
|
route: string;
|
||||||
|
/**
|
||||||
|
* The major parameter of the route
|
||||||
|
*
|
||||||
|
* For example, in `/channels/x`, this will be `x`.
|
||||||
|
* If there is no major parameter (e.g: `/bot/gateway`) this will be `global`.
|
||||||
|
*/
|
||||||
|
majorParameter: string;
|
||||||
|
/**
|
||||||
|
* Whether the rate limit that was reached was the global limit
|
||||||
|
*/
|
||||||
|
global: boolean;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A function that determines whether the rate limit hit should throw an Error
|
||||||
|
*/
|
||||||
|
export declare type RateLimitQueueFilter = (rateLimitData: RateLimitData) => boolean | Promise<boolean>;
|
||||||
|
export interface APIRequest {
|
||||||
|
/**
|
||||||
|
* The HTTP method used in this request
|
||||||
|
*/
|
||||||
|
method: string;
|
||||||
|
/**
|
||||||
|
* The full path used to make the request
|
||||||
|
*/
|
||||||
|
path: RouteLike;
|
||||||
|
/**
|
||||||
|
* The API route identifying the ratelimit for this request
|
||||||
|
*/
|
||||||
|
route: string;
|
||||||
|
/**
|
||||||
|
* Additional HTTP options for this request
|
||||||
|
*/
|
||||||
|
options: RequestInit;
|
||||||
|
/**
|
||||||
|
* The data that was used to form the body of this request
|
||||||
|
*/
|
||||||
|
data: Pick<InternalRequest, 'files' | 'body'>;
|
||||||
|
/**
|
||||||
|
* The number of times this request has been attempted
|
||||||
|
*/
|
||||||
|
retries: number;
|
||||||
|
}
|
||||||
|
export interface InvalidRequestWarningData {
|
||||||
|
/**
|
||||||
|
* Number of invalid requests that have been made in the window
|
||||||
|
*/
|
||||||
|
count: number;
|
||||||
|
/**
|
||||||
|
* Time in milliseconds remaining before the count resets
|
||||||
|
*/
|
||||||
|
remainingTime: number;
|
||||||
|
}
|
||||||
|
export interface RestEvents {
|
||||||
|
invalidRequestWarning: [invalidRequestInfo: InvalidRequestWarningData];
|
||||||
|
restDebug: [info: string];
|
||||||
|
rateLimited: [rateLimitInfo: RateLimitData];
|
||||||
|
request: [request: APIRequest];
|
||||||
|
response: [request: APIRequest, response: Response];
|
||||||
|
newListener: [name: string, listener: (...args: any) => void];
|
||||||
|
removeListener: [name: string, listener: (...args: any) => void];
|
||||||
|
hashSweep: [sweptHashes: Collection<string, HashData>];
|
||||||
|
handlerSweep: [sweptHandlers: Collection<string, IHandler>];
|
||||||
|
}
|
||||||
|
export interface REST {
|
||||||
|
on: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
|
||||||
|
once: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
|
||||||
|
emit: (<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]) => boolean) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, ...args: any[]) => boolean);
|
||||||
|
off: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
|
||||||
|
removeAllListeners: (<K extends keyof RestEvents>(event?: K) => this) & (<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>) => this);
|
||||||
|
}
|
||||||
|
export declare class REST extends EventEmitter {
|
||||||
|
readonly cdn: CDN;
|
||||||
|
readonly requestManager: RequestManager;
|
||||||
|
constructor(options?: Partial<RESTOptions>);
|
||||||
|
/**
|
||||||
|
* Sets the authorization token that should be used for requests
|
||||||
|
* @param token The authorization token to use
|
||||||
|
*/
|
||||||
|
setToken(token: string): this;
|
||||||
|
/**
|
||||||
|
* Runs a get request from the api
|
||||||
|
* @param fullRoute The full route to query
|
||||||
|
* @param options Optional request options
|
||||||
|
*/
|
||||||
|
get(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||||
|
/**
|
||||||
|
* Runs a delete request from the api
|
||||||
|
* @param fullRoute The full route to query
|
||||||
|
* @param options Optional request options
|
||||||
|
*/
|
||||||
|
delete(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||||
|
/**
|
||||||
|
* Runs a post request from the api
|
||||||
|
* @param fullRoute The full route to query
|
||||||
|
* @param options Optional request options
|
||||||
|
*/
|
||||||
|
post(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||||
|
/**
|
||||||
|
* Runs a put request from the api
|
||||||
|
* @param fullRoute The full route to query
|
||||||
|
* @param options Optional request options
|
||||||
|
*/
|
||||||
|
put(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||||
|
/**
|
||||||
|
* Runs a patch request from the api
|
||||||
|
* @param fullRoute The full route to query
|
||||||
|
* @param options Optional request options
|
||||||
|
*/
|
||||||
|
patch(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||||
|
/**
|
||||||
|
* Runs a request from the api
|
||||||
|
* @param options Request options
|
||||||
|
*/
|
||||||
|
request(options: InternalRequest): Promise<unknown>;
|
||||||
|
}
|
199
node_modules/@discordjs/rest/dist/lib/RequestManager.d.ts
generated
vendored
Normal file
199
node_modules/@discordjs/rest/dist/lib/RequestManager.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
/// <reference types="node" />
|
||||||
|
import Collection from '@discordjs/collection';
|
||||||
|
import { EventEmitter } from 'node:events';
|
||||||
|
import type { BodyInit } from 'node-fetch';
|
||||||
|
import type { IHandler } from './handlers/IHandler';
|
||||||
|
import type { RESTOptions, RestEvents } from './REST';
|
||||||
|
/**
|
||||||
|
* Represents a file to be added to the request
|
||||||
|
*/
|
||||||
|
export interface RawFile {
|
||||||
|
/**
|
||||||
|
* The name of the file
|
||||||
|
*/
|
||||||
|
fileName: string;
|
||||||
|
/**
|
||||||
|
* An explicit key to use for key of the formdata field for this file.
|
||||||
|
* When not provided, the index of the file in the files array is used in the form `files[${index}]`.
|
||||||
|
* If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
|
||||||
|
*/
|
||||||
|
key?: string;
|
||||||
|
/**
|
||||||
|
* The actual data for the file
|
||||||
|
*/
|
||||||
|
fileData: string | number | boolean | Buffer;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Represents possible data to be given to an endpoint
|
||||||
|
*/
|
||||||
|
export interface RequestData {
|
||||||
|
/**
|
||||||
|
* Whether to append JSON data to form data instead of `payload_json` when sending files
|
||||||
|
*/
|
||||||
|
appendToFormData?: boolean;
|
||||||
|
/**
|
||||||
|
* If this request needs the `Authorization` header
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
auth?: boolean;
|
||||||
|
/**
|
||||||
|
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
||||||
|
* @default 'Bot'
|
||||||
|
*/
|
||||||
|
authPrefix?: 'Bot' | 'Bearer';
|
||||||
|
/**
|
||||||
|
* The body to send to this request.
|
||||||
|
* If providing as BodyInit, set `passThroughBody: true`
|
||||||
|
*/
|
||||||
|
body?: BodyInit | unknown;
|
||||||
|
/**
|
||||||
|
* Files to be attached to this request
|
||||||
|
*/
|
||||||
|
files?: RawFile[] | undefined;
|
||||||
|
/**
|
||||||
|
* Additional headers to add to this request
|
||||||
|
*/
|
||||||
|
headers?: Record<string, string>;
|
||||||
|
/**
|
||||||
|
* Whether to pass-through the body property directly to `fetch()`.
|
||||||
|
* <warn>This only applies when files is NOT present</warn>
|
||||||
|
*/
|
||||||
|
passThroughBody?: boolean;
|
||||||
|
/**
|
||||||
|
* Query string parameters to append to the called endpoint
|
||||||
|
*/
|
||||||
|
query?: URLSearchParams;
|
||||||
|
/**
|
||||||
|
* Reason to show in the audit logs
|
||||||
|
*/
|
||||||
|
reason?: string;
|
||||||
|
/**
|
||||||
|
* If this request should be versioned
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
versioned?: boolean;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Possible headers for an API call
|
||||||
|
*/
|
||||||
|
export interface RequestHeaders {
|
||||||
|
Authorization?: string;
|
||||||
|
'User-Agent': string;
|
||||||
|
'X-Audit-Log-Reason'?: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Possible API methods to be used when doing requests
|
||||||
|
*/
|
||||||
|
export declare const enum RequestMethod {
|
||||||
|
Delete = "delete",
|
||||||
|
Get = "get",
|
||||||
|
Patch = "patch",
|
||||||
|
Post = "post",
|
||||||
|
Put = "put"
|
||||||
|
}
|
||||||
|
export declare type RouteLike = `/${string}`;
|
||||||
|
/**
|
||||||
|
* Internal request options
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export interface InternalRequest extends RequestData {
|
||||||
|
method: RequestMethod;
|
||||||
|
fullRoute: RouteLike;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Parsed route data for an endpoint
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export interface RouteData {
|
||||||
|
majorParameter: string;
|
||||||
|
bucketRoute: string;
|
||||||
|
original: RouteLike;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Represents a hash and its associated fields
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export interface HashData {
|
||||||
|
value: string;
|
||||||
|
lastAccess: number;
|
||||||
|
}
|
||||||
|
export interface RequestManager {
|
||||||
|
on: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
|
||||||
|
once: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
|
||||||
|
emit: (<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]) => boolean) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, ...args: any[]) => boolean);
|
||||||
|
off: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
|
||||||
|
removeAllListeners: (<K extends keyof RestEvents>(event?: K) => this) & (<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>) => this);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Represents the class that manages handlers for endpoints
|
||||||
|
*/
|
||||||
|
export declare class RequestManager extends EventEmitter {
|
||||||
|
#private;
|
||||||
|
/**
|
||||||
|
* The number of requests remaining in the global bucket
|
||||||
|
*/
|
||||||
|
globalRemaining: number;
|
||||||
|
/**
|
||||||
|
* The promise used to wait out the global rate limit
|
||||||
|
*/
|
||||||
|
globalDelay: Promise<void> | null;
|
||||||
|
/**
|
||||||
|
* The timestamp at which the global bucket resets
|
||||||
|
*/
|
||||||
|
globalReset: number;
|
||||||
|
/**
|
||||||
|
* API bucket hashes that are cached from provided routes
|
||||||
|
*/
|
||||||
|
readonly hashes: Collection<string, HashData>;
|
||||||
|
/**
|
||||||
|
* Request handlers created from the bucket hash and the major parameters
|
||||||
|
*/
|
||||||
|
readonly handlers: Collection<string, IHandler>;
|
||||||
|
private hashTimer;
|
||||||
|
private handlerTimer;
|
||||||
|
private agent;
|
||||||
|
readonly options: RESTOptions;
|
||||||
|
constructor(options: Partial<RESTOptions>);
|
||||||
|
private setupSweepers;
|
||||||
|
/**
|
||||||
|
* Sets the authorization token that should be used for requests
|
||||||
|
* @param token The authorization token to use
|
||||||
|
*/
|
||||||
|
setToken(token: string): this;
|
||||||
|
/**
|
||||||
|
* Queues a request to be sent
|
||||||
|
* @param request All the information needed to make a request
|
||||||
|
* @returns The response from the api request
|
||||||
|
*/
|
||||||
|
queueRequest(request: InternalRequest): Promise<unknown>;
|
||||||
|
/**
|
||||||
|
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
||||||
|
* @param hash The hash for the route
|
||||||
|
* @param majorParameter The major parameter for this handler
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
private createHandler;
|
||||||
|
/**
|
||||||
|
* Formats the request data to a usable format for fetch
|
||||||
|
* @param request The request data
|
||||||
|
*/
|
||||||
|
private resolveRequest;
|
||||||
|
/**
|
||||||
|
* Stops the hash sweeping interval
|
||||||
|
*/
|
||||||
|
clearHashSweeper(): void;
|
||||||
|
/**
|
||||||
|
* Stops the request handler sweeping interval
|
||||||
|
*/
|
||||||
|
clearHandlerSweeper(): void;
|
||||||
|
/**
|
||||||
|
* Generates route data for an endpoint:method
|
||||||
|
* @param endpoint The raw endpoint to generalize
|
||||||
|
* @param method The HTTP method this endpoint is called without
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
private static generateRouteData;
|
||||||
|
}
|
52
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.d.ts
generated
vendored
Normal file
52
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
import type { InternalRequest, RawFile } from '../RequestManager';
|
||||||
|
interface DiscordErrorFieldInformation {
|
||||||
|
code: string;
|
||||||
|
message: string;
|
||||||
|
}
|
||||||
|
interface DiscordErrorGroupWrapper {
|
||||||
|
_errors: DiscordError[];
|
||||||
|
}
|
||||||
|
declare type DiscordError = DiscordErrorGroupWrapper | DiscordErrorFieldInformation | {
|
||||||
|
[k: string]: DiscordError;
|
||||||
|
} | string;
|
||||||
|
export interface DiscordErrorData {
|
||||||
|
code: number;
|
||||||
|
message: string;
|
||||||
|
errors?: DiscordError;
|
||||||
|
}
|
||||||
|
export interface OAuthErrorData {
|
||||||
|
error: string;
|
||||||
|
error_description?: string;
|
||||||
|
}
|
||||||
|
export interface RequestBody {
|
||||||
|
files: RawFile[] | undefined;
|
||||||
|
json: unknown | undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Represents an API error returned by Discord
|
||||||
|
* @extends Error
|
||||||
|
*/
|
||||||
|
export declare class DiscordAPIError extends Error {
|
||||||
|
rawError: DiscordErrorData | OAuthErrorData;
|
||||||
|
code: number | string;
|
||||||
|
status: number;
|
||||||
|
method: string;
|
||||||
|
url: string;
|
||||||
|
requestBody: RequestBody;
|
||||||
|
/**
|
||||||
|
* @param rawError The error reported by Discord
|
||||||
|
* @param code The error code reported by Discord
|
||||||
|
* @param status The status code of the response
|
||||||
|
* @param method The method of the request that erred
|
||||||
|
* @param url The url of the request that erred
|
||||||
|
* @param bodyData The unparsed data for the request that errored
|
||||||
|
*/
|
||||||
|
constructor(rawError: DiscordErrorData | OAuthErrorData, code: number | string, status: number, method: string, url: string, bodyData: Pick<InternalRequest, 'files' | 'body'>);
|
||||||
|
/**
|
||||||
|
* The name of the error
|
||||||
|
*/
|
||||||
|
get name(): string;
|
||||||
|
private static getMessage;
|
||||||
|
private static flattenDiscordError;
|
||||||
|
}
|
||||||
|
export {};
|
21
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.d.ts
generated
vendored
Normal file
21
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import type { InternalRequest } from '../RequestManager';
|
||||||
|
import type { RequestBody } from './DiscordAPIError';
|
||||||
|
/**
|
||||||
|
* Represents a HTTP error
|
||||||
|
*/
|
||||||
|
export declare class HTTPError extends Error {
|
||||||
|
name: string;
|
||||||
|
status: number;
|
||||||
|
method: string;
|
||||||
|
url: string;
|
||||||
|
requestBody: RequestBody;
|
||||||
|
/**
|
||||||
|
* @param message The error message
|
||||||
|
* @param name The name of the error
|
||||||
|
* @param status The status code of the response
|
||||||
|
* @param method The method of the request that erred
|
||||||
|
* @param url The url of the request that erred
|
||||||
|
* @param bodyData The unparsed data for the request that errored
|
||||||
|
*/
|
||||||
|
constructor(message: string, name: string, status: number, method: string, url: string, bodyData: Pick<InternalRequest, 'files' | 'body'>);
|
||||||
|
}
|
16
node_modules/@discordjs/rest/dist/lib/errors/RateLimitError.d.ts
generated
vendored
Normal file
16
node_modules/@discordjs/rest/dist/lib/errors/RateLimitError.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import type { RateLimitData } from '../REST';
|
||||||
|
export declare class RateLimitError extends Error implements RateLimitData {
|
||||||
|
timeToReset: number;
|
||||||
|
limit: number;
|
||||||
|
method: string;
|
||||||
|
hash: string;
|
||||||
|
url: string;
|
||||||
|
route: string;
|
||||||
|
majorParameter: string;
|
||||||
|
global: boolean;
|
||||||
|
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global }: RateLimitData);
|
||||||
|
/**
|
||||||
|
* The name of the error
|
||||||
|
*/
|
||||||
|
get name(): string;
|
||||||
|
}
|
7
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.d.ts
generated
vendored
Normal file
7
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import type { RequestInit } from 'node-fetch';
|
||||||
|
import type { InternalRequest, RouteData } from '../RequestManager';
|
||||||
|
export interface IHandler {
|
||||||
|
queueRequest: (routeId: RouteData, url: string, options: RequestInit, bodyData: Pick<InternalRequest, 'files' | 'body'>) => Promise<unknown>;
|
||||||
|
readonly inactive: boolean;
|
||||||
|
readonly id: string;
|
||||||
|
}
|
82
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.d.ts
generated
vendored
Normal file
82
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
import { RequestInit } from 'node-fetch';
|
||||||
|
import type { InternalRequest, RequestManager, RouteData } from '../RequestManager';
|
||||||
|
/**
|
||||||
|
* The structure used to handle requests for a given bucket
|
||||||
|
*/
|
||||||
|
export declare class SequentialHandler {
|
||||||
|
#private;
|
||||||
|
private readonly manager;
|
||||||
|
private readonly hash;
|
||||||
|
private readonly majorParameter;
|
||||||
|
/**
|
||||||
|
* The unique id of the handler
|
||||||
|
*/
|
||||||
|
readonly id: string;
|
||||||
|
/**
|
||||||
|
* The time this rate limit bucket will reset
|
||||||
|
*/
|
||||||
|
private reset;
|
||||||
|
/**
|
||||||
|
* The remaining requests that can be made before we are rate limited
|
||||||
|
*/
|
||||||
|
private remaining;
|
||||||
|
/**
|
||||||
|
* The total number of requests that can be made before we are rate limited
|
||||||
|
*/
|
||||||
|
private limit;
|
||||||
|
/**
|
||||||
|
* @param manager The request manager
|
||||||
|
* @param hash The hash that this RequestHandler handles
|
||||||
|
* @param majorParameter The major parameter for this handler
|
||||||
|
*/
|
||||||
|
constructor(manager: RequestManager, hash: string, majorParameter: string);
|
||||||
|
/**
|
||||||
|
* If the bucket is currently inactive (no pending requests)
|
||||||
|
*/
|
||||||
|
get inactive(): boolean;
|
||||||
|
/**
|
||||||
|
* If the rate limit bucket is currently limited by the global limit
|
||||||
|
*/
|
||||||
|
private get globalLimited();
|
||||||
|
/**
|
||||||
|
* If the rate limit bucket is currently limited by its limit
|
||||||
|
*/
|
||||||
|
private get localLimited();
|
||||||
|
/**
|
||||||
|
* If the rate limit bucket is currently limited
|
||||||
|
*/
|
||||||
|
private get limited();
|
||||||
|
/**
|
||||||
|
* The time until queued requests can continue
|
||||||
|
*/
|
||||||
|
private get timeToReset();
|
||||||
|
/**
|
||||||
|
* Emits a debug message
|
||||||
|
* @param message The message to debug
|
||||||
|
*/
|
||||||
|
private debug;
|
||||||
|
/**
|
||||||
|
* Delay all requests for the specified amount of time, handling global rate limits
|
||||||
|
* @param time The amount of time to delay all requests for
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
private globalDelayFor;
|
||||||
|
private onRateLimit;
|
||||||
|
/**
|
||||||
|
* Queues a request to be sent
|
||||||
|
* @param routeId The generalized api route with literal ids for major parameters
|
||||||
|
* @param url The url to do the request on
|
||||||
|
* @param options All the information needed to make a request
|
||||||
|
* @param bodyData The data that was used to form the body, passed to any errors generated and for determining whether to sublimit
|
||||||
|
*/
|
||||||
|
queueRequest(routeId: RouteData, url: string, options: RequestInit, bodyData: Pick<InternalRequest, 'files' | 'body'>): Promise<unknown>;
|
||||||
|
/**
|
||||||
|
* The method that actually makes the request to the api, and updates info about the bucket accordingly
|
||||||
|
* @param routeId The generalized api route with literal ids for major parameters
|
||||||
|
* @param url The fully resolved url to make the request to
|
||||||
|
* @param options The node-fetch options needed to make the request
|
||||||
|
* @param bodyData The data that was used to form the body, passed to any errors generated
|
||||||
|
* @param retries The number of retries this request has already attempted (recursion)
|
||||||
|
*/
|
||||||
|
private runRequest;
|
||||||
|
}
|
21
node_modules/@discordjs/rest/dist/lib/utils/constants.d.ts
generated
vendored
Normal file
21
node_modules/@discordjs/rest/dist/lib/utils/constants.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import type { RESTOptions } from '../REST';
|
||||||
|
export declare const DefaultUserAgent: string;
|
||||||
|
export declare const DefaultRestOptions: Required<RESTOptions>;
|
||||||
|
/**
|
||||||
|
* The events that the REST manager emits
|
||||||
|
*/
|
||||||
|
export declare const enum RESTEvents {
|
||||||
|
Debug = "restDebug",
|
||||||
|
InvalidRequestWarning = "invalidRequestWarning",
|
||||||
|
RateLimited = "rateLimited",
|
||||||
|
Request = "request",
|
||||||
|
Response = "response",
|
||||||
|
HashSweep = "hashSweep",
|
||||||
|
HandlerSweep = "handlerSweep"
|
||||||
|
}
|
||||||
|
export declare const ALLOWED_EXTENSIONS: readonly ["webp", "png", "jpg", "jpeg", "gif"];
|
||||||
|
export declare const ALLOWED_STICKER_EXTENSIONS: readonly ["png", "json"];
|
||||||
|
export declare const ALLOWED_SIZES: readonly [16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
|
||||||
|
export declare type ImageExtension = typeof ALLOWED_EXTENSIONS[number];
|
||||||
|
export declare type StickerExtension = typeof ALLOWED_STICKER_EXTENSIONS[number];
|
||||||
|
export declare type ImageSize = typeof ALLOWED_SIZES[number];
|
14
node_modules/@discordjs/rest/dist/lib/utils/utils.d.ts
generated
vendored
Normal file
14
node_modules/@discordjs/rest/dist/lib/utils/utils.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import type { Response } from 'node-fetch';
|
||||||
|
/**
|
||||||
|
* Converts the response to usable data
|
||||||
|
* @param res The node-fetch response
|
||||||
|
*/
|
||||||
|
export declare function parseResponse(res: Response): Promise<unknown>;
|
||||||
|
/**
|
||||||
|
* Check whether a request falls under a sublimit
|
||||||
|
* @param bucketRoute The buckets route identifier
|
||||||
|
* @param body The options provided as JSON data
|
||||||
|
* @param method The HTTP method that will be used to make the request
|
||||||
|
* @returns Whether the request falls under a sublimit
|
||||||
|
*/
|
||||||
|
export declare function hasSublimit(bucketRoute: string, body?: unknown, method?: string): boolean;
|
1
node_modules/@discordjs/rest/docs/README.md
generated
vendored
Normal file
1
node_modules/@discordjs/rest/docs/README.md
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
## [View the documentation here.](https://discord.js.org/#/docs/rest)
|
5
node_modules/@discordjs/rest/docs/index.yml
generated
vendored
Normal file
5
node_modules/@discordjs/rest/docs/index.yml
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
- name: General
|
||||||
|
files:
|
||||||
|
- name: Welcome
|
||||||
|
id: welcome
|
||||||
|
path: ../../README.md
|
89
node_modules/@discordjs/rest/package.json
generated
vendored
Normal file
89
node_modules/@discordjs/rest/package.json
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
{
|
||||||
|
"name": "@discordjs/rest",
|
||||||
|
"version": "0.3.0",
|
||||||
|
"description": "The REST API for discord.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsup && tsc --emitDeclarationOnly --incremental",
|
||||||
|
"test": "jest --pass-with-no-tests --collect-coverage",
|
||||||
|
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
||||||
|
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
|
||||||
|
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs",
|
||||||
|
"prepublishOnly": "yarn build && yarn lint && yarn test",
|
||||||
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/rest/*'"
|
||||||
|
},
|
||||||
|
"main": "./dist/index.js",
|
||||||
|
"module": "./dist/index.mjs",
|
||||||
|
"typings": "./dist/index.d.ts",
|
||||||
|
"exports": {
|
||||||
|
"import": "./dist/index.mjs",
|
||||||
|
"require": "./dist/index.js"
|
||||||
|
},
|
||||||
|
"directories": {
|
||||||
|
"lib": "src",
|
||||||
|
"test": "__tests__"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"contributors": [
|
||||||
|
"Crawl <icrawltogo@gmail.com>",
|
||||||
|
"Amish Shah <amishshah.2k@gmail.com>",
|
||||||
|
"SpaceEEC <spaceeec@yahoo.com>",
|
||||||
|
"Vlad Frangu <kingdgrizzle@gmail.com>",
|
||||||
|
"Antonio Roman <kyradiscord@gmail.com>"
|
||||||
|
],
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"keywords": [
|
||||||
|
"discord",
|
||||||
|
"api",
|
||||||
|
"rest",
|
||||||
|
"discordapp",
|
||||||
|
"discordjs"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/discordjs/discord.js.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/discordjs/discord.js/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://discord.js.org",
|
||||||
|
"dependencies": {
|
||||||
|
"@discordjs/collection": "^0.4.0",
|
||||||
|
"@sapphire/async-queue": "^1.1.9",
|
||||||
|
"@sapphire/snowflake": "^3.0.1",
|
||||||
|
"discord-api-types": "^0.26.1",
|
||||||
|
"form-data": "^4.0.0",
|
||||||
|
"node-fetch": "^2.6.5",
|
||||||
|
"tslib": "^2.3.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.16.12",
|
||||||
|
"@babel/plugin-proposal-decorators": "^7.16.7",
|
||||||
|
"@babel/preset-env": "^7.16.11",
|
||||||
|
"@babel/preset-typescript": "^7.16.7",
|
||||||
|
"@discordjs/ts-docgen": "^0.3.4",
|
||||||
|
"@types/jest": "^27.4.0",
|
||||||
|
"@types/node-fetch": "^2.5.10",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
||||||
|
"@typescript-eslint/parser": "^5.10.0",
|
||||||
|
"babel-plugin-const-enum": "^1.2.0",
|
||||||
|
"babel-plugin-transform-typescript-metadata": "^0.3.2",
|
||||||
|
"eslint": "^8.7.0",
|
||||||
|
"eslint-config-marine": "^9.3.2",
|
||||||
|
"eslint-config-prettier": "^8.3.0",
|
||||||
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"jest": "^27.4.7",
|
||||||
|
"nock": "^13.2.2",
|
||||||
|
"prettier": "^2.5.1",
|
||||||
|
"tsup": "^5.11.11",
|
||||||
|
"typedoc": "^0.22.11",
|
||||||
|
"typescript": "^4.5.5"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.9.0"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
}
|
||||||
|
}
|
24
node_modules/@sapphire/async-queue/LICENSE.md
generated
vendored
Normal file
24
node_modules/@sapphire/async-queue/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# 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.
|
92
node_modules/@sapphire/async-queue/README.md
generated
vendored
Normal file
92
node_modules/@sapphire/async-queue/README.md
generated
vendored
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
# @sapphire/async-queue
|
||||||
|
|
||||||
|
**Sequential asynchronous lock-based queue for promises.**
|
||||||
|
|
||||||
|
[](https://github.com/sapphiredev/utilities/blob/main/LICENSE.md)
|
||||||
|
[](https://codecov.io/gh/sapphiredev/utilities)
|
||||||
|
[](https://bundlephobia.com/result?p=@sapphire/async-queue)
|
||||||
|
[](https://www.npmjs.com/package/@sapphire/async-queue)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
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
|
||||||
|
- Offers CommonJS, ESM and UMD bundles
|
||||||
|
- Fully tested
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
You can use the following command to install this package, or replace `npm install` with your package manager of choice.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install @sapphire/async-queue
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Buy us some doughnuts
|
||||||
|
|
||||||
|
Sapphire Community is and always will be open source, even if we don't get donations. That being said, we know there are amazing people who may still want to donate just to show their appreciation. Thank you very much in advance!
|
||||||
|
|
||||||
|
We accept donations through Open Collective, Ko-fi, PayPal, Patreon and GitHub Sponsorships. You can use the buttons below to donate through your method of choice.
|
||||||
|
|
||||||
|
| Donate With | Address |
|
||||||
|
| :-------------: | :-------------------------------------------------: |
|
||||||
|
| Open Collective | [Click Here](https://sapphirejs.dev/opencollective) |
|
||||||
|
| Ko-fi | [Click Here](https://sapphirejs.dev/kofi) |
|
||||||
|
| Patreon | [Click Here](https://sapphirejs.dev/patreon) |
|
||||||
|
| PayPal | [Click Here](https://sapphirejs.dev/paypal) |
|
||||||
|
|
||||||
|
## Contributors ✨
|
||||||
|
|
||||||
|
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
||||||
|
|
||||||
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
||||||
|
<!-- prettier-ignore-start -->
|
||||||
|
<!-- 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://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>
|
||||||
|
<td align="center"><a href="https://github.com/Stitch07"><img src="https://avatars0.githubusercontent.com/u/29275227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stitch07</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Stitch07" title="Code">💻</a> <a href="#projectManagement-Stitch07" title="Project Management">📆</a> <a href="https://github.com/sapphiredev/utilities/commits?author=Stitch07" title="Tests">⚠️</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/apps/depfu"><img src="https://avatars3.githubusercontent.com/in/715?v=4?s=100" width="100px;" alt=""/><br /><sub><b>depfu[bot]</b></sub></a><br /><a href="#maintenance-depfu[bot]" title="Maintenance">🚧</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/apps/allcontributors"><img src="https://avatars0.githubusercontent.com/in/23186?v=4?s=100" width="100px;" alt=""/><br /><sub><b>allcontributors[bot]</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=allcontributors[bot]" title="Documentation">📖</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars1.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Nytelife26" title="Documentation">📖</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/Alcremie"><img src="https://avatars0.githubusercontent.com/u/54785334?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ivan Lieder</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Alcremie" title="Code">💻</a> <a href="https://github.com/sapphiredev/utilities/issues?q=author%3AAlcremie" title="Bug reports">🐛</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/RealShadowNova"><img src="https://avatars3.githubusercontent.com/u/46537907?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hezekiah Hendry</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=RealShadowNova" title="Code">💻</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/Vetlix"><img src="https://avatars.githubusercontent.com/u/31412314?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vetlix</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Vetlix" title="Code">💻</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/ethamitc"><img src="https://avatars.githubusercontent.com/u/27776796?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ethan Mitchell</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=ethamitc" title="Documentation">📖</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/noftaly"><img src="https://avatars.githubusercontent.com/u/34779161?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Elliot</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=noftaly" title="Code">💻</a></td>
|
||||||
|
<td align="center"><a href="https://jurien.dev"><img src="https://avatars.githubusercontent.com/u/5418114?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jurien Hamaker</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=jurienhamaker" title="Code">💻</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center"><a href="https://fanoulis.dev/"><img src="https://avatars.githubusercontent.com/u/38255093?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Charalampos Fanoulis</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=cfanoulis" title="Documentation">📖</a></td>
|
||||||
|
<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://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>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- markdownlint-restore -->
|
||||||
|
<!-- prettier-ignore-end -->
|
||||||
|
|
||||||
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
||||||
|
|
||||||
|
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
2
node_modules/@sapphire/async-queue/dist/index.d.ts
generated
vendored
Normal file
2
node_modules/@sapphire/async-queue/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export * from './lib/AsyncQueue';
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
1
node_modules/@sapphire/async-queue/dist/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@sapphire/async-queue/dist/index.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
70
node_modules/@sapphire/async-queue/dist/index.js
generated
vendored
Normal file
70
node_modules/@sapphire/async-queue/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
node_modules/@sapphire/async-queue/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@sapphire/async-queue/dist/index.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.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":";;;;AAAA;;;MAGa,UAAU;IAAvB;;;;QAWC;;;;mBAAwD,EAAE;WAAC;KA6C3D;;;;IApDA,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;KAC5B;;;;;;;;;;;;;;;;;;;;;;IA4BM,IAAI;QACV,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;QACxG,IAAI,OAAmB,CAAC;QACxB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,GAAG;YACrC,OAAO,GAAG,GAAG,CAAC;SACd,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAClB,OAAO,EAAE,OAAQ;YACjB,OAAO;SACP,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;KACZ;;;;IAKM,KAAK;QACX,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,OAAO,QAAQ,KAAK,WAAW;YAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;KACxD;;;;;"}
|
66
node_modules/@sapphire/async-queue/dist/index.mjs
generated
vendored
Normal file
66
node_modules/@sapphire/async-queue/dist/index.mjs
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { AsyncQueue };
|
||||||
|
//# sourceMappingURL=index.mjs.map
|
1
node_modules/@sapphire/async-queue/dist/index.mjs.map
generated
vendored
Normal file
1
node_modules/@sapphire/async-queue/dist/index.mjs.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.mjs","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":"AAAA;;;MAGa,UAAU;IAAvB;;;;QAWC;;;;mBAAwD,EAAE;WAAC;KA6C3D;;;;IApDA,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;KAC5B;;;;;;;;;;;;;;;;;;;;;;IA4BM,IAAI;QACV,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;QACxG,IAAI,OAAmB,CAAC;QACxB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,GAAG;YACrC,OAAO,GAAG,GAAG,CAAC;SACd,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAClB,OAAO,EAAE,OAAQ;YACjB,OAAO;SACP,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;KACZ;;;;IAKM,KAAK;QACX,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,OAAO,QAAQ,KAAK,WAAW;YAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;KACxD;;;;;"}
|
76
node_modules/@sapphire/async-queue/dist/index.umd.js
generated
vendored
Normal file
76
node_modules/@sapphire/async-queue/dist/index.umd.js
generated
vendored
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
(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
Normal file
1
node_modules/@sapphire/async-queue/dist/index.umd.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"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
Normal file
40
node_modules/@sapphire/async-queue/dist/lib/AsyncQueue.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/**
|
||||||
|
* 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
Normal file
1
node_modules/@sapphire/async-queue/dist/lib/AsyncQueue.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"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"}
|
56
node_modules/@sapphire/async-queue/package.json
generated
vendored
Normal file
56
node_modules/@sapphire/async-queue/package.json
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
24
node_modules/@sapphire/snowflake/LICENSE.md
generated
vendored
Normal file
24
node_modules/@sapphire/snowflake/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# 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.
|
219
node_modules/@sapphire/snowflake/README.md
generated
vendored
Normal file
219
node_modules/@sapphire/snowflake/README.md
generated
vendored
Normal file
|
@ -0,0 +1,219 @@
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
# @sapphire/snowflake
|
||||||
|
|
||||||
|
**Deconstruct and generate snowflake IDs using BigInts.**
|
||||||
|
|
||||||
|
[](https://github.com/sapphiredev/utilities/blob/main/LICENSE.md)
|
||||||
|
[](https://codecov.io/gh/sapphiredev/utilities)
|
||||||
|
[](https://bundlephobia.com/result?p=@sapphire/snowflake)
|
||||||
|
[](https://www.npmjs.com/package/@sapphire/snowflake)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
**Table of Contents**
|
||||||
|
|
||||||
|
- [Description](#description)
|
||||||
|
- [Features](#features)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Usage](#usage)
|
||||||
|
- [Constructing snowflakes](#constructing-snowflakes)
|
||||||
|
- [Snowflakes with custom epoch](#snowflakes-with-custom-epoch)
|
||||||
|
- [Snowflake with Discord epoch constant](#snowflake-with-discord-epoch-constant)
|
||||||
|
- [Snowflake with Twitter epoch constant](#snowflake-with-twitter-epoch-constant)
|
||||||
|
- [Deconstructing snowflakes](#deconstructing-snowflakes)
|
||||||
|
- [Snowflakes with custom epoch](#snowflakes-with-custom-epoch-1)
|
||||||
|
- [Snowflake with Discord epoch constant](#snowflake-with-discord-epoch-constant-1)
|
||||||
|
- [Snowflake with Twitter epoch constant](#snowflake-with-twitter-epoch-constant-1)
|
||||||
|
- [Buy us some doughnuts](#buy-us-some-doughnuts)
|
||||||
|
- [Contributors ✨](#contributors-%E2%9C%A8)
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
There is often a need to get a unique ID for entities, be that for Discord messages/channels/servers, keys in a database or many other similar examples. There are many ways to get such a unique ID, and one of those is using a so-called "snowflake". You can read more about snowflake IDs in [this Medium article](https://medium.com/better-programming/uuid-generation-snowflake-identifiers-unique-2aed8b1771bc).
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Written in TypeScript
|
||||||
|
- Bundled with Rollup so it can be used in NodeJS and browsers
|
||||||
|
- Offers CommonJS, ESM and UMD bundles
|
||||||
|
- Offers predefined epochs for Discord and Twitter
|
||||||
|
- Fully tested
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
You can use the following command to install this package, or replace `npm install` with your package manager of choice.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install @sapphire/snowflake
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
**Note:** While this section uses `require`, the imports match 1:1 with ESM imports. For example `const { Snowflake } = require('@sapphire/snowflake')` equals `import { Snowflake } from '@sapphire/snowflake'`.
|
||||||
|
|
||||||
|
### Constructing snowflakes
|
||||||
|
|
||||||
|
#### Snowflakes with custom epoch
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Import the Snowflake class
|
||||||
|
const { Snowflake } = require('@sapphire/snowflake');
|
||||||
|
|
||||||
|
// Define a custom epoch
|
||||||
|
const epoch = new Date('2000-01-01T00:00:00.000Z');
|
||||||
|
|
||||||
|
// Create an instance of Snowflake
|
||||||
|
const snowflake = new Snowflake(epoch);
|
||||||
|
|
||||||
|
// Generate a snowflake with the given epoch
|
||||||
|
const uniqueId = snowflake.generate();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Snowflake with Discord epoch constant
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Import the Snowflake class
|
||||||
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
|
|
||||||
|
// Create an instance of Snowflake
|
||||||
|
const discordSnowflake = new DiscordSnowflake();
|
||||||
|
|
||||||
|
// Generate a snowflake with Discord's epoch
|
||||||
|
const uniqueId = discordSnowflake.generate();
|
||||||
|
|
||||||
|
// Alternatively, you can use the method directly
|
||||||
|
const uniqueId = DiscordSnowflake.generate();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Snowflake with Twitter epoch constant
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Import the Snowflake class
|
||||||
|
const { TwitterSnowflake } = require('@sapphire/snowflake');
|
||||||
|
|
||||||
|
// Create an instance of Snowflake
|
||||||
|
const twitterSnowflake = new TwitterSnowflake();
|
||||||
|
|
||||||
|
// Generate a snowflake with Twitter's epoch
|
||||||
|
const uniqueId = twitterSnowflake.generate();
|
||||||
|
|
||||||
|
// Alternatively, you can use the method directly
|
||||||
|
const uniqueId = TwitterSnowflake.generate();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Deconstructing snowflakes
|
||||||
|
|
||||||
|
#### Snowflakes with custom epoch
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Import the Snowflake class
|
||||||
|
const { Snowflake } = require('@sapphire/snowflake');
|
||||||
|
|
||||||
|
// Define a custom epoch
|
||||||
|
const epoch = new Date('2000-01-01T00:00:00.000Z');
|
||||||
|
|
||||||
|
// Create an instance of Snowflake
|
||||||
|
const snowflake = new Snowflake(epoch);
|
||||||
|
|
||||||
|
// Deconstruct a snowflake with the given epoch
|
||||||
|
const uniqueId = snowflake.deconstruct('3971046231244935168');
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Snowflake with Discord epoch constant
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Import the Snowflake class
|
||||||
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
|
|
||||||
|
// Create an instance of Snowflake
|
||||||
|
const discordSnowflake = new DiscordSnowflake();
|
||||||
|
|
||||||
|
// Deconstruct a snowflake with Discord's epoch
|
||||||
|
const uniqueId = discordSnowflake.deconstruct('3971046231244935168');
|
||||||
|
|
||||||
|
// Alternatively, you can use the method directly
|
||||||
|
const uniqueId = DiscordSnowflake.deconstruct('3971046231244935168');
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Snowflake with Twitter epoch constant
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Import the Snowflake class
|
||||||
|
const { TwitterSnowflake } = require('@sapphire/snowflake');
|
||||||
|
|
||||||
|
// Create an instance of Snowflake
|
||||||
|
const twitterSnowflake = new TwitterSnowflake();
|
||||||
|
|
||||||
|
// Deconstruct a snowflake with Twitter's epoch
|
||||||
|
const uniqueId = twitterSnowflake.deconstruct('3971046231244935168');
|
||||||
|
|
||||||
|
// Alternatively, you can use the method directly
|
||||||
|
const uniqueId = TwitterSnowflake.deconstruct('3971046231244935168');
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Buy us some doughnuts
|
||||||
|
|
||||||
|
Sapphire Community is and always will be open source, even if we don't get donations. That being said, we know there are amazing people who may still want to donate just to show their appreciation. Thank you very much in advance!
|
||||||
|
|
||||||
|
We accept donations through Open Collective, Ko-fi, PayPal, Patreon and GitHub Sponsorships. You can use the buttons below to donate through your method of choice.
|
||||||
|
|
||||||
|
| Donate With | Address |
|
||||||
|
| :-------------: | :-------------------------------------------------: |
|
||||||
|
| Open Collective | [Click Here](https://sapphirejs.dev/opencollective) |
|
||||||
|
| Ko-fi | [Click Here](https://sapphirejs.dev/kofi) |
|
||||||
|
| Patreon | [Click Here](https://sapphirejs.dev/patreon) |
|
||||||
|
| PayPal | [Click Here](https://sapphirejs.dev/paypal) |
|
||||||
|
|
||||||
|
## Contributors ✨
|
||||||
|
|
||||||
|
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
||||||
|
|
||||||
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
||||||
|
<!-- prettier-ignore-start -->
|
||||||
|
<!-- 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://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>
|
||||||
|
<td align="center"><a href="https://github.com/Stitch07"><img src="https://avatars0.githubusercontent.com/u/29275227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stitch07</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Stitch07" title="Code">💻</a> <a href="#projectManagement-Stitch07" title="Project Management">📆</a> <a href="https://github.com/sapphiredev/utilities/commits?author=Stitch07" title="Tests">⚠️</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/apps/depfu"><img src="https://avatars3.githubusercontent.com/in/715?v=4?s=100" width="100px;" alt=""/><br /><sub><b>depfu[bot]</b></sub></a><br /><a href="#maintenance-depfu[bot]" title="Maintenance">🚧</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/apps/allcontributors"><img src="https://avatars0.githubusercontent.com/in/23186?v=4?s=100" width="100px;" alt=""/><br /><sub><b>allcontributors[bot]</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=allcontributors[bot]" title="Documentation">📖</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars1.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Nytelife26" title="Documentation">📖</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/Alcremie"><img src="https://avatars0.githubusercontent.com/u/54785334?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ivan Lieder</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Alcremie" title="Code">💻</a> <a href="https://github.com/sapphiredev/utilities/issues?q=author%3AAlcremie" title="Bug reports">🐛</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/RealShadowNova"><img src="https://avatars3.githubusercontent.com/u/46537907?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hezekiah Hendry</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=RealShadowNova" title="Code">💻</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/Vetlix"><img src="https://avatars.githubusercontent.com/u/31412314?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vetlix</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Vetlix" title="Code">💻</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/ethamitc"><img src="https://avatars.githubusercontent.com/u/27776796?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ethan Mitchell</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=ethamitc" title="Documentation">📖</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/noftaly"><img src="https://avatars.githubusercontent.com/u/34779161?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Elliot</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=noftaly" title="Code">💻</a></td>
|
||||||
|
<td align="center"><a href="https://jurien.dev"><img src="https://avatars.githubusercontent.com/u/5418114?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jurien Hamaker</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=jurienhamaker" title="Code">💻</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center"><a href="https://fanoulis.dev/"><img src="https://avatars.githubusercontent.com/u/38255093?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Charalampos Fanoulis</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=cfanoulis" title="Documentation">📖</a></td>
|
||||||
|
<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://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> <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>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- markdownlint-restore -->
|
||||||
|
<!-- prettier-ignore-end -->
|
||||||
|
|
||||||
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
||||||
|
|
||||||
|
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
4
node_modules/@sapphire/snowflake/dist/index.d.ts
generated
vendored
Normal file
4
node_modules/@sapphire/snowflake/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export * from './lib/DiscordSnowflake';
|
||||||
|
export * from './lib/Snowflake';
|
||||||
|
export * from './lib/TwitterSnowflake';
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
1
node_modules/@sapphire/snowflake/dist/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@sapphire/snowflake/dist/index.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}
|
162
node_modules/@sapphire/snowflake/dist/index.js
generated
vendored
Normal file
162
node_modules/@sapphire/snowflake/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
|
||||||
|
/*! *****************************************************************************
|
||||||
|
Copyright (c) Microsoft Corporation.
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
***************************************************************************** */
|
||||||
|
|
||||||
|
function __classPrivateFieldGet(receiver, state, kind, f) {
|
||||||
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||||
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||||
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
||||||
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
||||||
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
||||||
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
||||||
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
||||||
|
}
|
||||||
|
|
||||||
|
var _Snowflake_increment, _Snowflake_epoch;
|
||||||
|
const ProcessId = 1n;
|
||||||
|
const WorkerId = 0n;
|
||||||
|
/**
|
||||||
|
* A class for generating and deconstructing Twitter snowflakes.
|
||||||
|
*
|
||||||
|
* A {@link https://developer.twitter.com/en/docs/twitter-ids Twitter snowflake}
|
||||||
|
* is a 64-bit unsigned integer with 4 fields that have a fixed epoch value.
|
||||||
|
*
|
||||||
|
* If we have a snowflake `266241948824764416` we can represent it as binary:
|
||||||
|
* ```
|
||||||
|
* 64 22 17 12 0
|
||||||
|
* 000000111011000111100001101001000101000000 00001 00000 000000000000
|
||||||
|
* number of ms since epoch worker pid increment
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
class Snowflake {
|
||||||
|
/**
|
||||||
|
* @param epoch the epoch to use
|
||||||
|
*/
|
||||||
|
constructor(epoch) {
|
||||||
|
/**
|
||||||
|
* Internal incrementor for generating snowflakes
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
_Snowflake_increment.set(this, 0n);
|
||||||
|
/**
|
||||||
|
* Internal reference of the epoch passed in the constructor
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
_Snowflake_epoch.set(this, void 0);
|
||||||
|
/**
|
||||||
|
* Alias for {@link deconstruct}
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/unbound-method, @typescript-eslint/no-invalid-this
|
||||||
|
Object.defineProperty(this, "decode", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
writable: true,
|
||||||
|
value: this.deconstruct
|
||||||
|
});
|
||||||
|
__classPrivateFieldSet(this, _Snowflake_epoch, BigInt(epoch instanceof Date ? epoch.getTime() : epoch), "f");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The epoch for this snowflake.
|
||||||
|
*/
|
||||||
|
get epoch() {
|
||||||
|
return __classPrivateFieldGet(this, _Snowflake_epoch, "f");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Generates a snowflake given an epoch and optionally a timestamp
|
||||||
|
* @param options options to pass into the generator, see {@link SnowflakeGenerateOptions}
|
||||||
|
*
|
||||||
|
* **note** when `increment` is not provided it defaults to the private `increment` of the instance
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const epoch = new Date('2000-01-01T00:00:00.000Z');
|
||||||
|
* const snowflake = new Snowflake(epoch).generate();
|
||||||
|
* ```
|
||||||
|
* @returns A unique snowflake
|
||||||
|
*/
|
||||||
|
generate({ increment, timestamp = Date.now(), workerId = WorkerId, processId = ProcessId } = {}) {
|
||||||
|
var _a, _b;
|
||||||
|
if (timestamp instanceof Date)
|
||||||
|
timestamp = BigInt(timestamp.getTime());
|
||||||
|
else if (typeof timestamp === 'number')
|
||||||
|
timestamp = BigInt(timestamp);
|
||||||
|
else if (typeof timestamp !== 'bigint') {
|
||||||
|
throw new TypeError(`"timestamp" argument must be a number, bigint, or Date (received ${typeof timestamp})`);
|
||||||
|
}
|
||||||
|
if (typeof increment === 'bigint' && increment >= 4095n)
|
||||||
|
increment = 0n;
|
||||||
|
else {
|
||||||
|
increment = (__classPrivateFieldSet(this, _Snowflake_increment, (_b = __classPrivateFieldGet(this, _Snowflake_increment, "f"), _a = _b++, _b), "f"), _a);
|
||||||
|
if (__classPrivateFieldGet(this, _Snowflake_increment, "f") >= 4095n)
|
||||||
|
__classPrivateFieldSet(this, _Snowflake_increment, 0n, "f");
|
||||||
|
}
|
||||||
|
// timestamp, workerId, processId, increment
|
||||||
|
return ((timestamp - __classPrivateFieldGet(this, _Snowflake_epoch, "f")) << 22n) | ((workerId & 31n) << 17n) | ((processId & 31n) << 12n) | increment;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Deconstructs a snowflake given a snowflake ID
|
||||||
|
* @param id the snowflake to deconstruct
|
||||||
|
* @returns a deconstructed snowflake
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const epoch = new Date('2000-01-01T00:00:00.000Z');
|
||||||
|
* const snowflake = new Snowflake(epoch).deconstruct('3971046231244935168');
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
deconstruct(id) {
|
||||||
|
const bigIntId = BigInt(id);
|
||||||
|
return {
|
||||||
|
id: bigIntId,
|
||||||
|
timestamp: (bigIntId >> 22n) + __classPrivateFieldGet(this, _Snowflake_epoch, "f"),
|
||||||
|
workerId: (bigIntId >> 17n) & 31n,
|
||||||
|
processId: (bigIntId >> 12n) & 31n,
|
||||||
|
increment: bigIntId & 4095n,
|
||||||
|
epoch: __classPrivateFieldGet(this, _Snowflake_epoch, "f")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Retrieves the timestamp field's value from a snowflake.
|
||||||
|
* @param id The snowflake to get the timestamp value from.
|
||||||
|
* @returns The UNIX timestamp that is stored in `id`.
|
||||||
|
*/
|
||||||
|
timestampFrom(id) {
|
||||||
|
return Number((BigInt(id) >> 22n) + __classPrivateFieldGet(this, _Snowflake_epoch, "f"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_Snowflake_increment = new WeakMap(), _Snowflake_epoch = new WeakMap();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class for parsing snowflake ids using Discord's snowflake epoch
|
||||||
|
*
|
||||||
|
* Which is 2015-01-01 at 00:00:00.000 UTC+0, {@linkplain https://discord.com/developers/docs/reference#snowflakes}
|
||||||
|
*/
|
||||||
|
const DiscordSnowflake = new Snowflake(1420070400000n);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class for parsing snowflake ids using Twitter's snowflake epoch
|
||||||
|
*
|
||||||
|
* Which is 2006-03-21 at 20:50:14.000 UTC+0, the time and date of the first tweet ever made {@linkplain https://twitter.com/jack/status/20}
|
||||||
|
*/
|
||||||
|
const TwitterSnowflake = new Snowflake(1142974214000n);
|
||||||
|
|
||||||
|
exports.DiscordSnowflake = DiscordSnowflake;
|
||||||
|
exports.Snowflake = Snowflake;
|
||||||
|
exports.TwitterSnowflake = TwitterSnowflake;
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
node_modules/@sapphire/snowflake/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@sapphire/snowflake/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
156
node_modules/@sapphire/snowflake/dist/index.mjs
generated
vendored
Normal file
156
node_modules/@sapphire/snowflake/dist/index.mjs
generated
vendored
Normal file
|
@ -0,0 +1,156 @@
|
||||||
|
/*! *****************************************************************************
|
||||||
|
Copyright (c) Microsoft Corporation.
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
***************************************************************************** */
|
||||||
|
|
||||||
|
function __classPrivateFieldGet(receiver, state, kind, f) {
|
||||||
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||||
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||||
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
||||||
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
||||||
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
||||||
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
||||||
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
||||||
|
}
|
||||||
|
|
||||||
|
var _Snowflake_increment, _Snowflake_epoch;
|
||||||
|
const ProcessId = 1n;
|
||||||
|
const WorkerId = 0n;
|
||||||
|
/**
|
||||||
|
* A class for generating and deconstructing Twitter snowflakes.
|
||||||
|
*
|
||||||
|
* A {@link https://developer.twitter.com/en/docs/twitter-ids Twitter snowflake}
|
||||||
|
* is a 64-bit unsigned integer with 4 fields that have a fixed epoch value.
|
||||||
|
*
|
||||||
|
* If we have a snowflake `266241948824764416` we can represent it as binary:
|
||||||
|
* ```
|
||||||
|
* 64 22 17 12 0
|
||||||
|
* 000000111011000111100001101001000101000000 00001 00000 000000000000
|
||||||
|
* number of ms since epoch worker pid increment
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
class Snowflake {
|
||||||
|
/**
|
||||||
|
* @param epoch the epoch to use
|
||||||
|
*/
|
||||||
|
constructor(epoch) {
|
||||||
|
/**
|
||||||
|
* Internal incrementor for generating snowflakes
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
_Snowflake_increment.set(this, 0n);
|
||||||
|
/**
|
||||||
|
* Internal reference of the epoch passed in the constructor
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
_Snowflake_epoch.set(this, void 0);
|
||||||
|
/**
|
||||||
|
* Alias for {@link deconstruct}
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/unbound-method, @typescript-eslint/no-invalid-this
|
||||||
|
Object.defineProperty(this, "decode", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
writable: true,
|
||||||
|
value: this.deconstruct
|
||||||
|
});
|
||||||
|
__classPrivateFieldSet(this, _Snowflake_epoch, BigInt(epoch instanceof Date ? epoch.getTime() : epoch), "f");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The epoch for this snowflake.
|
||||||
|
*/
|
||||||
|
get epoch() {
|
||||||
|
return __classPrivateFieldGet(this, _Snowflake_epoch, "f");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Generates a snowflake given an epoch and optionally a timestamp
|
||||||
|
* @param options options to pass into the generator, see {@link SnowflakeGenerateOptions}
|
||||||
|
*
|
||||||
|
* **note** when `increment` is not provided it defaults to the private `increment` of the instance
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const epoch = new Date('2000-01-01T00:00:00.000Z');
|
||||||
|
* const snowflake = new Snowflake(epoch).generate();
|
||||||
|
* ```
|
||||||
|
* @returns A unique snowflake
|
||||||
|
*/
|
||||||
|
generate({ increment, timestamp = Date.now(), workerId = WorkerId, processId = ProcessId } = {}) {
|
||||||
|
var _a, _b;
|
||||||
|
if (timestamp instanceof Date)
|
||||||
|
timestamp = BigInt(timestamp.getTime());
|
||||||
|
else if (typeof timestamp === 'number')
|
||||||
|
timestamp = BigInt(timestamp);
|
||||||
|
else if (typeof timestamp !== 'bigint') {
|
||||||
|
throw new TypeError(`"timestamp" argument must be a number, bigint, or Date (received ${typeof timestamp})`);
|
||||||
|
}
|
||||||
|
if (typeof increment === 'bigint' && increment >= 4095n)
|
||||||
|
increment = 0n;
|
||||||
|
else {
|
||||||
|
increment = (__classPrivateFieldSet(this, _Snowflake_increment, (_b = __classPrivateFieldGet(this, _Snowflake_increment, "f"), _a = _b++, _b), "f"), _a);
|
||||||
|
if (__classPrivateFieldGet(this, _Snowflake_increment, "f") >= 4095n)
|
||||||
|
__classPrivateFieldSet(this, _Snowflake_increment, 0n, "f");
|
||||||
|
}
|
||||||
|
// timestamp, workerId, processId, increment
|
||||||
|
return ((timestamp - __classPrivateFieldGet(this, _Snowflake_epoch, "f")) << 22n) | ((workerId & 31n) << 17n) | ((processId & 31n) << 12n) | increment;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Deconstructs a snowflake given a snowflake ID
|
||||||
|
* @param id the snowflake to deconstruct
|
||||||
|
* @returns a deconstructed snowflake
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const epoch = new Date('2000-01-01T00:00:00.000Z');
|
||||||
|
* const snowflake = new Snowflake(epoch).deconstruct('3971046231244935168');
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
deconstruct(id) {
|
||||||
|
const bigIntId = BigInt(id);
|
||||||
|
return {
|
||||||
|
id: bigIntId,
|
||||||
|
timestamp: (bigIntId >> 22n) + __classPrivateFieldGet(this, _Snowflake_epoch, "f"),
|
||||||
|
workerId: (bigIntId >> 17n) & 31n,
|
||||||
|
processId: (bigIntId >> 12n) & 31n,
|
||||||
|
increment: bigIntId & 4095n,
|
||||||
|
epoch: __classPrivateFieldGet(this, _Snowflake_epoch, "f")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Retrieves the timestamp field's value from a snowflake.
|
||||||
|
* @param id The snowflake to get the timestamp value from.
|
||||||
|
* @returns The UNIX timestamp that is stored in `id`.
|
||||||
|
*/
|
||||||
|
timestampFrom(id) {
|
||||||
|
return Number((BigInt(id) >> 22n) + __classPrivateFieldGet(this, _Snowflake_epoch, "f"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_Snowflake_increment = new WeakMap(), _Snowflake_epoch = new WeakMap();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class for parsing snowflake ids using Discord's snowflake epoch
|
||||||
|
*
|
||||||
|
* Which is 2015-01-01 at 00:00:00.000 UTC+0, {@linkplain https://discord.com/developers/docs/reference#snowflakes}
|
||||||
|
*/
|
||||||
|
const DiscordSnowflake = new Snowflake(1420070400000n);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class for parsing snowflake ids using Twitter's snowflake epoch
|
||||||
|
*
|
||||||
|
* Which is 2006-03-21 at 20:50:14.000 UTC+0, the time and date of the first tweet ever made {@linkplain https://twitter.com/jack/status/20}
|
||||||
|
*/
|
||||||
|
const TwitterSnowflake = new Snowflake(1142974214000n);
|
||||||
|
|
||||||
|
export { DiscordSnowflake, Snowflake, TwitterSnowflake };
|
||||||
|
//# sourceMappingURL=index.mjs.map
|
1
node_modules/@sapphire/snowflake/dist/index.mjs.map
generated
vendored
Normal file
1
node_modules/@sapphire/snowflake/dist/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
168
node_modules/@sapphire/snowflake/dist/index.umd.js
generated
vendored
Normal file
168
node_modules/@sapphire/snowflake/dist/index.umd.js
generated
vendored
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
(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.SapphireSnowflake = {}));
|
||||||
|
})(this, (function (exports) { 'use strict';
|
||||||
|
|
||||||
|
/*! *****************************************************************************
|
||||||
|
Copyright (c) Microsoft Corporation.
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
***************************************************************************** */
|
||||||
|
|
||||||
|
function __classPrivateFieldGet(receiver, state, kind, f) {
|
||||||
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||||
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||||
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
||||||
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
||||||
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
||||||
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
||||||
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
||||||
|
}
|
||||||
|
|
||||||
|
var _Snowflake_increment, _Snowflake_epoch;
|
||||||
|
const ProcessId = 1n;
|
||||||
|
const WorkerId = 0n;
|
||||||
|
/**
|
||||||
|
* A class for generating and deconstructing Twitter snowflakes.
|
||||||
|
*
|
||||||
|
* A {@link https://developer.twitter.com/en/docs/twitter-ids Twitter snowflake}
|
||||||
|
* is a 64-bit unsigned integer with 4 fields that have a fixed epoch value.
|
||||||
|
*
|
||||||
|
* If we have a snowflake `266241948824764416` we can represent it as binary:
|
||||||
|
* ```
|
||||||
|
* 64 22 17 12 0
|
||||||
|
* 000000111011000111100001101001000101000000 00001 00000 000000000000
|
||||||
|
* number of ms since epoch worker pid increment
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
class Snowflake {
|
||||||
|
/**
|
||||||
|
* @param epoch the epoch to use
|
||||||
|
*/
|
||||||
|
constructor(epoch) {
|
||||||
|
/**
|
||||||
|
* Internal incrementor for generating snowflakes
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
_Snowflake_increment.set(this, 0n);
|
||||||
|
/**
|
||||||
|
* Internal reference of the epoch passed in the constructor
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
_Snowflake_epoch.set(this, void 0);
|
||||||
|
/**
|
||||||
|
* Alias for {@link deconstruct}
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/unbound-method, @typescript-eslint/no-invalid-this
|
||||||
|
Object.defineProperty(this, "decode", {
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
writable: true,
|
||||||
|
value: this.deconstruct
|
||||||
|
});
|
||||||
|
__classPrivateFieldSet(this, _Snowflake_epoch, BigInt(epoch instanceof Date ? epoch.getTime() : epoch), "f");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The epoch for this snowflake.
|
||||||
|
*/
|
||||||
|
get epoch() {
|
||||||
|
return __classPrivateFieldGet(this, _Snowflake_epoch, "f");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Generates a snowflake given an epoch and optionally a timestamp
|
||||||
|
* @param options options to pass into the generator, see {@link SnowflakeGenerateOptions}
|
||||||
|
*
|
||||||
|
* **note** when `increment` is not provided it defaults to the private `increment` of the instance
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const epoch = new Date('2000-01-01T00:00:00.000Z');
|
||||||
|
* const snowflake = new Snowflake(epoch).generate();
|
||||||
|
* ```
|
||||||
|
* @returns A unique snowflake
|
||||||
|
*/
|
||||||
|
generate({ increment, timestamp = Date.now(), workerId = WorkerId, processId = ProcessId } = {}) {
|
||||||
|
var _a, _b;
|
||||||
|
if (timestamp instanceof Date)
|
||||||
|
timestamp = BigInt(timestamp.getTime());
|
||||||
|
else if (typeof timestamp === 'number')
|
||||||
|
timestamp = BigInt(timestamp);
|
||||||
|
else if (typeof timestamp !== 'bigint') {
|
||||||
|
throw new TypeError(`"timestamp" argument must be a number, bigint, or Date (received ${typeof timestamp})`);
|
||||||
|
}
|
||||||
|
if (typeof increment === 'bigint' && increment >= 4095n)
|
||||||
|
increment = 0n;
|
||||||
|
else {
|
||||||
|
increment = (__classPrivateFieldSet(this, _Snowflake_increment, (_b = __classPrivateFieldGet(this, _Snowflake_increment, "f"), _a = _b++, _b), "f"), _a);
|
||||||
|
if (__classPrivateFieldGet(this, _Snowflake_increment, "f") >= 4095n)
|
||||||
|
__classPrivateFieldSet(this, _Snowflake_increment, 0n, "f");
|
||||||
|
}
|
||||||
|
// timestamp, workerId, processId, increment
|
||||||
|
return ((timestamp - __classPrivateFieldGet(this, _Snowflake_epoch, "f")) << 22n) | ((workerId & 31n) << 17n) | ((processId & 31n) << 12n) | increment;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Deconstructs a snowflake given a snowflake ID
|
||||||
|
* @param id the snowflake to deconstruct
|
||||||
|
* @returns a deconstructed snowflake
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const epoch = new Date('2000-01-01T00:00:00.000Z');
|
||||||
|
* const snowflake = new Snowflake(epoch).deconstruct('3971046231244935168');
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
deconstruct(id) {
|
||||||
|
const bigIntId = BigInt(id);
|
||||||
|
return {
|
||||||
|
id: bigIntId,
|
||||||
|
timestamp: (bigIntId >> 22n) + __classPrivateFieldGet(this, _Snowflake_epoch, "f"),
|
||||||
|
workerId: (bigIntId >> 17n) & 31n,
|
||||||
|
processId: (bigIntId >> 12n) & 31n,
|
||||||
|
increment: bigIntId & 4095n,
|
||||||
|
epoch: __classPrivateFieldGet(this, _Snowflake_epoch, "f")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Retrieves the timestamp field's value from a snowflake.
|
||||||
|
* @param id The snowflake to get the timestamp value from.
|
||||||
|
* @returns The UNIX timestamp that is stored in `id`.
|
||||||
|
*/
|
||||||
|
timestampFrom(id) {
|
||||||
|
return Number((BigInt(id) >> 22n) + __classPrivateFieldGet(this, _Snowflake_epoch, "f"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_Snowflake_increment = new WeakMap(), _Snowflake_epoch = new WeakMap();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class for parsing snowflake ids using Discord's snowflake epoch
|
||||||
|
*
|
||||||
|
* Which is 2015-01-01 at 00:00:00.000 UTC+0, {@linkplain https://discord.com/developers/docs/reference#snowflakes}
|
||||||
|
*/
|
||||||
|
const DiscordSnowflake = new Snowflake(1420070400000n);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class for parsing snowflake ids using Twitter's snowflake epoch
|
||||||
|
*
|
||||||
|
* Which is 2006-03-21 at 20:50:14.000 UTC+0, the time and date of the first tweet ever made {@linkplain https://twitter.com/jack/status/20}
|
||||||
|
*/
|
||||||
|
const TwitterSnowflake = new Snowflake(1142974214000n);
|
||||||
|
|
||||||
|
exports.DiscordSnowflake = DiscordSnowflake;
|
||||||
|
exports.Snowflake = Snowflake;
|
||||||
|
exports.TwitterSnowflake = TwitterSnowflake;
|
||||||
|
|
||||||
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
|
||||||
|
}));
|
||||||
|
//# sourceMappingURL=index.umd.js.map
|
1
node_modules/@sapphire/snowflake/dist/index.umd.js.map
generated
vendored
Normal file
1
node_modules/@sapphire/snowflake/dist/index.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
8
node_modules/@sapphire/snowflake/dist/lib/DiscordSnowflake.d.ts
generated
vendored
Normal file
8
node_modules/@sapphire/snowflake/dist/lib/DiscordSnowflake.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { Snowflake } from './Snowflake';
|
||||||
|
/**
|
||||||
|
* A class for parsing snowflake ids using Discord's snowflake epoch
|
||||||
|
*
|
||||||
|
* Which is 2015-01-01 at 00:00:00.000 UTC+0, {@linkplain https://discord.com/developers/docs/reference#snowflakes}
|
||||||
|
*/
|
||||||
|
export declare const DiscordSnowflake: Snowflake;
|
||||||
|
//# sourceMappingURL=DiscordSnowflake.d.ts.map
|
1
node_modules/@sapphire/snowflake/dist/lib/DiscordSnowflake.d.ts.map
generated
vendored
Normal file
1
node_modules/@sapphire/snowflake/dist/lib/DiscordSnowflake.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"DiscordSnowflake.d.ts","sourceRoot":"","sources":["../../src/lib/DiscordSnowflake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WAAgC,CAAC"}
|
114
node_modules/@sapphire/snowflake/dist/lib/Snowflake.d.ts
generated
vendored
Normal file
114
node_modules/@sapphire/snowflake/dist/lib/Snowflake.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
/**
|
||||||
|
* A class for generating and deconstructing Twitter snowflakes.
|
||||||
|
*
|
||||||
|
* A {@link https://developer.twitter.com/en/docs/twitter-ids Twitter snowflake}
|
||||||
|
* is a 64-bit unsigned integer with 4 fields that have a fixed epoch value.
|
||||||
|
*
|
||||||
|
* If we have a snowflake `266241948824764416` we can represent it as binary:
|
||||||
|
* ```
|
||||||
|
* 64 22 17 12 0
|
||||||
|
* 000000111011000111100001101001000101000000 00001 00000 000000000000
|
||||||
|
* number of ms since epoch worker pid increment
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
export declare class Snowflake {
|
||||||
|
#private;
|
||||||
|
/**
|
||||||
|
* Alias for {@link deconstruct}
|
||||||
|
*/
|
||||||
|
decode: (id: string | bigint) => DeconstructedSnowflake;
|
||||||
|
/**
|
||||||
|
* @param epoch the epoch to use
|
||||||
|
*/
|
||||||
|
constructor(epoch: number | bigint | Date);
|
||||||
|
/**
|
||||||
|
* The epoch for this snowflake.
|
||||||
|
*/
|
||||||
|
get epoch(): bigint;
|
||||||
|
/**
|
||||||
|
* Generates a snowflake given an epoch and optionally a timestamp
|
||||||
|
* @param options options to pass into the generator, see {@link SnowflakeGenerateOptions}
|
||||||
|
*
|
||||||
|
* **note** when `increment` is not provided it defaults to the private `increment` of the instance
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const epoch = new Date('2000-01-01T00:00:00.000Z');
|
||||||
|
* const snowflake = new Snowflake(epoch).generate();
|
||||||
|
* ```
|
||||||
|
* @returns A unique snowflake
|
||||||
|
*/
|
||||||
|
generate({ increment, timestamp, workerId, processId }?: SnowflakeGenerateOptions): bigint;
|
||||||
|
/**
|
||||||
|
* Deconstructs a snowflake given a snowflake ID
|
||||||
|
* @param id the snowflake to deconstruct
|
||||||
|
* @returns a deconstructed snowflake
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const epoch = new Date('2000-01-01T00:00:00.000Z');
|
||||||
|
* const snowflake = new Snowflake(epoch).deconstruct('3971046231244935168');
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
deconstruct(id: string | bigint): DeconstructedSnowflake;
|
||||||
|
/**
|
||||||
|
* Retrieves the timestamp field's value from a snowflake.
|
||||||
|
* @param id The snowflake to get the timestamp value from.
|
||||||
|
* @returns The UNIX timestamp that is stored in `id`.
|
||||||
|
*/
|
||||||
|
timestampFrom(id: string | bigint): number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Options for Snowflake#generate
|
||||||
|
*/
|
||||||
|
export interface SnowflakeGenerateOptions {
|
||||||
|
/**
|
||||||
|
* Timestamp or date of the snowflake to generate
|
||||||
|
* @default Date.now()
|
||||||
|
*/
|
||||||
|
timestamp?: number | bigint | Date;
|
||||||
|
/**
|
||||||
|
* The increment to use
|
||||||
|
* @default 0n
|
||||||
|
* @remark keep in mind that this bigint is auto-incremented between generate calls
|
||||||
|
*/
|
||||||
|
increment?: bigint;
|
||||||
|
/**
|
||||||
|
* The worker ID to use, will be truncated to 5 bits (0-31)
|
||||||
|
* @default 0n
|
||||||
|
*/
|
||||||
|
workerId?: bigint;
|
||||||
|
/**
|
||||||
|
* The process ID to use, will be truncated to 5 bits (0-31)
|
||||||
|
* @default 1n
|
||||||
|
*/
|
||||||
|
processId?: bigint;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Object returned by Snowflake#deconstruct
|
||||||
|
*/
|
||||||
|
export interface DeconstructedSnowflake {
|
||||||
|
/**
|
||||||
|
* The id in BigInt form
|
||||||
|
*/
|
||||||
|
id: bigint;
|
||||||
|
/**
|
||||||
|
* The timestamp stored in the snowflake
|
||||||
|
*/
|
||||||
|
timestamp: bigint;
|
||||||
|
/**
|
||||||
|
* The worker id stored in the snowflake
|
||||||
|
*/
|
||||||
|
workerId: bigint;
|
||||||
|
/**
|
||||||
|
* The process id stored in the snowflake
|
||||||
|
*/
|
||||||
|
processId: bigint;
|
||||||
|
/**
|
||||||
|
* The increment stored in the snowflake
|
||||||
|
*/
|
||||||
|
increment: bigint;
|
||||||
|
/**
|
||||||
|
* The epoch to use in the snowflake
|
||||||
|
*/
|
||||||
|
epoch: bigint;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=Snowflake.d.ts.map
|
1
node_modules/@sapphire/snowflake/dist/lib/Snowflake.d.ts.map
generated
vendored
Normal file
1
node_modules/@sapphire/snowflake/dist/lib/Snowflake.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"Snowflake.d.ts","sourceRoot":"","sources":["../../src/lib/Snowflake.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,qBAAa,SAAS;;IAarB;;OAEG;IAEI,MAAM,OAuDU,MAAM,GAAG,MAAM,KAAG,sBAAsB,CAvD9B;IAEjC;;OAEG;gBACgB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIhD;;OAEG;IACH,IAAW,KAAK,IAAI,MAAM,CAEzB;IAED;;;;;;;;;;;OAWG;IACI,QAAQ,CAAC,EAAE,SAAS,EAAE,SAAsB,EAAE,QAAmB,EAAE,SAAqB,EAAE,GAAE,wBAA6B;IAiBhI;;;;;;;;;OASG;IACI,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,sBAAsB;IAY/D;;;;OAIG;IACI,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;CAGjD;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAEnC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACd"}
|
8
node_modules/@sapphire/snowflake/dist/lib/TwitterSnowflake.d.ts
generated
vendored
Normal file
8
node_modules/@sapphire/snowflake/dist/lib/TwitterSnowflake.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { Snowflake } from './Snowflake';
|
||||||
|
/**
|
||||||
|
* A class for parsing snowflake ids using Twitter's snowflake epoch
|
||||||
|
*
|
||||||
|
* Which is 2006-03-21 at 20:50:14.000 UTC+0, the time and date of the first tweet ever made {@linkplain https://twitter.com/jack/status/20}
|
||||||
|
*/
|
||||||
|
export declare const TwitterSnowflake: Snowflake;
|
||||||
|
//# sourceMappingURL=TwitterSnowflake.d.ts.map
|
1
node_modules/@sapphire/snowflake/dist/lib/TwitterSnowflake.d.ts.map
generated
vendored
Normal file
1
node_modules/@sapphire/snowflake/dist/lib/TwitterSnowflake.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"TwitterSnowflake.d.ts","sourceRoot":"","sources":["../../src/lib/TwitterSnowflake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WAAgC,CAAC"}
|
56
node_modules/@sapphire/snowflake/package.json
generated
vendored
Normal file
56
node_modules/@sapphire/snowflake/package.json
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
{
|
||||||
|
"name": "@sapphire/snowflake",
|
||||||
|
"version": "3.0.1",
|
||||||
|
"description": "Deconstructs and generates snoflake IDs using BigInts",
|
||||||
|
"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/snowflake",
|
||||||
|
"scripts": {
|
||||||
|
"test": "jest",
|
||||||
|
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
|
||||||
|
"build": "rollup -c",
|
||||||
|
"watch": "yarn build -w",
|
||||||
|
"prepublishOnly": "yarn build"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/sapphiredev/utilities.git",
|
||||||
|
"directory": "packages/snowflake"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"!dist/*.tsbuildinfo"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=v14.0.0",
|
||||||
|
"npm": ">=7.0.0"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"@sapphire/snowflake",
|
||||||
|
"bot",
|
||||||
|
"typescript",
|
||||||
|
"ts",
|
||||||
|
"yarn",
|
||||||
|
"discord",
|
||||||
|
"sapphire",
|
||||||
|
"standalone"
|
||||||
|
],
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/sapphiredev/utilities/issues"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"gitHead": "3a1f23df5fa8191c90760af66fbc72115fa2b13e"
|
||||||
|
}
|
227
node_modules/@sindresorhus/is/dist/index.d.ts
generated
vendored
Normal file
227
node_modules/@sindresorhus/is/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,227 @@
|
||||||
|
/// <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")[]];
|
||||||
|
declare type ObjectTypeName = typeof objectTypeNames[number];
|
||||||
|
declare const primitiveTypeNames: readonly ["null", "undefined", "string", "number", "bigint", "boolean", "symbol"];
|
||||||
|
declare type PrimitiveTypeName = typeof primitiveTypeNames[number];
|
||||||
|
export declare type TypeName = ObjectTypeName | PrimitiveTypeName;
|
||||||
|
declare function is(value: unknown): TypeName;
|
||||||
|
declare namespace is {
|
||||||
|
var undefined: (value: unknown) => value is undefined;
|
||||||
|
var string: (value: unknown) => value is string;
|
||||||
|
var number: (value: unknown) => value is number;
|
||||||
|
var bigint: (value: unknown) => value is bigint;
|
||||||
|
var function_: (value: unknown) => value is Function;
|
||||||
|
var null_: (value: unknown) => value is null;
|
||||||
|
var class_: (value: unknown) => value is Class<unknown, any[]>;
|
||||||
|
var boolean: (value: unknown) => value is boolean;
|
||||||
|
var symbol: (value: unknown) => value is symbol;
|
||||||
|
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 nullOrUndefined: (value: unknown) => value is null | undefined;
|
||||||
|
var object: (value: unknown) => value is object;
|
||||||
|
var iterable: <T = unknown>(value: unknown) => value is Iterable<T>;
|
||||||
|
var asyncIterable: <T = unknown>(value: unknown) => value is AsyncIterable<T>;
|
||||||
|
var generator: (value: unknown) => value is Generator<unknown, any, unknown>;
|
||||||
|
var asyncGenerator: (value: unknown) => value is AsyncGenerator<unknown, any, unknown>;
|
||||||
|
var nativePromise: <T = unknown>(value: unknown) => value is Promise<T>;
|
||||||
|
var promise: <T = unknown>(value: unknown) => value is Promise<T>;
|
||||||
|
var generatorFunction: (value: unknown) => value is GeneratorFunction;
|
||||||
|
var asyncGeneratorFunction: (value: unknown) => value is (...args: any[]) => Promise<unknown>;
|
||||||
|
var asyncFunction: <T = unknown>(value: unknown) => value is (...args: any[]) => Promise<T>;
|
||||||
|
var boundFunction: (value: unknown) => value is Function;
|
||||||
|
var regExp: (value: unknown) => value is RegExp;
|
||||||
|
var date: (value: unknown) => value is Date;
|
||||||
|
var error: (value: unknown) => value is Error;
|
||||||
|
var map: <Key = unknown, Value = unknown>(value: unknown) => value is Map<Key, Value>;
|
||||||
|
var set: <T = unknown>(value: unknown) => value is Set<T>;
|
||||||
|
var weakMap: <Key extends object = object, Value = unknown>(value: unknown) => value is WeakMap<Key, Value>;
|
||||||
|
var weakSet: (value: unknown) => value is WeakSet<object>;
|
||||||
|
var int8Array: (value: unknown) => value is Int8Array;
|
||||||
|
var uint8Array: (value: unknown) => value is Uint8Array;
|
||||||
|
var uint8ClampedArray: (value: unknown) => value is Uint8ClampedArray;
|
||||||
|
var int16Array: (value: unknown) => value is Int16Array;
|
||||||
|
var uint16Array: (value: unknown) => value is Uint16Array;
|
||||||
|
var int32Array: (value: unknown) => value is Int32Array;
|
||||||
|
var uint32Array: (value: unknown) => value is Uint32Array;
|
||||||
|
var float32Array: (value: unknown) => value is Float32Array;
|
||||||
|
var float64Array: (value: unknown) => value is Float64Array;
|
||||||
|
var bigInt64Array: (value: unknown) => value is BigInt64Array;
|
||||||
|
var bigUint64Array: (value: unknown) => value is BigUint64Array;
|
||||||
|
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 nan: (value: unknown) => boolean;
|
||||||
|
var primitive: (value: unknown) => value is Primitive;
|
||||||
|
var integer: (value: unknown) => value is number;
|
||||||
|
var safeInteger: (value: unknown) => value is number;
|
||||||
|
var plainObject: <Value = unknown>(value: unknown) => value is Record<string | number | symbol, Value>;
|
||||||
|
var typedArray: (value: unknown) => value is TypedArray;
|
||||||
|
var arrayLike: <T = unknown>(value: unknown) => value is ArrayLike<T>;
|
||||||
|
var inRange: (value: number, range: number | number[]) => value is number;
|
||||||
|
var domElement: (value: unknown) => value is HTMLElement;
|
||||||
|
var observable: (value: unknown) => value is ObservableLike;
|
||||||
|
var nodeStream: (value: unknown) => value is NodeStream;
|
||||||
|
var infinite: (value: unknown) => value is number;
|
||||||
|
var evenInteger: (value: number) => value is number;
|
||||||
|
var oddInteger: (value: number) => value is number;
|
||||||
|
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 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>;
|
||||||
|
var nonEmptySet: <T = unknown>(value: unknown) => value is Set<T>;
|
||||||
|
var emptyMap: (value: unknown) => value is Map<never, never>;
|
||||||
|
var nonEmptyMap: <Key = unknown, Value = unknown>(value: unknown) => value is Map<Key, Value>;
|
||||||
|
var propertyKey: (value: unknown) => value is string | number | symbol;
|
||||||
|
var formData: (value: unknown) => value is FormData;
|
||||||
|
var urlSearchParams: (value: unknown) => value is URLSearchParams;
|
||||||
|
var any: (predicate: Predicate | Predicate[], ...values: unknown[]) => boolean;
|
||||||
|
var all: (predicate: Predicate, ...values: unknown[]) => boolean;
|
||||||
|
}
|
||||||
|
export interface ArrayLike<T> {
|
||||||
|
readonly [index: number]: T;
|
||||||
|
readonly length: number;
|
||||||
|
}
|
||||||
|
export interface NodeStream extends NodeJS.EventEmitter {
|
||||||
|
pipe<T extends NodeJS.WritableStream>(destination: T, options?: {
|
||||||
|
end?: boolean;
|
||||||
|
}): T;
|
||||||
|
}
|
||||||
|
export declare type Predicate = (value: unknown) => boolean;
|
||||||
|
export declare const enum AssertionTypeDescription {
|
||||||
|
class_ = "Class",
|
||||||
|
numericString = "string with a number",
|
||||||
|
nullOrUndefined = "null or undefined",
|
||||||
|
iterable = "Iterable",
|
||||||
|
asyncIterable = "AsyncIterable",
|
||||||
|
nativePromise = "native Promise",
|
||||||
|
urlString = "string with a URL",
|
||||||
|
truthy = "truthy",
|
||||||
|
falsy = "falsy",
|
||||||
|
nan = "NaN",
|
||||||
|
primitive = "primitive",
|
||||||
|
integer = "integer",
|
||||||
|
safeInteger = "integer",
|
||||||
|
plainObject = "plain object",
|
||||||
|
arrayLike = "array-like",
|
||||||
|
typedArray = "TypedArray",
|
||||||
|
domElement = "HTMLElement",
|
||||||
|
nodeStream = "Node.js Stream",
|
||||||
|
infinite = "infinite number",
|
||||||
|
emptyArray = "empty array",
|
||||||
|
nonEmptyArray = "non-empty array",
|
||||||
|
emptyString = "empty string",
|
||||||
|
nonEmptyString = "non-empty string",
|
||||||
|
emptyStringOrWhitespace = "empty string or whitespace",
|
||||||
|
emptyObject = "empty object",
|
||||||
|
nonEmptyObject = "non-empty object",
|
||||||
|
emptySet = "empty set",
|
||||||
|
nonEmptySet = "non-empty set",
|
||||||
|
emptyMap = "empty map",
|
||||||
|
nonEmptyMap = "non-empty map",
|
||||||
|
evenInteger = "even integer",
|
||||||
|
oddInteger = "odd integer",
|
||||||
|
directInstanceOf = "T",
|
||||||
|
inRange = "in range",
|
||||||
|
any = "predicate returns truthy for any value",
|
||||||
|
all = "predicate returns truthy for all values"
|
||||||
|
}
|
||||||
|
interface Assert {
|
||||||
|
undefined: (value: unknown) => asserts value is undefined;
|
||||||
|
string: (value: unknown) => asserts value is string;
|
||||||
|
number: (value: unknown) => asserts value is number;
|
||||||
|
bigint: (value: unknown) => asserts value is bigint;
|
||||||
|
function_: (value: unknown) => asserts value is Function;
|
||||||
|
null_: (value: unknown) => asserts value is null;
|
||||||
|
class_: (value: unknown) => asserts value is Class;
|
||||||
|
boolean: (value: unknown) => asserts value is boolean;
|
||||||
|
symbol: (value: unknown) => asserts value is symbol;
|
||||||
|
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;
|
||||||
|
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>;
|
||||||
|
asyncIterable: <T = unknown>(value: unknown) => asserts value is AsyncIterable<T>;
|
||||||
|
generator: (value: unknown) => asserts value is Generator;
|
||||||
|
asyncGenerator: (value: unknown) => asserts value is AsyncGenerator;
|
||||||
|
nativePromise: <T = unknown>(value: unknown) => asserts value is Promise<T>;
|
||||||
|
promise: <T = unknown>(value: unknown) => asserts value is Promise<T>;
|
||||||
|
generatorFunction: (value: unknown) => asserts value is GeneratorFunction;
|
||||||
|
asyncGeneratorFunction: (value: unknown) => asserts value is AsyncGeneratorFunction;
|
||||||
|
asyncFunction: (value: unknown) => asserts value is Function;
|
||||||
|
boundFunction: (value: unknown) => asserts value is Function;
|
||||||
|
regExp: (value: unknown) => asserts value is RegExp;
|
||||||
|
date: (value: unknown) => asserts value is Date;
|
||||||
|
error: (value: unknown) => asserts value is Error;
|
||||||
|
map: <Key = unknown, Value = unknown>(value: unknown) => asserts value is Map<Key, Value>;
|
||||||
|
set: <T = unknown>(value: unknown) => asserts value is Set<T>;
|
||||||
|
weakMap: <Key extends object = object, Value = unknown>(value: unknown) => asserts value is WeakMap<Key, Value>;
|
||||||
|
weakSet: <T extends object = object>(value: unknown) => asserts value is WeakSet<T>;
|
||||||
|
int8Array: (value: unknown) => asserts value is Int8Array;
|
||||||
|
uint8Array: (value: unknown) => asserts value is Uint8Array;
|
||||||
|
uint8ClampedArray: (value: unknown) => asserts value is Uint8ClampedArray;
|
||||||
|
int16Array: (value: unknown) => asserts value is Int16Array;
|
||||||
|
uint16Array: (value: unknown) => asserts value is Uint16Array;
|
||||||
|
int32Array: (value: unknown) => asserts value is Int32Array;
|
||||||
|
uint32Array: (value: unknown) => asserts value is Uint32Array;
|
||||||
|
float32Array: (value: unknown) => asserts value is Float32Array;
|
||||||
|
float64Array: (value: unknown) => asserts value is Float64Array;
|
||||||
|
bigInt64Array: (value: unknown) => asserts value is BigInt64Array;
|
||||||
|
bigUint64Array: (value: unknown) => asserts value is BigUint64Array;
|
||||||
|
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;
|
||||||
|
falsy: (value: unknown) => asserts value is unknown;
|
||||||
|
nan: (value: unknown) => asserts value is unknown;
|
||||||
|
primitive: (value: unknown) => asserts value is Primitive;
|
||||||
|
integer: (value: unknown) => asserts value is number;
|
||||||
|
safeInteger: (value: unknown) => asserts value is number;
|
||||||
|
plainObject: <Value = unknown>(value: unknown) => asserts value is Record<PropertyKey, Value>;
|
||||||
|
typedArray: (value: unknown) => asserts value is TypedArray;
|
||||||
|
arrayLike: <T = unknown>(value: unknown) => asserts value is ArrayLike<T>;
|
||||||
|
domElement: (value: unknown) => asserts value is HTMLElement;
|
||||||
|
observable: (value: unknown) => asserts value is ObservableLike;
|
||||||
|
nodeStream: (value: unknown) => asserts value is NodeStream;
|
||||||
|
infinite: (value: unknown) => asserts value is number;
|
||||||
|
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;
|
||||||
|
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>;
|
||||||
|
nonEmptySet: <T = unknown>(value: unknown) => asserts value is Set<T>;
|
||||||
|
emptyMap: (value: unknown) => asserts value is Map<never, never>;
|
||||||
|
nonEmptyMap: <Key = unknown, Value = unknown>(value: unknown) => asserts value is Map<Key, Value>;
|
||||||
|
propertyKey: (value: unknown) => asserts value is PropertyKey;
|
||||||
|
formData: (value: unknown) => asserts value is FormData;
|
||||||
|
urlSearchParams: (value: unknown) => asserts value is URLSearchParams;
|
||||||
|
evenInteger: (value: number) => asserts value is number;
|
||||||
|
oddInteger: (value: number) => asserts value is number;
|
||||||
|
directInstanceOf: <T>(instance: unknown, class_: Class<T>) => asserts instance is T;
|
||||||
|
inRange: (value: number, range: number | number[]) => asserts value is number;
|
||||||
|
any: (predicate: Predicate | Predicate[], ...values: unknown[]) => void | never;
|
||||||
|
all: (predicate: Predicate, ...values: unknown[]) => void | never;
|
||||||
|
}
|
||||||
|
export declare const assert: Assert;
|
||||||
|
export default is;
|
||||||
|
export { Class, TypedArray, ObservableLike, Primitive } from './types';
|
429
node_modules/@sindresorhus/is/dist/index.js
generated
vendored
Normal file
429
node_modules/@sindresorhus/is/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,429 @@
|
||||||
|
"use strict";
|
||||||
|
/// <reference lib="es2018"/>
|
||||||
|
/// <reference lib="dom"/>
|
||||||
|
/// <reference types="node"/>
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const typedArrayTypeNames = [
|
||||||
|
'Int8Array',
|
||||||
|
'Uint8Array',
|
||||||
|
'Uint8ClampedArray',
|
||||||
|
'Int16Array',
|
||||||
|
'Uint16Array',
|
||||||
|
'Int32Array',
|
||||||
|
'Uint32Array',
|
||||||
|
'Float32Array',
|
||||||
|
'Float64Array',
|
||||||
|
'BigInt64Array',
|
||||||
|
'BigUint64Array'
|
||||||
|
];
|
||||||
|
function isTypedArrayName(name) {
|
||||||
|
return typedArrayTypeNames.includes(name);
|
||||||
|
}
|
||||||
|
const objectTypeNames = [
|
||||||
|
'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',
|
||||||
|
...typedArrayTypeNames
|
||||||
|
];
|
||||||
|
function isObjectTypeName(name) {
|
||||||
|
return objectTypeNames.includes(name);
|
||||||
|
}
|
||||||
|
const primitiveTypeNames = [
|
||||||
|
'null',
|
||||||
|
'undefined',
|
||||||
|
'string',
|
||||||
|
'number',
|
||||||
|
'bigint',
|
||||||
|
'boolean',
|
||||||
|
'symbol'
|
||||||
|
];
|
||||||
|
function isPrimitiveTypeName(name) {
|
||||||
|
return primitiveTypeNames.includes(name);
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
|
function isOfType(type) {
|
||||||
|
return (value) => typeof value === type;
|
||||||
|
}
|
||||||
|
const { toString } = Object.prototype;
|
||||||
|
const getObjectType = (value) => {
|
||||||
|
const objectTypeName = toString.call(value).slice(8, -1);
|
||||||
|
if (/HTML\w+Element/.test(objectTypeName) && is.domElement(value)) {
|
||||||
|
return 'HTMLElement';
|
||||||
|
}
|
||||||
|
if (isObjectTypeName(objectTypeName)) {
|
||||||
|
return objectTypeName;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
const isObjectOfType = (type) => (value) => getObjectType(value) === type;
|
||||||
|
function is(value) {
|
||||||
|
if (value === null) {
|
||||||
|
return 'null';
|
||||||
|
}
|
||||||
|
switch (typeof value) {
|
||||||
|
case 'undefined':
|
||||||
|
return 'undefined';
|
||||||
|
case 'string':
|
||||||
|
return 'string';
|
||||||
|
case 'number':
|
||||||
|
return 'number';
|
||||||
|
case 'boolean':
|
||||||
|
return 'boolean';
|
||||||
|
case 'function':
|
||||||
|
return 'Function';
|
||||||
|
case 'bigint':
|
||||||
|
return 'bigint';
|
||||||
|
case 'symbol':
|
||||||
|
return 'symbol';
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
if (is.observable(value)) {
|
||||||
|
return 'Observable';
|
||||||
|
}
|
||||||
|
if (is.array(value)) {
|
||||||
|
return 'Array';
|
||||||
|
}
|
||||||
|
if (is.buffer(value)) {
|
||||||
|
return 'Buffer';
|
||||||
|
}
|
||||||
|
const tagType = getObjectType(value);
|
||||||
|
if (tagType) {
|
||||||
|
return tagType;
|
||||||
|
}
|
||||||
|
if (value instanceof String || value instanceof Boolean || value instanceof Number) {
|
||||||
|
throw new TypeError('Please don\'t use object wrappers for primitive types');
|
||||||
|
}
|
||||||
|
return 'Object';
|
||||||
|
}
|
||||||
|
is.undefined = isOfType('undefined');
|
||||||
|
is.string = isOfType('string');
|
||||||
|
const isNumberType = isOfType('number');
|
||||||
|
is.number = (value) => isNumberType(value) && !is.nan(value);
|
||||||
|
is.bigint = isOfType('bigint');
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
|
is.function_ = isOfType('function');
|
||||||
|
is.null_ = (value) => value === null;
|
||||||
|
is.class_ = (value) => is.function_(value) && value.toString().startsWith('class ');
|
||||||
|
is.boolean = (value) => value === true || value === false;
|
||||||
|
is.symbol = isOfType('symbol');
|
||||||
|
is.numericString = (value) => is.string(value) && !is.emptyStringOrWhitespace(value) && !Number.isNaN(Number(value));
|
||||||
|
is.array = (value, assertion) => {
|
||||||
|
if (!Array.isArray(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!is.function_(assertion)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
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.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]); };
|
||||||
|
is.asyncIterable = (value) => { var _a; return is.function_((_a = value) === null || _a === void 0 ? void 0 : _a[Symbol.asyncIterator]); };
|
||||||
|
is.generator = (value) => { var _a, _b; return is.iterable(value) && is.function_((_a = value) === null || _a === void 0 ? void 0 : _a.next) && is.function_((_b = value) === null || _b === void 0 ? void 0 : _b.throw); };
|
||||||
|
is.asyncGenerator = (value) => is.asyncIterable(value) && is.function_(value.next) && is.function_(value.throw);
|
||||||
|
is.nativePromise = (value) => isObjectOfType('Promise')(value);
|
||||||
|
const hasPromiseAPI = (value) => {
|
||||||
|
var _a, _b;
|
||||||
|
return is.function_((_a = value) === null || _a === void 0 ? void 0 : _a.then) &&
|
||||||
|
is.function_((_b = value) === null || _b === void 0 ? void 0 : _b.catch);
|
||||||
|
};
|
||||||
|
is.promise = (value) => is.nativePromise(value) || hasPromiseAPI(value);
|
||||||
|
is.generatorFunction = isObjectOfType('GeneratorFunction');
|
||||||
|
is.asyncGeneratorFunction = (value) => getObjectType(value) === 'AsyncGeneratorFunction';
|
||||||
|
is.asyncFunction = (value) => getObjectType(value) === 'AsyncFunction';
|
||||||
|
// eslint-disable-next-line no-prototype-builtins, @typescript-eslint/ban-types
|
||||||
|
is.boundFunction = (value) => is.function_(value) && !value.hasOwnProperty('prototype');
|
||||||
|
is.regExp = isObjectOfType('RegExp');
|
||||||
|
is.date = isObjectOfType('Date');
|
||||||
|
is.error = isObjectOfType('Error');
|
||||||
|
is.map = (value) => isObjectOfType('Map')(value);
|
||||||
|
is.set = (value) => isObjectOfType('Set')(value);
|
||||||
|
is.weakMap = (value) => isObjectOfType('WeakMap')(value);
|
||||||
|
is.weakSet = (value) => isObjectOfType('WeakSet')(value);
|
||||||
|
is.int8Array = isObjectOfType('Int8Array');
|
||||||
|
is.uint8Array = isObjectOfType('Uint8Array');
|
||||||
|
is.uint8ClampedArray = isObjectOfType('Uint8ClampedArray');
|
||||||
|
is.int16Array = isObjectOfType('Int16Array');
|
||||||
|
is.uint16Array = isObjectOfType('Uint16Array');
|
||||||
|
is.int32Array = isObjectOfType('Int32Array');
|
||||||
|
is.uint32Array = isObjectOfType('Uint32Array');
|
||||||
|
is.float32Array = isObjectOfType('Float32Array');
|
||||||
|
is.float64Array = isObjectOfType('Float64Array');
|
||||||
|
is.bigInt64Array = isObjectOfType('BigInt64Array');
|
||||||
|
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) => {
|
||||||
|
if (!is.string(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
new URL(value); // eslint-disable-line no-new
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (_a) {
|
||||||
|
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);`
|
||||||
|
is.falsy = (value) => !value;
|
||||||
|
is.nan = (value) => Number.isNaN(value);
|
||||||
|
is.primitive = (value) => is.null_(value) || isPrimitiveTypeName(typeof value);
|
||||||
|
is.integer = (value) => Number.isInteger(value);
|
||||||
|
is.safeInteger = (value) => Number.isSafeInteger(value);
|
||||||
|
is.plainObject = (value) => {
|
||||||
|
// From: https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
|
||||||
|
if (toString.call(value) !== '[object Object]') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const prototype = Object.getPrototypeOf(value);
|
||||||
|
return prototype === null || prototype === Object.getPrototypeOf({});
|
||||||
|
};
|
||||||
|
is.typedArray = (value) => isTypedArrayName(getObjectType(value));
|
||||||
|
const isValidLength = (value) => is.safeInteger(value) && value >= 0;
|
||||||
|
is.arrayLike = (value) => !is.nullOrUndefined(value) && !is.function_(value) && isValidLength(value.length);
|
||||||
|
is.inRange = (value, range) => {
|
||||||
|
if (is.number(range)) {
|
||||||
|
return value >= Math.min(0, range) && value <= Math.max(range, 0);
|
||||||
|
}
|
||||||
|
if (is.array(range) && range.length === 2) {
|
||||||
|
return value >= Math.min(...range) && value <= Math.max(...range);
|
||||||
|
}
|
||||||
|
throw new TypeError(`Invalid range: ${JSON.stringify(range)}`);
|
||||||
|
};
|
||||||
|
const NODE_TYPE_ELEMENT = 1;
|
||||||
|
const DOM_PROPERTIES_TO_CHECK = [
|
||||||
|
'innerHTML',
|
||||||
|
'ownerDocument',
|
||||||
|
'style',
|
||||||
|
'attributes',
|
||||||
|
'nodeValue'
|
||||||
|
];
|
||||||
|
is.domElement = (value) => {
|
||||||
|
return is.object(value) &&
|
||||||
|
value.nodeType === NODE_TYPE_ELEMENT &&
|
||||||
|
is.string(value.nodeName) &&
|
||||||
|
!is.plainObject(value) &&
|
||||||
|
DOM_PROPERTIES_TO_CHECK.every(property => property in value);
|
||||||
|
};
|
||||||
|
is.observable = (value) => {
|
||||||
|
var _a, _b, _c, _d;
|
||||||
|
if (!value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line no-use-extend-native/no-use-extend-native
|
||||||
|
if (value === ((_b = (_a = value)[Symbol.observable]) === null || _b === void 0 ? void 0 : _b.call(_a))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (value === ((_d = (_c = value)['@@observable']) === null || _d === void 0 ? void 0 : _d.call(_c))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
is.nodeStream = (value) => is.object(value) && is.function_(value.pipe) && !is.observable(value);
|
||||||
|
is.infinite = (value) => value === Infinity || value === -Infinity;
|
||||||
|
const isAbsoluteMod2 = (remainder) => (value) => is.integer(value) && Math.abs(value % 2) === remainder;
|
||||||
|
is.evenInteger = isAbsoluteMod2(0);
|
||||||
|
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);
|
||||||
|
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
|
||||||
|
is.nonEmptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length > 0;
|
||||||
|
is.emptySet = (value) => is.set(value) && value.size === 0;
|
||||||
|
is.nonEmptySet = (value) => is.set(value) && value.size > 0;
|
||||||
|
is.emptyMap = (value) => is.map(value) && value.size === 0;
|
||||||
|
is.nonEmptyMap = (value) => is.map(value) && value.size > 0;
|
||||||
|
// `PropertyKey` is any value that can be used as an object key (string, number, or symbol)
|
||||||
|
is.propertyKey = (value) => is.any([is.string, is.number, is.symbol], value);
|
||||||
|
is.formData = (value) => isObjectOfType('FormData')(value);
|
||||||
|
is.urlSearchParams = (value) => isObjectOfType('URLSearchParams')(value);
|
||||||
|
const predicateOnArray = (method, predicate, values) => {
|
||||||
|
if (!is.function_(predicate)) {
|
||||||
|
throw new TypeError(`Invalid predicate: ${JSON.stringify(predicate)}`);
|
||||||
|
}
|
||||||
|
if (values.length === 0) {
|
||||||
|
throw new TypeError('Invalid number of values');
|
||||||
|
}
|
||||||
|
return method.call(values, predicate);
|
||||||
|
};
|
||||||
|
is.any = (predicate, ...values) => {
|
||||||
|
const predicates = is.array(predicate) ? predicate : [predicate];
|
||||||
|
return predicates.some(singlePredicate => predicateOnArray(Array.prototype.some, singlePredicate, values));
|
||||||
|
};
|
||||||
|
is.all = (predicate, ...values) => predicateOnArray(Array.prototype.every, predicate, values);
|
||||||
|
const assertType = (condition, description, value, options = {}) => {
|
||||||
|
if (!condition) {
|
||||||
|
const { multipleValues } = options;
|
||||||
|
const valuesMessage = multipleValues ?
|
||||||
|
`received values of types ${[
|
||||||
|
...new Set(value.map(singleValue => `\`${is(singleValue)}\``))
|
||||||
|
].join(', ')}` :
|
||||||
|
`received value of type \`${is(value)}\``;
|
||||||
|
throw new TypeError(`Expected value which is \`${description}\`, ${valuesMessage}.`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
exports.assert = {
|
||||||
|
// Unknowns.
|
||||||
|
undefined: (value) => assertType(is.undefined(value), 'undefined', value),
|
||||||
|
string: (value) => assertType(is.string(value), 'string', value),
|
||||||
|
number: (value) => assertType(is.number(value), 'number', value),
|
||||||
|
bigint: (value) => assertType(is.bigint(value), 'bigint', value),
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
|
function_: (value) => assertType(is.function_(value), 'Function', value),
|
||||||
|
null_: (value) => assertType(is.null_(value), 'null', value),
|
||||||
|
class_: (value) => assertType(is.class_(value), "Class" /* class_ */, value),
|
||||||
|
boolean: (value) => assertType(is.boolean(value), 'boolean', value),
|
||||||
|
symbol: (value) => assertType(is.symbol(value), 'symbol', value),
|
||||||
|
numericString: (value) => assertType(is.numericString(value), "string with a number" /* numericString */, value),
|
||||||
|
array: (value, assertion) => {
|
||||||
|
const assert = assertType;
|
||||||
|
assert(is.array(value), 'Array', value);
|
||||||
|
if (assertion) {
|
||||||
|
value.forEach(assertion);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
buffer: (value) => assertType(is.buffer(value), 'Buffer', 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),
|
||||||
|
asyncIterable: (value) => assertType(is.asyncIterable(value), "AsyncIterable" /* asyncIterable */, value),
|
||||||
|
generator: (value) => assertType(is.generator(value), 'Generator', value),
|
||||||
|
asyncGenerator: (value) => assertType(is.asyncGenerator(value), 'AsyncGenerator', value),
|
||||||
|
nativePromise: (value) => assertType(is.nativePromise(value), "native Promise" /* nativePromise */, value),
|
||||||
|
promise: (value) => assertType(is.promise(value), 'Promise', value),
|
||||||
|
generatorFunction: (value) => assertType(is.generatorFunction(value), 'GeneratorFunction', value),
|
||||||
|
asyncGeneratorFunction: (value) => assertType(is.asyncGeneratorFunction(value), 'AsyncGeneratorFunction', value),
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
|
asyncFunction: (value) => assertType(is.asyncFunction(value), 'AsyncFunction', value),
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
|
boundFunction: (value) => assertType(is.boundFunction(value), 'Function', value),
|
||||||
|
regExp: (value) => assertType(is.regExp(value), 'RegExp', value),
|
||||||
|
date: (value) => assertType(is.date(value), 'Date', value),
|
||||||
|
error: (value) => assertType(is.error(value), 'Error', value),
|
||||||
|
map: (value) => assertType(is.map(value), 'Map', value),
|
||||||
|
set: (value) => assertType(is.set(value), 'Set', value),
|
||||||
|
weakMap: (value) => assertType(is.weakMap(value), 'WeakMap', value),
|
||||||
|
weakSet: (value) => assertType(is.weakSet(value), 'WeakSet', value),
|
||||||
|
int8Array: (value) => assertType(is.int8Array(value), 'Int8Array', value),
|
||||||
|
uint8Array: (value) => assertType(is.uint8Array(value), 'Uint8Array', value),
|
||||||
|
uint8ClampedArray: (value) => assertType(is.uint8ClampedArray(value), 'Uint8ClampedArray', value),
|
||||||
|
int16Array: (value) => assertType(is.int16Array(value), 'Int16Array', value),
|
||||||
|
uint16Array: (value) => assertType(is.uint16Array(value), 'Uint16Array', value),
|
||||||
|
int32Array: (value) => assertType(is.int32Array(value), 'Int32Array', value),
|
||||||
|
uint32Array: (value) => assertType(is.uint32Array(value), 'Uint32Array', value),
|
||||||
|
float32Array: (value) => assertType(is.float32Array(value), 'Float32Array', value),
|
||||||
|
float64Array: (value) => assertType(is.float64Array(value), 'Float64Array', value),
|
||||||
|
bigInt64Array: (value) => assertType(is.bigInt64Array(value), 'BigInt64Array', value),
|
||||||
|
bigUint64Array: (value) => assertType(is.bigUint64Array(value), 'BigUint64Array', value),
|
||||||
|
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),
|
||||||
|
falsy: (value) => assertType(is.falsy(value), "falsy" /* falsy */, value),
|
||||||
|
nan: (value) => assertType(is.nan(value), "NaN" /* nan */, value),
|
||||||
|
primitive: (value) => assertType(is.primitive(value), "primitive" /* primitive */, value),
|
||||||
|
integer: (value) => assertType(is.integer(value), "integer" /* integer */, value),
|
||||||
|
safeInteger: (value) => assertType(is.safeInteger(value), "integer" /* safeInteger */, value),
|
||||||
|
plainObject: (value) => assertType(is.plainObject(value), "plain object" /* plainObject */, value),
|
||||||
|
typedArray: (value) => assertType(is.typedArray(value), "TypedArray" /* typedArray */, value),
|
||||||
|
arrayLike: (value) => assertType(is.arrayLike(value), "array-like" /* arrayLike */, value),
|
||||||
|
domElement: (value) => assertType(is.domElement(value), "HTMLElement" /* domElement */, value),
|
||||||
|
observable: (value) => assertType(is.observable(value), 'Observable', value),
|
||||||
|
nodeStream: (value) => assertType(is.nodeStream(value), "Node.js Stream" /* nodeStream */, value),
|
||||||
|
infinite: (value) => assertType(is.infinite(value), "infinite number" /* infinite */, value),
|
||||||
|
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),
|
||||||
|
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),
|
||||||
|
nonEmptySet: (value) => assertType(is.nonEmptySet(value), "non-empty set" /* nonEmptySet */, value),
|
||||||
|
emptyMap: (value) => assertType(is.emptyMap(value), "empty map" /* emptyMap */, value),
|
||||||
|
nonEmptyMap: (value) => assertType(is.nonEmptyMap(value), "non-empty map" /* nonEmptyMap */, value),
|
||||||
|
propertyKey: (value) => assertType(is.propertyKey(value), 'PropertyKey', value),
|
||||||
|
formData: (value) => assertType(is.formData(value), 'FormData', value),
|
||||||
|
urlSearchParams: (value) => assertType(is.urlSearchParams(value), 'URLSearchParams', value),
|
||||||
|
// Numbers.
|
||||||
|
evenInteger: (value) => assertType(is.evenInteger(value), "even integer" /* evenInteger */, value),
|
||||||
|
oddInteger: (value) => assertType(is.oddInteger(value), "odd integer" /* oddInteger */, value),
|
||||||
|
// Two arguments.
|
||||||
|
directInstanceOf: (instance, class_) => assertType(is.directInstanceOf(instance, class_), "T" /* directInstanceOf */, instance),
|
||||||
|
inRange: (value, range) => assertType(is.inRange(value, range), "in range" /* inRange */, value),
|
||||||
|
// Variadic functions.
|
||||||
|
any: (predicate, ...values) => {
|
||||||
|
return assertType(is.any(predicate, ...values), "predicate returns truthy for any value" /* any */, values, { multipleValues: true });
|
||||||
|
},
|
||||||
|
all: (predicate, ...values) => assertType(is.all(predicate, ...values), "predicate returns truthy for all values" /* all */, values, { multipleValues: true })
|
||||||
|
};
|
||||||
|
// Some few keywords are reserved, but we'll populate them for Node.js users
|
||||||
|
// See https://github.com/Microsoft/TypeScript/issues/2536
|
||||||
|
Object.defineProperties(is, {
|
||||||
|
class: {
|
||||||
|
value: is.class_
|
||||||
|
},
|
||||||
|
function: {
|
||||||
|
value: is.function_
|
||||||
|
},
|
||||||
|
null: {
|
||||||
|
value: is.null_
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Object.defineProperties(exports.assert, {
|
||||||
|
class: {
|
||||||
|
value: exports.assert.class_
|
||||||
|
},
|
||||||
|
function: {
|
||||||
|
value: exports.assert.function_
|
||||||
|
},
|
||||||
|
null: {
|
||||||
|
value: exports.assert.null_
|
||||||
|
}
|
||||||
|
});
|
||||||
|
exports.default = is;
|
||||||
|
// For CommonJS default export support
|
||||||
|
module.exports = is;
|
||||||
|
module.exports.default = is;
|
||||||
|
module.exports.assert = exports.assert;
|
24
node_modules/@sindresorhus/is/dist/types.d.ts
generated
vendored
Normal file
24
node_modules/@sindresorhus/is/dist/types.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/**
|
||||||
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
||||||
|
*/
|
||||||
|
export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
||||||
|
/**
|
||||||
|
Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
||||||
|
*/
|
||||||
|
export declare type Class<T = unknown, Arguments extends any[] = any[]> = new (...arguments_: Arguments) => T;
|
||||||
|
/**
|
||||||
|
Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
|
||||||
|
*/
|
||||||
|
export declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
||||||
|
declare global {
|
||||||
|
interface SymbolConstructor {
|
||||||
|
readonly observable: symbol;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable).
|
||||||
|
*/
|
||||||
|
export interface ObservableLike {
|
||||||
|
subscribe(observer: (value: unknown) => void): void;
|
||||||
|
[Symbol.observable](): ObservableLike;
|
||||||
|
}
|
3
node_modules/@sindresorhus/is/dist/types.js
generated
vendored
Normal file
3
node_modules/@sindresorhus/is/dist/types.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
"use strict";
|
||||||
|
// Extracted from https://github.com/sindresorhus/type-fest/blob/78019f42ea888b0cdceb41a4a78163868de57555/index.d.ts
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
9
node_modules/@sindresorhus/is/license
generated
vendored
Normal file
9
node_modules/@sindresorhus/is/license
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||||
|
|
||||||
|
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.
|
96
node_modules/@sindresorhus/is/package.json
generated
vendored
Normal file
96
node_modules/@sindresorhus/is/package.json
generated
vendored
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
{
|
||||||
|
"name": "@sindresorhus/is",
|
||||||
|
"version": "4.3.0",
|
||||||
|
"description": "Type check values",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "sindresorhus/is",
|
||||||
|
"funding": "https://github.com/sindresorhus/is?sponsor=1",
|
||||||
|
"author": {
|
||||||
|
"name": "Sindre Sorhus",
|
||||||
|
"email": "sindresorhus@gmail.com",
|
||||||
|
"url": "https://sindresorhus.com"
|
||||||
|
},
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "del dist && tsc",
|
||||||
|
"test": "xo && ava",
|
||||||
|
"prepare": "npm run build"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"type",
|
||||||
|
"types",
|
||||||
|
"is",
|
||||||
|
"check",
|
||||||
|
"checking",
|
||||||
|
"validate",
|
||||||
|
"validation",
|
||||||
|
"utility",
|
||||||
|
"util",
|
||||||
|
"typeof",
|
||||||
|
"instanceof",
|
||||||
|
"object",
|
||||||
|
"assert",
|
||||||
|
"assertion",
|
||||||
|
"test",
|
||||||
|
"kind",
|
||||||
|
"primitive",
|
||||||
|
"verify",
|
||||||
|
"compare",
|
||||||
|
"typescript",
|
||||||
|
"typeguards",
|
||||||
|
"types"
|
||||||
|
],
|
||||||
|
"devDependencies": {
|
||||||
|
"@sindresorhus/tsconfig": "^0.7.0",
|
||||||
|
"@types/jsdom": "^16.1.0",
|
||||||
|
"@types/node": "^14.0.13",
|
||||||
|
"@types/zen-observable": "^0.8.0",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^2.20.0",
|
||||||
|
"@typescript-eslint/parser": "^2.20.0",
|
||||||
|
"ava": "^3.3.0",
|
||||||
|
"del-cli": "^2.0.0",
|
||||||
|
"eslint-config-xo-typescript": "^0.26.0",
|
||||||
|
"jsdom": "^16.0.1",
|
||||||
|
"rxjs": "^6.4.0",
|
||||||
|
"tempy": "^0.4.0",
|
||||||
|
"ts-node": "^8.3.0",
|
||||||
|
"typescript": "~3.8.2",
|
||||||
|
"xo": "^0.26.1",
|
||||||
|
"zen-observable": "^0.8.8"
|
||||||
|
},
|
||||||
|
"types": "dist/index.d.ts",
|
||||||
|
"sideEffects": false,
|
||||||
|
"ava": {
|
||||||
|
"extensions": [
|
||||||
|
"ts"
|
||||||
|
],
|
||||||
|
"require": [
|
||||||
|
"ts-node/register"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"xo": {
|
||||||
|
"extends": "xo-typescript",
|
||||||
|
"extensions": [
|
||||||
|
"ts"
|
||||||
|
],
|
||||||
|
"parserOptions": {
|
||||||
|
"project": "./tsconfig.xo.json"
|
||||||
|
},
|
||||||
|
"globals": [
|
||||||
|
"BigInt",
|
||||||
|
"BigInt64Array",
|
||||||
|
"BigUint64Array"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"@typescript-eslint/promise-function-async": "off",
|
||||||
|
"@typescript-eslint/no-empty-function": "off",
|
||||||
|
"@typescript-eslint/explicit-function-return-type": "off"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
651
node_modules/@sindresorhus/is/readme.md
generated
vendored
Normal file
651
node_modules/@sindresorhus/is/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,651 @@
|
||||||
|
# is
|
||||||
|
|
||||||
|
> Type check values
|
||||||
|
|
||||||
|
For example, `is.string('🦄') //=> true`
|
||||||
|
|
||||||
|
<img src="header.gif" width="182" align="right">
|
||||||
|
|
||||||
|
## Highlights
|
||||||
|
|
||||||
|
- Written in TypeScript
|
||||||
|
- [Extensive use of type guards](#type-guards)
|
||||||
|
- [Supports type assertions](#type-assertions)
|
||||||
|
- [Aware of generic type parameters](#generic-type-parameters) (use with caution)
|
||||||
|
- Actively maintained
|
||||||
|
- 
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```
|
||||||
|
$ npm install @sindresorhus/is
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
const is = require('@sindresorhus/is');
|
||||||
|
|
||||||
|
is('🦄');
|
||||||
|
//=> 'string'
|
||||||
|
|
||||||
|
is(new Map());
|
||||||
|
//=> 'Map'
|
||||||
|
|
||||||
|
is.number(6);
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
[Assertions](#type-assertions) perform the same type checks, but throw an error if the type does not match.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const {assert} = require('@sindresorhus/is');
|
||||||
|
|
||||||
|
assert.string(2);
|
||||||
|
//=> Error: Expected value which is `string`, received value of type `number`.
|
||||||
|
```
|
||||||
|
|
||||||
|
And with TypeScript:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import {assert} from '@sindresorhus/is';
|
||||||
|
|
||||||
|
assert.string(foo);
|
||||||
|
// `foo` is now typed as a `string`.
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### is(value)
|
||||||
|
|
||||||
|
Returns the type of `value`.
|
||||||
|
|
||||||
|
Primitives are lowercase and object types are camelcase.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
- `'undefined'`
|
||||||
|
- `'null'`
|
||||||
|
- `'string'`
|
||||||
|
- `'symbol'`
|
||||||
|
- `'Array'`
|
||||||
|
- `'Function'`
|
||||||
|
- `'Object'`
|
||||||
|
|
||||||
|
Note: It will throw an error if you try to feed it object-wrapped primitives, as that's a bad practice. For example `new String('foo')`.
|
||||||
|
|
||||||
|
### is.{method}
|
||||||
|
|
||||||
|
All the below methods accept a value and returns a boolean for whether the value is of the desired type.
|
||||||
|
|
||||||
|
#### Primitives
|
||||||
|
|
||||||
|
##### .undefined(value)
|
||||||
|
##### .null(value)
|
||||||
|
##### .string(value)
|
||||||
|
##### .number(value)
|
||||||
|
|
||||||
|
Note: `is.number(NaN)` returns `false`. This intentionally deviates from `typeof` behavior to increase user-friendliness of `is` type checks.
|
||||||
|
|
||||||
|
##### .boolean(value)
|
||||||
|
##### .symbol(value)
|
||||||
|
##### .bigint(value)
|
||||||
|
|
||||||
|
#### Built-in types
|
||||||
|
|
||||||
|
##### .array(value, assertion?)
|
||||||
|
|
||||||
|
Returns true if `value` is an array and all of its items match the assertion (if provided).
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.array(value); // Validate `value` is an array.
|
||||||
|
is.array(value, is.number); // Validate `value` is an array and all of its items are numbers.
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .function(value)
|
||||||
|
##### .buffer(value)
|
||||||
|
##### .object(value)
|
||||||
|
|
||||||
|
Keep in mind that [functions are objects too](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions).
|
||||||
|
|
||||||
|
##### .numericString(value)
|
||||||
|
|
||||||
|
Returns `true` for a string that represents a number satisfying `is.number`, for example, `'42'` and `'-8.3'`.
|
||||||
|
|
||||||
|
Note: `'NaN'` returns `false`, but `'Infinity'` and `'-Infinity'` return `true`.
|
||||||
|
|
||||||
|
##### .regExp(value)
|
||||||
|
##### .date(value)
|
||||||
|
##### .error(value)
|
||||||
|
##### .nativePromise(value)
|
||||||
|
##### .promise(value)
|
||||||
|
|
||||||
|
Returns `true` for any object with a `.then()` and `.catch()` method. Prefer this one over `.nativePromise()` as you usually want to allow userland promise implementations too.
|
||||||
|
|
||||||
|
##### .generator(value)
|
||||||
|
|
||||||
|
Returns `true` for any object that implements its own `.next()` and `.throw()` methods and has a function definition for `Symbol.iterator`.
|
||||||
|
|
||||||
|
##### .generatorFunction(value)
|
||||||
|
|
||||||
|
##### .asyncFunction(value)
|
||||||
|
|
||||||
|
Returns `true` for any `async` function that can be called with the `await` operator.
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.asyncFunction(async () => {});
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.asyncFunction(() => {});
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .asyncGenerator(value)
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.asyncGenerator(
|
||||||
|
(async function * () {
|
||||||
|
yield 4;
|
||||||
|
})()
|
||||||
|
);
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.asyncGenerator(
|
||||||
|
(function * () {
|
||||||
|
yield 4;
|
||||||
|
})()
|
||||||
|
);
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .asyncGeneratorFunction(value)
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.asyncGeneratorFunction(async function * () {
|
||||||
|
yield 4;
|
||||||
|
});
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.asyncGeneratorFunction(function * () {
|
||||||
|
yield 4;
|
||||||
|
});
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .boundFunction(value)
|
||||||
|
|
||||||
|
Returns `true` for any `bound` function.
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.boundFunction(() => {});
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.boundFunction(function () {}.bind(null));
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.boundFunction(function () {});
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .map(value)
|
||||||
|
##### .set(value)
|
||||||
|
##### .weakMap(value)
|
||||||
|
##### .weakSet(value)
|
||||||
|
|
||||||
|
#### Typed arrays
|
||||||
|
|
||||||
|
##### .int8Array(value)
|
||||||
|
##### .uint8Array(value)
|
||||||
|
##### .uint8ClampedArray(value)
|
||||||
|
##### .int16Array(value)
|
||||||
|
##### .uint16Array(value)
|
||||||
|
##### .int32Array(value)
|
||||||
|
##### .uint32Array(value)
|
||||||
|
##### .float32Array(value)
|
||||||
|
##### .float64Array(value)
|
||||||
|
##### .bigInt64Array(value)
|
||||||
|
##### .bigUint64Array(value)
|
||||||
|
|
||||||
|
#### Structured data
|
||||||
|
|
||||||
|
##### .arrayBuffer(value)
|
||||||
|
##### .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.
|
||||||
|
|
||||||
|
##### .nonEmptyString(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is a `string` and the `.length` is more than 0.
|
||||||
|
|
||||||
|
##### .emptyStringOrWhitespace(value)
|
||||||
|
|
||||||
|
Returns `true` if `is.emptyString(value)` or if it's a `string` that is all whitespace.
|
||||||
|
|
||||||
|
##### .emptyArray(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is an `Array` and the `.length` is 0.
|
||||||
|
|
||||||
|
##### .nonEmptyArray(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is an `Array` and the `.length` is more than 0.
|
||||||
|
|
||||||
|
##### .emptyObject(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is an `Object` and `Object.keys(value).length` is 0.
|
||||||
|
|
||||||
|
Please note that `Object.keys` returns only own enumerable properties. Hence something like this can happen:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const object1 = {};
|
||||||
|
|
||||||
|
Object.defineProperty(object1, 'property1', {
|
||||||
|
value: 42,
|
||||||
|
writable: true,
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
|
||||||
|
is.emptyObject(object1);
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .nonEmptyObject(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is an `Object` and `Object.keys(value).length` is more than 0.
|
||||||
|
|
||||||
|
##### .emptySet(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is a `Set` and the `.size` is 0.
|
||||||
|
|
||||||
|
##### .nonEmptySet(Value)
|
||||||
|
|
||||||
|
Returns `true` if the value is a `Set` and the `.size` is more than 0.
|
||||||
|
|
||||||
|
##### .emptyMap(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is a `Map` and the `.size` is 0.
|
||||||
|
|
||||||
|
##### .nonEmptyMap(value)
|
||||||
|
|
||||||
|
Returns `true` if the value is a `Map` and the `.size` is more than 0.
|
||||||
|
|
||||||
|
#### Miscellaneous
|
||||||
|
|
||||||
|
##### .directInstanceOf(value, class)
|
||||||
|
|
||||||
|
Returns `true` if `value` is a direct instance of `class`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.directInstanceOf(new Error(), Error);
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
class UnicornError extends Error {}
|
||||||
|
|
||||||
|
is.directInstanceOf(new UnicornError(), Error);
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .urlInstance(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is an instance of the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL).
|
||||||
|
|
||||||
|
```js
|
||||||
|
const url = new URL('https://example.com');
|
||||||
|
|
||||||
|
is.urlInstance(url);
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .urlString(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is a URL string.
|
||||||
|
|
||||||
|
Note: this only does basic checking using the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL) constructor.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const url = 'https://example.com';
|
||||||
|
|
||||||
|
is.urlString(url);
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.urlString(new URL(url));
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .truthy(value)
|
||||||
|
|
||||||
|
Returns `true` for all values that evaluate to true in a boolean context:
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.truthy('🦄');
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.truthy(undefined);
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .falsy(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is one of: `false`, `0`, `''`, `null`, `undefined`, `NaN`.
|
||||||
|
|
||||||
|
##### .nan(value)
|
||||||
|
##### .nullOrUndefined(value)
|
||||||
|
##### .primitive(value)
|
||||||
|
|
||||||
|
JavaScript primitives are as follows: `null`, `undefined`, `string`, `number`, `boolean`, `symbol`.
|
||||||
|
|
||||||
|
##### .integer(value)
|
||||||
|
|
||||||
|
##### .safeInteger(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is a [safe integer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
|
||||||
|
|
||||||
|
##### .plainObject(value)
|
||||||
|
|
||||||
|
An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`.
|
||||||
|
|
||||||
|
##### .iterable(value)
|
||||||
|
##### .asyncIterable(value)
|
||||||
|
##### .class(value)
|
||||||
|
|
||||||
|
Returns `true` for instances created by a class.
|
||||||
|
|
||||||
|
##### .typedArray(value)
|
||||||
|
|
||||||
|
##### .arrayLike(value)
|
||||||
|
|
||||||
|
A `value` is array-like if it is not a function and has a `value.length` that is a safe integer greater than or equal to 0.
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.arrayLike(document.forms);
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
function foo() {
|
||||||
|
is.arrayLike(arguments);
|
||||||
|
//=> true
|
||||||
|
}
|
||||||
|
foo();
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .inRange(value, range)
|
||||||
|
|
||||||
|
Check if `value` (number) is in the given `range`. The range is an array of two values, lower bound and upper bound, in no specific order.
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.inRange(3, [0, 5]);
|
||||||
|
is.inRange(3, [5, 0]);
|
||||||
|
is.inRange(0, [-2, 2]);
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .inRange(value, upperBound)
|
||||||
|
|
||||||
|
Check if `value` (number) is in the range of `0` to `upperBound`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.inRange(3, 10);
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .domElement(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is a DOM Element.
|
||||||
|
|
||||||
|
##### .nodeStream(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is a Node.js [stream](https://nodejs.org/api/stream.html).
|
||||||
|
|
||||||
|
```js
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
is.nodeStream(fs.createReadStream('unicorn.png'));
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .observable(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is an `Observable`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const {Observable} = require('rxjs');
|
||||||
|
|
||||||
|
is.observable(new Observable());
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .infinite(value)
|
||||||
|
|
||||||
|
Check if `value` is `Infinity` or `-Infinity`.
|
||||||
|
|
||||||
|
##### .evenInteger(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is an even integer.
|
||||||
|
|
||||||
|
##### .oddInteger(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is an odd integer.
|
||||||
|
|
||||||
|
##### .propertyKey(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` can be used as an object property key (either `string`, `number`, or `symbol`).
|
||||||
|
|
||||||
|
##### .formData(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is an instance of the [`FormData` class](https://developer.mozilla.org/en-US/docs/Web/API/FormData).
|
||||||
|
|
||||||
|
```js
|
||||||
|
const data = new FormData();
|
||||||
|
|
||||||
|
is.formData(data);
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .urlSearchParams(value)
|
||||||
|
|
||||||
|
Returns `true` if `value` is an instance of the [`URLSearchParams` class](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams).
|
||||||
|
|
||||||
|
```js
|
||||||
|
const searchParams = new URLSearchParams();
|
||||||
|
|
||||||
|
is.urlSearchParams(searchParams);
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .any(predicate | predicate[], ...values)
|
||||||
|
|
||||||
|
Using a single `predicate` argument, returns `true` if **any** of the input `values` returns true in the `predicate`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.any(is.string, {}, true, '🦄');
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.any(is.boolean, 'unicorns', [], new Map());
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
Using an array of `predicate[]`, returns `true` if **any** of the input `values` returns true for **any** of the `predicates` provided in an array:
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.any([is.string, is.number], {}, true, '🦄');
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.any([is.boolean, is.number], 'unicorns', [], new Map());
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
##### .all(predicate, ...values)
|
||||||
|
|
||||||
|
Returns `true` if **all** of the input `values` returns true in the `predicate`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
is.all(is.object, {}, new Map(), new Set());
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
is.all(is.string, '🦄', [], 'unicorns');
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
## Type guards
|
||||||
|
|
||||||
|
When using `is` together with TypeScript, [type guards](http://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types) are being used extensively to infer the correct type inside if-else statements.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import is from '@sindresorhus/is';
|
||||||
|
|
||||||
|
const padLeft = (value: string, padding: string | number) => {
|
||||||
|
if (is.number(padding)) {
|
||||||
|
// `padding` is typed as `number`
|
||||||
|
return Array(padding + 1).join(' ') + value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is.string(padding)) {
|
||||||
|
// `padding` is typed as `string`
|
||||||
|
return padding + value;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new TypeError(`Expected 'padding' to be of type 'string' or 'number', got '${is(padding)}'.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
padLeft('🦄', 3);
|
||||||
|
//=> ' 🦄'
|
||||||
|
|
||||||
|
padLeft('🦄', '🌈');
|
||||||
|
//=> '🌈🦄'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Type assertions
|
||||||
|
|
||||||
|
The type guards are also available as [type assertions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions), which throw an error for unexpected types. It is a convenient one-line version of the often repetitive "if-not-expected-type-throw" pattern.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import {assert} from '@sindresorhus/is';
|
||||||
|
|
||||||
|
const handleMovieRatingApiResponse = (response: unknown) => {
|
||||||
|
assert.plainObject(response);
|
||||||
|
// `response` is now typed as a plain `object` with `unknown` properties.
|
||||||
|
|
||||||
|
assert.number(response.rating);
|
||||||
|
// `response.rating` is now typed as a `number`.
|
||||||
|
|
||||||
|
assert.string(response.title);
|
||||||
|
// `response.title` is now typed as a `string`.
|
||||||
|
|
||||||
|
return `${response.title} (${response.rating * 10})`;
|
||||||
|
};
|
||||||
|
|
||||||
|
handleMovieRatingApiResponse({rating: 0.87, title: 'The Matrix'});
|
||||||
|
//=> 'The Matrix (8.7)'
|
||||||
|
|
||||||
|
// This throws an error.
|
||||||
|
handleMovieRatingApiResponse({rating: '🦄'});
|
||||||
|
```
|
||||||
|
|
||||||
|
## Generic type parameters
|
||||||
|
|
||||||
|
The type guards and type assertions are aware of [generic type parameters](https://www.typescriptlang.org/docs/handbook/generics.html), such as `Promise<T>` and `Map<Key, Value>`. The default is `unknown` for most cases, since `is` cannot check them at runtime. If the generic type is known at compile-time, either implicitly (inferred) or explicitly (provided), `is` propagates the type so it can be used later.
|
||||||
|
|
||||||
|
Use generic type parameters with caution. They are only checked by the TypeScript compiler, and not checked by `is` at runtime. This can lead to unexpected behavior, where the generic type is _assumed_ at compile-time, but actually is something completely different at runtime. It is best to use `unknown` (default) and type-check the value of the generic type parameter at runtime with `is` or `assert`.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import {assert} from '@sindresorhus/is';
|
||||||
|
|
||||||
|
async function badNumberAssumption(input: unknown) {
|
||||||
|
// Bad assumption about the generic type parameter fools the compile-time type system.
|
||||||
|
assert.promise<number>(input);
|
||||||
|
// `input` is a `Promise` but only assumed to be `Promise<number>`.
|
||||||
|
|
||||||
|
const resolved = await input;
|
||||||
|
// `resolved` is typed as `number` but was not actually checked at runtime.
|
||||||
|
|
||||||
|
// Multiplication will return NaN if the input promise did not actually contain a number.
|
||||||
|
return 2 * resolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function goodNumberAssertion(input: unknown) {
|
||||||
|
assert.promise(input);
|
||||||
|
// `input` is typed as `Promise<unknown>`
|
||||||
|
|
||||||
|
const resolved = await input;
|
||||||
|
// `resolved` is typed as `unknown`
|
||||||
|
|
||||||
|
assert.number(resolved);
|
||||||
|
// `resolved` is typed as `number`
|
||||||
|
|
||||||
|
// Uses runtime checks so only numbers will reach the multiplication.
|
||||||
|
return 2 * resolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
badNumberAssumption(Promise.resolve('An unexpected string'));
|
||||||
|
//=> NaN
|
||||||
|
|
||||||
|
// This correctly throws an error because of the unexpected string value.
|
||||||
|
goodNumberAssertion(Promise.resolve('An unexpected string'));
|
||||||
|
```
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
### Why yet another type checking module?
|
||||||
|
|
||||||
|
There are hundreds of type checking modules on npm, unfortunately, I couldn't find any that fit my needs:
|
||||||
|
|
||||||
|
- Includes both type methods and ability to get the type
|
||||||
|
- Types of primitives returned as lowercase and object types as camelcase
|
||||||
|
- Covers all built-ins
|
||||||
|
- Unsurprising behavior
|
||||||
|
- Well-maintained
|
||||||
|
- Comprehensive test suite
|
||||||
|
|
||||||
|
For the ones I found, pick 3 of these.
|
||||||
|
|
||||||
|
The most common mistakes I noticed in these modules was using `instanceof` for type checking, forgetting that functions are objects, and omitting `symbol` as a primitive.
|
||||||
|
|
||||||
|
### Why not just use `instanceof` instead of this package?
|
||||||
|
|
||||||
|
`instanceof` does not work correctly for all types and it does not work across [realms](https://stackoverflow.com/a/49832343/64949). Examples of realms are iframes, windows, web workers, and the `vm` module in Node.js.
|
||||||
|
|
||||||
|
## For enterprise
|
||||||
|
|
||||||
|
Available as part of the Tidelift Subscription.
|
||||||
|
|
||||||
|
The maintainers of @sindresorhus/is and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-sindresorhus-is?utm_source=npm-sindresorhus-is&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
- [ow](https://github.com/sindresorhus/ow) - Function argument validation for humans
|
||||||
|
- [is-stream](https://github.com/sindresorhus/is-stream) - Check if something is a Node.js stream
|
||||||
|
- [is-observable](https://github.com/sindresorhus/is-observable) - Check if a value is an Observable
|
||||||
|
- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array
|
||||||
|
- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address
|
||||||
|
- [is-array-sorted](https://github.com/sindresorhus/is-array-sorted) - Check if an Array is sorted
|
||||||
|
- [is-error-constructor](https://github.com/sindresorhus/is-error-constructor) - Check if a value is an error constructor
|
||||||
|
- [is-empty-iterable](https://github.com/sindresorhus/is-empty-iterable) - Check if an Iterable is empty
|
||||||
|
- [is-blob](https://github.com/sindresorhus/is-blob) - Check if a value is a Blob - File-like object of immutable, raw data
|
||||||
|
- [has-emoji](https://github.com/sindresorhus/has-emoji) - Check whether a string has any emoji
|
||||||
|
|
||||||
|
## Maintainers
|
||||||
|
|
||||||
|
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||||
|
- [Giora Guttsait](https://github.com/gioragutt)
|
||||||
|
- [Brandon Smith](https://github.com/brandon93s)
|
21
node_modules/@types/node-fetch/LICENSE
generated
vendored
Executable file
21
node_modules/@types/node-fetch/LICENSE
generated
vendored
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
16
node_modules/@types/node-fetch/README.md
generated
vendored
Executable file
16
node_modules/@types/node-fetch/README.md
generated
vendored
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/node-fetch`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for node-fetch (https://github.com/bitinn/node-fetch).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
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
|
||||||
|
* 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).
|
21
node_modules/@types/node-fetch/externals.d.ts
generated
vendored
Executable file
21
node_modules/@types/node-fetch/externals.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
// `AbortSignal` is defined here to prevent a dependency on a particular
|
||||||
|
// implementation like the `abort-controller` package, and to avoid requiring
|
||||||
|
// the `dom` library in `tsconfig.json`.
|
||||||
|
|
||||||
|
export interface AbortSignal {
|
||||||
|
aborted: boolean;
|
||||||
|
|
||||||
|
addEventListener: (type: "abort", listener: ((this: AbortSignal, event: any) => any), options?: boolean | {
|
||||||
|
capture?: boolean | undefined,
|
||||||
|
once?: boolean | undefined,
|
||||||
|
passive?: boolean | undefined
|
||||||
|
}) => void;
|
||||||
|
|
||||||
|
removeEventListener: (type: "abort", listener: ((this: AbortSignal, event: any) => any), options?: boolean | {
|
||||||
|
capture?: boolean | undefined
|
||||||
|
}) => void;
|
||||||
|
|
||||||
|
dispatchEvent: (event: any) => boolean;
|
||||||
|
|
||||||
|
onabort: null | ((this: AbortSignal, event: any) => void);
|
||||||
|
}
|
223
node_modules/@types/node-fetch/index.d.ts
generated
vendored
Executable file
223
node_modules/@types/node-fetch/index.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,223 @@
|
||||||
|
// Type definitions for node-fetch 2.5
|
||||||
|
// Project: https://github.com/bitinn/node-fetch
|
||||||
|
// Definitions 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>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
|
||||||
|
/// <reference types="node" />
|
||||||
|
|
||||||
|
import FormData = require('form-data');
|
||||||
|
import { Agent } from "http";
|
||||||
|
import { URLSearchParams, URL } from "url";
|
||||||
|
import { AbortSignal } from "./externals";
|
||||||
|
|
||||||
|
export class Request extends Body {
|
||||||
|
constructor(input: RequestInfo, init?: RequestInit);
|
||||||
|
clone(): Request;
|
||||||
|
context: RequestContext;
|
||||||
|
headers: Headers;
|
||||||
|
method: string;
|
||||||
|
redirect: RequestRedirect;
|
||||||
|
referrer: string;
|
||||||
|
url: string;
|
||||||
|
|
||||||
|
// node-fetch extensions to the whatwg/fetch spec
|
||||||
|
agent?: Agent | ((parsedUrl: URL) => Agent) | undefined;
|
||||||
|
compress: boolean;
|
||||||
|
counter: number;
|
||||||
|
follow: number;
|
||||||
|
hostname: string;
|
||||||
|
port?: number | undefined;
|
||||||
|
protocol: string;
|
||||||
|
size: number;
|
||||||
|
timeout: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RequestInit {
|
||||||
|
// whatwg/fetch standard options
|
||||||
|
body?: BodyInit | undefined;
|
||||||
|
headers?: HeadersInit | undefined;
|
||||||
|
method?: string | undefined;
|
||||||
|
redirect?: RequestRedirect | undefined;
|
||||||
|
signal?: AbortSignal | null | undefined;
|
||||||
|
|
||||||
|
// node-fetch extensions
|
||||||
|
agent?: Agent | ((parsedUrl: URL) => Agent) | undefined; // =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
|
||||||
|
timeout?: number | undefined; // =0 req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies)
|
||||||
|
|
||||||
|
// node-fetch does not support mode, cache or credentials options
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RequestContext =
|
||||||
|
"audio"
|
||||||
|
| "beacon"
|
||||||
|
| "cspreport"
|
||||||
|
| "download"
|
||||||
|
| "embed"
|
||||||
|
| "eventsource"
|
||||||
|
| "favicon"
|
||||||
|
| "fetch"
|
||||||
|
| "font"
|
||||||
|
| "form"
|
||||||
|
| "frame"
|
||||||
|
| "hyperlink"
|
||||||
|
| "iframe"
|
||||||
|
| "image"
|
||||||
|
| "imageset"
|
||||||
|
| "import"
|
||||||
|
| "internal"
|
||||||
|
| "location"
|
||||||
|
| "manifest"
|
||||||
|
| "object"
|
||||||
|
| "ping"
|
||||||
|
| "plugin"
|
||||||
|
| "prefetch"
|
||||||
|
| "script"
|
||||||
|
| "serviceworker"
|
||||||
|
| "sharedworker"
|
||||||
|
| "style"
|
||||||
|
| "subresource"
|
||||||
|
| "track"
|
||||||
|
| "video"
|
||||||
|
| "worker"
|
||||||
|
| "xmlhttprequest"
|
||||||
|
| "xslt";
|
||||||
|
export type RequestMode = "cors" | "no-cors" | "same-origin";
|
||||||
|
export type RequestRedirect = "error" | "follow" | "manual";
|
||||||
|
export type RequestCredentials = "omit" | "include" | "same-origin";
|
||||||
|
|
||||||
|
export type RequestCache =
|
||||||
|
"default"
|
||||||
|
| "force-cache"
|
||||||
|
| "no-cache"
|
||||||
|
| "no-store"
|
||||||
|
| "only-if-cached"
|
||||||
|
| "reload";
|
||||||
|
|
||||||
|
export class Headers implements Iterable<[string, string]> {
|
||||||
|
constructor(init?: HeadersInit);
|
||||||
|
forEach(callback: (value: string, name: string) => void): void;
|
||||||
|
append(name: string, value: string): void;
|
||||||
|
delete(name: string): void;
|
||||||
|
get(name: string): string | null;
|
||||||
|
has(name: string): boolean;
|
||||||
|
raw(): { [k: string]: string[] };
|
||||||
|
set(name: string, value: string): void;
|
||||||
|
|
||||||
|
// Iterable methods
|
||||||
|
entries(): IterableIterator<[string, string]>;
|
||||||
|
keys(): IterableIterator<string>;
|
||||||
|
values(): IterableIterator<string>;
|
||||||
|
[Symbol.iterator](): Iterator<[string, string]>;
|
||||||
|
}
|
||||||
|
|
||||||
|
type BlobPart = ArrayBuffer | ArrayBufferView | Blob | string;
|
||||||
|
|
||||||
|
interface BlobOptions {
|
||||||
|
type?: string | undefined;
|
||||||
|
endings?: "transparent" | "native" | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Blob {
|
||||||
|
constructor(blobParts?: BlobPart[], options?: BlobOptions);
|
||||||
|
readonly type: string;
|
||||||
|
readonly size: number;
|
||||||
|
slice(start?: number, end?: number): Blob;
|
||||||
|
text(): Promise<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Body {
|
||||||
|
constructor(body?: any, opts?: { size?: number | undefined; timeout?: number | undefined });
|
||||||
|
arrayBuffer(): Promise<ArrayBuffer>;
|
||||||
|
blob(): Promise<Blob>;
|
||||||
|
body: NodeJS.ReadableStream;
|
||||||
|
bodyUsed: boolean;
|
||||||
|
buffer(): Promise<Buffer>;
|
||||||
|
json(): Promise<any>;
|
||||||
|
size: number;
|
||||||
|
text(): Promise<string>;
|
||||||
|
textConverted(): Promise<string>;
|
||||||
|
timeout: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SystemError extends Error {
|
||||||
|
code?: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class FetchError extends Error {
|
||||||
|
name: "FetchError";
|
||||||
|
constructor(message: string, type: string, systemError?: SystemError);
|
||||||
|
type: string;
|
||||||
|
code?: string | undefined;
|
||||||
|
errno?: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Response extends Body {
|
||||||
|
constructor(body?: BodyInit, init?: ResponseInit);
|
||||||
|
static error(): Response;
|
||||||
|
static redirect(url: string, status: number): Response;
|
||||||
|
clone(): Response;
|
||||||
|
headers: Headers;
|
||||||
|
ok: boolean;
|
||||||
|
redirected: boolean;
|
||||||
|
status: number;
|
||||||
|
statusText: string;
|
||||||
|
type: ResponseType;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ResponseType =
|
||||||
|
"basic"
|
||||||
|
| "cors"
|
||||||
|
| "default"
|
||||||
|
| "error"
|
||||||
|
| "opaque"
|
||||||
|
| "opaqueredirect";
|
||||||
|
|
||||||
|
export interface ResponseInit {
|
||||||
|
headers?: HeadersInit | undefined;
|
||||||
|
size?: number | undefined;
|
||||||
|
status?: number | undefined;
|
||||||
|
statusText?: string | undefined;
|
||||||
|
timeout?: number | undefined;
|
||||||
|
url?: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface URLLike {
|
||||||
|
href: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HeadersInit = Headers | string[][] | { [key: string]: string };
|
||||||
|
// HeaderInit is exported to support backwards compatibility. See PR #34382
|
||||||
|
export type HeaderInit = HeadersInit;
|
||||||
|
export type BodyInit =
|
||||||
|
ArrayBuffer
|
||||||
|
| ArrayBufferView
|
||||||
|
| NodeJS.ReadableStream
|
||||||
|
| string
|
||||||
|
| URLSearchParams
|
||||||
|
| FormData;
|
||||||
|
export type RequestInfo = string | URLLike | Request;
|
||||||
|
|
||||||
|
declare function fetch(
|
||||||
|
url: RequestInfo,
|
||||||
|
init?: RequestInit
|
||||||
|
): Promise<Response>;
|
||||||
|
|
||||||
|
declare namespace fetch {
|
||||||
|
function isRedirect(code: number): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default fetch;
|
356
node_modules/@types/node-fetch/node_modules/form-data/README.md.bak
generated
vendored
Normal file
356
node_modules/@types/node-fetch/node_modules/form-data/README.md.bak
generated
vendored
Normal file
|
@ -0,0 +1,356 @@
|
||||||
|
# Form-Data [](https://www.npmjs.com/package/form-data) [](https://gitter.im/form-data/form-data)
|
||||||
|
|
||||||
|
A library to create readable ```"multipart/form-data"``` streams. Can be used to submit forms and file uploads to other web applications.
|
||||||
|
|
||||||
|
The API of this library is inspired by the [XMLHttpRequest-2 FormData Interface][xhr2-fd].
|
||||||
|
|
||||||
|
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
|
||||||
|
|
||||||
|
[](https://travis-ci.org/form-data/form-data)
|
||||||
|
[](https://travis-ci.org/form-data/form-data)
|
||||||
|
[](https://travis-ci.org/form-data/form-data)
|
||||||
|
|
||||||
|
[](https://coveralls.io/github/form-data/form-data?branch=master)
|
||||||
|
[](https://david-dm.org/form-data/form-data)
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install --save form-data
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
In this example we are constructing a form with 3 fields that contain a string,
|
||||||
|
a buffer and a file stream.
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
var FormData = require('form-data');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
var form = new FormData();
|
||||||
|
form.append('my_field', 'my value');
|
||||||
|
form.append('my_buffer', new Buffer(10));
|
||||||
|
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
|
||||||
|
```
|
||||||
|
|
||||||
|
Also you can use http-response stream:
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
var FormData = require('form-data');
|
||||||
|
var http = require('http');
|
||||||
|
|
||||||
|
var form = new FormData();
|
||||||
|
|
||||||
|
http.request('http://nodejs.org/images/logo.png', function(response) {
|
||||||
|
form.append('my_field', 'my value');
|
||||||
|
form.append('my_buffer', new Buffer(10));
|
||||||
|
form.append('my_logo', response);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Or @mikeal's [request](https://github.com/request/request) stream:
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
var FormData = require('form-data');
|
||||||
|
var request = require('request');
|
||||||
|
|
||||||
|
var form = new FormData();
|
||||||
|
|
||||||
|
form.append('my_field', 'my value');
|
||||||
|
form.append('my_buffer', new Buffer(10));
|
||||||
|
form.append('my_logo', request('http://nodejs.org/images/logo.png'));
|
||||||
|
```
|
||||||
|
|
||||||
|
In order to submit this form to a web application, call ```submit(url, [callback])``` method:
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
form.submit('http://example.org/', function(err, res) {
|
||||||
|
// res – response object (http.IncomingMessage) //
|
||||||
|
res.resume();
|
||||||
|
});
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods.
|
||||||
|
|
||||||
|
### Custom options
|
||||||
|
|
||||||
|
You can provide custom options, such as `maxDataSize`:
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
var FormData = require('form-data');
|
||||||
|
|
||||||
|
var form = new FormData({ maxDataSize: 20971520 });
|
||||||
|
form.append('my_field', 'my value');
|
||||||
|
form.append('my_buffer', /* something big */);
|
||||||
|
```
|
||||||
|
|
||||||
|
List of available options could be found in [combined-stream](https://github.com/felixge/node-combined-stream/blob/master/lib/combined_stream.js#L7-L15)
|
||||||
|
|
||||||
|
### Alternative submission methods
|
||||||
|
|
||||||
|
You can use node's http client interface:
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
var http = require('http');
|
||||||
|
|
||||||
|
var request = http.request({
|
||||||
|
method: 'post',
|
||||||
|
host: 'example.org',
|
||||||
|
path: '/upload',
|
||||||
|
headers: form.getHeaders()
|
||||||
|
});
|
||||||
|
|
||||||
|
form.pipe(request);
|
||||||
|
|
||||||
|
request.on('response', function(res) {
|
||||||
|
console.log(res.statusCode);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Or if you would prefer the `'Content-Length'` header to be set for you:
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
form.submit('example.org/upload', function(err, res) {
|
||||||
|
console.log(res.statusCode);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
To use custom headers and pre-known length in parts:
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
var CRLF = '\r\n';
|
||||||
|
var form = new FormData();
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF,
|
||||||
|
knownLength: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
form.append('my_buffer', buffer, options);
|
||||||
|
|
||||||
|
form.submit('http://example.com/', function(err, res) {
|
||||||
|
if (err) throw err;
|
||||||
|
console.log('Done');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Form-Data can recognize and fetch all the required information from common types of streams (```fs.readStream```, ```http.response``` and ```mikeal's request```), for some other types of streams you'd need to provide "file"-related information manually:
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
someModule.stream(function(err, stdout, stderr) {
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
|
var form = new FormData();
|
||||||
|
|
||||||
|
form.append('file', stdout, {
|
||||||
|
filename: 'unicycle.jpg', // ... or:
|
||||||
|
filepath: 'photos/toys/unicycle.jpg',
|
||||||
|
contentType: 'image/jpeg',
|
||||||
|
knownLength: 19806
|
||||||
|
});
|
||||||
|
|
||||||
|
form.submit('http://example.com/', function(err, res) {
|
||||||
|
if (err) throw err;
|
||||||
|
console.log('Done');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
The `filepath` property overrides `filename` and may contain a relative path. This is typically used when uploading [multiple files from a directory](https://wicg.github.io/entries-api/#dom-htmlinputelement-webkitdirectory).
|
||||||
|
|
||||||
|
For edge cases, like POST request to URL with query string or to pass HTTP auth credentials, object can be passed to `form.submit()` as first parameter:
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
form.submit({
|
||||||
|
host: 'example.com',
|
||||||
|
path: '/probably.php?extra=params',
|
||||||
|
auth: 'username:password'
|
||||||
|
}, function(err, res) {
|
||||||
|
console.log(res.statusCode);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
In case you need to also send custom HTTP headers with the POST request, you can use the `headers` key in first parameter of `form.submit()`:
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
form.submit({
|
||||||
|
host: 'example.com',
|
||||||
|
path: '/surelynot.php',
|
||||||
|
headers: {'x-test-header': 'test-header-value'}
|
||||||
|
}, function(err, res) {
|
||||||
|
console.log(res.statusCode);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Methods
|
||||||
|
|
||||||
|
- [_Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )](https://github.com/form-data/form-data#void-append-string-field-mixed-value--mixed-options-).
|
||||||
|
- [_Headers_ getHeaders( [**Headers** _userHeaders_] )](https://github.com/form-data/form-data#array-getheaders-array-userheaders-)
|
||||||
|
- [_String_ getBoundary()](https://github.com/form-data/form-data#string-getboundary)
|
||||||
|
- [_Void_ setBoundary()](https://github.com/form-data/form-data#void-setboundary)
|
||||||
|
- [_Buffer_ getBuffer()](https://github.com/form-data/form-data#buffer-getbuffer)
|
||||||
|
- [_Integer_ getLengthSync()](https://github.com/form-data/form-data#integer-getlengthsync)
|
||||||
|
- [_Integer_ getLength( **function** _callback_ )](https://github.com/form-data/form-data#integer-getlength-function-callback-)
|
||||||
|
- [_Boolean_ hasKnownLength()](https://github.com/form-data/form-data#boolean-hasknownlength)
|
||||||
|
- [_Request_ submit( _params_, **function** _callback_ )](https://github.com/form-data/form-data#request-submit-params-function-callback-)
|
||||||
|
- [_String_ toString()](https://github.com/form-data/form-data#string-tostring)
|
||||||
|
|
||||||
|
#### _Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )
|
||||||
|
Append data to the form. You can submit about any format (string, integer, boolean, buffer, etc.). However, Arrays are not supported and need to be turned into strings by the user.
|
||||||
|
```javascript
|
||||||
|
var form = new FormData();
|
||||||
|
form.append( 'my_string', 'my value' );
|
||||||
|
form.append( 'my_integer', 1 );
|
||||||
|
form.append( 'my_boolean', true );
|
||||||
|
form.append( 'my_buffer', new Buffer(10) );
|
||||||
|
form.append( 'my_array_as_json', JSON.stringify( ['bird','cute'] ) )
|
||||||
|
```
|
||||||
|
|
||||||
|
You may provide a string for options, or an object.
|
||||||
|
```javascript
|
||||||
|
// Set filename by providing a string for options
|
||||||
|
form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), 'bar.jpg' );
|
||||||
|
|
||||||
|
// provide an object.
|
||||||
|
form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), {filename: 'bar.jpg', contentType: 'image/jpeg', knownLength: 19806} );
|
||||||
|
```
|
||||||
|
|
||||||
|
#### _Headers_ getHeaders( [**Headers** _userHeaders_] )
|
||||||
|
This method adds the correct `content-type` header to the provided array of `userHeaders`.
|
||||||
|
|
||||||
|
#### _String_ getBoundary()
|
||||||
|
Return the boundary of the formData. By default, the boundary consists of 26 `-` followed by 24 numbers
|
||||||
|
for example:
|
||||||
|
```javascript
|
||||||
|
--------------------------515890814546601021194782
|
||||||
|
```
|
||||||
|
|
||||||
|
#### _Void_ setBoundary(String _boundary_)
|
||||||
|
Set the boundary string, overriding the default behavior described above.
|
||||||
|
|
||||||
|
_Note: The boundary must be unique and may not appear in the data._
|
||||||
|
|
||||||
|
#### _Buffer_ getBuffer()
|
||||||
|
Return the full formdata request package, as a Buffer. You can insert this Buffer in e.g. Axios to send multipart data.
|
||||||
|
```javascript
|
||||||
|
var form = new FormData();
|
||||||
|
form.append( 'my_buffer', Buffer.from([0x4a,0x42,0x20,0x52,0x6f,0x63,0x6b,0x73]) );
|
||||||
|
form.append( 'my_file', fs.readFileSync('/foo/bar.jpg') );
|
||||||
|
|
||||||
|
axios.post( 'https://example.com/path/to/api',
|
||||||
|
form.getBuffer(),
|
||||||
|
form.getHeaders()
|
||||||
|
)
|
||||||
|
```
|
||||||
|
**Note:** Because the output is of type Buffer, you can only append types that are accepted by Buffer: *string, Buffer, ArrayBuffer, Array, or Array-like Object*. A ReadStream for example will result in an error.
|
||||||
|
|
||||||
|
#### _Integer_ getLengthSync()
|
||||||
|
Same as `getLength` but synchronous.
|
||||||
|
|
||||||
|
_Note: getLengthSync __doesn't__ calculate streams length._
|
||||||
|
|
||||||
|
#### _Integer_ getLength( **function** _callback_ )
|
||||||
|
Returns the `Content-Length` async. The callback is used to handle errors and continue once the length has been calculated
|
||||||
|
```javascript
|
||||||
|
this.getLength(function(err, length) {
|
||||||
|
if (err) {
|
||||||
|
this._error(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add content length
|
||||||
|
request.setHeader('Content-Length', length);
|
||||||
|
|
||||||
|
...
|
||||||
|
}.bind(this));
|
||||||
|
```
|
||||||
|
|
||||||
|
#### _Boolean_ hasKnownLength()
|
||||||
|
Checks if the length of added values is known.
|
||||||
|
|
||||||
|
#### _Request_ submit( _params_, **function** _callback_ )
|
||||||
|
Submit the form to a web application.
|
||||||
|
```javascript
|
||||||
|
var form = new FormData();
|
||||||
|
form.append( 'my_string', 'Hello World' );
|
||||||
|
|
||||||
|
form.submit( 'http://example.com/', function(err, res) {
|
||||||
|
// res – response object (http.IncomingMessage) //
|
||||||
|
res.resume();
|
||||||
|
} );
|
||||||
|
```
|
||||||
|
|
||||||
|
#### _String_ toString()
|
||||||
|
Returns the form data as a string. Don't use this if you are sending files or buffers, use `getBuffer()` instead.
|
||||||
|
|
||||||
|
### Integration with other libraries
|
||||||
|
|
||||||
|
#### Request
|
||||||
|
|
||||||
|
Form submission using [request](https://github.com/request/request):
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var formData = {
|
||||||
|
my_field: 'my_value',
|
||||||
|
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
|
||||||
|
};
|
||||||
|
|
||||||
|
request.post({url:'http://service.com/upload', formData: formData}, function(err, httpResponse, body) {
|
||||||
|
if (err) {
|
||||||
|
return console.error('upload failed:', err);
|
||||||
|
}
|
||||||
|
console.log('Upload successful! Server responded with:', body);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
For more details see [request readme](https://github.com/request/request#multipartform-data-multipart-form-uploads).
|
||||||
|
|
||||||
|
#### node-fetch
|
||||||
|
|
||||||
|
You can also submit a form using [node-fetch](https://github.com/bitinn/node-fetch):
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var form = new FormData();
|
||||||
|
|
||||||
|
form.append('a', 1);
|
||||||
|
|
||||||
|
fetch('http://example.com', { method: 'POST', body: form })
|
||||||
|
.then(function(res) {
|
||||||
|
return res.json();
|
||||||
|
}).then(function(json) {
|
||||||
|
console.log(json);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### axios
|
||||||
|
|
||||||
|
In Node.js you can post a file using [axios](https://github.com/axios/axios):
|
||||||
|
```javascript
|
||||||
|
const form = new FormData();
|
||||||
|
const stream = fs.createReadStream(PATH_TO_FILE);
|
||||||
|
|
||||||
|
form.append('image', stream);
|
||||||
|
|
||||||
|
// In Node.js environment you need to set boundary in the header field 'Content-Type' by calling method `getHeaders`
|
||||||
|
const formHeaders = form.getHeaders();
|
||||||
|
|
||||||
|
axios.post('http://example.com', form, {
|
||||||
|
headers: {
|
||||||
|
...formHeaders,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(response => response)
|
||||||
|
.catch(error => error)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround.
|
||||||
|
- Starting version `2.x` FormData has dropped support for `node@0.10.x`.
|
||||||
|
- Starting version `3.x` FormData has dropped support for `node@4.x`.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Form-Data is released under the [MIT](License) license.
|
|
@ -6,11 +6,11 @@ The API of this library is inspired by the [XMLHttpRequest-2 FormData Interface]
|
||||||
|
|
||||||
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
|
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
|
||||||
|
|
||||||
[](https://travis-ci.org/form-data/form-data)
|
[](https://travis-ci.org/form-data/form-data)
|
||||||
[](https://travis-ci.org/form-data/form-data)
|
[](https://travis-ci.org/form-data/form-data)
|
||||||
[](https://travis-ci.org/form-data/form-data)
|
[](https://travis-ci.org/form-data/form-data)
|
||||||
|
|
||||||
[](https://coveralls.io/github/form-data/form-data?branch=master)
|
[](https://coveralls.io/github/form-data/form-data?branch=master)
|
||||||
[](https://david-dm.org/form-data/form-data)
|
[](https://david-dm.org/form-data/form-data)
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
@ -189,6 +189,7 @@ form.submit({
|
||||||
- [_Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )](https://github.com/form-data/form-data#void-append-string-field-mixed-value--mixed-options-).
|
- [_Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )](https://github.com/form-data/form-data#void-append-string-field-mixed-value--mixed-options-).
|
||||||
- [_Headers_ getHeaders( [**Headers** _userHeaders_] )](https://github.com/form-data/form-data#array-getheaders-array-userheaders-)
|
- [_Headers_ getHeaders( [**Headers** _userHeaders_] )](https://github.com/form-data/form-data#array-getheaders-array-userheaders-)
|
||||||
- [_String_ getBoundary()](https://github.com/form-data/form-data#string-getboundary)
|
- [_String_ getBoundary()](https://github.com/form-data/form-data#string-getboundary)
|
||||||
|
- [_Void_ setBoundary()](https://github.com/form-data/form-data#void-setboundary)
|
||||||
- [_Buffer_ getBuffer()](https://github.com/form-data/form-data#buffer-getbuffer)
|
- [_Buffer_ getBuffer()](https://github.com/form-data/form-data#buffer-getbuffer)
|
||||||
- [_Integer_ getLengthSync()](https://github.com/form-data/form-data#integer-getlengthsync)
|
- [_Integer_ getLengthSync()](https://github.com/form-data/form-data#integer-getlengthsync)
|
||||||
- [_Integer_ getLength( **function** _callback_ )](https://github.com/form-data/form-data#integer-getlength-function-callback-)
|
- [_Integer_ getLength( **function** _callback_ )](https://github.com/form-data/form-data#integer-getlength-function-callback-)
|
||||||
|
@ -220,11 +221,15 @@ form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), {filename: 'bar.jpg
|
||||||
This method adds the correct `content-type` header to the provided array of `userHeaders`.
|
This method adds the correct `content-type` header to the provided array of `userHeaders`.
|
||||||
|
|
||||||
#### _String_ getBoundary()
|
#### _String_ getBoundary()
|
||||||
Return the boundary of the formData. A boundary consists of 26 `-` followed by 24 numbers
|
Return the boundary of the formData. By default, the boundary consists of 26 `-` followed by 24 numbers
|
||||||
for example:
|
for example:
|
||||||
```javascript
|
```javascript
|
||||||
--------------------------515890814546601021194782
|
--------------------------515890814546601021194782
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### _Void_ setBoundary(String _boundary_)
|
||||||
|
Set the boundary string, overriding the default behavior described above.
|
||||||
|
|
||||||
_Note: The boundary must be unique and may not appear in the data._
|
_Note: The boundary must be unique and may not appear in the data._
|
||||||
|
|
||||||
#### _Buffer_ getBuffer()
|
#### _Buffer_ getBuffer()
|
||||||
|
@ -343,8 +348,6 @@ axios.post('http://example.com', form, {
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround.
|
- ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround.
|
||||||
- ```getLength(cb)``` will send an error as first parameter of callback if stream length cannot be calculated (e.g. send in custom streams w/o using ```knownLength```).
|
|
||||||
- ```sbumit``` will not add `content-length` if form length is unknown or not calculable.
|
|
||||||
- Starting version `2.x` FormData has dropped support for `node@0.10.x`.
|
- Starting version `2.x` FormData has dropped support for `node@0.10.x`.
|
||||||
- Starting version `3.x` FormData has dropped support for `node@4.x`.
|
- Starting version `3.x` FormData has dropped support for `node@4.x`.
|
||||||
|
|
|
@ -36,6 +36,7 @@ declare class FormData extends stream.Readable {
|
||||||
callback?: (error: Error | null, response: http.IncomingMessage) => void
|
callback?: (error: Error | null, response: http.IncomingMessage) => void
|
||||||
): http.ClientRequest;
|
): http.ClientRequest;
|
||||||
getBuffer(): Buffer;
|
getBuffer(): Buffer;
|
||||||
|
setBoundary(boundary: string): void;
|
||||||
getBoundary(): string;
|
getBoundary(): string;
|
||||||
getLength(callback: (err: Error | null, length: number) => void): void;
|
getLength(callback: (err: Error | null, length: number) => void): void;
|
||||||
getLengthSync(): number;
|
getLengthSync(): number;
|
498
node_modules/@types/node-fetch/node_modules/form-data/lib/form_data.js
generated
vendored
Normal file
498
node_modules/@types/node-fetch/node_modules/form-data/lib/form_data.js
generated
vendored
Normal file
|
@ -0,0 +1,498 @@
|
||||||
|
var CombinedStream = require('combined-stream');
|
||||||
|
var util = require('util');
|
||||||
|
var path = require('path');
|
||||||
|
var http = require('http');
|
||||||
|
var https = require('https');
|
||||||
|
var parseUrl = require('url').parse;
|
||||||
|
var fs = require('fs');
|
||||||
|
var mime = require('mime-types');
|
||||||
|
var asynckit = require('asynckit');
|
||||||
|
var populate = require('./populate.js');
|
||||||
|
|
||||||
|
// Public API
|
||||||
|
module.exports = FormData;
|
||||||
|
|
||||||
|
// make it a Stream
|
||||||
|
util.inherits(FormData, CombinedStream);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create readable "multipart/form-data" streams.
|
||||||
|
* Can be used to submit forms
|
||||||
|
* and file uploads to other web applications.
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
* @param {Object} options - Properties to be added/overriden for FormData and CombinedStream
|
||||||
|
*/
|
||||||
|
function FormData(options) {
|
||||||
|
if (!(this instanceof FormData)) {
|
||||||
|
return new FormData(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._overheadLength = 0;
|
||||||
|
this._valueLength = 0;
|
||||||
|
this._valuesToMeasure = [];
|
||||||
|
|
||||||
|
CombinedStream.call(this);
|
||||||
|
|
||||||
|
options = options || {};
|
||||||
|
for (var option in options) {
|
||||||
|
this[option] = options[option];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FormData.LINE_BREAK = '\r\n';
|
||||||
|
FormData.DEFAULT_CONTENT_TYPE = 'application/octet-stream';
|
||||||
|
|
||||||
|
FormData.prototype.append = function(field, value, options) {
|
||||||
|
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
// allow filename as single option
|
||||||
|
if (typeof options == 'string') {
|
||||||
|
options = {filename: options};
|
||||||
|
}
|
||||||
|
|
||||||
|
var append = CombinedStream.prototype.append.bind(this);
|
||||||
|
|
||||||
|
// all that streamy business can't handle numbers
|
||||||
|
if (typeof value == 'number') {
|
||||||
|
value = '' + value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/felixge/node-form-data/issues/38
|
||||||
|
if (util.isArray(value)) {
|
||||||
|
// Please convert your array into string
|
||||||
|
// the way web server expects it
|
||||||
|
this._error(new Error('Arrays are not supported.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var header = this._multiPartHeader(field, value, options);
|
||||||
|
var footer = this._multiPartFooter();
|
||||||
|
|
||||||
|
append(header);
|
||||||
|
append(value);
|
||||||
|
append(footer);
|
||||||
|
|
||||||
|
// pass along options.knownLength
|
||||||
|
this._trackLength(header, value, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype._trackLength = function(header, value, options) {
|
||||||
|
var valueLength = 0;
|
||||||
|
|
||||||
|
// used w/ getLengthSync(), when length is known.
|
||||||
|
// e.g. for streaming directly from a remote server,
|
||||||
|
// w/ a known file a size, and not wanting to wait for
|
||||||
|
// incoming file to finish to get its size.
|
||||||
|
if (options.knownLength != null) {
|
||||||
|
valueLength += +options.knownLength;
|
||||||
|
} else if (Buffer.isBuffer(value)) {
|
||||||
|
valueLength = value.length;
|
||||||
|
} else if (typeof value === 'string') {
|
||||||
|
valueLength = Buffer.byteLength(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._valueLength += valueLength;
|
||||||
|
|
||||||
|
// @check why add CRLF? does this account for custom/multiple CRLFs?
|
||||||
|
this._overheadLength +=
|
||||||
|
Buffer.byteLength(header) +
|
||||||
|
FormData.LINE_BREAK.length;
|
||||||
|
|
||||||
|
// empty or either doesn't have path or not an http response
|
||||||
|
if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) )) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// no need to bother with the length
|
||||||
|
if (!options.knownLength) {
|
||||||
|
this._valuesToMeasure.push(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype._lengthRetriever = function(value, callback) {
|
||||||
|
|
||||||
|
if (value.hasOwnProperty('fd')) {
|
||||||
|
|
||||||
|
// take read range into a account
|
||||||
|
// `end` = Infinity –> read file till the end
|
||||||
|
//
|
||||||
|
// TODO: Looks like there is bug in Node fs.createReadStream
|
||||||
|
// it doesn't respect `end` options without `start` options
|
||||||
|
// Fix it when node fixes it.
|
||||||
|
// https://github.com/joyent/node/issues/7819
|
||||||
|
if (value.end != undefined && value.end != Infinity && value.start != undefined) {
|
||||||
|
|
||||||
|
// when end specified
|
||||||
|
// no need to calculate range
|
||||||
|
// inclusive, starts with 0
|
||||||
|
callback(null, value.end + 1 - (value.start ? value.start : 0));
|
||||||
|
|
||||||
|
// not that fast snoopy
|
||||||
|
} else {
|
||||||
|
// still need to fetch file size from fs
|
||||||
|
fs.stat(value.path, function(err, stat) {
|
||||||
|
|
||||||
|
var fileSize;
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update final size based on the range options
|
||||||
|
fileSize = stat.size - (value.start ? value.start : 0);
|
||||||
|
callback(null, fileSize);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// or http response
|
||||||
|
} else if (value.hasOwnProperty('httpVersion')) {
|
||||||
|
callback(null, +value.headers['content-length']);
|
||||||
|
|
||||||
|
// or request stream http://github.com/mikeal/request
|
||||||
|
} else if (value.hasOwnProperty('httpModule')) {
|
||||||
|
// wait till response come back
|
||||||
|
value.on('response', function(response) {
|
||||||
|
value.pause();
|
||||||
|
callback(null, +response.headers['content-length']);
|
||||||
|
});
|
||||||
|
value.resume();
|
||||||
|
|
||||||
|
// something else
|
||||||
|
} else {
|
||||||
|
callback('Unknown stream');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype._multiPartHeader = function(field, value, options) {
|
||||||
|
// custom header specified (as string)?
|
||||||
|
// it becomes responsible for boundary
|
||||||
|
// (e.g. to handle extra CRLFs on .NET servers)
|
||||||
|
if (typeof options.header == 'string') {
|
||||||
|
return options.header;
|
||||||
|
}
|
||||||
|
|
||||||
|
var contentDisposition = this._getContentDisposition(value, options);
|
||||||
|
var contentType = this._getContentType(value, options);
|
||||||
|
|
||||||
|
var contents = '';
|
||||||
|
var headers = {
|
||||||
|
// add custom disposition as third element or keep it two elements if not
|
||||||
|
'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || []),
|
||||||
|
// if no content type. allow it to be empty array
|
||||||
|
'Content-Type': [].concat(contentType || [])
|
||||||
|
};
|
||||||
|
|
||||||
|
// allow custom headers.
|
||||||
|
if (typeof options.header == 'object') {
|
||||||
|
populate(headers, options.header);
|
||||||
|
}
|
||||||
|
|
||||||
|
var header;
|
||||||
|
for (var prop in headers) {
|
||||||
|
if (!headers.hasOwnProperty(prop)) continue;
|
||||||
|
header = headers[prop];
|
||||||
|
|
||||||
|
// skip nullish headers.
|
||||||
|
if (header == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert all headers to arrays.
|
||||||
|
if (!Array.isArray(header)) {
|
||||||
|
header = [header];
|
||||||
|
}
|
||||||
|
|
||||||
|
// add non-empty headers.
|
||||||
|
if (header.length) {
|
||||||
|
contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '--' + this.getBoundary() + FormData.LINE_BREAK + contents + FormData.LINE_BREAK;
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype._getContentDisposition = function(value, options) {
|
||||||
|
|
||||||
|
var filename
|
||||||
|
, contentDisposition
|
||||||
|
;
|
||||||
|
|
||||||
|
if (typeof options.filepath === 'string') {
|
||||||
|
// custom filepath for relative paths
|
||||||
|
filename = path.normalize(options.filepath).replace(/\\/g, '/');
|
||||||
|
} else if (options.filename || value.name || value.path) {
|
||||||
|
// custom filename take precedence
|
||||||
|
// formidable and the browser add a name property
|
||||||
|
// fs- and request- streams have path property
|
||||||
|
filename = path.basename(options.filename || value.name || value.path);
|
||||||
|
} else if (value.readable && value.hasOwnProperty('httpVersion')) {
|
||||||
|
// or try http response
|
||||||
|
filename = path.basename(value.client._httpMessage.path || '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filename) {
|
||||||
|
contentDisposition = 'filename="' + filename + '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
return contentDisposition;
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype._getContentType = function(value, options) {
|
||||||
|
|
||||||
|
// use custom content-type above all
|
||||||
|
var contentType = options.contentType;
|
||||||
|
|
||||||
|
// or try `name` from formidable, browser
|
||||||
|
if (!contentType && value.name) {
|
||||||
|
contentType = mime.lookup(value.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// or try `path` from fs-, request- streams
|
||||||
|
if (!contentType && value.path) {
|
||||||
|
contentType = mime.lookup(value.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// or if it's http-reponse
|
||||||
|
if (!contentType && value.readable && value.hasOwnProperty('httpVersion')) {
|
||||||
|
contentType = value.headers['content-type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// or guess it from the filepath or filename
|
||||||
|
if (!contentType && (options.filepath || options.filename)) {
|
||||||
|
contentType = mime.lookup(options.filepath || options.filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fallback to the default content type if `value` is not simple value
|
||||||
|
if (!contentType && typeof value == 'object') {
|
||||||
|
contentType = FormData.DEFAULT_CONTENT_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return contentType;
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype._multiPartFooter = function() {
|
||||||
|
return function(next) {
|
||||||
|
var footer = FormData.LINE_BREAK;
|
||||||
|
|
||||||
|
var lastPart = (this._streams.length === 0);
|
||||||
|
if (lastPart) {
|
||||||
|
footer += this._lastBoundary();
|
||||||
|
}
|
||||||
|
|
||||||
|
next(footer);
|
||||||
|
}.bind(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype._lastBoundary = function() {
|
||||||
|
return '--' + this.getBoundary() + '--' + FormData.LINE_BREAK;
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype.getHeaders = function(userHeaders) {
|
||||||
|
var header;
|
||||||
|
var formHeaders = {
|
||||||
|
'content-type': 'multipart/form-data; boundary=' + this.getBoundary()
|
||||||
|
};
|
||||||
|
|
||||||
|
for (header in userHeaders) {
|
||||||
|
if (userHeaders.hasOwnProperty(header)) {
|
||||||
|
formHeaders[header.toLowerCase()] = userHeaders[header];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return formHeaders;
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype.setBoundary = function(boundary) {
|
||||||
|
this._boundary = boundary;
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype.getBoundary = function() {
|
||||||
|
if (!this._boundary) {
|
||||||
|
this._generateBoundary();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._boundary;
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype.getBuffer = function() {
|
||||||
|
var dataBuffer = new Buffer.alloc( 0 );
|
||||||
|
var boundary = this.getBoundary();
|
||||||
|
|
||||||
|
// Create the form content. Add Line breaks to the end of data.
|
||||||
|
for (var i = 0, len = this._streams.length; i < len; i++) {
|
||||||
|
if (typeof this._streams[i] !== 'function') {
|
||||||
|
|
||||||
|
// Add content to the buffer.
|
||||||
|
if(Buffer.isBuffer(this._streams[i])) {
|
||||||
|
dataBuffer = Buffer.concat( [dataBuffer, this._streams[i]]);
|
||||||
|
}else {
|
||||||
|
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(this._streams[i])]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add break after content.
|
||||||
|
if (typeof this._streams[i] !== 'string' || this._streams[i].substring( 2, boundary.length + 2 ) !== boundary) {
|
||||||
|
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(FormData.LINE_BREAK)] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the footer and return the Buffer object.
|
||||||
|
return Buffer.concat( [dataBuffer, Buffer.from(this._lastBoundary())] );
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype._generateBoundary = function() {
|
||||||
|
// This generates a 50 character boundary similar to those used by Firefox.
|
||||||
|
// They are optimized for boyer-moore parsing.
|
||||||
|
var boundary = '--------------------------';
|
||||||
|
for (var i = 0; i < 24; i++) {
|
||||||
|
boundary += Math.floor(Math.random() * 10).toString(16);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._boundary = boundary;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Note: getLengthSync DOESN'T calculate streams length
|
||||||
|
// As workaround one can calculate file size manually
|
||||||
|
// and add it as knownLength option
|
||||||
|
FormData.prototype.getLengthSync = function() {
|
||||||
|
var knownLength = this._overheadLength + this._valueLength;
|
||||||
|
|
||||||
|
// Don't get confused, there are 3 "internal" streams for each keyval pair
|
||||||
|
// so it basically checks if there is any value added to the form
|
||||||
|
if (this._streams.length) {
|
||||||
|
knownLength += this._lastBoundary().length;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/form-data/form-data/issues/40
|
||||||
|
if (!this.hasKnownLength()) {
|
||||||
|
// Some async length retrievers are present
|
||||||
|
// therefore synchronous length calculation is false.
|
||||||
|
// Please use getLength(callback) to get proper length
|
||||||
|
this._error(new Error('Cannot calculate proper length in synchronous way.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return knownLength;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Public API to check if length of added values is known
|
||||||
|
// https://github.com/form-data/form-data/issues/196
|
||||||
|
// https://github.com/form-data/form-data/issues/262
|
||||||
|
FormData.prototype.hasKnownLength = function() {
|
||||||
|
var hasKnownLength = true;
|
||||||
|
|
||||||
|
if (this._valuesToMeasure.length) {
|
||||||
|
hasKnownLength = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hasKnownLength;
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype.getLength = function(cb) {
|
||||||
|
var knownLength = this._overheadLength + this._valueLength;
|
||||||
|
|
||||||
|
if (this._streams.length) {
|
||||||
|
knownLength += this._lastBoundary().length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this._valuesToMeasure.length) {
|
||||||
|
process.nextTick(cb.bind(this, null, knownLength));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
|
||||||
|
if (err) {
|
||||||
|
cb(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
values.forEach(function(length) {
|
||||||
|
knownLength += length;
|
||||||
|
});
|
||||||
|
|
||||||
|
cb(null, knownLength);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype.submit = function(params, cb) {
|
||||||
|
var request
|
||||||
|
, options
|
||||||
|
, defaults = {method: 'post'}
|
||||||
|
;
|
||||||
|
|
||||||
|
// parse provided url if it's string
|
||||||
|
// or treat it as options object
|
||||||
|
if (typeof params == 'string') {
|
||||||
|
|
||||||
|
params = parseUrl(params);
|
||||||
|
options = populate({
|
||||||
|
port: params.port,
|
||||||
|
path: params.pathname,
|
||||||
|
host: params.hostname,
|
||||||
|
protocol: params.protocol
|
||||||
|
}, defaults);
|
||||||
|
|
||||||
|
// use custom params
|
||||||
|
} else {
|
||||||
|
|
||||||
|
options = populate(params, defaults);
|
||||||
|
// if no port provided use default one
|
||||||
|
if (!options.port) {
|
||||||
|
options.port = options.protocol == 'https:' ? 443 : 80;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// put that good code in getHeaders to some use
|
||||||
|
options.headers = this.getHeaders(params.headers);
|
||||||
|
|
||||||
|
// https if specified, fallback to http in any other case
|
||||||
|
if (options.protocol == 'https:') {
|
||||||
|
request = https.request(options);
|
||||||
|
} else {
|
||||||
|
request = http.request(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get content length and fire away
|
||||||
|
this.getLength(function(err, length) {
|
||||||
|
if (err) {
|
||||||
|
this._error(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add content length
|
||||||
|
request.setHeader('Content-Length', length);
|
||||||
|
|
||||||
|
this.pipe(request);
|
||||||
|
if (cb) {
|
||||||
|
var onResponse;
|
||||||
|
|
||||||
|
var callback = function (error, responce) {
|
||||||
|
request.removeListener('error', callback);
|
||||||
|
request.removeListener('response', onResponse);
|
||||||
|
|
||||||
|
return cb.call(this, error, responce);
|
||||||
|
};
|
||||||
|
|
||||||
|
onResponse = callback.bind(this, null);
|
||||||
|
|
||||||
|
request.on('error', callback);
|
||||||
|
request.on('response', onResponse);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
return request;
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype._error = function(err) {
|
||||||
|
if (!this.error) {
|
||||||
|
this.error = err;
|
||||||
|
this.pause();
|
||||||
|
this.emit('error', err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
FormData.prototype.toString = function () {
|
||||||
|
return '[object FormData]';
|
||||||
|
};
|
|
@ -1,45 +1,47 @@
|
||||||
{
|
{
|
||||||
"_from": "@discordjs/form-data@^3.0.1",
|
"author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)",
|
||||||
"_id": "@discordjs/form-data@3.0.1",
|
"name": "form-data",
|
||||||
"_inBundle": false,
|
"description": "A library to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.",
|
||||||
"_integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
|
"version": "3.0.1",
|
||||||
"_location": "/@discordjs/form-data",
|
"repository": {
|
||||||
"_phantomChildren": {},
|
"type": "git",
|
||||||
"_requested": {
|
"url": "git://github.com/form-data/form-data.git"
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "@discordjs/form-data@^3.0.1",
|
|
||||||
"name": "@discordjs/form-data",
|
|
||||||
"escapedName": "@discordjs%2fform-data",
|
|
||||||
"scope": "@discordjs",
|
|
||||||
"rawSpec": "^3.0.1",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^3.0.1"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/discord.js"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
|
|
||||||
"_shasum": "5c9e6be992e2e57d0dfa0e39979a850225fb4697",
|
|
||||||
"_spec": "@discordjs/form-data@^3.0.1",
|
|
||||||
"_where": "C:\\Users\\hlack\\Desktop\\discord bot\\node_modules\\discord.js",
|
|
||||||
"author": {
|
|
||||||
"name": "Felix Geisendörfer",
|
|
||||||
"email": "felix@debuggable.com",
|
|
||||||
"url": "http://debuggable.com/"
|
|
||||||
},
|
},
|
||||||
|
"main": "./lib/form_data",
|
||||||
"browser": "./lib/browser",
|
"browser": "./lib/browser",
|
||||||
"bugs": {
|
"typings": "./index.d.ts",
|
||||||
"url": "https://github.com/form-data/form-data/issues"
|
"scripts": {
|
||||||
|
"pretest": "rimraf coverage test/tmp",
|
||||||
|
"test": "istanbul cover test/run.js",
|
||||||
|
"posttest": "istanbul report lcov text",
|
||||||
|
"lint": "eslint lib/*.js test/*.js test/integration/*.js",
|
||||||
|
"report": "istanbul report lcov text",
|
||||||
|
"ci-lint": "is-node-modern 8 && npm run lint || is-node-not-modern 8",
|
||||||
|
"ci-test": "npm run test && npm run browser && npm run report",
|
||||||
|
"predebug": "rimraf coverage test/tmp",
|
||||||
|
"debug": "verbose=1 ./test/run.js",
|
||||||
|
"browser": "browserify -t browserify-istanbul test/run-browser.js | obake --coverage",
|
||||||
|
"check": "istanbul check-coverage coverage/coverage*.json",
|
||||||
|
"files": "pkgfiles --sort=name",
|
||||||
|
"get-version": "node -e \"console.log(require('./package.json').version)\"",
|
||||||
|
"update-readme": "sed -i.bak 's/\\/master\\.svg/\\/v'$(npm --silent run get-version)'.svg/g' README.md",
|
||||||
|
"restore-readme": "mv README.md.bak README.md",
|
||||||
|
"prepublish": "in-publish && npm run update-readme || not-in-publish",
|
||||||
|
"postpublish": "npm run restore-readme"
|
||||||
|
},
|
||||||
|
"pre-commit": [
|
||||||
|
"lint",
|
||||||
|
"ci-test",
|
||||||
|
"check"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6"
|
||||||
},
|
},
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"asynckit": "^0.4.0",
|
"asynckit": "^0.4.0",
|
||||||
"combined-stream": "^1.0.8",
|
"combined-stream": "^1.0.8",
|
||||||
"mime-types": "^2.1.12"
|
"mime-types": "^2.1.12"
|
||||||
},
|
},
|
||||||
"deprecated": false,
|
|
||||||
"description": "A library to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.",
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^12.0.10",
|
"@types/node": "^12.0.10",
|
||||||
"browserify": "^13.1.1",
|
"browserify": "^13.1.1",
|
||||||
|
@ -54,45 +56,13 @@
|
||||||
"is-node-modern": "^1.0.0",
|
"is-node-modern": "^1.0.0",
|
||||||
"istanbul": "^0.4.5",
|
"istanbul": "^0.4.5",
|
||||||
"obake": "^0.1.2",
|
"obake": "^0.1.2",
|
||||||
|
"puppeteer": "^1.19.0",
|
||||||
"pkgfiles": "^2.3.0",
|
"pkgfiles": "^2.3.0",
|
||||||
"pre-commit": "^1.1.3",
|
"pre-commit": "^1.1.3",
|
||||||
"puppeteer": "^1.19.0",
|
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
"rimraf": "^2.7.1",
|
"rimraf": "^2.7.1",
|
||||||
"tape": "^4.6.2",
|
"tape": "^4.6.2",
|
||||||
"typescript": "^3.5.2"
|
"typescript": "^3.5.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"license": "MIT"
|
||||||
"node": ">= 6"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/form-data/form-data#readme",
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "./lib/form_data",
|
|
||||||
"name": "@discordjs/form-data",
|
|
||||||
"pre-commit": [
|
|
||||||
"lint",
|
|
||||||
"ci-test",
|
|
||||||
"check"
|
|
||||||
],
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git://github.com/form-data/form-data.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"browser": "browserify -t browserify-istanbul test/run-browser.js | obake --coverage",
|
|
||||||
"check": "istanbul check-coverage coverage/coverage*.json",
|
|
||||||
"ci-lint": "is-node-modern 8 && npm run lint || is-node-not-modern 8",
|
|
||||||
"ci-test": "npm run test && npm run browser && npm run report",
|
|
||||||
"debug": "verbose=1 ./test/run.js",
|
|
||||||
"files": "pkgfiles --sort=name",
|
|
||||||
"get-version": "node -e \"console.log(require('./package.json').version)\"",
|
|
||||||
"lint": "eslint lib/*.js test/*.js test/integration/*.js",
|
|
||||||
"posttest": "istanbul report lcov text",
|
|
||||||
"predebug": "rimraf coverage test/tmp",
|
|
||||||
"pretest": "rimraf coverage test/tmp",
|
|
||||||
"report": "istanbul report lcov text",
|
|
||||||
"test": "istanbul cover test/run.js"
|
|
||||||
},
|
|
||||||
"typings": "./index.d.ts",
|
|
||||||
"version": "3.0.1"
|
|
||||||
}
|
}
|
78
node_modules/@types/node-fetch/package.json
generated
vendored
Executable file
78
node_modules/@types/node-fetch/package.json
generated
vendored
Executable file
|
@ -0,0 +1,78 @@
|
||||||
|
{
|
||||||
|
"name": "@types/node-fetch",
|
||||||
|
"version": "2.5.12",
|
||||||
|
"description": "TypeScript definitions for node-fetch",
|
||||||
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-fetch",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Torsten Werner",
|
||||||
|
"url": "https://github.com/torstenwerner",
|
||||||
|
"githubUsername": "torstenwerner"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Niklas Lindgren",
|
||||||
|
"url": "https://github.com/nikcorg",
|
||||||
|
"githubUsername": "nikcorg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Vinay Bedre",
|
||||||
|
"url": "https://github.com/vinaybedre",
|
||||||
|
"githubUsername": "vinaybedre"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Antonio Román",
|
||||||
|
"url": "https://github.com/kyranet",
|
||||||
|
"githubUsername": "kyranet"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Andrew Leedham",
|
||||||
|
"url": "https://github.com/AndrewLeedham",
|
||||||
|
"githubUsername": "AndrewLeedham"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jason Li",
|
||||||
|
"url": "https://github.com/JasonLi914",
|
||||||
|
"githubUsername": "JasonLi914"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Steve Faulkner",
|
||||||
|
"url": "https://github.com/southpolesteve",
|
||||||
|
"githubUsername": "southpolesteve"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ExE Boss",
|
||||||
|
"url": "https://github.com/ExE-Boss",
|
||||||
|
"githubUsername": "ExE-Boss"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alex Savin",
|
||||||
|
"url": "https://github.com/alexandrusavin",
|
||||||
|
"githubUsername": "alexandrusavin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alexis Tyler",
|
||||||
|
"url": "https://github.com/OmgImAlexis",
|
||||||
|
"githubUsername": "OmgImAlexis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jakub Kisielewski",
|
||||||
|
"url": "https://github.com/kbkk",
|
||||||
|
"githubUsername": "kbkk"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index.d.ts",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/node-fetch"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*",
|
||||||
|
"form-data": "^3.0.0"
|
||||||
|
},
|
||||||
|
"typesPublisherContentHash": "cb95d0ddf740cecae06afa5d31c7c25945a352c24620ceb89c3b0da970a3d5e0",
|
||||||
|
"typeScriptVersion": "3.6"
|
||||||
|
}
|
21
node_modules/@types/node/LICENSE
generated
vendored
Executable file
21
node_modules/@types/node/LICENSE
generated
vendored
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
16
node_modules/@types/node/README.md
generated
vendored
Executable file
16
node_modules/@types/node/README.md
generated
vendored
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/node`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for Node.js (https://nodejs.org/).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
||||||
|
|
||||||
|
### Additional Details
|
||||||
|
* Last updated: Tue, 18 Jan 2022 18:31:37 GMT
|
||||||
|
* Dependencies: none
|
||||||
|
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [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), [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).
|
912
node_modules/@types/node/assert.d.ts
generated
vendored
Executable file
912
node_modules/@types/node/assert.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,912 @@
|
||||||
|
/**
|
||||||
|
* The `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)
|
||||||
|
*/
|
||||||
|
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 `assert` module
|
||||||
|
* will be instances of the `AssertionError` class.
|
||||||
|
*/
|
||||||
|
class AssertionError extends Error {
|
||||||
|
actual: unknown;
|
||||||
|
expected: unknown;
|
||||||
|
operator: string;
|
||||||
|
generatedMessage: boolean;
|
||||||
|
code: 'ERR_ASSERTION';
|
||||||
|
constructor(options?: {
|
||||||
|
/** If provided, the error message is set to this value. */
|
||||||
|
message?: string | 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 currently experimental and behavior might still change.
|
||||||
|
* @since v14.2.0, v12.19.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
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 '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;
|
||||||
|
/**
|
||||||
|
* 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';
|
||||||
|
*
|
||||||
|
* // 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();
|
||||||
|
* // [
|
||||||
|
* // {
|
||||||
|
* // 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 of objects containing information about the wrapper functions returned by `calls`.
|
||||||
|
*/
|
||||||
|
report(): CallTrackerReportInformation[];
|
||||||
|
/**
|
||||||
|
* 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';
|
||||||
|
*
|
||||||
|
* // 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 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 '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 '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 '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 [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`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import assert from '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 [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`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import assert from '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 'assert';
|
||||||
|
*
|
||||||
|
* const obj1 = {
|
||||||
|
* a: {
|
||||||
|
* b: 1
|
||||||
|
* }
|
||||||
|
* };
|
||||||
|
* const obj2 = {
|
||||||
|
* a: {
|
||||||
|
* b: 2
|
||||||
|
* }
|
||||||
|
* };
|
||||||
|
* const obj3 = {
|
||||||
|
* a: {
|
||||||
|
* b: 1
|
||||||
|
* }
|
||||||
|
* };
|
||||||
|
* const obj4 = Object.create(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 the [SameValue Comparison](https://tc39.github.io/ecma262/#sec-samevalue).
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import assert from '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 the [SameValue Comparison](https://tc39.github.io/ecma262/#sec-samevalue).
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import assert from '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 '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 '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:
|
||||||
|
* 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:
|
||||||
|
* 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 '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 '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 '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 '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 '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 '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 '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 '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 'assert/strict';
|
||||||
|
*
|
||||||
|
* await assert.rejects(
|
||||||
|
* async () => {
|
||||||
|
* throw new TypeError('Wrong value');
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* name: 'TypeError',
|
||||||
|
* message: 'Wrong value'
|
||||||
|
* }
|
||||||
|
* );
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import assert from '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 '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 'assert/strict';
|
||||||
|
*
|
||||||
|
* await assert.doesNotReject(
|
||||||
|
* async () => {
|
||||||
|
* throw new TypeError('Wrong value');
|
||||||
|
* },
|
||||||
|
* SyntaxError
|
||||||
|
* );
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import assert from '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 '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 '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/assert/strict.d.ts
generated
vendored
Executable file
8
node_modules/@types/node/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;
|
||||||
|
}
|
501
node_modules/@types/node/async_hooks.d.ts
generated
vendored
Executable file
501
node_modules/@types/node/async_hooks.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,501 @@
|
||||||
|
/**
|
||||||
|
* The `async_hooks` module provides an API to track asynchronous resources. It
|
||||||
|
* can be accessed using:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* import async_hooks from 'async_hooks';
|
||||||
|
* ```
|
||||||
|
* @experimental
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/async_hooks.js)
|
||||||
|
*/
|
||||||
|
declare module 'async_hooks' {
|
||||||
|
/**
|
||||||
|
* ```js
|
||||||
|
* import { executionAsyncId } from 'async_hooks';
|
||||||
|
*
|
||||||
|
* 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 'fs';
|
||||||
|
* import { executionAsyncId, executionAsyncResource } from '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 '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 '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 '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 9.3)
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Binds the given function to execute to this `AsyncResource`'s scope.
|
||||||
|
*
|
||||||
|
* The returned function will have an `asyncResource` property referencing
|
||||||
|
* the `AsyncResource` to which the function is bound.
|
||||||
|
* @since v14.8.0, v12.19.0
|
||||||
|
* @param fn The function to bind to the current `AsyncResource`.
|
||||||
|
*/
|
||||||
|
bind<Func extends (...args: any[]) => any>(
|
||||||
|
fn: Func
|
||||||
|
): Func & {
|
||||||
|
asyncResource: AsyncResource;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Call the provided function with the provided arguments in the execution context
|
||||||
|
* of the async resource. This will establish the context, trigger the AsyncHooks
|
||||||
|
* before callbacks, call the function, trigger the AsyncHooks after callbacks, and
|
||||||
|
* then restore the original execution context.
|
||||||
|
* @since v9.6.0
|
||||||
|
* @param fn The function to call in the execution context of this async resource.
|
||||||
|
* @param thisArg The receiver to be used for the function call.
|
||||||
|
* @param args Optional arguments to pass to the function.
|
||||||
|
*/
|
||||||
|
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 `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';
|
||||||
|
*
|
||||||
|
* const asyncLocalStorage = new AsyncLocalStorage();
|
||||||
|
*
|
||||||
|
* function logWithId(msg) {
|
||||||
|
* const id = asyncLocalStorage.getStore();
|
||||||
|
* console.log(`${id !== undefined ? id : '-'}:`, msg);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* let idSeq = 0;
|
||||||
|
* http.createServer((req, res) => {
|
||||||
|
* asyncLocalStorage.run(idSeq++, () => {
|
||||||
|
* logWithId('start');
|
||||||
|
* // Imagine any chain of async operations here
|
||||||
|
* setImmediate(() => {
|
||||||
|
* logWithId('finish');
|
||||||
|
* res.end();
|
||||||
|
* });
|
||||||
|
* });
|
||||||
|
* }).listen(8080);
|
||||||
|
*
|
||||||
|
* http.get('http://localhost:8080');
|
||||||
|
* http.get('http://localhost:8080');
|
||||||
|
* // Prints:
|
||||||
|
* // 0: start
|
||||||
|
* // 1: start
|
||||||
|
* // 0: finish
|
||||||
|
* // 1: finish
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Each instance of `AsyncLocalStorage` maintains an independent storage context.
|
||||||
|
* Multiple instances can safely exist simultaneously without risk of interfering
|
||||||
|
* with each other data.
|
||||||
|
* @since v13.10.0, v12.17.0
|
||||||
|
*/
|
||||||
|
class AsyncLocalStorage<T> {
|
||||||
|
/**
|
||||||
|
* Disables the instance of `AsyncLocalStorage`. All subsequent calls
|
||||||
|
* to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
|
||||||
|
*
|
||||||
|
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
||||||
|
* instance will be exited.
|
||||||
|
*
|
||||||
|
* Calling `asyncLocalStorage.disable()` is required before the`asyncLocalStorage` can be garbage collected. This does not apply to stores
|
||||||
|
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
||||||
|
* along with the corresponding async resources.
|
||||||
|
*
|
||||||
|
* Use this method when the `asyncLocalStorage` is not in use anymore
|
||||||
|
* in the current process.
|
||||||
|
* @since v13.10.0, v12.17.0
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
disable(): void;
|
||||||
|
/**
|
||||||
|
* Returns the current store.
|
||||||
|
* If called outside of an asynchronous context initialized by
|
||||||
|
* calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
|
||||||
|
* returns `undefined`.
|
||||||
|
* @since v13.10.0, v12.17.0
|
||||||
|
*/
|
||||||
|
getStore(): T | undefined;
|
||||||
|
/**
|
||||||
|
* Runs a function synchronously within a context and returns its
|
||||||
|
* return value. The store is not accessible outside of the callback function.
|
||||||
|
* 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, 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';
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue