sfcode
An Online Competing and Development Environment
|
A ponyfill for Buffer.from
, uses native implementation if available.
array
<Array>Allocates a new Buffer
using an array
of octets.
arrayBuffer
<ArrayBuffer> The .buffer
property of a TypedArray or ArrayBufferbyteOffset
<Integer> Where to start copying from arrayBuffer
. Default: 0
length
<Integer> How many bytes to copy from arrayBuffer
. 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
.
buffer
<Buffer> An existing Buffer
to copy data fromCopies the passed buffer
data onto a new Buffer
instance.
string
<String> A string to encode.encoding
<String> The encoding of string
. Default: ‘'utf8’`Creates a new Buffer
containing the given JavaScript string string
. If provided, the encoding
parameter identifies the character encoding of string
.
Buffer.alloc
Buffer.allocUnsafe