vm.runInNewContext()

vm.runInNewContext(code[, sandbox][, options]) vm.runInNewContext() compiles code, contextifies sandbox if passed or creates a new contextified sandbox if it's omitted, and then runs the code with the sandbox as the global object and returns the result. vm.runInNewContext() takes the same options as vm.runInThisContext(). Example: compile and execute code that increments a global variable and sets a new one. These globals are contained in the sandbox. const util = require('util'); const vm =

Sign

Class: Sign The Sign Class is a utility for generating signatures. It can be used in one of two ways: As a writable stream, where data to be signed is written and the sign.sign() method is used to generate and return the signature, or Using the sign.update() and sign.sign() methods to produce the signature. The crypto.createSign() method is used to create Sign instances. Sign objects are not to be created directly using the new keyword. Example: Using Sign objects as streams: const crypto

path.relative()

path.relative(from, to) Solve the relative path from from to to. At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve, which means we see that: path.resolve(from, path.relative(from, to)) == path.resolve(to) Examples: path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb') // returns '..\\..\\impl\\bbb' path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb') // returns '

tls.createSecurePair()

tls.createSecurePair([context][, isServer][, requestCert][, rejectUnauthorized][, options]) Creates a new secure pair object with two streams, one of which reads and writes the encrypted data and the other of which reads and writes the cleartext data. Generally, the encrypted stream is piped to/from an incoming encrypted data stream and the cleartext one is used as a replacement for the initial encrypted stream. credentials: A secure context object from tls.createSecureContext( ... ). isSer

assert.deepEqual()

assert.deepEqual(actual, expected[, message]) Tests for deep equality between the actual and expected parameters. Primitive values are compared with the equal comparison operator ( == ). Only enumerable "own" properties are considered. The deepEqual() implementation does not test object prototypes, attached symbols, or non-enumerable properties. This can lead to some potentially surprising results. For example, the following example does not throw an AssertionError because the properties on th

Buffer.allocUnsafe()

Class Method: Buffer.allocUnsafe(size) size <Number> Allocates a new non-zero-filled Buffer of size bytes. The size must be less than or equal to the value of require('buffer').kMaxLength (on 64-bit architectures, kMaxLength is (2^31)-1). Otherwise, a RangeError is thrown. If a size less than 0 is specified, a zero-length Buffer will be created. The underlying memory for Buffer instances created in this way is not initialized. The contents of the newly created Buffer are unknown and

SIGTSTP event (Readline)

Event: 'SIGTSTP' function () {} This does not work on Windows. Emitted whenever the input stream receives a ^Z, respectively known as SIGTSTP. If there is no SIGTSTP event listener present when the input stream receives a SIGTSTP, the program will be sent to the background. When the program is resumed with fg, the 'pause' and SIGCONT events will be emitted. You can use either to resume the stream. The 'pause' and SIGCONT events will not be triggered if the stream was paused before the progr

RangeError

Class: RangeError A subclass of Error that indicates that a provided argument was not within the set or range of acceptable values for a function; whether that is a numeric range, or outside the set of options for a given function parameter. For example: require('net').connect(-1); // throws RangeError, port should be > 0 && < 65536 Node.js will generate and throw RangeError instances immediately as a form of argument validation.

domain.run()

domain.run(fn[, arg][, ...]) fn <Function> Run the supplied function in the context of the domain, implicitly binding all event emitters, timers, and lowlevel requests that are created in that context. Optionally, arguments can be passed to the function. This is the most basic way to use a domain. Example: const domain = require('domain'); const fs = require('fs'); const d = domain.create(); d.on('error', (er) => { console.error('Caught error!', er); }); d.run(() => { pro

stream.push()

stream.push('') Pushing a zero-byte string or Buffer (when not in Object mode) has an interesting side effect. Because it is a call to stream.push(), it will end the reading process. However, it does not add any data to the readable buffer, so there's nothing for a user to consume. Very rarely, there are cases where you have no data to provide now, but the consumer of your stream (or, perhaps, another bit of your own code) will know when to check again, by calling stream.read(0). In those cas