0.2.1 • Published 2 months ago

@stdlib/buffer-from-array v0.2.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

array2buffer

NPM version Build Status Coverage Status

Allocate a buffer using an octet array.

Installation

npm install @stdlib/buffer-from-array

Usage

var array2buffer = require( '@stdlib/buffer-from-array' );

array2buffer( arr )

Allocates a buffer using an array (or array-like object) of octets.

var buf = array2buffer( [ 1, 2, 3, 4 ] );
// returns <Buffer>[ 1, 2, 3, 4 ]

Examples

var array2buffer = require( '@stdlib/buffer-from-array' );

var octets;
var buf;
var str;
var i;

// Define a string we want to convert to a buffer:
str = 'this is a string.';

// Manually convert the string to an array of octets...
octets = new Array( str.length );
for ( i = 0; i < str.length; i++ ) {
    octets[ i ] = str.charCodeAt( i ) % 256;
}

// Create a buffer from the octet array:
buf = array2buffer( octets );
console.log( buf.toString() );

See Also


Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2024. The Stdlib Authors.

@everything-registry/sub-chunk-867@stdlib/buffer-from-arraybuffer@stdlib/buffer-reviver@stdlib/random-streams-laplace-cli@stdlib/random-streams-levy-cli@stdlib/random-streams-logistic-cli@stdlib/random-streams-lognormal-cli@stdlib/random-streams-minstd-cli@stdlib/random-streams-minstd-shuffle-cli@stdlib/random-streams-mt19937-cli@stdlib/random-streams-negative-binomial-cli@stdlib/random-streams-normal-cli@stdlib/random-streams-pareto-type1-cli@stdlib/random-streams-poisson-cli@stdlib/random-streams-randi-cli@stdlib/random-streams-randn-cli@stdlib/random-streams-randu-cli@stdlib/random-streams-rayleigh-cli@stdlib/random-streams-t-cli@stdlib/random-streams-triangular-cli@stdlib/random-streams-uniform-cli@stdlib/random-streams-weibull-cli@stdlib/random-streams-arcsine-cli@stdlib/random-streams-bernoulli-cli@stdlib/random-streams-beta-cli@stdlib/random-streams-chi-cli@stdlib/random-streams-chisquare-cli@stdlib/random-streams-cosine-cli@stdlib/random-streams-discrete-uniform-cli@stdlib/random-streams-erlang-cli@stdlib/random-streams-exponential-cli@stdlib/random-streams-f-cli@stdlib/random-streams-frechet-cli@stdlib/random-streams-geometric-cli@stdlib/random-streams-gumbel-cli@stdlib/random-streams-hypergeometric-cli@stdlib/random-streams-improved-ziggurat-cli@stdlib/random-streams-invgamma-cli@stdlib/random-streams-kumaraswamy-cli@stdlib/random-streams-betaprime-cli@stdlib/random-streams-binomial-cli@stdlib/random-streams-box-muller-cli@stdlib/random-streams-cauchy-cli@stdlib/random-streams-gamma-cli@zalastax/nolb-_stdlib_b@infinitebrahmanuniverse/nolb-_stdlib_b
0.2.1

2 months ago

0.2.0

2 months ago

0.1.0

7 months ago

0.0.7

2 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago