2.0.4 • Published 7 years ago

buffjs v2.0.4

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

Buff.js

Translate ArrayBuffers to strings and vice versa in JavaScript. This library is mainly useful for sending WebSocket messages as Binary packets.

Browser

Insert the script tag into your markup:

<script src="https://cdn.jsdelivr.net/npm/buffjs/dist/buff.min.js"></script>

Usage in the browser:

Buff = window.Buff;

var buffer = Buff.Writer('a test string'); // Translates the string "test" info an ArrayBuffer.
var string = Buff.Reader(buffer); // Translates the ArrayBuffer back into the string "test".

Node.JS

Install with the command:

npm i buff.js

Usage in Node.js:

const Buff = require('buffjs');

var buffer = Buff.Writer('a test string'); // Translates the string "test" info an ArrayBuffer.
var string = Buff.Reader(buffer); // Translates the ArrayBuffer back into the string "test".

WebSockets Example