buffer.entries()

buf.entries() Return: <Iterator> Creates and returns an iterator of [index, byte] pairs from the Buffer contents. const buf = Buffer.from('buffer'); for (var pair of buf.entries()) { console.log(pair); } // prints: // [0, 98] // [1, 117] // [2, 102] // [3, 102] // [4, 101] // [5, 114]

buffer.copy()

buf.copy(targetBuffer[, targetStart[, sourceStart[, sourceEnd]]]) targetBuffer <Buffer> Buffer to copy into targetStart <Number> Default: 0 sourceStart <Number> Default: 0 sourceEnd <Number> Default: buffer.length Return: <Number> The number of bytes copied. Copies data from a region of this Buffer to a region in the target Buffer even if the target memory region overlaps with the source. Example: build two Buffers, then copy buf1 from byte 16 through byte

Buffer.concat()

Class Method: Buffer.concat(list[, totalLength]) list <Array> List of Buffer objects to concat totalLength <Number> Total length of the Buffers in the list when concatenated Return: <Buffer> Returns a new Buffer which is the result of concatenating all the Buffers in the list together. If the list has no items, or if the totalLength is 0, then a new zero-length Buffer is returned. If totalLength is not provided, it is calculated from the Buffers in the list. This, howev

buffer.compare()

buf.compare(otherBuffer) otherBuffer <Buffer> Return: <Number> Compares two Buffer instances and returns a number indicating whether buf comes before, after, or is the same as the otherBuffer in sort order. Comparison is based on the actual sequence of bytes in each Buffer. 0 is returned if otherBuffer is the same as buf 1 is returned if otherBuffer should come before buf when sorted. -1 is returned if otherBuffer should come after buf when sorted. const buf1 = Buffer.fr

Buffer.compare()

Class Method: Buffer.compare(buf1, buf2) buf1 <Buffer> buf2 <Buffer> Return: <Number> Compares buf1 to buf2 typically for the purpose of sorting arrays of Buffers. This is equivalent is calling buf1.compare(buf2). const arr = [Buffer.from('1234'), Buffer.from('0123')]; arr.sort(Buffer.compare);

Buffer.byteLength()

Class Method: Buffer.byteLength(string[, encoding]) string <String> | <Buffer> | <TypedArray> | <DataView> | <ArrayBuffer> encoding <String> Default: 'utf8' Return: <Number> Returns the actual byte length of a string. This is not the same as String.prototype.length since that returns the number of characters in a string. Example: const str = '\u00bd + \u00bc = \u00be'; console.log(`${str}: ${str.length} characters, ` + `${Buffer.by

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

Buffer.alloc()

Class Method: Buffer.alloc(size[, fill[, encoding]]) size <Number> fill <Value> Default: undefined encoding <String> Default: utf8 Allocates a new Buffer of size bytes. If fill is undefined, the Buffer will be zero-filled. const buf = Buffer.alloc(5); console.log(buf); // <Buffer 00 00 00 00 00> 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.

Buffer

Class: Buffer The Buffer class is a global type for dealing with binary data directly. It can be constructed in a variety of ways.

beforeExit event (Process)

Event: 'beforeExit' This event is emitted when Node.js empties its event loop and has nothing else to schedule. Normally, Node.js exits when there is no work scheduled, but a listener for 'beforeExit' can make asynchronous calls, and cause Node.js to continue. 'beforeExit' is not emitted for conditions causing explicit termination, such as process.exit() or uncaught exceptions, and should not be used as an alternative to the 'exit' event unless the intention is to schedule more work.