fs.appendFile()

fs.appendFile(file, data[, options], callback) file <String> | <Number> filename or file descriptor data <String> | <Buffer> options <Object> | <String> encoding <String> | <Null> default = 'utf8' mode <Number> default = 0o666 flag <String> default = 'a' callback <Function> Asynchronously append data to a file, creating the file if it does not yet exist. data can be a string or a buffer. Example: fs.appendFile('me

fs.accessSync()

fs.accessSync(path[, mode]) Synchronous version of fs.access(). This throws if any accessibility checks fail, and does nothing otherwise.

fs.access()

fs.access(path[, mode], callback) Tests a user's permissions for the file specified by path. mode is an optional integer that specifies the accessibility checks to be performed. The following constants define the possible values of mode. It is possible to create a mask consisting of the bitwise OR of two or more values. fs.F_OK - File is visible to the calling process. This is useful for determining if a file exists, but says nothing about rwx permissions. Default if no mode is specified. fs

fork event (Cluster)

Event: 'fork' worker <cluster.Worker> When a new worker is forked the cluster module will emit a 'fork' event. This can be used to log worker activity, and create your own timeout. var timeouts = []; function errorMsg() { console.error('Something must be wrong with the connection ...'); } cluster.on('fork', (worker) => { timeouts[worker.id] = setTimeout(errorMsg, 2000); }); cluster.on('listening', (worker, address) => { clearTimeout(timeouts[worker.id]); }); cluster.on('

finish event (stream.Writable)

Stability: 2 - Stable A stream is an abstract interface implemented by various objects in Node.js. For example a request to an HTTP server is a stream, as is process.stdout. Streams are readable, writable, or both. All streams are instances of EventEmitter. You can load the Stream base classes by doing require('stream'). There are base classes provided for Readable streams, Writable streams, Duplex streams, and Transform streams. This document is split up into 3 sections: The first section e

finish event (http.ServerResponse)

Event: 'finish' function () { } Emitted when the response has been sent. More specifically, this event is emitted when the last segment of the response headers and body have been handed off to the operating system for transmission over the network. It does not imply that the client has received anything yet. After this event, no more events will be emitted on the response object.

exit event (Worker)

Event: 'exit' code <Number> the exit code, if it exited normally. signal <String> the name of the signal (eg. 'SIGHUP') that caused the process to be killed. Similar to the cluster.on('exit') event, but specific to this worker. const worker = cluster.fork(); worker.on('exit', (code, signal) => { if( signal ) { console.log(`worker was killed by signal: ${signal}`); } else if( code !== 0 ) { console.log(`worker exited with error code: ${code}`); } else { cons

exit event (REPLServer)

Event: 'exit' function () {} Emitted when the user exits the REPL in any of the defined ways. Namely, typing .exit at the repl, pressing Ctrl+C twice to signal SIGINT, or pressing Ctrl+D to signal 'end' on the input stream. Example of listening for exit: replServer.on('exit', () => { console.log('Got "exit" event from repl!'); process.exit(); });

exit event (Process)

Event: 'exit' Emitted when the process is about to exit. There is no way to prevent the exiting of the event loop at this point, and once all 'exit' listeners have finished running the process will exit. Therefore you must only perform synchronous operations in this handler. This is a good hook to perform checks on the module's state (like for unit tests). The callback takes one argument, the code the process is exiting with. This event is only emitted when Node.js exits explicitly by process.

exit event (Cluster)

Event: 'exit' worker <cluster.Worker> code <Number> the exit code, if it exited normally. signal <String> the name of the signal (eg. 'SIGHUP') that caused the process to be killed. When any of the workers die the cluster module will emit the 'exit' event. This can be used to restart the worker by calling .fork() again. cluster.on('exit', (worker, code, signal) => { console.log('worker %d died (%s). restarting...', worker.process.pid, signal || code); cluste