(callback)
| 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. |
| 113 | function 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 | |
| 147 | function runMicrotask() { |
| 148 | this.runInAsyncScope(() => { |
nothing calls this directly
no test coverage detected