mbot/node_modules/@discordjs/util/dist/index.js.map

1 line
8.7 KiB
Plaintext
Raw Normal View History

2024-05-11 05:39:11 +00:00
{"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/functions/polyfillDispose.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/**\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 = '1.1.0' as string;\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","/**\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","/* 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.WebSo