diff options
Diffstat (limited to 'node_modules/@discordjs/util/dist')
-rw-r--r-- | node_modules/@discordjs/util/dist/index.d.mts | 117 | ||||
-rw-r--r-- | node_modules/@discordjs/util/dist/index.d.ts | 117 | ||||
-rw-r--r-- | node_modules/@discordjs/util/dist/index.js | 130 | ||||
-rw-r--r-- | node_modules/@discordjs/util/dist/index.js.map | 1 | ||||
-rw-r--r-- | node_modules/@discordjs/util/dist/index.mjs | 99 | ||||
-rw-r--r-- | node_modules/@discordjs/util/dist/index.mjs.map | 1 |
6 files changed, 465 insertions, 0 deletions
diff --git a/node_modules/@discordjs/util/dist/index.d.mts b/node_modules/@discordjs/util/dist/index.d.mts new file mode 100644 index 0000000..cef642f --- /dev/null +++ b/node_modules/@discordjs/util/dist/index.d.mts @@ -0,0 +1,117 @@ +/** + * Represents a type that may or may not be a promise + */ +type Awaitable<T> = PromiseLike<T> | T; + +/** + * Lazy is a wrapper around a value that is computed lazily. It is useful for + * cases where the value is expensive to compute and the computation may not + * be needed at all. + * + * @param cb - The callback to lazily evaluate + * @typeParam T - The type of the value + * @example + * ```ts + * const value = lazy(() => computeExpensiveValue()); + * ``` + */ +declare function lazy<T>(cb: () => T): () => T; + +/** + * Options for creating a range + */ +interface RangeOptions { + /** + * The end of the range (exclusive) + */ + end: number; + /** + * The start of the range (inclusive) + */ + start: number; + /** + * The amount to increment by + * + * @defaultValue `1` + */ + step?: number; +} +/** + * A generator to yield numbers in a given range + * + * @remarks + * This method is end-exclusive, for example the last number yielded by `range(5)` is 4. If you + * prefer for the end to be included add 1 to the range or `end` option. + * @param range - A number representing the the range to yield (exclusive) or an object with start, end and step + * @example + * Basic range + * ```ts + * for (const number of range(5)) { + * console.log(number); + * } + * // Prints 0, 1, 2, 3, 4 + * ``` + * @example + * Range with a step + * ```ts + * for (const number of range({ start: 3, end: 10, step: 2 })) { + * console.log(number); + * } + * // Prints 3, 5, 7, 9 + * ``` + */ +declare function range(range: RangeOptions | number): Generator<number, void, unknown>; + +/** + * Calculates the shard id for a given guild id. + * + * @param guildId - The guild id to calculate the shard id for + * @param shardCount - The total number of shards + */ +declare function calculateShardId(guildId: string, shardCount: number): number; + +declare function shouldUseGlobalFetchAndWebSocket(): boolean; + +/** + * Resolves the user agent appendix string for the current environment. + */ +declare function getUserAgentAppendix(): string; + +/** + * Represents an object capable of representing itself as a JSON object + * + * @typeParam T - The JSON type corresponding to {@link JSONEncodable.toJSON} outputs. + */ +interface JSONEncodable<T> { + /** + * Transforms this object to its JSON format + */ + toJSON(): T; +} +/** + * Indicates if an object is encodable or not. + * + * @param maybeEncodable - The object to check against + */ +declare function isJSONEncodable(maybeEncodable: unknown): maybeEncodable is JSONEncodable<unknown>; + +/** + * Represents a structure that can be checked against another + * given structure for equality + * + * @typeParam T - The type of object to compare the current object to + */ +interface Equatable<T> { + /** + * Whether or not this is equal to another structure + */ + equals(other: T): boolean; +} +/** + * Indicates if an object is equatable or not. + * + * @param maybeEquatable - The object to check against + */ +declare function isEquatable(maybeEquatable: unknown): maybeEquatable is Equatable<unknown>; + +export { Awaitable, Equatable, JSONEncodable, RangeOptions, calculateShardId, getUserAgentAppendix, isEquatable, isJSONEncodable, lazy, range, shouldUseGlobalFetchAndWebSocket }; diff --git a/node_modules/@discordjs/util/dist/index.d.ts b/node_modules/@discordjs/util/dist/index.d.ts new file mode 100644 index 0000000..cef642f --- /dev/null +++ b/node_modules/@discordjs/util/dist/index.d.ts @@ -0,0 +1,117 @@ +/** + * Represents a type that may or may not be a promise + */ +type Awaitable<T> = PromiseLike<T> | T; + +/** + * Lazy is a wrapper around a value that is computed lazily. It is useful for + * cases where the value is expensive to compute and the computation may not + * be needed at all. + * + * @param cb - The callback to lazily evaluate + * @typeParam T - The type of the value + * @example + * ```ts + * const value = lazy(() => computeExpensiveValue()); + * ``` + */ +declare function lazy<T>(cb: () => T): () => T; + +/** + * Options for creating a range + */ +interface RangeOptions { + /** + * The end of the range (exclusive) + */ + end: number; + /** + * The start of the range (inclusive) + */ + start: number; + /** + * The amount to increment by + * + * @defaultValue `1` + */ + step?: number; +} +/** + * A generator to yield numbers in a given range + * + * @remarks + * This method is end-exclusive, for example the last number yielded by `range(5)` is 4. If you + * prefer for the end to be included add 1 to the range or `end` option. + * @param range - A number representing the the range to yield (exclusive) or an object with start, end and step + * @example + * Basic range + * ```ts + * for (const number of range(5)) { + * console.log(number); + * } + * // Prints 0, 1, 2, 3, 4 + * ``` + * @example + * Range with a step + * ```ts + * for (const number of range({ start: 3, end: 10, step: 2 })) { + * console.log(number); + * } + * // Prints 3, 5, 7, 9 + * ``` + */ +declare function range(range: RangeOptions | number): Generator<number, void, unknown>; + +/** + * Calculates the shard id for a given guild id. + * + * @param guildId - The guild id to calculate the shard id for + * @param shardCount - The total number of shards + */ +declare function calculateShardId(guildId: string, shardCount: number): number; + +declare function shouldUseGlobalFetchAndWebSocket(): boolean; + +/** + * Resolves the user agent appendix string for the current environment. + */ +declare function getUserAgentAppendix(): string; + +/** + * Represents an object capable of representing itself as a JSON object + * + * @typeParam T - The JSON type corresponding to {@link JSONEncodable.toJSON} outputs. + */ +interface JSONEncodable<T> { + /** + * Transforms this object to its JSON format + */ + toJSON(): T; +} +/** + * Indicates if an object is encodable or not. + * + * @param maybeEncodable - The object to check against + */ +declare function isJSONEncodable(maybeEncodable: unknown): maybeEncodable is JSONEncodable<unknown>; + +/** + * Represents a structure that can be checked against another + * given structure for equality + * + * @typeParam T - The type of object to compare the current object to + */ +interface Equatable<T> { + /** + * Whether or not this is equal to another structure + */ + equals(other: T): boolean; +} +/** + * Indicates if an object is equatable or not. + * + * @param maybeEquatable - The object to check against + */ +declare function isEquatable(maybeEquatable: unknown): maybeEquatable is Equatable<unknown>; + +export { Awaitable, Equatable, JSONEncodable, RangeOptions, calculateShardId, getUserAgentAppendix, isEquatable, isJSONEncodable, lazy, range, shouldUseGlobalFetchAndWebSocket }; diff --git a/node_modules/@discordjs/util/dist/index.js b/node_modules/@discordjs/util/dist/index.js new file mode 100644 index 0000000..ce50bf1 --- /dev/null +++ b/node_modules/@discordjs/util/dist/index.js @@ -0,0 +1,130 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/index.ts +var src_exports = {}; +__export(src_exports, { + calculateShardId: () => calculateShardId, + getUserAgentAppendix: () => getUserAgentAppendix, + isEquatable: () => isEquatable, + isJSONEncodable: () => isJSONEncodable, + lazy: () => lazy, + range: () => range, + shouldUseGlobalFetchAndWebSocket: () => shouldUseGlobalFetchAndWebSocket +}); +module.exports = __toCommonJS(src_exports); + +// src/functions/lazy.ts +function lazy(cb) { + let defaultValue; + return () => defaultValue ??= cb(); +} +__name(lazy, "lazy"); + +// src/functions/range.ts +function* range(range2) { + let rangeEnd; + let start = 0; + let step = 1; + if (typeof range2 === "number") { + rangeEnd = range2; + } else { + start = range2.start; + rangeEnd = range2.end; + step = range2.step ?? 1; + } + for (let index = start; index < rangeEnd; index += step) { + yield index; + } +} +__name(range, "range"); + +// src/functions/calculateShardId.ts +function calculateShardId(guildId, shardCount) { + return Number(BigInt(guildId) >> 22n) % shardCount; +} +__name(calculateShardId, "calculateShardId"); + +// src/functions/runtime.ts +function shouldUseGlobalFetchAndWebSocket() { + if (typeof globalThis.process === "undefined") { + return "fetch" in globalThis && "WebSocket" in globalThis; + } + if ("versions" in globalThis.process) { + return "deno" in globalThis.process.versions || "bun" in globalThis.process.versions; + } + return false; +} +__name(shouldUseGlobalFetchAndWebSocket, "shouldUseGlobalFetchAndWebSocket"); + +// src/functions/userAgentAppendix.ts +function getUserAgentAppendix() { + if (typeof globalThis.EdgeRuntime !== "undefined") { + return "Vercel-Edge-Functions"; + } + if (typeof globalThis.R2 !== "undefined" && typeof globalThis.WebSocketPair !== "undefined") { + return "Cloudflare-Workers"; + } + if (typeof globalThis.Netlify !== "undefined") { + return "Netlify-Edge-Functions"; + } + if (typeof globalThis.process !== "object") { + if (typeof globalThis.navigator === "object") { + return globalThis.navigator.userAgent; + } + return "UnknownEnvironment"; + } + if ("versions" in globalThis.process) { + if ("deno" in globalThis.process.versions) { + return `Deno/${globalThis.process.versions.deno}`; + } + if ("bun" in globalThis.process.versions) { + return `Bun/${globalThis.process.versions.bun}`; + } + if ("node" in globalThis.process.versions) { + return `Node.js/${globalThis.process.versions.node}`; + } + } + return "UnknownEnvironment"; +} +__name(getUserAgentAppendix, "getUserAgentAppendix"); + +// src/JSONEncodable.ts +function isJSONEncodable(maybeEncodable) { + return maybeEncodable !== null && typeof maybeEncodable === "object" && "toJSON" in maybeEncodable; +} +__name(isJSONEncodable, "isJSONEncodable"); + +// src/Equatable.ts +function isEquatable(maybeEquatable) { + return maybeEquatable !== null && typeof maybeEquatable === "object" && "equals" in maybeEquatable; +} +__name(isEquatable, "isEquatable"); +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + calculateShardId, + getUserAgentAppendix, + isEquatable, + isJSONEncodable, + lazy, + range, + shouldUseGlobalFetchAndWebSocket +}); +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/@discordjs/util/dist/index.js.map b/node_modules/@discordjs/util/dist/index.js.map new file mode 100644 index 0000000..14f7b9f --- /dev/null +++ b/node_modules/@discordjs/util/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/index.ts","../src/functions/lazy.ts","../src/functions/range.ts","../src/functions/calculateShardId.ts","../src/functions/runtime.ts","../src/functions/userAgentAppendix.ts","../src/JSONEncodable.ts","../src/Equatable.ts"],"sourcesContent":["export * from './types.js';\nexport * from './functions/index.js';\nexport * from './JSONEncodable.js';\nexport * from './Equatable.js';\n","/**\n * Lazy is a wrapper around a value that is computed lazily. It is useful for\n * cases where the value is expensive to compute and the computation may not\n * be needed at all.\n *\n * @param cb - The callback to lazily evaluate\n * @typeParam T - The type of the value\n * @example\n * ```ts\n * const value = lazy(() => computeExpensiveValue());\n * ```\n */\n// eslint-disable-next-line promise/prefer-await-to-callbacks\nexport function lazy<T>(cb: () => T): () => T {\n\tlet defaultValue: T;\n\t// eslint-disable-next-line promise/prefer-await-to-callbacks\n\treturn () => (defaultValue ??= cb());\n}\n","/**\n * Options for creating a range\n */\nexport interface RangeOptions {\n\t/**\n\t * The end of the range (exclusive)\n\t */\n\tend: number;\n\t/**\n\t * The start of the range (inclusive)\n\t */\n\tstart: number;\n\t/**\n\t * The amount to increment by\n\t *\n\t * @defaultValue `1`\n\t */\n\tstep?: number;\n}\n\n/**\n * A generator to yield numbers in a given range\n *\n * @remarks\n * This method is end-exclusive, for example the last number yielded by `range(5)` is 4. If you\n * prefer for the end to be included add 1 to the range or `end` option.\n * @param range - A number representing the the range to yield (exclusive) or an object with start, end and step\n * @example\n * Basic range\n * ```ts\n * for (const number of range(5)) {\n * console.log(number);\n * }\n * // Prints 0, 1, 2, 3, 4\n * ```\n * @example\n * Range with a step\n * ```ts\n * for (const number of range({ start: 3, end: 10, step: 2 })) {\n * \tconsole.log(number);\n * }\n * // Prints 3, 5, 7, 9\n * ```\n */\nexport function* range(range: RangeOptions | number) {\n\tlet rangeEnd: number;\n\tlet start = 0;\n\tlet step = 1;\n\n\tif (typeof range === 'number') {\n\t\trangeEnd = range;\n\t} else {\n\t\tstart = range.start;\n\t\trangeEnd = range.end;\n\t\tstep = range.step ?? 1;\n\t}\n\n\tfor (let index = start; index < rangeEnd; index += step) {\n\t\tyield index;\n\t}\n}\n","/**\n * Calculates the shard id for a given guild id.\n *\n * @param guildId - The guild id to calculate the shard id for\n * @param shardCount - The total number of shards\n */\nexport function calculateShardId(guildId: string, shardCount: number) {\n\treturn Number(BigInt(guildId) >> 22n) % shardCount;\n}\n","export function shouldUseGlobalFetchAndWebSocket() {\n\t// Browser env and deno when ran directly\n\tif (typeof globalThis.process === 'undefined') {\n\t\treturn 'fetch' in globalThis && 'WebSocket' in globalThis;\n\t}\n\n\tif ('versions' in globalThis.process) {\n\t\treturn 'deno' in globalThis.process.versions || 'bun' in globalThis.process.versions;\n\t}\n\n\treturn false;\n}\n","/* eslint-disable n/prefer-global/process */\n/* eslint-disable no-restricted-globals */\n\n/**\n * Resolves the user agent appendix string for the current environment.\n */\nexport function getUserAgentAppendix(): string {\n\t// https://vercel.com/docs/concepts/functions/edge-functions/edge-runtime#check-if-you're-running-on-the-edge-runtime\n\t// @ts-expect-error Vercel Edge functions\n\tif (typeof globalThis.EdgeRuntime !== 'undefined') {\n\t\treturn 'Vercel-Edge-Functions';\n\t}\n\n\t// @ts-expect-error Cloudflare Workers\n\tif (typeof globalThis.R2 !== 'undefined' && typeof globalThis.WebSocketPair !== 'undefined') {\n\t\t// https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent\n\t\treturn 'Cloudflare-Workers';\n\t}\n\n\t// https://docs.netlify.com/edge-functions/api/#netlify-global-object\n\t// @ts-expect-error Netlify Edge functions\n\tif (typeof globalThis.Netlify !== 'undefined') {\n\t\treturn 'Netlify-Edge-Functions';\n\t}\n\n\t// Most (if not all) edge environments will have `process` defined. Within a web browser we'll extract it using `navigator.userAgent`.\n\tif (typeof globalThis.process !== 'object') {\n\t\t// @ts-expect-error web env\n\t\tif (typeof globalThis.navigator === 'object') {\n\t\t\t// @ts-expect-error web env\n\t\t\treturn globalThis.navigator.userAgent;\n\t\t}\n\n\t\treturn 'UnknownEnvironment';\n\t}\n\n\tif ('versions' in globalThis.process) {\n\t\tif ('deno' in globalThis.process.versions) {\n\t\t\treturn `Deno/${globalThis.process.versions.deno}`;\n\t\t}\n\n\t\tif ('bun' in globalThis.process.versions) {\n\t\t\treturn `Bun/${globalThis.process.versions.bun}`;\n\t\t}\n\n\t\tif ('node' in globalThis.process.versions) {\n\t\t\treturn `Node.js/${globalThis.process.versions.node}`;\n\t\t}\n\t}\n\n\treturn 'UnknownEnvironment';\n}\n","/**\n * Represents an object capable of representing itself as a JSON object\n *\n * @typeParam T - The JSON type corresponding to {@link JSONEncodable.toJSON} outputs.\n */\nexport interface JSONEncodable<T> {\n\t/**\n\t * Transforms this object to its JSON format\n\t */\n\ttoJSON(): T;\n}\n\n/**\n * Indicates if an object is encodable or not.\n *\n * @param maybeEncodable - The object to check against\n */\nexport function isJSONEncodable(maybeEncodable: unknown): maybeEncodable is JSONEncodable<unknown> {\n\treturn maybeEncodable !== null && typeof maybeEncodable === 'object' && 'toJSON' in maybeEncodable;\n}\n","/**\n * Represents a structure that can be checked against another\n * given structure for equality\n *\n * @typeParam T - The type of object to compare the current object to\n */\nexport interface Equatable<T> {\n\t/**\n\t * Whether or not this is equal to another structure\n\t */\n\tequals(other: T): boolean;\n}\n\n/**\n * Indicates if an object is equatable or not.\n *\n * @param maybeEquatable - The object to check against\n */\nexport function isEquatable(maybeEquatable: unknown): maybeEquatable is Equatable<unknown> {\n\treturn maybeEquatable !== null && typeof maybeEquatable === 'object' && 'equals' in maybeEquatable;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,SAAS,KAAQ,IAAsB;AAC7C,MAAI;AAEJ,SAAO,MAAO,iBAAiB,GAAG;AACnC;AAJgB;;;AC+BT,UAAU,MAAMA,QAA8B;AACpD,MAAI;AACJ,MAAI,QAAQ;AACZ,MAAI,OAAO;AAEX,MAAI,OAAOA,WAAU,UAAU;AAC9B,eAAWA;AAAA,EACZ,OAAO;AACN,YAAQA,OAAM;AACd,eAAWA,OAAM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,mBAAmB,YAAY,YAAY;AACrF;AAFgB;;;ACCT,SAAS,YAAY,gBAA+D;AAC1F,SAAO,mBAAmB,QAAQ,OAAO,mBAAmB,YAAY,YAAY;AACrF;AAFgB;","names":["range"]}
\ No newline at end of file diff --git a/node_modules/@discordjs/util/dist/index.mjs b/node_modules/@discordjs/util/dist/index.mjs new file mode 100644 index 0000000..6030649 --- /dev/null +++ b/node_modules/@discordjs/util/dist/index.mjs @@ -0,0 +1,99 @@ +var __defProp = Object.defineProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); + +// src/functions/lazy.ts +function lazy(cb) { + let defaultValue; + return () => defaultValue ??= cb(); +} +__name(lazy, "lazy"); + +// src/functions/range.ts +function* range(range2) { + let rangeEnd; + let start = 0; + let step = 1; + if (typeof range2 === "number") { + rangeEnd = range2; + } else { + start = range2.start; + rangeEnd = range2.end; + step = range2.step ?? 1; + } + for (let index = start; index < rangeEnd; index += step) { + yield index; + } +} +__name(range, "range"); + +// src/functions/calculateShardId.ts +function calculateShardId(guildId, shardCount) { + return Number(BigInt(guildId) >> 22n) % shardCount; +} +__name(calculateShardId, "calculateShardId"); + +// src/functions/runtime.ts +function shouldUseGlobalFetchAndWebSocket() { + if (typeof globalThis.process === "undefined") { + return "fetch" in globalThis && "WebSocket" in globalThis; + } + if ("versions" in globalThis.process) { + return "deno" in globalThis.process.versions || "bun" in globalThis.process.versions; + } + return false; +} +__name(shouldUseGlobalFetchAndWebSocket, "shouldUseGlobalFetchAndWebSocket"); + +// src/functions/userAgentAppendix.ts +function getUserAgentAppendix() { + if (typeof globalThis.EdgeRuntime !== "undefined") { + return "Vercel-Edge-Functions"; + } + if (typeof globalThis.R2 !== "undefined" && typeof globalThis.WebSocketPair !== "undefined") { + return "Cloudflare-Workers"; + } + if (typeof globalThis.Netlify !== "undefined") { + return "Netlify-Edge-Functions"; + } + if (typeof globalThis.process !== "object") { + if (typeof globalThis.navigator === "object") { + return globalThis.navigator.userAgent; + } + return "UnknownEnvironment"; + } + if ("versions" in globalThis.process) { + if ("deno" in globalThis.process.versions) { + return `Deno/${globalThis.process.versions.deno}`; + } + if ("bun" in globalThis.process.versions) { + return `Bun/${globalThis.process.versions.bun}`; + } + if ("node" in globalThis.process.versions) { + return `Node.js/${globalThis.process.versions.node}`; + } + } + return "UnknownEnvironment"; +} +__name(getUserAgentAppendix, "getUserAgentAppendix"); + +// src/JSONEncodable.ts +function isJSONEncodable(maybeEncodable) { + return maybeEncodable !== null && typeof maybeEncodable === "object" && "toJSON" in maybeEncodable; +} +__name(isJSONEncodable, "isJSONEncodable"); + +// src/Equatable.ts +function isEquatable(maybeEquatable) { + return maybeEquatable !== null && typeof maybeEquatable === "object" && "equals" in maybeEquatable; +} +__name(isEquatable, "isEquatable"); +export { + calculateShardId, + getUserAgentAppendix, + isEquatable, + isJSONEncodable, + lazy, + range, + shouldUseGlobalFetchAndWebSocket +}; +//# sourceMappingURL=index.mjs.map
\ No newline at end of file diff --git a/node_modules/@discordjs/util/dist/index.mjs.map b/node_modules/@discordjs/util/dist/index.mjs.map new file mode 100644 index 0000000..482f14f --- /dev/null +++ b/node_modules/@discordjs/util/dist/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/functions/lazy.ts","../src/functions/range.ts","../src/functions/calculateShardId.ts","../src/functions/runtime.ts","../src/functions/userAgentAppendix.ts","../src/JSONEncodable.ts","../src/Equatable.ts"],"sourcesContent":["/**\n * Lazy is a wrapper around a value that is computed lazily. It is useful for\n * cases where the value is expensive to compute and the computation may not\n * be needed at all.\n *\n * @param cb - The callback to lazily evaluate\n * @typeParam T - The type of the value\n * @example\n * ```ts\n * const value = lazy(() => computeExpensiveValue());\n * ```\n */\n// eslint-disable-next-line promise/prefer-await-to-callbacks\nexport function lazy<T>(cb: () => T): () => T {\n\tlet defaultValue: T;\n\t// eslint-disable-next-line promise/prefer-await-to-callbacks\n\treturn () => (defaultValue ??= cb());\n}\n","/**\n * Options for creating a range\n */\nexport interface RangeOptions {\n\t/**\n\t * The end of the range (exclusive)\n\t */\n\tend: number;\n\t/**\n\t * The start of the range (inclusive)\n\t */\n\tstart: number;\n\t/**\n\t * The amount to increment by\n\t *\n\t * @defaultValue `1`\n\t */\n\tstep?: number;\n}\n\n/**\n * A generator to yield numbers in a given range\n *\n * @remarks\n * This method is end-exclusive, for example the last number yielded by `range(5)` is 4. If you\n * prefer for the end to be included add 1 to the range or `end` option.\n * @param range - A number representing the the range to yield (exclusive) or an object with start, end and step\n * @example\n * Basic range\n * ```ts\n * for (const number of range(5)) {\n * console.log(number);\n * }\n * // Prints 0, 1, 2, 3, 4\n * ```\n * @example\n * Range with a step\n * ```ts\n * for (const number of range({ start: 3, end: 10, step: 2 })) {\n * \tconsole.log(number);\n * }\n * // Prints 3, 5, 7, 9\n * ```\n */\nexport function* range(range: RangeOptions | number) {\n\tlet rangeEnd: number;\n\tlet start = 0;\n\tlet step = 1;\n\n\tif (typeof range === 'number') {\n\t\trangeEnd = range;\n\t} else {\n\t\tstart = range.start;\n\t\trangeEnd = range.end;\n\t\tstep = range.step ?? 1;\n\t}\n\n\tfor (let index = start; index < rangeEnd; index += step) {\n\t\tyield index;\n\t}\n}\n","/**\n * Calculates the shard id for a given guild id.\n *\n * @param guildId - The guild id to calculate the shard id for\n * @param shardCount - The total number of shards\n */\nexport function calculateShardId(guildId: string, shardCount: number) {\n\treturn Number(BigInt(guildId) >> 22n) % shardCount;\n}\n","export function shouldUseGlobalFetchAndWebSocket() {\n\t// Browser env and deno when ran directly\n\tif (typeof globalThis.process === 'undefined') {\n\t\treturn 'fetch' in globalThis && 'WebSocket' in globalThis;\n\t}\n\n\tif ('versions' in globalThis.process) {\n\t\treturn 'deno' in globalThis.process.versions || 'bun' in globalThis.process.versions;\n\t}\n\n\treturn false;\n}\n","/* eslint-disable n/prefer-global/process */\n/* eslint-disable no-restricted-globals */\n\n/**\n * Resolves the user agent appendix string for the current environment.\n */\nexport function getUserAgentAppendix(): string {\n\t// https://vercel.com/docs/concepts/functions/edge-functions/edge-runtime#check-if-you're-running-on-the-edge-runtime\n\t// @ts-expect-error Vercel Edge functions\n\tif (typeof globalThis.EdgeRuntime !== 'undefined') {\n\t\treturn 'Vercel-Edge-Functions';\n\t}\n\n\t// @ts-expect-error Cloudflare Workers\n\tif (typeof globalThis.R2 !== 'undefined' && typeof globalThis.WebSocketPair !== 'undefined') {\n\t\t// https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent\n\t\treturn 'Cloudflare-Workers';\n\t}\n\n\t// https://docs.netlify.com/edge-functions/api/#netlify-global-object\n\t// @ts-expect-error Netlify Edge functions\n\tif (typeof globalThis.Netlify !== 'undefined') {\n\t\treturn 'Netlify-Edge-Functions';\n\t}\n\n\t// Most (if not all) edge environments will have `process` defined. Within a web browser we'll extract it using `navigator.userAgent`.\n\tif (typeof globalThis.process !== 'object') {\n\t\t// @ts-expect-error web env\n\t\tif (typeof globalThis.navigator === 'object') {\n\t\t\t// @ts-expect-error web env\n\t\t\treturn globalThis.navigator.userAgent;\n\t\t}\n\n\t\treturn 'UnknownEnvironment';\n\t}\n\n\tif ('versions' in globalThis.process) {\n\t\tif ('deno' in globalThis.process.versions) {\n\t\t\treturn `Deno/${globalThis.process.versions.deno}`;\n\t\t}\n\n\t\tif ('bun' in globalThis.process.versions) {\n\t\t\treturn `Bun/${globalThis.process.versions.bun}`;\n\t\t}\n\n\t\tif ('node' in globalThis.process.versions) {\n\t\t\treturn `Node.js/${globalThis.process.versions.node}`;\n\t\t}\n\t}\n\n\treturn 'UnknownEnvironment';\n}\n","/**\n * Represents an object capable of representing itself as a JSON object\n *\n * @typeParam T - The JSON type corresponding to {@link JSONEncodable.toJSON} outputs.\n */\nexport interface JSONEncodable<T> {\n\t/**\n\t * Transforms this object to its JSON format\n\t */\n\ttoJSON(): T;\n}\n\n/**\n * Indicates if an object is encodable or not.\n *\n * @param maybeEncodable - The object to check against\n */\nexport function isJSONEncodable(maybeEncodable: unknown): maybeEncodable is JSONEncodable<unknown> {\n\treturn maybeEncodable !== null && typeof maybeEncodable === 'object' && 'toJSON' in maybeEncodable;\n}\n","/**\n * Represents a structure that can be checked against another\n * given structure for equality\n *\n * @typeParam T - The type of object to compare the current object to\n */\nexport interface Equatable<T> {\n\t/**\n\t * Whether or not this is equal to another structure\n\t */\n\tequals(other: T): boolean;\n}\n\n/**\n * Indicates if an object is equatable or not.\n *\n * @param maybeEquatable - The object to check against\n */\nexport function isEquatable(maybeEquatable: unknown): maybeEquatable is Equatable<unknown> {\n\treturn maybeEquatable !== null && typeof maybeEquatable === 'object' && 'equals' in maybeEquatable;\n}\n"],"mappings":";;;;AAaO,SAAS,KAAQ,IAAsB;AAC7C,MAAI;AAEJ,SAAO,MAAO,iBAAiB,GAAG;AACnC;AAJgB;;;AC+BT,UAAU,MAAMA,QAA8B;AACpD,MAAI;AACJ,MAAI,QAAQ;AACZ,MAAI,OAAO;AAEX,MAAI,OAAOA,WAAU,UAAU;AAC9B,eAAWA;AAAA,EACZ,OAAO;AACN,YAAQA,OAAM;AACd,eAAWA,OAAM;AACjB,WAAOA,OAAM,QAAQ;AAAA,EACtB;AAEA,WAAS,QAAQ,OAAO,QAAQ,UAAU,SAAS,MAAM;AACxD,UAAM;AAAA,EACP;AACD;AAhBiB;;;ACtCV,SAAS,iBAAiB,SAAiB,YAAoB;AACrE,SAAO,OAAO,OAAO,OAAO,KAAK,GAAG,IAAI;AACzC;AAFgB;;;ACNT,SAAS,mCAAmC;AAElD,MAAI,OAAO,WAAW,YAAY,aAAa;AAC9C,WAAO,WAAW,cAAc,eAAe;AAAA,EAChD;AAEA,MAAI,cAAc,WAAW,SAAS;AACrC,WAAO,UAAU,WAAW,QAAQ,YAAY,SAAS,WAAW,QAAQ;AAAA,EAC7E;AAEA,SAAO;AACR;AAXgB;;;ACMT,SAAS,uBAA+B;AAG9C,MAAI,OAAO,WAAW,gBAAgB,aAAa;AAClD,WAAO;AAAA,EACR;AAGA,MAAI,OAAO,WAAW,OAAO,eAAe,OAAO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