diff options
author | Steven Guerrero <stephenguerrero43@gmail.com> | 2020-11-16 14:44:37 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-16 14:44:37 -0500 |
commit | 8ab20a4582016542ac3d8140593f817ab920005f (patch) | |
tree | 0834ffa57b83ee03b69bf380c1bc660b99778169 /std/node/process.ts | |
parent | dd9c2048849ec9bf0e1457a1bef431fd3f9be80d (diff) |
feat(std/node): implement process.nextTick (#8386)
Diffstat (limited to 'std/node/process.ts')
-rw-r--r-- | std/node/process.ts | 20 |
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, }; /** |