This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.setup = setupNextTick; | |
function setupNextTick() { | |
// ...redacted... | |
// tickInfo is used so that the C++ code in src/node.cc can | |
// have easy access to our nextTick state, and avoid unnecessary | |
// calls into JS land. | |
// runMicrotasks is used to run V8's micro task queue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function startup() { | |
// ...redacted... | |
setupProcessObject(); | |
// ...redacted... | |
setupV8(); | |
// ...redacted... | |
NativeModule.require('internal/process/warning').setup(); | |
NativeModule.require('internal/process/next_tick').setup(); | |
// ...redacted... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _tickCallback() { | |
let tock; | |
do { | |
while (tock = queue.shift()) { | |
const asyncId = tock[async_id_symbol]; | |
emitBefore(asyncId, tock[trigger_async_id_symbol]); | |
if (destroyHooksExist()) | |
emitDestroy(asyncId); | |
const callback = tock.callback; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.setup = setupNextTick; | |
function setupNextTick() { | |
// ...redacted... | |
const [ | |
tickInfo, | |
runMicrotasks | |
] = process._setupNextTick(_tickCallback); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Environment::Start(int argc, | |
const char* const* argv, | |
int exec_argc, | |
const char* const* exec_argv, | |
bool start_profiler_idle_notifier) { | |
// ...redacted... | |
SetupProcessObject(this, argc, argv, exec_argc, exec_argv); | |
// ...redacted... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Module.runMain = function() { | |
// Load the main module--the command line argument. | |
Module._load(process.argv[1], null, true); | |
// Handle any nextTicks added in the first tick of the program | |
process._tickCallback(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mergeXpathList(xpathList) { | |
return xpathList.reduce((output, curr) => { | |
const out = output; | |
if (out.length === 0) { return [curr]; } | |
for (let i = 0; i < out.length; i += 1) { | |
if (curr.includes(out[i])) { | |
out[i] = curr; | |
return out; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function processImmediate() { | |
const queue = outstandingQueue.head !== null ? | |
outstandingQueue : immediateQueue; | |
var immediate = queue.head; | |
const tail = queue.tail; | |
// Clear the linked list early in case new `setImmediate()` calls occur while | |
// immediate callbacks are executed | |
queue.head = queue.tail = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function SquareAsync (number, callback) { | |
if (number > 100) { | |
process.nextTick(() => { | |
callback(new Error('number is too large for me to handle')); | |
}); | |
return; | |
} | |
setTimeout(() => { | |
callback(null, number ** 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
NODE_VERSION=`node --version` | |
BUNYAN_VERSION=`bunyan --version | awk '{print $2}'` | |
echo "Running with node version: "$NODE_VERSION" and bunyan version: "$BUNYAN_VERSION"..." | |
node $* | bunyan |