Uname: Linux webm016.cluster127.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 7.4.33 [ PHP INFO ] PHP os: Linux
Server Ip: 54.36.31.145
Your Ip: 216.73.216.182
User: homesquasz (91404) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : Enum.js
const {Enum, uint8, DecodeStream, EncodeStream} = require('../');
const should = require('chai').should();
const concat = require('concat-stream');

describe('Enum', function() {
  const e = new Enum(uint8, ['foo', 'bar', 'baz']);
  it('should have the right size', () => e.size().should.equal(1));

  it('should decode', function() {
    const stream = new DecodeStream(Buffer.from([1, 2, 0]));
    e.decode(stream).should.equal('bar');
    e.decode(stream).should.equal('baz');
    return e.decode(stream).should.equal('foo');
  });

  it('should encode', function(done) {
    const stream = new EncodeStream;
    stream.pipe(concat(function(buf) {
      buf.should.deep.equal(Buffer.from([1, 2, 0]));
      return done();
    })
    );

    e.encode(stream, 'bar');
    e.encode(stream, 'baz');
    e.encode(stream, 'foo');
    return stream.end();
  });

  return it('should throw on unknown option', function() {
    const stream = new EncodeStream;
    return should.throw(() => e.encode(stream, 'unknown'));
  });
});
© 2026 GrazzMean