@discordjs/util 2.0.0-pr-10758.1765463096-d081e1706 → 2.0.0-pr-11005.1765538001-01ed3c43b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -146,7 +146,7 @@ var GatewayRateLimitError = class _GatewayRateLimitError extends Error {
146
146
  };
147
147
 
148
148
  // src/index.ts
149
- var version = "2.0.0-pr-10758.1765463096-d081e1706";
149
+ var version = "2.0.0-pr-11005.1765538001-01ed3c43b";
150
150
  // Annotate the CommonJS export names for ESM import in node:
151
151
  0 && (module.exports = {
152
152
  GatewayRateLimitError,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/functions/calculateShardId.ts","../src/functions/embedLength.ts","../src/functions/lazy.ts","../src/functions/range.ts","../src/functions/runtime.ts","../src/functions/userAgentAppendix.ts","../src/encodables.ts","../src/Equatable.ts","../src/gatewayRateLimitError.ts"],"sourcesContent":["export type * from './types.js';\nexport * from './functions/index.js';\nexport * from './encodables.js';\nexport type * from './RawFile.js';\nexport * from './Equatable.js';\nexport * from './gatewayRateLimitError.js';\n\n/**\n * The {@link https://github.com/discordjs/discord.js/blob/main/packages/util#readme | @discordjs/util} version\n * that you are currently using.\n *\n * @privateRemarks This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild.\n */\nexport const version = '2.0.0-pr-10758.1765463096-d081e1706' as string;\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","import type { APIEmbed } from 'discord-api-types/v10';\n\n/**\n * Calculates the length of an embed.\n *\n * @param data - The embed data to check\n */\nexport function embedLength(data: APIEmbed) {\n\treturn (\n\t\t(data.title?.length ?? 0) +\n\t\t(data.description?.length ?? 0) +\n\t\t(data.fields?.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) ?? 0) +\n\t\t(data.footer?.text.length ?? 0) +\n\t\t(data.author?.name.length ?? 0)\n\t);\n}\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 Value - 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<Value>(cb: () => Value): () => Value {\n\tlet defaultValue: Value;\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 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","/* eslint-disable n/prefer-global/process */\n\nexport 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\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\tif (typeof globalThis.navigator === 'object') {\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","import type { RawFile } from './RawFile.js';\n\n/**\n * Represents an object capable of representing itself as a JSON object\n *\n * @typeParam Value - The JSON type corresponding to {@link JSONEncodable.toJSON} outputs.\n */\nexport interface JSONEncodable<Value> {\n\t/**\n\t * Transforms this object to its JSON format\n\t */\n\ttoJSON(): Value;\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/**\n * Result of encoding an object that includes file attachments\n *\n * @typeParam BodyValue - The JSON body type\n */\nexport interface FileBodyEncodableResult<BodyValue> {\n\t/**\n\t * The JSON body to send with the request\n\t */\n\tbody: BodyValue;\n\t/**\n\t * The files to attach to the request\n\t */\n\tfiles: RawFile[];\n}\n\n/**\n * Represents an object capable of representing itself as a request body with file attachments.\n * Objects implementing this interface can separate JSON body data from binary file data,\n * which is necessary for multipart/form-data requests.\n *\n * @typeParam BodyValue - The JSON body type\n */\nexport interface FileBodyEncodable<BodyValue> {\n\t/**\n\t * Transforms this object to its file body format, separating the JSON body from file attachments.\n\t */\n\ttoFileBody(): FileBodyEncodableResult<BodyValue>;\n}\n\n/**\n * Indicates if an object is file body encodable or not.\n *\n * @param maybeEncodable - The object to check against\n */\nexport function isFileBodyEncodable(maybeEncodable: unknown): maybeEncodable is FileBodyEncodable<unknown> {\n\treturn maybeEncodable !== null && typeof maybeEncodable === 'object' && 'toFileBody' in maybeEncodable;\n}\n","/**\n * Represents a structure that can be checked against another\n * given structure for equality\n *\n * @typeParam Value - The type of object to compare the current object to\n */\nexport interface Equatable<Value> {\n\t/**\n\t * Whether or not this is equal to another structure\n\t */\n\tequals(other: Value): 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","import type { GatewayOpcodeRateLimitMetadataMap, GatewayRateLimitedDispatchData } from 'discord-api-types/v10';\n\n/**\n * Represents the error thrown when the gateway emits a `RATE_LIMITED` event after a certain request.\n */\nexport class GatewayRateLimitError extends Error {\n\tpublic override readonly name = GatewayRateLimitError.name;\n\n\tpublic constructor(\n\t\t/**\n\t\t * The data associated with the rate limit event\n\t\t */\n\t\tpublic readonly data: GatewayRateLimitedDispatchData<keyof GatewayOpcodeRateLimitMetadataMap>,\n\t\t/**\n\t\t * The payload data that lead to this rate limit\n\t\t *\n\t\t * @privateRemarks\n\t\t * Too complicated to type properly here (i.e. extract the ['data']\n\t\t * of event payloads that have t = keyof GatewayOpcodeRateLimitMetadataMap)\n\t\t */\n\t\tpublic readonly payload: unknown,\n\t) {\n\t\tsuper(`Request with opcode ${data.opcode} was rate limited. Retry after ${data.retry_after} seconds.`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,SAAS,iBAAiB,SAAiB,YAAoB;AACrE,SAAO,OAAO,OAAO,OAAO,KAAK,GAAG,IAAI;AACzC;AAFgB;;;ACCT,SAAS,YAAY,MAAgB;AAC3C,UACE,KAAK,OAAO,UAAU,MACtB,KAAK,aAAa,UAAU,MAC5B,KAAK,QAAQ,OAAO,CAAC,MAAM,SAAS,OAAO,KAAK,KAAK,SAAS,KAAK,MAAM,QAAQ,CAAC,KAAK,MACvF,KAAK,QAAQ,KAAK,UAAU,MAC5B,KAAK,QAAQ,KAAK,UAAU;AAE/B;AARgB;;;ACMT,SAAS,KAAY,IAA8B;AACzD,MAAI;AAEJ,SAAO,MAAO,iBAAiB,GAAG;AACnC;AAJgB;;;AC+BT,UAAU,MAAMA,QAA8B;AACpD,MAAI;AACJ,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AClG,SAAO,mBAAmB,QAAQ,OAAO,mBAAmB,YAAY,YAAY;AACrF;AAFgB;AAuCT,SAAS,oBAAoB,gBAAuE;AAC1G,SAAO,mBAAmB,QAAQ,OAAO,mBAAmB,YAAY,gBAAgB;AACzF;AAFgB;;;ACxCT,SAAS,YAAY,gBAA+D;AAC1F,SAAO,mBAAmB,QAAQ,OAAO,mBAAmB,YAAY,YAAY;AACrF;AAFgB;;;ACbT,IAAM,wBAAN,MAAM,+BAA8B,MAAM;AAAA,EAGzC,YAIU,MAQA,SACf;AACD,UAAM,uBAAuB,KAAK,MAAM,kCAAkC,KAAK,WAAW,WAAW;AAVrF;AAQA;AAAA,EAGjB;AAAA,EAvBD,OAKiD;AAAA;AAAA;AAAA,EACvB,OAAO,uBAAsB;AAkBvD;;;ATXO,IAAM,UAAU;","names":["range"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/functions/calculateShardId.ts","../src/functions/embedLength.ts","../src/functions/lazy.ts","../src/functions/range.ts","../src/functions/runtime.ts","../src/functions/userAgentAppendix.ts","../src/encodables.ts","../src/Equatable.ts","../src/gatewayRateLimitError.ts"],"sourcesContent":["export type * from './types.js';\nexport * from './functions/index.js';\nexport * from './encodables.js';\nexport type * from './RawFile.js';\nexport * from './Equatable.js';\nexport * from './gatewayRateLimitError.js';\n\n/**\n * The {@link https://github.com/discordjs/discord.js/blob/main/packages/util#readme | @discordjs/util} version\n * that you are currently using.\n *\n * @privateRemarks This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild.\n */\nexport const version = '2.0.0-pr-11005.1765538001-01ed3c43b' as string;\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","import type { APIEmbed } from 'discord-api-types/v10';\n\n/**\n * Calculates the length of an embed.\n *\n * @param data - The embed data to check\n */\nexport function embedLength(data: APIEmbed) {\n\treturn (\n\t\t(data.title?.length ?? 0) +\n\t\t(data.description?.length ?? 0) +\n\t\t(data.fields?.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) ?? 0) +\n\t\t(data.footer?.text.length ?? 0) +\n\t\t(data.author?.name.length ?? 0)\n\t);\n}\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 Value - 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<Value>(cb: () => Value): () => Value {\n\tlet defaultValue: Value;\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 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","/* eslint-disable n/prefer-global/process */\n\nexport 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\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\tif (typeof globalThis.navigator === 'object') {\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","import type { RawFile } from './RawFile.js';\n\n/**\n * Represents an object capable of representing itself as a JSON object\n *\n * @typeParam Value - The JSON type corresponding to {@link JSONEncodable.toJSON} outputs.\n */\nexport interface JSONEncodable<Value> {\n\t/**\n\t * Transforms this object to its JSON format\n\t */\n\ttoJSON(): Value;\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/**\n * Result of encoding an object that includes file attachments\n *\n * @typeParam BodyValue - The JSON body type\n */\nexport interface FileBodyEncodableResult<BodyValue> {\n\t/**\n\t * The JSON body to send with the request\n\t */\n\tbody: BodyValue;\n\t/**\n\t * The files to attach to the request\n\t */\n\tfiles: RawFile[];\n}\n\n/**\n * Represents an object capable of representing itself as a request body with file attachments.\n * Objects implementing this interface can separate JSON body data from binary file data,\n * which is necessary for multipart/form-data requests.\n *\n * @typeParam BodyValue - The JSON body type\n */\nexport interface FileBodyEncodable<BodyValue> {\n\t/**\n\t * Transforms this object to its file body format, separating the JSON body from file attachments.\n\t */\n\ttoFileBody(): FileBodyEncodableResult<BodyValue>;\n}\n\n/**\n * Indicates if an object is file body encodable or not.\n *\n * @param maybeEncodable - The object to check against\n */\nexport function isFileBodyEncodable(maybeEncodable: unknown): maybeEncodable is FileBodyEncodable<unknown> {\n\treturn maybeEncodable !== null && typeof maybeEncodable === 'object' && 'toFileBody' in maybeEncodable;\n}\n","/**\n * Represents a structure that can be checked against another\n * given structure for equality\n *\n * @typeParam Value - The type of object to compare the current object to\n */\nexport interface Equatable<Value> {\n\t/**\n\t * Whether or not this is equal to another structure\n\t */\n\tequals(other: Value): 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","import type { GatewayOpcodeRateLimitMetadataMap, GatewayRateLimitedDispatchData } from 'discord-api-types/v10';\n\n/**\n * Represents the error thrown when the gateway emits a `RATE_LIMITED` event after a certain request.\n */\nexport class GatewayRateLimitError extends Error {\n\tpublic override readonly name = GatewayRateLimitError.name;\n\n\tpublic constructor(\n\t\t/**\n\t\t * The data associated with the rate limit event\n\t\t */\n\t\tpublic readonly data: GatewayRateLimitedDispatchData<keyof GatewayOpcodeRateLimitMetadataMap>,\n\t\t/**\n\t\t * The payload data that lead to this rate limit\n\t\t *\n\t\t * @privateRemarks\n\t\t * Too complicated to type properly here (i.e. extract the ['data']\n\t\t * of event payloads that have t = keyof GatewayOpcodeRateLimitMetadataMap)\n\t\t */\n\t\tpublic readonly payload: unknown,\n\t) {\n\t\tsuper(`Request with opcode ${data.opcode} was rate limited. Retry after ${data.retry_after} seconds.`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,SAAS,iBAAiB,SAAiB,YAAoB;AACrE,SAAO,OAAO,OAAO,OAAO,KAAK,GAAG,IAAI;AACzC;AAFgB;;;ACCT,SAAS,YAAY,MAAgB;AAC3C,UACE,KAAK,OAAO,UAAU,MACtB,KAAK,aAAa,UAAU,MAC5B,KAAK,QAAQ,OAAO,CAAC,MAAM,SAAS,OAAO,KAAK,KAAK,SAAS,KAAK,MAAM,QAAQ,CAAC,KAAK,MACvF,KAAK,QAAQ,KAAK,UAAU,MAC5B,KAAK,QAAQ,KAAK,UAAU;AAE/B;AARgB;;;ACMT,SAAS,KAAY,IAA8B;AACzD,MAAI;AAEJ,SAA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AI;AAAA,IACnD;AAAA,EACD;AAEA,SAAO;AACR;AA3CgB;;;ACcT,SAAS,gBAAgB,gBAAmE;AAClG,SAAO,mBAAmB,QAAQ,OAAO,mBAAmB,YAAY,YAAY;AACrF;AAFgB;AAuCT,SAAS,oBAAoB,gBAAuE;AAC1G,SAAO,mBAAmB,QAAQ,OAAO,mBAAmB,YAAY,gBAAgB;AACzF;AAFgB;;;ACxCT,SAAS,YAAY,gBAA+D;AAC1F,SAAO,mBAAmB,QAAQ,OAAO,mBAAmB,YAAY,YAAY;AACrF;AAFgB;;;ACbT,IAAM,wBAAN,MAAM,+BAA8B,MAAM;AAAA,EAGzC,YAIU,MAQA,SACf;AACD,UAAM,uBAAuB,KAAK,MAAM,kCAAkC,KAAK,WAAW,WAAW;AAVrF;AAQA;AAAA,EAGjB;AAAA,EAvBD,OAKiD;AAAA;AAAA;AAAA,EACvB,OAAO,uBAAsB;AAkBvD;;;ATXO,IAAM,UAAU;","names":["range"]}
package/dist/index.mjs CHANGED
@@ -112,7 +112,7 @@ var GatewayRateLimitError = class _GatewayRateLimitError extends Error {
112
112
  };
113
113
 
114
114
  // src/index.ts
115
- var version = "2.0.0-pr-10758.1765463096-d081e1706";
115
+ var version = "2.0.0-pr-11005.1765538001-01ed3c43b";
116
116
  export {
117
117
  GatewayRateLimitError,
118
118
  calculateShardId,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/functions/calculateShardId.ts","../src/functions/embedLength.ts","../src/functions/lazy.ts","../src/functions/range.ts","../src/functions/runtime.ts","../src/functions/userAgentAppendix.ts","../src/encodables.ts","../src/Equatable.ts","../src/gatewayRateLimitError.ts","../src/index.ts"],"sourcesContent":["/**\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","import type { APIEmbed } from 'discord-api-types/v10';\n\n/**\n * Calculates the length of an embed.\n *\n * @param data - The embed data to check\n */\nexport function embedLength(data: APIEmbed) {\n\treturn (\n\t\t(data.title?.length ?? 0) +\n\t\t(data.description?.length ?? 0) +\n\t\t(data.fields?.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) ?? 0) +\n\t\t(data.footer?.text.length ?? 0) +\n\t\t(data.author?.name.length ?? 0)\n\t);\n}\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 Value - 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<Value>(cb: () => Value): () => Value {\n\tlet defaultValue: Value;\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 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","/* eslint-disable n/prefer-global/process */\n\nexport 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\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\tif (typeof globalThis.navigator === 'object') {\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","import type { RawFile } from './RawFile.js';\n\n/**\n * Represents an object capable of representing itself as a JSON object\n *\n * @typeParam Value - The JSON type corresponding to {@link JSONEncodable.toJSON} outputs.\n */\nexport interface JSONEncodable<Value> {\n\t/**\n\t * Transforms this object to its JSON format\n\t */\n\ttoJSON(): Value;\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/**\n * Result of encoding an object that includes file attachments\n *\n * @typeParam BodyValue - The JSON body type\n */\nexport interface FileBodyEncodableResult<BodyValue> {\n\t/**\n\t * The JSON body to send with the request\n\t */\n\tbody: BodyValue;\n\t/**\n\t * The files to attach to the request\n\t */\n\tfiles: RawFile[];\n}\n\n/**\n * Represents an object capable of representing itself as a request body with file attachments.\n * Objects implementing this interface can separate JSON body data from binary file data,\n * which is necessary for multipart/form-data requests.\n *\n * @typeParam BodyValue - The JSON body type\n */\nexport interface FileBodyEncodable<BodyValue> {\n\t/**\n\t * Transforms this object to its file body format, separating the JSON body from file attachments.\n\t */\n\ttoFileBody(): FileBodyEncodableResult<BodyValue>;\n}\n\n/**\n * Indicates if an object is file body encodable or not.\n *\n * @param maybeEncodable - The object to check against\n */\nexport function isFileBodyEncodable(maybeEncodable: unknown): maybeEncodable is FileBodyEncodable<unknown> {\n\treturn maybeEncodable !== null && typeof maybeEncodable === 'object' && 'toFileBody' in maybeEncodable;\n}\n","/**\n * Represents a structure that can be checked against another\n * given structure for equality\n *\n * @typeParam Value - The type of object to compare the current object to\n */\nexport interface Equatable<Value> {\n\t/**\n\t * Whether or not this is equal to another structure\n\t */\n\tequals(other: Value): 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","import type { GatewayOpcodeRateLimitMetadataMap, GatewayRateLimitedDispatchData } from 'discord-api-types/v10';\n\n/**\n * Represents the error thrown when the gateway emits a `RATE_LIMITED` event after a certain request.\n */\nexport class GatewayRateLimitError extends Error {\n\tpublic override readonly name = GatewayRateLimitError.name;\n\n\tpublic constructor(\n\t\t/**\n\t\t * The data associated with the rate limit event\n\t\t */\n\t\tpublic readonly data: GatewayRateLimitedDispatchData<keyof GatewayOpcodeRateLimitMetadataMap>,\n\t\t/**\n\t\t * The payload data that lead to this rate limit\n\t\t *\n\t\t * @privateRemarks\n\t\t * Too complicated to type properly here (i.e. extract the ['data']\n\t\t * of event payloads that have t = keyof GatewayOpcodeRateLimitMetadataMap)\n\t\t */\n\t\tpublic readonly payload: unknown,\n\t) {\n\t\tsuper(`Request with opcode ${data.opcode} was rate limited. Retry after ${data.retry_after} seconds.`);\n\t}\n}\n","export type * from './types.js';\nexport * from './functions/index.js';\nexport * from './encodables.js';\nexport type * from './RawFile.js';\nexport * from './Equatable.js';\nexport * from './gatewayRateLimitError.js';\n\n/**\n * The {@link https://github.com/discordjs/discord.js/blob/main/packages/util#readme | @discordjs/util} version\n * that you are currently using.\n *\n * @privateRemarks This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild.\n */\nexport const version = '2.0.0-pr-10758.1765463096-d081e1706' as string;\n"],"mappings":";;;;AAMO,SAAS,iBAAiB,SAAiB,YAAoB;AACrE,SAAO,OAAO,OAAO,OAAO,KAAK,GAAG,IAAI;AACzC;AAFgB;;;ACCT,SAAS,YAAY,MAAgB;AAC3C,UACE,KAAK,OAAO,UAAU,MACtB,KAAK,aAAa,UAAU,MAC5B,KAAK,QA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,WAAW,QAAQ,SAAS,IAAI;AAAA,IAChD;AAEA,QAAI,SAAS,WAAW,QAAQ,UAAU;AACzC,aAAO,OAAO,WAAW,QAAQ,SAAS,GAAG;AAAA,IAC9C;AAEA,QAAI,UAAU,WAAW,QAAQ,UAAU;AAC1C,aAAO,WAAW,WAAW,QAAQ,SAAS,IAAI;AAAA,IACnD;AAAA,EACD;AAEA,SAAO;AACR;AA3CgB;;;ACcT,SAAS,gBAAgB,gBAAmE;AAClG,SAAO,mBAAmB,QAAQ,OAAO,mBAAmB,YAAY,YAAY;AACrF;AAFgB;AAuCT,SAAS,oBAAoB,gBAAuE;AAC1G,SAAO,mBAAmB,QAAQ,OAAO,mBAAmB,YAAY,gBAAgB;AACzF;AAFgB;;;ACxCT,SAAS,YAAY,gBAA+D;AAC1F,SAAO,mBAAmB,QAAQ,OAAO,mBAAmB,YAAY,YAAY;AACrF;AAFgB;;;ACbT,IAAM,wBAAN,MAAM,+BAA8B,MAAM;AAAA,EAGzC,YAIU,MAQA,SACf;AACD,UAAM,uBAAuB,KAAK,MAAM,kCAAkC,KAAK,WAAW,WAAW;AAVrF;AAQA;AAAA,EAGjB;AAAA,EAvBD,OAKiD;AAAA;AAAA;AAAA,EACvB,OAAO,uBAAsB;AAkBvD;;;ACXO,IAAM,UAAU;","names":["range"]}
1
+ {"version":3,"sources":["../src/functions/calculateShardId.ts","../src/functions/embedLength.ts","../src/functions/lazy.ts","../src/functions/range.ts","../src/functions/runtime.ts","../src/functions/userAgentAppendix.ts","../src/encodables.ts","../src/Equatable.ts","../src/gatewayRateLimitError.ts","../src/index.ts"],"sourcesContent":["/**\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","import type { APIEmbed } from 'discord-api-types/v10';\n\n/**\n * Calculates the length of an embed.\n *\n * @param data - The embed data to check\n */\nexport function embedLength(data: APIEmbed) {\n\treturn (\n\t\t(data.title?.length ?? 0) +\n\t\t(data.description?.length ?? 0) +\n\t\t(data.fields?.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) ?? 0) +\n\t\t(data.footer?.text.length ?? 0) +\n\t\t(data.author?.name.length ?? 0)\n\t);\n}\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 Value - 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<Value>(cb: () => Value): () => Value {\n\tlet defaultValue: Value;\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 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","/* eslint-disable n/prefer-global/process */\n\nexport 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\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\tif (typeof globalThis.navigator === 'object') {\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","import type { RawFile } from './RawFile.js';\n\n/**\n * Represents an object capable of representing itself as a JSON object\n *\n * @typeParam Value - The JSON type corresponding to {@link JSONEncodable.toJSON} outputs.\n */\nexport interface JSONEncodable<Value> {\n\t/**\n\t * Transforms this object to its JSON format\n\t */\n\ttoJSON(): Value;\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/**\n * Result of encoding an object that includes file attachments\n *\n * @typeParam BodyValue - The JSON body type\n */\nexport interface FileBodyEncodableResult<BodyValue> {\n\t/**\n\t * The JSON body to send with the request\n\t */\n\tbody: BodyValue;\n\t/**\n\t * The files to attach to the request\n\t */\n\tfiles: RawFile[];\n}\n\n/**\n * Represents an object capable of representing itself as a request body with file attachments.\n * Objects implementing this interface can separate JSON body data from binary file data,\n * which is necessary for multipart/form-data requests.\n *\n * @typeParam BodyValue - The JSON body type\n */\nexport interface FileBodyEncodable<BodyValue> {\n\t/**\n\t * Transforms this object to its file body format, separating the JSON body from file attachments.\n\t */\n\ttoFileBody(): FileBodyEncodableResult<BodyValue>;\n}\n\n/**\n * Indicates if an object is file body encodable or not.\n *\n * @param maybeEncodable - The object to check against\n */\nexport function isFileBodyEncodable(maybeEncodable: unknown): maybeEncodable is FileBodyEncodable<unknown> {\n\treturn maybeEncodable !== null && typeof maybeEncodable === 'object' && 'toFileBody' in maybeEncodable;\n}\n","/**\n * Represents a structure that can be checked against another\n * given structure for equality\n *\n * @typeParam Value - The type of object to compare the current object to\n */\nexport interface Equatable<Value> {\n\t/**\n\t * Whether or not this is equal to another structure\n\t */\n\tequals(other: Value): 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","import type { GatewayOpcodeRateLimitMetadataMap, GatewayRateLimitedDispatchData } from 'discord-api-types/v10';\n\n/**\n * Represents the error thrown when the gateway emits a `RATE_LIMITED` event after a certain request.\n */\nexport class GatewayRateLimitError extends Error {\n\tpublic override readonly name = GatewayRateLimitError.name;\n\n\tpublic constructor(\n\t\t/**\n\t\t * The data associated with the rate limit event\n\t\t */\n\t\tpublic readonly data: GatewayRateLimitedDispatchData<keyof GatewayOpcodeRateLimitMetadataMap>,\n\t\t/**\n\t\t * The payload data that lead to this rate limit\n\t\t *\n\t\t * @privateRemarks\n\t\t * Too complicated to type properly here (i.e. extract the ['data']\n\t\t * of event payloads that have t = keyof GatewayOpcodeRateLimitMetadataMap)\n\t\t */\n\t\tpublic readonly payload: unknown,\n\t) {\n\t\tsuper(`Request with opcode ${data.opcode} was rate limited. Retry after ${data.retry_after} seconds.`);\n\t}\n}\n","export type * from './types.js';\nexport * from './functions/index.js';\nexport * from './encodables.js';\nexport type * from './RawFile.js';\nexport * from './Equatable.js';\nexport * from './gatewayRateLimitError.js';\n\n/**\n * The {@link https://github.com/discordjs/discord.js/blob/main/packages/util#readme | @discordjs/util} version\n * that you are currently using.\n *\n * @privateRemarks This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild.\n */\nexport const version = '2.0.0-pr-11005.1765538001-01ed3c43b' as string;\n"],"mappings":";;;;AAMO,SAAS,iBAAiB,SAAiB,YAAoB;AACrE,SAAO,OAAO,OAAO,OAAO,KAAK,GAAG,IAAI;AACzC;AAFgB;;;ACCT,SAAS,YAAY,MAAgB;AAC3C,UACE,KAAK,OAAO,UAAU,MACtB,KAAK,aAAa,UAAU,MAC5B,KAAK,QAAQ,OAAO,CAAC,MAAM,SAAS,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AAA,IAChD;AAEA,QAAI,SAAS,WAAW,QAAQ,UAAU;AACzC,aAAO,OAAO,WAAW,QAAQ,SAAS,GAAG;AAAA,IAC9C;AAEA,QAAI,UAAU,WAAW,QAAQ,UAAU;AAC1C,aAAO,WAAW,WAAW,QAAQ,SAAS,IAAI;AAAA,IACnD;AAAA,EACD;AAEA,SAAO;AACR;AA3CgB;;;ACcT,SAAS,gBAAgB,gBAAmE;AAClG,SAAO,mBAAmB,QAAQ,OAAO,mBAAmB,YAAY,YAAY;AACrF;AAFgB;AAuCT,SAAS,oBAAoB,gBAAuE;AAC1G,SAAO,mBAAmB,QAAQ,OAAO,mBAAmB,YAAY,gBAAgB;AACzF;AAFgB;;;ACxCT,SAAS,YAAY,gBAA+D;AAC1F,SAAO,mBAAmB,QAAQ,OAAO,mBAAmB,YAAY,YAAY;AACrF;AAFgB;;;ACbT,IAAM,wBAAN,MAAM,+BAA8B,MAAM;AAAA,EAGzC,YAIU,MAQA,SACf;AACD,UAAM,uBAAuB,KAAK,MAAM,kCAAkC,KAAK,WAAW,WAAW;AAVrF;AAQA;AAAA,EAGjB;AAAA,EAvBD,OAKiD;AAAA;AAAA;AAAA,EACvB,OAAO,uBAAsB;AAkBvD;;;ACXO,IAAM,UAAU;","names":["range"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@discordjs/util",
4
- "version": "2.0.0-pr-10758.1765463096-d081e1706",
4
+ "version": "2.0.0-pr-11005.1765538001-01ed3c43b",
5
5
  "description": "Utilities shared across Discord.js packages",
6
6
  "exports": {
7
7
  ".": {