mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 11:29:26 +00:00

Several changes: * Soft-Deprecate Buffer() constructors * Add `Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()` * Add `--zero-fill-buffers` command line option * Add byteOffset and length to `new Buffer(arrayBuffer)` constructor * buffer.fill('') previously had no effect, now zero-fills * Update the docs PR-URL: https://github.com/nodejs/node/pull/4682 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
29 lines
525 B
JavaScript
29 lines
525 B
JavaScript
'use strict';
|
|
require('../common');
|
|
var assert = require('assert');
|
|
|
|
var zlib = require('zlib');
|
|
var gz = zlib.Gzip();
|
|
var emptyBuffer = Buffer.alloc(0);
|
|
var received = 0;
|
|
gz.on('data', function(c) {
|
|
received += c.length;
|
|
});
|
|
var ended = false;
|
|
gz.on('end', function() {
|
|
ended = true;
|
|
});
|
|
var finished = false;
|
|
gz.on('finish', function() {
|
|
finished = true;
|
|
});
|
|
gz.write(emptyBuffer);
|
|
gz.end();
|
|
|
|
process.on('exit', function() {
|
|
assert.equal(received, 20);
|
|
assert(ended);
|
|
assert(finished);
|
|
console.log('ok');
|
|
});
|