Buffer From
A ponyfill for Buffer.from
, uses native implementation if available.
Installation
Usage
API
bufferFrom(array)
array
<Array>
Allocates a new Buffer
using an array
of octets.
bufferFrom(arrayBuffer[, byteOffset[, length]])
arrayBuffer
<ArrayBuffer> The.buffer
property of a TypedArray or ArrayBufferbyteOffset
<Integer> Where to start copying fromarrayBuffer
. Default:0
length
<Integer> How many bytes to copy fromarrayBuffer
. Default:arrayBuffer.length - byteOffset
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.
The optional byteOffset
and length
arguments specify a memory range within the arrayBuffer
that will be shared by the Buffer
.
bufferFrom(buffer)
buffer
<Buffer> An existingBuffer
to copy data from
Copies the passed buffer
data onto a new Buffer
instance.
bufferFrom(string[, encoding])
string
<String> A string to encode.encoding
<String> The encoding ofstring
. Default:'utf8'
Creates a new Buffer
containing the given JavaScript string string
. If provided, the encoding
parameter identifies the character encoding of string
.
See also
buffer-alloc A ponyfill for
Buffer.alloc
buffer-alloc-unsafe A ponyfill for
Buffer.allocUnsafe
Last updated