0.1.0-4 • Published 11 years ago

bite v0.1.0-4

Weekly downloads
15
License
-
Repository
github
Last release
11 years ago

bite

Lightweight library for word decoding in pure javascript. Contains methods for decoding/encoding byte string words to/from numbers (signed and unsigned, big and little endian).

API

  • decodeWord(< Buffer >buffer, < bool >signed, < bool >bigEndian) - (void)
    Decodes a word contained in buffer, i.e. all of buffer is treated as one word. Treats the word as signed if signed is set to true (false is default), and big endian if bigEndian is set to true (false is default).

  • encodeWord(< Buffer >buffer, < number >value, < bool >signed, < bool >bigEndian) - (buffer)
    Encodes a number value into a byte string word of the same length as buffer, and stores the result in buffer. Will create the word as signed if signed is set to true (false is default), and big endian if bigEndian is set to true (false is default). The buffer provided is returned for convenience.

Example

var bite = require('bite');

var buffer = new Buffer([0xFF, 0xFF]);
var value = bite.decodeWord(buffer, true); // = -1
var word = bite.encodeWord(new Buffer(2), value); // = <Buffer ff ff>
0.1.0-4

11 years ago

0.1.0-3

11 years ago

0.1.0-2

11 years ago

0.1.0

11 years ago