diff options
author | James M Snell <jasnell@gmail.com> | 2016-01-25 15:00:06 -0800 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-03-16 08:34:02 -0700 |
commit | 85ab4a5f1281c4e1dd06450ac7bd3250326267fa (patch) | |
tree | 7a51edfc5d6efc231cf821d575c9ca4a26d0545f /test/parallel/test-buffer-concat.js | |
parent | 90a5fc20be22b4278a01bc58acba0cb732da0140 (diff) | |
download | node-new-85ab4a5f1281c4e1dd06450ac7bd3250326267fa.tar.gz |
buffer: add .from(), .alloc() and .allocUnsafe()
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>
Diffstat (limited to 'test/parallel/test-buffer-concat.js')
-rw-r--r-- | test/parallel/test-buffer-concat.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/parallel/test-buffer-concat.js b/test/parallel/test-buffer-concat.js index 7aec811720..bc628e656b 100644 --- a/test/parallel/test-buffer-concat.js +++ b/test/parallel/test-buffer-concat.js @@ -3,9 +3,9 @@ require('../common'); var assert = require('assert'); var zero = []; -var one = [ new Buffer('asdf') ]; +var one = [ Buffer.from('asdf') ]; var long = []; -for (var i = 0; i < 10; i++) long.push(new Buffer('asdf')); +for (var i = 0; i < 10; i++) long.push(Buffer.from('asdf')); var flatZero = Buffer.concat(zero); var flatOne = Buffer.concat(one); @@ -22,10 +22,10 @@ assert(flatLongLen.toString() === (new Array(10 + 1).join('asdf'))); assertWrongList(); assertWrongList(null); -assertWrongList(new Buffer('hello')); +assertWrongList(Buffer.from('hello')); assertWrongList([42]); assertWrongList(['hello', 'world']); -assertWrongList(['hello', new Buffer('world')]); +assertWrongList(['hello', Buffer.from('world')]); function assertWrongList(value) { assert.throws(function() { |