Type: Runtime (supports [--pending-deprecation
][])
The Buffer()
function and new Buffer()
constructor are deprecated due to
API usability issues that can lead to accidental security issues.
As an alternative, use one of the following methods of constructing Buffer
objects:
- [
Buffer.alloc(size[, fill[, encoding]])
][alloc]: Create aBuffer
with initialized memory. - [
Buffer.allocUnsafe(size)
][alloc_unsafe_size]: Create aBuffer
with uninitialized memory. - [
Buffer.allocUnsafeSlow(size)
][]: Create aBuffer
with uninitialized memory. - [
Buffer.from(array)
][]: Create aBuffer
with a copy ofarray
- [
Buffer.from(arrayBuffer[, byteOffset[, length]])
][from_arraybuffer] - Create aBuffer
that wraps the givenarrayBuffer
. - [
Buffer.from(buffer)
][]: Create aBuffer
that copiesbuffer
. - [
Buffer.from(string[, encoding])
][from_string_encoding]: Create aBuffer
that copiesstring
.
Without --pending-deprecation
, runtime warnings occur only for code not in
node_modules
. This means there will not be deprecation warnings for
Buffer()
usage in dependencies. With --pending-deprecation
, a runtime
warning results no matter where the Buffer()
usage occurs.