# array2buffer
> Allocate a [buffer][@stdlib/buffer/ctor] using an octet array.
## Usage
```javascript
var array2buffer = require( '@stdlib/buffer/from-array' );
```
#### array2buffer( arr )
Allocates a [buffer][@stdlib/buffer/ctor] using an `array` (or array-like `object`) of octets.
```javascript
var buf = array2buffer( [ 1, 2, 3, 4 ] );
// returns [ 1, 2, 3, 4 ]
```
## Examples
```javascript
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() );
```
[@stdlib/buffer/ctor]: https://www.npmjs.com/package/@stdlib/buffer/tree/main/ctor