Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on Apr 22, 2024 via pnpm

buffer-from 1.1.2

A [ponyfill](https://ponyfill.com) for `Buffer.from`, uses native implementation if available.
Package summary
Share
0
issues
1
license
1
MIT
Package created
18 Aug 2016
Version published
29 Jul 2021
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
buffer-from@1.1.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of buffer-from 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does buffer-from do?

"Buffer-from" is an npm package that acts as a ponyfill for the Buffer.from function in JavaScript. Essentially, it uses the native implementation of Buffer.from if available but provides a fallback version if not, making it a very useful tool in backwards compatibility context. Its purpose is to allocate a new Buffer using various types of input, such as an array of octets, an ArrayBuffer and a specific range within it, an existing Buffer, or a particular JavaScript string with a specified encoding.

How do you use buffer-from?

To use "buffer-from", you'd first need to install it using npm with the command npm install --save buffer-from. Once installed, you'd require it in your JavaScript file like so: const bufferFrom = require('buffer-from'). "Buffer-from" provides different use-cases and ways to manipulate data to obtain Buffer objects, which can give you the exact Byte data that you need. Here are some examples:

If you want to create a buffer from an array of octets, you would use:

const bufferFrom = require('buffer-from')

console.log(bufferFrom([1, 2, 3, 4]))
//=> <Buffer 01 02 03 04>

To use a TypedArray or ArrayBuffer and specify a memory range, you could use:

const arr = new Uint8Array([1, 2, 3, 4])
console.log(bufferFrom(arr.buffer, 1, 2))
//=> <Buffer 02 03>

Creating a new buffer from a string with specific encoding looks like this:

console.log(bufferFrom('test', 'utf8'))
//=> <Buffer 74 65 73 74>

And copying data from an existing buffer to a new buffer would look like this:

const buf = bufferFrom('test')
console.log(bufferFrom(buf))
//=> <Buffer 74 65 73 74>

Where are the buffer-from docs?

The documentation for "buffer-from" can be found within the README file in the package's GitHub repository, which is hosted at https://github.com/LinusU/buffer-from. The README provides detailed installation and usage instructions, along with descriptions of the API methods and the parameters they accept.