summaryrefslogtreecommitdiff
path: root/std/node/process.ts
diff options
context:
space:
mode:
authorSteven Guerrero <stephenguerrero43@gmail.com>2020-11-16 14:44:37 -0500
committerGitHub <noreply@github.com>2020-11-16 14:44:37 -0500
commit8ab20a4582016542ac3d8140593f817ab920005f (patch)
tree0834ffa57b83ee03b69bf380c1bc660b99778169 /std/node/process.ts
parentdd9c2048849ec9bf0e1457a1bef431fd3f9be80d (diff)
feat(std/node): implement process.nextTick (#8386)
Diffstat (limited to 'std/node/process.ts')
-rw-r--r--std/node/process.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/std/node/process.ts b/std/node/process.ts
index a47140f15..6f61a074a 100644
--- a/std/node/process.ts
+++ b/std/node/process.ts
@@ -28,6 +28,25 @@ export const versions = {
...Deno.version,
};
+/** https://nodejs.org/api/process.html#process_process_nexttick_callback_args */
+export function nextTick(this: unknown, cb: () => void): void;
+export function nextTick<T extends Array<unknown>>(
+ this: unknown,
+ cb: (...args: T) => void,
+ ...args: T
+): void;
+export function nextTick<T extends Array<unknown>>(
+ this: unknown,
+ cb: (...args: T) => void,
+ ...args: T
+) {
+ if (args) {
+ queueMicrotask(() => cb.call(this, ...args));
+ } else {
+ queueMicrotask(cb);
+ }
+}
+
/** https://nodejs.org/api/process.html#process_process */
// @deprecated `import { process } from 'process'` for backwards compatibility with old deno versions
export const process = {
@@ -123,6 +142,7 @@ export const process = {
// Getter also allows the export Proxy instance to function as intended
return Deno.env.toObject();
},
+ nextTick,
};
/**