mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
feat: add @discordjs/util (#8591)
* feat: add @discordjs/util * fix: builders test * refactor: make rest use lazy for ESM import * chore: make requested changes * Apply suggestions from code review Co-authored-by: Parbez <imranbarbhuiya.fsd@gmail.com> Co-authored-by: A. Román <kyradiscord@gmail.com> * chore: make requested changes and add tests * chore: regen lockfile * test: add type tests * chore: push missing files * chore: make requested changes * chore: update CI stuff * chore: fix lockfile * chore: make requested changes Co-authored-by: Parbez <imranbarbhuiya.fsd@gmail.com> Co-authored-by: A. Román <kyradiscord@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { EventEmitter } from 'node:events';
|
||||
import { setInterval, clearInterval } from 'node:timers';
|
||||
import type { URLSearchParams } from 'node:url';
|
||||
import { Collection } from '@discordjs/collection';
|
||||
import { lazy } from '@discordjs/util';
|
||||
import { DiscordSnowflake } from '@sapphire/snowflake';
|
||||
import { FormData, type RequestInit, type BodyInit, type Dispatcher, type Agent } from 'undici';
|
||||
import type { RESTOptions, RestEvents, RequestOptions } from './REST.js';
|
||||
@@ -12,12 +13,7 @@ import { DefaultRestOptions, DefaultUserAgent, RESTEvents } from './utils/consta
|
||||
import { resolveBody } from './utils/utils.js';
|
||||
|
||||
// Make this a lazy dynamic import as file-type is a pure ESM package
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
||||
const getFileType = async (): Promise<typeof import('file-type')> => {
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
||||
let cached: Promise<typeof import('file-type')>;
|
||||
return (cached ??= import('file-type'));
|
||||
};
|
||||
const getFileType = lazy(async () => import('file-type'));
|
||||
|
||||
/**
|
||||
* Represents a file to be added to the request
|
||||
|
||||
Reference in New Issue
Block a user