1
0
mirror of https://github.com/S2-/gitlit synced 2025-08-03 21:00:04 +02:00
This commit is contained in:
s2
2018-05-18 17:26:33 +02:00
parent 0ea0853165
commit 2c5b23c10e
1125 changed files with 118732 additions and 1 deletions

46
app/node_modules/binary/test/bu.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
var binary = require('../');
var test = require('tap').test;
test('bu', function (t) {
t.plan(8);
// note: can't store -12667700813876161 exactly in an ieee float
var buf = new Buffer([
44, // a == 44
2, 43, // b == 555
164, 213, 37, 37, // c == 2765432101
29, 81, 180, 20, 155, 115, 203, 193, // d == 2112667700813876161
]);
binary.parse(buf)
.word8bu('a')
.word16bu('b')
.word32bu('c')
.word64bu('d')
.tap(function (vars) {
t.same(vars.a, 44);
t.same(vars.b, 555);
t.same(vars.c, 2765432101);
t.ok(
Math.abs(vars.d - 2112667700813876161) < 1500
);
})
;
// also check aliases here:
binary.parse(buf)
.word8be('a')
.word16be('b')
.word32be('c')
.word64be('d')
.tap(function (vars) {
t.same(vars.a, 44);
t.same(vars.b, 555);
t.same(vars.c, 2765432101);
t.ok(
Math.abs(vars.d - 2112667700813876161) < 1500
);
})
;
});

20
app/node_modules/binary/test/deferred.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('deferred', function (t) {
t.plan(1);
var em = new EventEmitter;
binary.stream(em)
.word8('a')
.word16be('bc')
.tap(function (vars) {
t.same(vars, { a : 97, bc : 25187 });
})
;
setTimeout(function () {
em.emit('data', new Buffer([ 97, 98, 99 ]));
}, 10);
});

23
app/node_modules/binary/test/dots.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
var binary = require('../');
var test = require('tap').test;
test('dots', function (t) {
t.plan(1);
binary.parse(new Buffer([ 97, 98, 99, 100, 101, 102 ]))
.word8('a')
.word16be('b.x')
.word16be('b.y')
.word8('b.z')
.tap(function (vars) {
t.same(vars, {
a : 97,
b : {
x : 256 * 98 + 99,
y : 256 * 100 + 101,
z : 102
},
});
})
;
});

41
app/node_modules/binary/test/eof.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('eof', function (t) {
t.plan(4);
var stream = new EventEmitter;
binary.stream(stream)
.buffer('sixone', 5)
.peek(function () {
this.word32le('len');
})
.buffer('buf', 'len')
.word8('x')
.tap(function (vars) {
t.same(
[].slice.call(vars.sixone),
[].slice.call(new Buffer([ 6, 1, 6, 1, 6 ]))
);
t.same(vars.buf.length, vars.len);
t.same(
[].slice.call(vars.buf),
[ 9, 0, 0, 0, 97, 98, 99, 100, 101 ]
);
t.same(vars.x, 102);
})
;
var bufs = [
new Buffer([ 6, 1, 6, 1, 6, 9, 0, 0, 0, 97 ]),
new Buffer([ 98, 99 ]),
new Buffer([ 100, 101, 102 ]),
];
bufs.forEach(function (buf) {
stream.emit('data', buf);
});
stream.emit('end');
});

17
app/node_modules/binary/test/flush.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
var binary = require('../');
var test = require('tap').test;
test('flush', function (t) {
t.plan(1);
binary.parse(new Buffer([ 97, 98, 99, 100, 101, 102 ]))
.word8('a')
.word16be('b')
.word16be('c')
.flush()
.word8('d')
.tap(function (vars) {
t.same(vars, { d : 102 });
})
;
});

14
app/node_modules/binary/test/from_buffer.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
var binary = require('../');
var test = require('tap').test;
test('from buffer', function (t) {
t.plan(1);
binary(new Buffer([ 97, 98, 99 ]))
.word8('a')
.word16be('bc')
.tap(function (vars) {
t.same(vars, { a : 97, bc : 25187 });
})
;
});

28
app/node_modules/binary/test/get_buffer.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
var binary = require('../');
var test = require('tap').test;
test('get buffer', function (t) {
t.plan(4);
var buf = new Buffer([ 4, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ]);
binary.parse(buf)
.word8('a')
.buffer('b', 7)
.word16lu('c')
.tap(function (vars) {
t.equal(vars.a, 4);
t.equal(
vars.b.toString(),
new Buffer([ 2, 3, 4, 5, 6, 7, 8 ]).toString()
);
t.equal(vars.c, 2569);
})
.buffer('d', 'a')
.tap(function (vars) {
t.equal(
vars.d.toString(),
new Buffer([ 11, 12, 13, 14 ]).toString()
);
})
;
});

18
app/node_modules/binary/test/immediate.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('immediate', function (t) {
t.plan(1);
var em = new EventEmitter;
binary.stream(em, 'moo')
.word8('a')
.word16be('bc')
.tap(function (vars) {
t.same(vars, { a : 97, bc : 25187 });
})
;
em.emit('moo', new Buffer([ 97, 98, 99 ]));
});

38
app/node_modules/binary/test/interval.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('interval', function (t) {
t.plan(1);
var em = new EventEmitter;
var i = 0;
var iv = setInterval(function () {
var buf = new Buffer(1000);
buf[0] = 0xff;
if (++i >= 1000) {
clearInterval(iv);
buf[0] = 0;
}
em.emit('data', buf);
}, 1);
var loops = 0;
binary(em)
.loop(function (end) {
this
.word8('x')
.word8('y')
.word32be('z')
.word32le('w')
.buffer('buf', 1000 - 10)
.tap(function (vars) {
loops ++;
if (vars.x == 0) end();
})
})
.tap(function () {
t.same(loops, 1000);
})
;
});

35
app/node_modules/binary/test/into_buffer.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
var binary = require('../');
var test = require('tap').test;
test('intoBuffer', function (t) {
t.plan(3);
var buf = new Buffer([ 1, 2, 3, 4, 5, 6 ])
binary.parse(buf)
.into('moo', function () {
this
.word8('x')
.word8('y')
.word8('z')
;
})
.tap(function (vars) {
t.same(vars, { moo : { x : 1, y : 2, z : 3 } });
})
.word8('w')
.tap(function (vars) {
t.same(vars, {
moo : { x : 1, y : 2, z : 3 },
w : 4,
});
})
.word8('x')
.tap(function (vars) {
t.same(vars, {
moo : { x : 1, y : 2, z : 3 },
w : 4,
x : 5,
});
})
;
});

43
app/node_modules/binary/test/into_stream.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('into stream', function (t) {
t.plan(3);
var digits = [ 1, 2, 3, 4, 5, 6 ];
var stream = new EventEmitter;
var iv = setInterval(function () {
var d = digits.shift();
if (d) stream.emit('data', new Buffer([ d ]))
else clearInterval(iv)
}, 20);
binary.stream(stream)
.into('moo', function () {
this
.word8('x')
.word8('y')
.word8('z')
;
})
.tap(function (vars) {
t.same(vars, { moo : { x : 1, y : 2, z : 3 } });
})
.word8('w')
.tap(function (vars) {
t.same(vars, {
moo : { x : 1, y : 2, z : 3 },
w : 4,
});
})
.word8('x')
.tap(function (vars) {
t.same(vars, {
moo : { x : 1, y : 2, z : 3 },
w : 4,
x : 5,
});
})
;
});

44
app/node_modules/binary/test/loop.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('loop', function (t) {
t.plan(3 * 2 + 1);
var em = new EventEmitter;
binary.stream(em)
.loop(function (end, vars) {
t.strictEqual(vars, this.vars);
this
.word16lu('a')
.word8u('b')
.word8s('c')
.tap(function (vars_) {
t.strictEqual(vars, vars_);
if (vars.c < 0) end();
})
;
})
.tap(function (vars) {
t.same(vars, { a : 1337, b : 55, c : -5 });
})
;
setTimeout(function () {
em.emit('data', new Buffer([ 2, 10, 88 ]));
}, 10);
setTimeout(function () {
em.emit('data', new Buffer([ 100, 3, 6, 242, 30 ]));
}, 20);
setTimeout(function () {
em.emit('data', new Buffer([ 60, 60, 199, 44 ]));
}, 30);
setTimeout(function () {
em.emit('data', new Buffer([ 57, 5 ]));
}, 80);
setTimeout(function () {
em.emit('data', new Buffer([ 55, 251 ]));
}, 90);
});

54
app/node_modules/binary/test/loop_scan.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('loop scan', function (t) {
t.plan(8 + 6 + 2);
var em = new EventEmitter;
binary.stream(em)
.loop(function (end) {
var vars_ = this.vars;
this
.scan('filler', 'BEGINMSG')
.buffer('cmd', 3)
.word8('num')
.tap(function (vars) {
t.strictEqual(vars, vars_);
if (vars.num != 0x02 && vars.num != 0x06) {
t.same(vars.filler.length, 0);
}
if (vars.cmd.toString() == 'end') end();
})
;
})
.tap(function (vars) {
t.same(vars.cmd.toString(), 'end');
t.same(vars.num, 0x08);
})
;
setTimeout(function () {
em.emit('data', new Buffer(
'BEGINMSGcmd\x01'
+ 'GARBAGEDATAXXXX'
+ 'BEGINMSGcmd\x02'
+ 'BEGINMSGcmd\x03'
));
}, 10);
setTimeout(function () {
em.emit('data', new Buffer(
'BEGINMSGcmd\x04'
+ 'BEGINMSGcmd\x05'
+ 'GARBAGEDATAXXXX'
+ 'BEGINMSGcmd\x06'
));
em.emit('data', new Buffer('BEGINMSGcmd\x07'));
}, 20);
setTimeout(function () {
em.emit('data', new Buffer('BEGINMSGend\x08'));
}, 30);
});

46
app/node_modules/binary/test/lu.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
var binary = require('../');
var test = require('tap').test;
test('lu', function (t) {
t.plan(8);
// note: can't store -12667700813876161 exactly in an ieee float
var buf = new Buffer([
44, // a == 44
43, 2, // b == 555
37, 37, 213, 164, // c == 2765432101
193, 203, 115, 155, 20, 180, 81, 29, // d == 2112667700813876161
]);
binary.parse(buf)
.word8lu('a')
.word16lu('b')
.word32lu('c')
.word64lu('d')
.tap(function (vars) {
t.same(vars.a, 44);
t.same(vars.b, 555);
t.same(vars.c, 2765432101);
t.ok(
Math.abs(vars.d - 2112667700813876161) < 1500
);
})
;
// also check aliases here:
binary.parse(buf)
.word8le('a')
.word16le('b')
.word32le('c')
.word64le('d')
.tap(function (vars) {
t.same(vars.a, 44);
t.same(vars.b, 555);
t.same(vars.c, 2765432101);
t.ok(
Math.abs(vars.d - 2112667700813876161) < 1500
);
})
;
});

29
app/node_modules/binary/test/negbs.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
var binary = require('../');
var test = require('tap').test;
test('negbs', function (t) {
t.plan(4);
// note: can't store -12667700813876161 exactly in an ieee float
var buf = new Buffer([
226, // a == -30
246, 219, // b == -2341
255, 243, 245, 236, // c == -789012
255, 210, 254, 203, 16, 222, 52, 63, // d == -12667700813876161
]);
binary.parse(buf)
.word8bs('a')
.word16bs('b')
.word32bs('c')
.word64bs('d')
.tap(function (vars) {
t.same(vars.a, -30);
t.same(vars.b, -2341);
t.same(vars.c, -789012);
t.ok(
Math.abs(vars.d - -12667700813876161) < 1500
);
})
;
});

29
app/node_modules/binary/test/negls.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
var binary = require('../');
var test = require('tap').test;
test('negls', function (t) {
t.plan(4);
// note: can't store -12667700813876161 exactly in an ieee float
var buf = new Buffer([
226, // a == -30
219, 246, // b == -2341
236, 245, 243, 255, // c == -789012
63, 52, 222, 16, 203, 254, 210, 255, // d == -12667700813876161
]);
binary.parse(buf)
.word8ls('a')
.word16ls('b')
.word32ls('c')
.word64ls('d')
.tap(function (vars) {
t.same(vars.a, -30);
t.same(vars.b, -2341);
t.same(vars.c, -789012);
t.ok(
Math.abs(vars.d - -12667700813876161) < 1000
);
})
;
});

35
app/node_modules/binary/test/nested.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('nested', function (t) {
t.plan(3);
var insideDone = false;
var em = new EventEmitter;
binary.stream(em)
.word16be('ab')
.tap(function () {
this
.word8('c')
.word8('d')
.tap(function () {
insideDone = true;
})
;
})
.tap(function (vars) {
t.ok(insideDone);
t.same(vars.c, 'c'.charCodeAt(0));
t.same(vars.d, 'd'.charCodeAt(0));
})
;
var strs = [ 'abc', 'def', 'hi', 'jkl' ];
var iv = setInterval(function () {
var s = strs.shift();
if (s) em.emit('data', new Buffer(s));
else clearInterval(iv);
}, 50);
});

17
app/node_modules/binary/test/not_enough_buf.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
var binary = require('../');
var test = require('tap').test;
test('not enough buf', function (t) {
t.plan(3);
var vars = binary(new Buffer([1,2,3,4]))
.word8('a')
.buffer('b', 10)
.word8('c')
.vars
;
t.same(vars.a, 1);
t.equal(vars.b.toString(), new Buffer([2,3,4]).toString());
t.strictEqual(vars.c, null);
});

19
app/node_modules/binary/test/not_enough_parse.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
var binary = require('../');
var test = require('tap').test;
test('not enough parse', function (t) {
t.plan(4);
var vars = binary(new Buffer([1,2]))
.word8('a')
.word8('b')
.word8('c')
.word8('d')
.vars
;
t.same(vars.a, 1);
t.same(vars.b, 2);
t.strictEqual(vars.c, null);
t.strictEqual(vars.d, null);
});

54
app/node_modules/binary/test/parse.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
var binary = require('../');
var test = require('tap').test;
test('parse', function (t) {
t.plan(6);
var res = binary.parse(new Buffer([ 97, 98, 99, 99, 99, 99, 1, 2, 3 ]))
.word8('a')
.word16be('bc')
.skip(3)
.buffer('def', 3)
.tap(function (vars) {
t.equal(vars.a, 97);
t.equal(vars.bc, 25187);
t.same(
[].slice.call(vars.def),
[].slice.call(new Buffer([ 1, 2, 3]))
);
})
.vars
;
t.equal(res.a, 97);
t.equal(res.bc, 25187);
t.same(
[].slice.call(res.def),
[].slice.call(new Buffer([ 1, 2, 3 ]))
);
});
test('loop', function (t) {
t.plan(2);
var res = binary.parse(new Buffer([ 97, 98, 99, 4, 5, 2, -3, 9 ]))
.word8('a')
.word16be('bc')
.loop(function (end) {
var x = this.word8s('x').vars.x;
if (x < 0) end();
})
.tap(function (vars) {
t.same(vars, {
a : 97,
bc : 25187,
x : -3,
});
})
.word8('y')
.vars
;
t.same(res, {
a : 97,
bc : 25187,
x : -3,
y : 9,
});
});

40
app/node_modules/binary/test/peek.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('peek', function (t) {
t.plan(4);
var bufs = [
new Buffer([ 6, 1, 6, 1, 6, 9, 0, 0, 0, 97 ]),
new Buffer([ 98, 99 ]),
new Buffer([ 100, 101, 102 ]),
];
var stream = new EventEmitter;
var iv = setInterval(function () {
var buf = bufs.shift();
if (buf) stream.emit('data', buf)
else clearInterval(iv)
}, 20);
binary.stream(stream)
.buffer('sixone', 5)
.peek(function () {
this.word32le('len');
})
.buffer('buf', 'len')
.word8('x')
.tap(function (vars) {
t.same(
[].slice.call(vars.sixone),
[].slice.call(new Buffer([ 6, 1, 6, 1, 6 ]))
);
t.same(vars.buf.length, vars.len);
t.same(
[].slice.call(vars.buf),
[ 9, 0, 0, 0, 97, 98, 99, 100, 101 ]
);
t.same(vars.x, 102);
})
;
});

49
app/node_modules/binary/test/pipe.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
var binary = require('../');
var test = require('tap').test;
var Stream = require('stream').Stream;
test('loop', function (t) {
t.plan(3 * 2 + 1);
var rs = new Stream;
rs.readable = true;
var ws = binary()
.loop(function (end, vars) {
t.strictEqual(vars, this.vars);
this
.word16lu('a')
.word8u('b')
.word8s('c')
.tap(function (vars_) {
t.strictEqual(vars, vars_);
if (vars.c < 0) end();
})
;
})
.tap(function (vars) {
t.same(vars, { a : 1337, b : 55, c : -5 });
})
;
rs.pipe(ws);
setTimeout(function () {
rs.emit('data', new Buffer([ 2, 10, 88 ]));
}, 10);
setTimeout(function () {
rs.emit('data', new Buffer([ 100, 3, 6, 242, 30 ]));
}, 20);
setTimeout(function () {
rs.emit('data', new Buffer([ 60, 60, 199, 44 ]));
}, 30);
setTimeout(function () {
rs.emit('data', new Buffer([ 57, 5 ]));
}, 80);
setTimeout(function () {
rs.emit('data', new Buffer([ 55, 251 ]));
}, 90);
setTimeout(function () {
rs.emit('end');
}, 100);
});

29
app/node_modules/binary/test/posbs.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
var binary = require('../');
var test = require('tap').test;
test('posbs', function (t) {
t.plan(4);
// note: can't store 12667700813876161 exactly in an ieee float
var buf = new Buffer([
30, // a == -30
9, 37, // b == -2341
0, 12, 10, 20, // c == -789012
0, 45, 1, 52, 239, 33, 203, 193, // d == 12667700813876161
]);
binary.parse(buf)
.word8bs('a')
.word16bs('b')
.word32bs('c')
.word64bs('d')
.tap(function (vars) {
t.same(vars.a, 30);
t.same(vars.b, 2341);
t.same(vars.c, 789012);
t.ok(
Math.abs(vars.d - 12667700813876161) < 1000
);
})
;
});

29
app/node_modules/binary/test/posls.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
var binary = require('../');
var test = require('tap').test;
test('posls', function (t) {
t.plan(4);
// note: can't store 12667700813876161 exactly in an ieee float
var buf = new Buffer([
30, // a == -30
37, 9, // b == -2341
20, 10, 12, 0, // c == -789012
193, 203, 33, 239, 52, 1, 45, 0, // d == 12667700813876161
]);
binary.parse(buf)
.word8ls('a')
.word16ls('b')
.word32ls('c')
.word64ls('d')
.tap(function (vars) {
t.same(vars.a, 30);
t.same(vars.b, 2341);
t.same(vars.c, 789012);
t.ok(
Math.abs(vars.d - 12667700813876161) < 1000
);
})
;
});

33
app/node_modules/binary/test/scan.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('scan', function (t) {
t.plan(4);
var em = new EventEmitter;
binary(em)
.word8('a')
.scan('l1', new Buffer('\r\n'))
.scan('l2', '\r\n')
.word8('z')
.tap(function (vars) {
t.same(vars.a, 99);
t.same(vars.l1.toString(), 'foo bar');
t.same(vars.l2.toString(), 'baz');
t.same(vars.z, 42);
})
;
setTimeout(function () {
em.emit('data', new Buffer([99,0x66,0x6f,0x6f,0x20]));
}, 20);
setTimeout(function () {
em.emit('data', new Buffer('bar\r'));
}, 40);
setTimeout(function () {
em.emit('data', new Buffer('\nbaz\r\n*'));
}, 60);
});

18
app/node_modules/binary/test/scan_buf.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
var binary = require('../');
var test = require('tap').test;
test('scan buf', function (t) {
t.plan(4);
var vars = binary(new Buffer('\x63foo bar\r\nbaz\r\n*'))
.word8('a')
.scan('l1', new Buffer('\r\n'))
.scan('l2', '\r\n')
.word8('z')
.vars
;
t.same(vars.a, 99);
t.same(vars.z, 42);
t.same(vars.l1.toString(), 'foo bar');
t.same(vars.l2.toString(), 'baz');
});

16
app/node_modules/binary/test/scan_buf_null.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
var binary = require('../');
var test = require('tap').test;
test('scan buf null', function (t) {
t.plan(3);
var vars = binary(new Buffer('\x63foo bar baz'))
.word8('a')
.scan('b', '\r\n')
.word8('c')
.vars
;
t.same(vars.a, 99);
t.same(vars.b.toString(), 'foo bar baz');
t.strictEqual(vars.c, null);
});

58
app/node_modules/binary/test/skip.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
var seq = require('seq');
test('skip', function (t) {
t.plan(7);
var em = new EventEmitter;
var state = 0;
binary(em)
.word16lu('a')
.tap(function () { state = 1 })
.skip(7)
.tap(function () { state = 2 })
.word8('b')
.tap(function () { state = 3 })
.tap(function (vars) {
t.same(state, 3);
t.same(vars, {
a : 2569,
b : 8,
});
})
;
seq()
.seq(setTimeout, seq, 20)
.seq(function () {
t.same(state, 0);
em.emit('data', new Buffer([ 9 ]));
this(null);
})
.seq(setTimeout, seq, 5)
.seq(function () {
t.same(state, 0);
em.emit('data', new Buffer([ 10, 1, 2 ]));
this(null);
})
.seq(setTimeout, seq, 30)
.seq(function () {
t.same(state, 1);
em.emit('data', new Buffer([ 3, 4, 5 ]));
this(null);
})
.seq(setTimeout, seq, 15)
.seq(function () {
t.same(state, 1);
em.emit('data', new Buffer([ 6, 7 ]));
this(null);
})
.seq(function () {
t.same(state, 2);
em.emit('data', new Buffer([ 8 ]));
this(null);
})
;
});

34
app/node_modules/binary/test/split.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('split', function (t) {
t.plan(1);
var em = new EventEmitter;
binary.stream(em)
.word8('a')
.word16be('bc')
.word32ls('x')
.word32bs('y')
.tap(function (vars) {
t.same(vars, {
a : 97,
bc : 25187,
x : 621609828,
y : 621609828,
});
})
;
em.emit('data', new Buffer([ 97, 98 ]));
setTimeout(function () {
em.emit('data', new Buffer([ 99, 100 ]));
}, 25);
setTimeout(function () {
em.emit('data', new Buffer([ 3, 13, 37, 37 ]));
}, 30);
setTimeout(function () {
em.emit('data', new Buffer([ 13, 3, 100 ]));
}, 40);
});