summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/timers.ts
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-06-24 15:50:02 +1000
committerGitHub <noreply@github.com>2024-06-24 15:50:02 +1000
commitdc4a88b7a636a52c4d8e255f91c81eb304b1a5c3 (patch)
tree2ae53ff032b799f1a132bbf10b220d68c67a2967 /ext/node/polyfills/timers.ts
parent1c7ae83ca1e73da36cda92416cb730531b7a454b (diff)
fix(ext/node): use primordials in `ext/node/polyfills/timers.ts` (#24311)
Towards #24236
Diffstat (limited to 'ext/node/polyfills/timers.ts')
-rw-r--r--ext/node/polyfills/timers.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/ext/node/polyfills/timers.ts b/ext/node/polyfills/timers.ts
index 033afd952..b96f448da 100644
--- a/ext/node/polyfills/timers.ts
+++ b/ext/node/polyfills/timers.ts
@@ -1,12 +1,12 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-// TODO(petamoriken): enable prefer-primordials for node polyfills
-// deno-lint-ignore-file prefer-primordials
-
import { primordials } from "ext:core/mod.js";
const {
MapPrototypeGet,
MapPrototypeDelete,
+ ObjectDefineProperty,
+ Promise,
+ SafeArrayIterator,
} = primordials;
import {
@@ -32,9 +32,11 @@ export function setTimeout(
return new Timeout(callback, timeout, args, false, true);
}
-Object.defineProperty(setTimeout, promisify.custom, {
+ObjectDefineProperty(setTimeout, promisify.custom, {
value: (timeout: number, ...args: unknown[]) => {
- return new Promise((cb) => setTimeout(cb, timeout, ...args));
+ return new Promise((cb) =>
+ setTimeout(cb, timeout, ...new SafeArrayIterator(args))
+ );
},
enumerable: true,
});
@@ -74,7 +76,7 @@ export function setImmediate(
cb: (...args: unknown[]) => void,
...args: unknown[]
): Timeout {
- return new Immediate(cb, ...args);
+ return new Immediate(cb, ...new SafeArrayIterator(args));
}
export function clearImmediate(immediate: Immediate) {
if (immediate == null) {