BufferConstructor
Raw data is stored in instances of the Buffer class. A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized. Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex'
Methods
- alloc
- allocUnsafe
- allocUnsafeSlow
- byteLength
- compare
- concat
- copyBytesFrom
- from
- isBuffer
- isEncoding
- of
Constructors
constructor
**new BufferConstructor**(str, encoding?)
Allocates a new buffer containing the given {str}.
Parameters
str
stringRequiredencoding
BufferEncodingDeprecated
since v10.0.0 - Use Buffer.from(string[, encoding])
instead.
**new BufferConstructor**(size)
Allocates a new buffer of {size} octets.
Parameters
size
numberRequiredDeprecated
since v10.0.0 - Use Buffer.alloc()
instead (also see Buffer.allocUnsafe()
).
**new BufferConstructor**(array)
Allocates a new buffer containing the given {array} of octets.
Parameters
array
Uint8ArrayRequiredDeprecated
since v10.0.0 - Use Buffer.from(array)
instead.
**new BufferConstructor**(arrayBuffer)
Produces a Buffer backed by the same allocated memory as the given {ArrayBuffer}/{SharedArrayBuffer}.
Parameters
Deprecated
since v10.0.0 - Use Buffer.from(arrayBuffer[, byteOffset[, length]])
instead.
**new BufferConstructor**(array)
Allocates a new buffer containing the given {array} of octets.
Parameters
array
readonly any[]RequiredDeprecated
since v10.0.0 - Use Buffer.from(array)
instead.
**new BufferConstructor**(buffer)
Copies the passed {buffer} data onto a new {Buffer} instance.
Parameters
The buffer to copy.
Deprecated
since v10.0.0 - Use Buffer.from(buffer)
instead.
Properties
poolSize
numberRequiredBuffer
instances used for pooling. This value may be modified.