0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -05:00

fix(ext/node): spread args in setImmediate (#22998)

Closes https://github.com/denoland/deno/issues/22997

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
This commit is contained in:
Satya Rohith 2024-03-20 13:22:50 +05:30 committed by GitHub
parent 724cdcec7b
commit fb0744f4e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 3 deletions

View file

@ -117,8 +117,8 @@ Timeout.prototype[Symbol.toPrimitive] = function () {
}; };
// Immediate constructor function. // Immediate constructor function.
export function Immediate(callback, args) { export function Immediate(callback, ...args) {
this._immediateId = setImmediate_(callback, args); this._immediateId = setImmediate_(callback, ...args);
} }
// Make sure the linked list only shows the minimal necessary information. // Make sure the linked list only shows the minimal necessary information.

View file

@ -30,7 +30,7 @@ Deno.test("[node/timers setInterval]", () => {
} }
}); });
Deno.test("[node/timers setImmediate]", () => { Deno.test("[node/timers setImmediate]", async () => {
{ {
const { clearImmediate, setImmediate } = timers; const { clearImmediate, setImmediate } = timers;
const imm = setImmediate(() => {}); const imm = setImmediate(() => {});
@ -41,6 +41,21 @@ Deno.test("[node/timers setImmediate]", () => {
const imm = timers.setImmediate(() => {}); const imm = timers.setImmediate(() => {});
timers.clearImmediate(imm); timers.clearImmediate(imm);
} }
{
const deffered = Promise.withResolvers<void>();
const imm = timers.setImmediate(
(a, b) => {
assert(a === 1);
assert(b === 2);
deffered.resolve();
},
1,
2,
);
await deffered;
timers.clearImmediate(imm);
}
}); });
Deno.test("[node/timers/promises setTimeout]", () => { Deno.test("[node/timers/promises setTimeout]", () => {