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:
parent
724cdcec7b
commit
fb0744f4e1
2 changed files with 18 additions and 3 deletions
|
@ -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.
|
||||||
|
|
|
@ -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]", () => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue