Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 2, 2024 via pnpm

buffer-from 0.1.1

A [ponyfill](https://ponyfill.com) for `Buffer.from`, uses native implementation if available.
Package summary
Share
0
issues
1
license
48
MIT
Package created
18 Aug 2016
Version published
16 Oct 2016
Maintainers
1
Total deps
48
Direct deps
1
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
48 Packages, Including:
attempt-x@1.1.3
buffer-from@0.1.1
cached-constructors-x@1.0.2
has-own-property-x@3.2.0
has-symbol-support-x@1.4.2
has-symbols@1.0.3
has-to-string-tag-x@1.4.1
has-tostringtag@1.0.2
infinity-x@1.0.2
is-array-buffer-x@1.7.0
is-date-object@1.0.5
is-falsey-x@1.0.3
is-finite-x@3.0.4
is-function-x@3.3.0
is-index-x@1.1.0
is-nan-x@1.0.3
is-nil-x@1.4.2
is-object-like-x@1.7.1
is-primitive@2.0.0
is-primitive@3.0.1
is-string@1.0.7
is-symbol@1.0.4
lodash.isnull@3.0.0
math-clamp-x@1.2.0
math-sign-x@3.0.0
max-safe-integer@1.0.1
nan-x@1.0.2
normalize-space-x@3.0.0
object-get-own-property-descriptor-x@3.2.0
parse-int-x@2.0.0
property-is-enumerable-x@1.1.0
replace-comments-x@2.0.0
require-coercible-to-string-x@1.0.2
require-object-coercible-x@1.4.3
to-boolean-x@1.0.3
to-integer-x@3.0.0
to-number-x@2.0.0
to-object-x@1.5.0
to-primitive-x@1.1.0
to-property-key-x@2.0.2
to-string-symbols-supported-x@1.0.2
to-string-tag-x@1.4.3
to-string-x@1.4.5
trim-left-x@3.0.0
trim-right-x@3.0.0
trim-x@3.0.0
validate.io-undefined@1.0.3
white-space-x@3.0.1
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

1
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
is-array-buffer-x1.7.030.11 kBMIT
prod

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.