Sha256: 63cc442b7033bf9ca0d82a0586a7e6631bd181c6ce134da49f65b28136cbb0c9

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

'use strict';
const common = require('../common');
const assert = require('assert');
const zlib = require('zlib');
const path = require('path');
const fs = require('fs');

const file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg'));
const chunkSize = 16;
const opts = { level: 0 };
const deflater = zlib.createDeflate(opts);

const chunk = file.slice(0, chunkSize);
const expectedNone = Buffer.from([0x78, 0x01]);
const blkhdr = Buffer.from([0x00, 0x10, 0x00, 0xef, 0xff]);
const adler32 = Buffer.from([0x00, 0x00, 0x00, 0xff, 0xff]);
const expectedFull = Buffer.concat([blkhdr, chunk, adler32]);
let actualNone;
let actualFull;

deflater.write(chunk, function() {
  deflater.flush(zlib.constants.Z_NO_FLUSH, function() {
    actualNone = deflater.read();
    deflater.flush(function() {
      var bufs = [], buf;
      while (buf = deflater.read())
        bufs.push(buf);
      actualFull = Buffer.concat(bufs);
    });
  });
});

process.once('exit', function() {
  assert.deepStrictEqual(actualNone, expectedNone);
  assert.deepStrictEqual(actualFull, expectedFull);
});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
node-compiler-0.9.1 vendor/node/test/parallel/test-zlib-flush.js
node-compiler-0.9.0 vendor/node-v7.2.1/test/parallel/test-zlib-flush.js
node-compiler-0.8.0 vendor/node-v7.2.0/test/parallel/test-zlib-flush.js
node-compiler-0.7.0 vendor/node-v7.1.0/test/parallel/test-zlib-flush.js