pack H2H0ms ‣
assert.deepEqual(
btools.pack('<H2H', [1, 1, 1]),
[1, 0, 1, 0, 1, 0]);
pack H2H0ms ‣
assert.deepEqual(
btools.pack('<2HH', [1, 1, 1]),
[1, 0, 1, 0, 1, 0]);
pack 2H2H0ms ‣
assert.deepEqual(
btools.pack('<2H3H', [1, 1, 1, 1, 1]),
[1, 0, 1, 0, 1, 0, 1, 0, 1, 0]);
pack 2H2H0ms ‣
assert.deepEqual(
btools.pack('<3H2H', [1, 1, 1, 1, 1]),
[1, 0, 1, 0, 1, 0, 1, 0, 1, 0]);
pack 2H2H2H1ms ‣
assert.deepEqual(
btools.pack('<3H2H2H', [1, 1, 1, 1, 1, 1, 1]),
[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]);
pack s2s0ms ‣
assert.deepEqual(
btools.pack('<s2s', ['a', 'ba']),
[97, 98, 97]);
pack 2ss0ms ‣
assert.deepEqual(
btools.pack('<2ss', ['ab', 'a']),
[97, 98, 97]);
pack 2s3s0ms ‣
assert.deepEqual(
btools.pack('<2s3s', ['ab','aba']),
[97, 98, 97, 98, 97]);
pack 3s2s0ms ‣
assert.deepEqual(
btools.pack('<3s2s', ['aba', 'ba']),
[97, 98, 97, 98, 97]);
pack 3s2s2s0ms ‣
assert.deepEqual(
btools.pack('<3s2s2s', ['aba', 'ba', 'ba']),
[97, 98, 97, 98, 97, 98, 97]);
pack ss0ms ‣
assert.deepEqual(
btools.pack('<ss', ['a', 'b']),
[97, 98]);
pack u2u1ms ‣
assert.deepEqual(
btools.pack('<u2u', ['a', 'ba']),
[97, 98, 97]);
pack 2uu0ms ‣
assert.deepEqual(
btools.pack('<2uu', ['ab', 'a']),
[97, 98, 97]);
pack 2u3u0ms ‣
assert.deepEqual(
btools.pack('<2u3u', ['ab','aba']),
[97, 98, 97, 98, 97]);
pack 3u2u0ms ‣
assert.deepEqual(
btools.pack('<3u2u', ['aba', 'ba']),
[97, 98, 97, 98, 97]);
pack 3u2u2u0ms ‣
assert.deepEqual(
btools.pack('<3u2u2u', ['aba', 'ba', 'ba']),
[97, 98, 97, 98, 97, 98, 97]);
pack uu0ms ‣
assert.deepEqual(
btools.pack('<uu', ['a', 'b']),
[97, 98]);
pack uuh0ms ‣
assert.deepEqual(
btools.pack('<uuh', ['a', 'b', 1]),
[97, 98, 1, 0]);
pack uu2h0ms ‣
assert.deepEqual(
btools.pack('<uu2h', ['a', 'b', 1, 1]),
[97, 98, 1, 0, 1, 0]);
pack uuhh0ms ‣
assert.deepEqual(
btools.pack('<uuhh', ['a', 'b', 1, 1]),
[97, 98, 1, 0, 1, 0]);
pack uu2hu0ms ‣
assert.deepEqual(
btools.pack('<uu2hu', ['a', 'b', 1, 1, 'a']),
[97, 98, 1, 0, 1, 0, 97]);
pack uuhhu0ms ‣
assert.deepEqual(
btools.pack('<uuhhu', ['a', 'b', 1, 1, 'a']),
[97, 98, 1, 0, 1, 0, 97]);
pack H0BH0ms ‣
assert.deepEqual(
btools.pack('<H0BH', [1,1,1]),
[1, 0, 1, 1, 0]);
pack H10BH0ms ‣
assert.deepEqual(
btools.pack('<H10BH', [1, 1,1,1,1,1,1,1,1,1,1, 1]),
[1, 0, 1,1,1,1,1,1,1,1,1,1, 1, 0]);
pack <H11BH1ms ‣
assert.deepEqual(
btools.pack('<H11BH', [1, 1,1,1,1,1,1,1,1,1,1,1, 1]),
[1, 0, 1,1,1,1,1,1,1,1,1,1,1, 1, 0]);
pack <H101BH0ms ‣
assert.deepEqual(
btools.pack('<H101BH', [1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1]),
[1, 0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1, 0]);
pack <H2BH0ms ‣
assert.deepEqual(
btools.pack('<H2BH', [1, 1,1, 1]),
[1, 0, 1,1, 1, 0]);
pack <H0ms ‣
assert.deepEqual(
btools.pack('<H', 1),
[1, 0]);
pack >H0ms ‣
assert.deepEqual(
btools.pack('>H', 1),
[0, 1]);
pack H0ms ‣
assert.deepEqual(
btools.pack('H', 1),
[1, 0]);
pack <H2 (junk in the format string)0ms ‣
assert.deepEqual(
btools.pack('<H2', 1),
[1, 0]);
pack <H22 (junk in the format string)0ms ‣
assert.deepEqual(
btools.pack('<H22', 1),
[1, 0]);
pack <HH22 (junk in the format string)0ms ‣
assert.deepEqual(
btools.pack('<HH22', [1, 1]),
[1, 0, 1, 0]);
pack >H> (junk in the format string)0ms ‣
assert.deepEqual(
btools.pack('>H>', 1),
[0, 1]);
pack >HH> (junk in the format string)0ms ‣
assert.deepEqual(
btools.pack('>HH>', [1, 1]),
[0, 1, 0, 1]);
pack >HH>> (junk in the format string)0ms ‣
assert.deepEqual(
btools.pack('>HH>>', [1, 1]),
[0, 1, 0, 1]);
pack >HH>>2< (junk in the format string)0ms ‣
assert.deepEqual(
btools.pack('>HH>>2<', [1, 1]),
[0, 1, 0, 1]);
pack >H<H> (junk in the format string)1ms ‣
assert.deepEqual(
btools.pack('>H<H>', [1, 1]),
[0, 1, 0, 1]);
pack !H<H> (junk in the format string)0ms ‣
assert.deepEqual(
btools.pack('!H<H>', [1, 1]),
[0, 1, 0, 1]);
pack !H!H! (junk in the format string)1ms ‣
assert.deepEqual(
btools.pack('!H!H!', [1, 1]),
[0, 1, 0, 1]);
pack H4< (junk in the format string)1ms ‣
assert.deepEqual(
btools.pack('H4<', 1),
[1, 0]);
packTo uInt16 (65535, 16) with < representing little-endian0ms ‣
var buffer = new Array(2);
btools.packTo('<H', 1, buffer);
assert.deepEqual(
buffer,
[1, 0]);
packTo >H0ms ‣
var buffer = new Array(2);
btools.packTo('>H', 1, buffer);
assert.deepEqual(
buffer,
[0, 1]);
packTo !H0ms ‣
var buffer = new Array(2);
btools.packTo('!H', 1, buffer);
assert.deepEqual(
buffer,
[0, 1]);
packTo !H!0ms ‣
var buffer = new Array(2);
btools.packTo('!H!', 1, buffer);
assert.deepEqual(
buffer,
[0, 1]);
packTo >H, larger buffer0ms ‣
var buffer = ['x', 'x', 0, 0, 'x', 'x'];
btools.packTo('>H', 1, buffer, false, 2);
assert.deepEqual(
buffer,
['x', 'x', 0, 1, 'x', 'x']);
packTo !H, larger buffer0ms ‣
var buffer = ['x', 'x', 0, 0, 'x', 'x'];
btools.packTo('!H', 1, buffer, false, 2);
assert.deepEqual(
buffer,
['x', 'x', 0, 1, 'x', 'x']);
packTo H0ms ‣
var buffer = new Array(2);
btools.packTo('H', 1, buffer);
assert.deepEqual(
buffer,
[1, 0]);
packTo HH0ms ‣
var buffer = new Array(4);
btools.packTo('HH', [1, 1], buffer);
assert.deepEqual(
buffer,
[1, 0, 1, 0]);
packTo HHh0ms ‣
var buffer = new Array(6);
btools.packTo('HHh', [1, 1, 1], buffer);
assert.deepEqual(
buffer,
[1, 0, 1, 0, 1, 0]);
pack HH0ms ‣
var buffer = btools.pack('HH', [1, 1]);
assert.deepEqual(
buffer,
[1, 0, 1, 0]);
pack HHh0ms ‣
var buffer = btools.pack('HHh', [1, 1, 1]);
assert.deepEqual(
buffer,
[1, 0, 1, 0, 1, 0]);
pack HHhh0ms ‣
var buffer = btools.pack('HHhh', [1, 1, 1, 1]);
assert.deepEqual(
buffer,
[1, 0, 1, 0, 1, 0, 1, 0]);