Protect your apps from supply chain attacksInstall
A ponyfill for
Buffer.from, uses native implementation if available.
npm install --save buffer-from
const bufferFrom = require('buffer-from') console.log(bufferFrom([1, 2, 3, 4])) //=> <Buffer 01 02 03 04> const arr = new Uint8Array([1, 2, 3, 4]) console.log(bufferFrom(arr.buffer, 1, 2)) //=> <Buffer 02 03> console.log(bufferFrom('test', 'utf8')) //=> <Buffer 74 65 73 74> const buf = bufferFrom('test') console.log(bufferFrom(buf)) //=> <Buffer 74 65 73 74>
Allocates a new
Buffer using an
array of octets.
.bufferproperty of a TypedArray or ArrayBuffer
byteOffset<Integer> Where to start copying from
length<Integer> How many bytes to copy from
arrayBuffer.length - byteOffset
When passed a reference to the
.buffer property of a TypedArray instance, the
Buffer will share the same allocated memory as the TypedArray.
length arguments specify a memory range within
arrayBuffer that will be shared by the
buffer<Buffer> An existing
Bufferto copy data from
Copies the passed
buffer data onto a new
string<String> A string to encode.
encoding<String> The encoding of
Creates a new
encoding parameter identifies the character encoding of
A [ponyfill](https://ponyfill.com) for `Buffer.from`, uses native implementation if available.
The npm package buffer-from receives a total of 21,928,081 weekly downloads. As such, buffer-from popularity was classified as popular.
We found that buffer-from demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.