Returns the maximum number of bytes that will be returned when buf.inspect() is called.
Returns the maximum number of bytes that will be returned when buf.inspect() is called. This can be overridden by user modules. See util.inspect() for more details on buf.inspect() behavior.
Note that this is a property on the buffer module returned by require('buffer'), not on the Buffer global or a Buffer instance.
Allocates a new Buffer of size bytes.
Allocates a new Buffer of size bytes. If fill is undefined, the Buffer will be zero-filled.
The desired length of the new Buffer
A value to pre-fill the new Buffer with. Default: 0
If fill is a string, this is its encoding. Default: 'utf8'
a new Buffer
Buffer.alloc(size[, fill[, encoding]])
Calling Buffer.alloc(size) can be significantly slower than the alternative Buffer.allocUnsafe(size) but ensures that the newly created Buffer instance contents will never contain sensitive data.
Calling Buffer.alloc(size) can be significantly slower than the alternative Buffer.allocUnsafe(size) but ensures that the newly created Buffer instance contents will never contain sensitive data.
the allocated size.
Buffer.allocUnsafe(size)
Allocates a new non-zero-filled and non-pooled Buffer of size bytes.
Allocates a new non-zero-filled and non-pooled 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. A zero-length Buffer will be created if a size less than or equal to 0 is specified.
The underlying memory for Buffer instances created in this way is not initialized. The contents of the newly created Buffer are unknown and may contain sensitive data. Use buf.fill(0) to initialize such Buffer instances to zeroes.
When using Buffer.allocUnsafe() to allocate new Buffer instances, allocations under 4KB are, by default, sliced from a single pre-allocated Buffer. This allows applications to avoid the garbage collection overhead of creating many individually allocated Buffers. This approach improves both performance and memory usage by eliminating the need to track and cleanup as many Persistent objects.
However, in the case where a developer may need to retain a small chunk of memory from a pool for an indeterminate amount of time, it may be appropriate to create an un-pooled Buffer instance using Buffer.allocUnsafeSlow() then copy out the relevant bits. (2^31)-1). }}} is thrown. A zero-length Buffer will be created if a size less than or equal to 0 is specified.
The underlying memory for Buffer instances created in this way is not initialized. The contents of the newly created Buffer are unknown and may contain sensitive data. Use buf.fill(0) to initialize such Buffer instances to zeroes.
When using Buffer.allocUnsafe() to allocate new Buffer instances, allocations under 4KB are, by default, sliced from a single pre-allocated Buffer. This allows applications to avoid the garbage collection overhead of creating many individually allocated Buffers. This approach improves both performance and memory usage by eliminating the need to track and cleanup as many Persistent objects.
However, in the case where a developer may need to retain a small chunk of memory from a pool for an indeterminate amount of time, it may be appropriate to create an un-pooled Buffer instance using Buffer.allocUnsafeSlow() then copy out the relevant bits.
the allocated size.
Buffer.allocUnsafeSlow(size)
Returns the actual byte length of a string.
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.
<String> | <Buffer> | <TypedArray> | <DataView> | <ArrayBuffer>
the optional encoding (default "utf8")
Buffer.byteLength(string[, encoding])
Compares buf1 to buf2 typically for the purpose of sorting arrays of Buffers.
Compares buf1 to buf2 typically for the purpose of sorting arrays of Buffers. This is equivalent is calling buf1.compare(buf2).
Returns a new Buffer which is the result of concatenating all the Buffers in the list together.
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, however, adds an additional loop to the function, so it is faster to provide the length explicitly.
the list of Buffer objects to concat
Buffer.concat(list[, totalLength])
Returns a new Buffer which is the result of concatenating all the Buffers in the list together.
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, however, adds an additional loop to the function, so it is faster to provide the length explicitly.
the list of Buffer objects to concat
the optional total length
Buffer.concat(list[, totalLength])
Creates a new Buffer containing the given JavaScript string str.
Creates a new Buffer containing the given JavaScript string str. If provided, the encoding parameter identifies the strings character encoding.
the source string
the given encoding
a new Buffer
Allocates a new Buffer using an array of octets.
Allocates a new Buffer using an array of octets.
Buffer.from(array)
When passed a reference to the .buffer property of a TypedArray instance, the newly created Buffer will share the same allocated memory as the TypedArray.
When passed a reference to the .buffer property of a TypedArray instance, the newly created Buffer will share the same allocated memory as the TypedArray.
Buffer.from(arrayBuffer[, byteOffset[, length]])
When passed a reference to the .buffer property of a TypedArray instance, the newly created Buffer will share the same allocated memory as the TypedArray.
When passed a reference to the .buffer property of a TypedArray instance, the newly created Buffer will share the same allocated memory as the TypedArray.
Buffer.from(arrayBuffer[, byteOffset[, length]])
When passed a reference to the .buffer property of a TypedArray instance, the newly created Buffer will share the same allocated memory as the TypedArray.
When passed a reference to the .buffer property of a TypedArray instance, the newly created Buffer will share the same allocated memory as the TypedArray.
Buffer.from(arrayBuffer[, byteOffset[, length]])
Returns true if obj is a Buffer, false otherwise.
Returns true if obj is a Buffer, false otherwise.
the given object
true if obj is a Buffer, false otherwise.
Returns true if encoding contains a supported character encoding, or false otherwise.
Returns true if encoding contains a supported character encoding, or false otherwise.
A character encoding name to check
true if encoding contains a supported character encoding, or false otherwise.
On 32-bit architectures, this value is (230)-1 (~1GB). On 64-bit architectures, this value is (231)-1 (~2GB).F Note that this is a property on the buffer module returned by require('buffer'), not on the Buffer global or a Buffer instance.
This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling.
This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling. This value may be modified.
Re-encodes the given Buffer instance from one character encoding to another.
Re-encodes the given Buffer instance from one character encoding to another. Returns a new Buffer instance.
Throws if the fromEnc or toEnc specify invalid character encodings or if conversion from fromEnc to toEnc is not permitted.
The transcoding process will use substitution characters if a given byte sequence cannot be adequately represented in the target encoding.
A Buffer instance
The current encoding
To target encoding
a new Buffer instance.