Get new jQuery plugins just once a week

×

Restruct js

FavoriteLoadingAdd to favorites

August 16, 2012

Restruct js | Conversion to and from binary data types

Restruct js is a javascript Binary library performs conversion to and from binary data types. It utilizes an intuitive declarative API to define formats for binary structure parsers and emitters. It works in both the browser and on Node.
restruct.js has support for typed arrays, where available.
> struct = restruct.
... int8lu('opcode').
... int8lu('version').
... string('username', 20);

> packet = struct.pack({opcode: 1, version: 1, username: "test"});
[ 1, 1, 116, 101, 115, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]

> struct.unpack(packet);
{ opcode: 1,
version: 1,
username: 'test' }

Created by Tony Young

Download
Home
Tutorial

restruct-js

restruct.js performs conversion to and from binary data types

Restruct js

Related posts:

Box-js
jStorage
Ptty
restruct-js

http://jquer.in/wp-content/uploads/2012/07/restruct-js.png

jQuery plugin

Sign up for our weekly newsletter.

* We won't spam you ever