HEX
Server: Apache
System: Linux webd004.cluster130.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User: frenchy (106757)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/f/r/e/frenchy/www/french-american.org/current/node_modules/binary/test/get_buffer.js
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()
            );
        })
    ;
});