Sha256: 2dea2ac9687a308703dbd37573c3fc882c9a6518d13b39e307bfef9766148e2a

Contents?: true

Size: 1.01 KB

Versions: 69

Compression:

Stored size: 1.01 KB

Contents

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');
});

Version data entries

69 entries across 69 versions & 2 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.18 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.17 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.16 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.15 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.14 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.13 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.12 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.10 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.9 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.6 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.5 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js
trusty-festivity-extension-2.5.4 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/eof.js