MCPcopy Index your code
hub / github.com/nodejs/node / nextTick

Function nextTick

lib/internal/process/task_queues.js:113–145  ·  view source on GitHub ↗
(callback)

Source from the content-addressed store, hash-verified

111// `nextTick()` will not enqueue any callback when the process is about to
112// exit since the callback would not have a chance to be executed.
113function nextTick(callback) {
114 validateFunction(callback, 'callback');
115
116 if (process._exiting)
117 return;
118
119 let args;
120 switch (arguments.length) {
121 case 1: break;
122 case 2: args = [arguments[1]]; break;
123 case 3: args = [arguments[1], arguments[2]]; break;
124 case 4: args = [arguments[1], arguments[2], arguments[3]]; break;
125 default:
126 args = new Array(arguments.length - 1);
127 for (let i = 1; i < arguments.length; i++)
128 args[i - 1] = arguments[i];
129 }
130
131 if (queue.isEmpty())
132 setHasTickScheduled(true);
133 const asyncId = newAsyncId();
134 const triggerAsyncId = getDefaultTriggerAsyncId();
135 const tickObject = {
136 [async_id_symbol]: asyncId,
137 [trigger_async_id_symbol]: triggerAsyncId,
138 [async_context_frame]: AsyncContextFrame.current(),
139 callback,
140 args,
141 };
142 if (initHooksExist())
143 emitInit(asyncId, 'TickObject', triggerAsyncId, tickObject);
144 queue.push(tickObject);
145}
146
147function runMicrotask() {
148 this.runInAsyncScope(() => {

Callers

nothing calls this directly

Calls 7

setHasTickScheduledFunction · 0.85
newAsyncIdFunction · 0.85
getDefaultTriggerAsyncIdFunction · 0.85
initHooksExistFunction · 0.85
isEmptyMethod · 0.45
currentMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected