mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
chore: monorepo setup (#7175)
This commit is contained in:
12
packages/voice/src/util/abortAfter.ts
Normal file
12
packages/voice/src/util/abortAfter.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Creates an abort controller that aborts after the given time.
|
||||
*
|
||||
* @param delay - The time in milliseconds to wait before aborting
|
||||
*/
|
||||
export function abortAfter(delay: number): [AbortController, AbortSignal] {
|
||||
const ac = new AbortController();
|
||||
const timeout = setTimeout(() => ac.abort(), delay);
|
||||
// @ts-ignore
|
||||
ac.signal.addEventListener('abort', () => clearTimeout(timeout));
|
||||
return [ac, ac.signal];
|
||||
}
|
||||
Reference in New Issue
Block a user