Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ext/node): use primordials in ext/node/polyfills/timers.ts #24311

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions ext/node/polyfills/timers.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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,
});
Expand Down Expand Up @@ -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) {
Expand Down