init
This commit is contained in:
commit
ec53fcbe95
1905 changed files with 513762 additions and 0 deletions
13
utils/withResolvers.ts
Normal file
13
utils/withResolvers.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* Polyfill for Promise.withResolvers() (ES2024, Node 22+).
|
||||
* package.json declares "engines": { "node": ">=18.0.0" } so we can't use the native one.
|
||||
*/
|
||||
export function withResolvers<T>(): PromiseWithResolvers<T> {
|
||||
let resolve!: (value: T | PromiseLike<T>) => void
|
||||
let reject!: (reason?: unknown) => void
|
||||
const promise = new Promise<T>((res, rej) => {
|
||||
resolve = res
|
||||
reject = rej
|
||||
})
|
||||
return { promise, resolve, reject }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue