summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/_util/async.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/_util/async.ts')
-rw-r--r--ext/node/polyfills/_util/async.ts12
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);