How to use the binary.unpackByte function in binary

To help you get started, we’ve selected a few binary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hellomatty / daap.js / test / binary.js View on Github external
var assert = require('assert');
var binary = require('binary');
var sys = require('sys');

assert.equal(0, binary.packByte(0), 'pack_byte: 0');
assert.equal(255, binary.packByte(255), 'pack_byte: 255');

assert.equal(0, binary.unpackByte([0]), 'unpack_byte: 0');
assert.equal(255, binary.unpackByte([255]), 'unpack_byte: 255');

assert.deepEqual([0, 0], binary.packShort(0), 'pack_short: 0');
assert.deepEqual([0, 255], binary.packShort(255), 'pack_short: 255');
assert.deepEqual([1, 1], binary.packShort(257), 'pack_short: 256');

assert.equal(0, binary.unpackShort([0,0]), 'unpack_short: 0');
assert.equal(255, binary.unpackShort([0,255]), 'unpack_short: 255');
assert.equal(257, binary.unpackShort([1,1]), 'unpack_short: 257');

assert.deepEqual([0, 0, 0, 0], binary.packInt(0), 'pack_int: 0');
assert.deepEqual([0, 0, 0, 255], binary.packInt(255), 'pack_int: 255');
assert.deepEqual([109,115,112,105], binary.packInt('mspi'), 'pack_int: mspi');
assert.deepEqual([0, 0, 1, 1], binary.packInt(257), 'pack_int: 256');

assert.equal(0, binary.unpackInt([0,0,0,0]), 'unpack_int: 0');
github hellomatty / daap.js / lib / song.js View on Github external
BinaryFile.prototype.getByteAt = function(offset) {
  return binary.unpackByte(this.getBytesAt(offset, 1));
}