diff options
author | Kenta Moriuchi <moriken@kimamass.com> | 2023-12-08 18:00:03 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-08 18:00:03 +0900 |
commit | b24356d9b9827062bee35e720b5889a403ae89f3 (patch) | |
tree | dcbad198c448550dec1e79c9f26d3f79c4c6ec13 /ext/node/polyfills/_util/async.ts | |
parent | 3a74fa60ca948b0bc1608ae0ad6e00236ccc846a (diff) |
fix(ext/node): use primordials in ext/node/polyfills/_util (#21444)
Diffstat (limited to 'ext/node/polyfills/_util/async.ts')
-rw-r--r-- | ext/node/polyfills/_util/async.ts | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/node/polyfills/_util/async.ts b/ext/node/polyfills/_util/async.ts index 5eeda2a37..d0e6e04e8 100644 --- a/ext/node/polyfills/_util/async.ts +++ b/ext/node/polyfills/_util/async.ts @@ -2,8 +2,12 @@ // This module is vendored from std/async/delay.ts // (with some modifications) -// TODO(petamoriken): enable prefer-primordials for node polyfills -// deno-lint-ignore-file prefer-primordials +import { primordials } from "ext:core/mod.js"; +import { clearTimeout, setTimeout } from "ext:deno_web/02_timers.js"; +const { + Promise, + PromiseReject, +} = primordials; /** Resolve a Promise after a given amount of milliseconds. */ export function delay( @@ -12,12 +16,12 @@ export function delay( ): Promise<void> { const { signal } = options; if (signal?.aborted) { - return Promise.reject(new DOMException("Delay was aborted.", "AbortError")); + return PromiseReject(signal.reason); } return new Promise((resolve, reject) => { const abort = () => { clearTimeout(i); - reject(new DOMException("Delay was aborted.", "AbortError")); + reject(signal!.reason); }; const done = () => { signal?.removeEventListener("abort", abort); |