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>
28 lines
635 B
JavaScript
28 lines
635 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
const spawnSync = require('child_process').spawnSync;
|
|
|
|
const msgOut = 'this is stdout';
|
|
|
|
// This is actually not os.EOL?
|
|
const msgOutBuf = Buffer.from(msgOut + '\n');
|
|
|
|
const args = [
|
|
'-e',
|
|
`console.log("${msgOut}");`
|
|
];
|
|
|
|
const options = {
|
|
maxBuffer: 1
|
|
};
|
|
|
|
const ret = spawnSync(process.execPath, args, options);
|
|
|
|
assert.ok(ret.error, 'maxBuffer should error');
|
|
assert.strictEqual(ret.error.errno, 'ENOBUFS');
|
|
// We can have buffers larger than maxBuffer because underneath we alloc 64k
|
|
// that matches our read sizes
|
|
assert.deepEqual(ret.stdout, msgOutBuf);
|