Created
October 5, 2015 19:31
-
-
Save ivangeorgiev/3e3da22a881112700d4b to your computer and use it in GitHub Desktop.
Node.js Cheat .Sheet
This file contains hidden or 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
// Global Objects | |
// https://nodejs.org/api/globals.html | |
__filename; // The filename (resolved absolute path) of the code being executed. | |
__dirname; // The name of the directory that the currently executing script resides in. (absolute path) | |
global; // The global namespace object. | |
process; // The process object https://nodejs.org/api/process.html | |
process.chdir(directory); // Changes the current working directory of the process or throws an exception if that fails. | |
process.cwd(); // Returns the current working directory of the process. | |
process.env; // An object containing the user environment. You can write to this object. | |
process.exit([code]); // Ends the process with the specified code. | |
process.exitCode; // A number which will be the process exit code, when the process exits. | |
process.stdout // A Writable Stream to stdout (on fd 1). | |
process.stderr // A writable stream to stderr (on fd 2). | |
process.stdin; // A Readable Stream for stdin (on fd 0). | |
process.argv; // An array containing the command line arguments. | |
process.execPath; // This is the absolute pathname of the executable that started the process. | |
process.execArgv; // This is the set of Node.js-specific command line options from the executable that started the process. | |
console; // Console object. Used to print to stdout and stderr. https://nodejs.org/api/console.html | |
console.log([data][, ...]); // Prints to stdout. printf()-like format. See util.format(). | |
console.info([data][, ...]); // See console.info() | |
console.error([data][, ...]); // Prints to stderr. | |
console.warn([data][, ...]); // See console.warn() | |
console.dir(obj[, options]); // Uses util.inspect on obj and prints resulting string to stdout. | |
console.time(label); // Starts a named timer. | |
console.timeEnd(label); // Stops a named timer and prints elapsed time in ms. | |
module; // A reference to the current module. https://nodejs.org/api/modules.html | |
module.exports; | |
module.filename | |
setTimeout(cb, ms) // Run callback cb after at least ms milliseconds. | |
clearTimeout(t) // Stop a timer that was previously created with setTimeout(). t is the value returned by setTimeout() | |
setInterval(cb, ms) // Run callback cb repeatedly every ms milliseconds. | |
clearInterval(t) // Stop a timer that was previously created with setInterval(). t is the value returned by setInterval() | |
setImmediate(callback[, arg][, ...]) // To schedule the "immediate" execution of callback after I/O events callbacks and before setTimeout and setInterval. | |
clearImmediate(immediateObject) // Stops an immediate from triggering. immediateObject is returned from setImmediate() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment