Properties
Functions
Allocates a new Buffer
of size
bytes. If fill
is undefined
, theBuffer
will be zero-filled.
Allocates a new Buffer
of size
bytes. If size
is larger than {@link constants.MAX_LENGTH} or smaller than 0, ERR_OUT_OF_RANGE
is thrown.
Allocates a new Buffer
of size
bytes. If size
is larger than {@link constants.MAX_LENGTH} or smaller than 0, ERR_OUT_OF_RANGE
is thrown. A zero-length Buffer
is created if size
is 0.
Returns the byte length of a string when encoded using encoding
. This is not the same as String.prototype.length
, which does not account for the encoding that is used to convert the string into bytes.
Compares buf1
to buf2
, typically for the purpose of sorting arrays of Buffer
instances. This is equivalent to calling buf1.compare(buf2)
.
Returns a new Buffer
which is the result of concatenating all the Buffer
instances in the list
together.
Copies the underlying memory of view
into a new Buffer
.
Creates a new Buffer using the passed {data}
Creates a new Buffer containing the given JavaScript string {str}. If provided, the {encoding} parameter identifies the character encoding. If not provided, {encoding} defaults to 'utf8'.
Allocates a new Buffer
using an array
of bytes in the range 0
– 255
. Array entries outside that range will be truncated to fit into it.
Returns true
if encoding
is the name of a supported character encoding, or false
otherwise.