A barrel is a simple format for storing and transferring individual, variable-length binary objects within a byte array.
Install the oak-barrel
package into your project with npm.
npm install oak-barrel --save
Use the oak-barrel
module in your project.
import Barrel from 'oak-barrel'; // ES6
var Barrel = require('oak-barrel'); // ES5
// Convert from a String into a barrel-formatted Buffer
let barrel = Barrel.fromText('Hello, World!');
// <Buffer 48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 21 ff>
// Convert from a barrel-formatted Buffer into a String
let text = Barrel.toText(barrel);
// 'Hello, World!'
The public interface for oak-barrel
is defined in the API Guide.
Pull requests are welcome! To get started, see the Contributing Guide.