Skip to content
/ bite Public

Lightweight library for word decoding/encoding, in pure javascript.

License

Notifications You must be signed in to change notification settings

martinvl/bite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bite

Lightweight library for word decoding in pure javascript. Contains methods for decoding/encoding bytestring 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 bytestring 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>

About

Lightweight library for word decoding/encoding, in pure javascript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published