From 85ab4a5f1281c4e1dd06450ac7bd3250326267fa Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 25 Jan 2016 15:00:06 -0800 Subject: buffer: add .from(), .alloc() and .allocUnsafe() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Сковорода Никита Андреевич Reviewed-By: Stephen Belanger --- lib/string_decoder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/string_decoder.js') diff --git a/lib/string_decoder.js b/lib/string_decoder.js index a0bfd535ad8..16803921573 100644 --- a/lib/string_decoder.js +++ b/lib/string_decoder.js @@ -44,7 +44,7 @@ const StringDecoder = exports.StringDecoder = function(encoding) { // Enough space to store all bytes of a single character. UTF-8 needs 4 // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). - this.charBuffer = new Buffer(6); + this.charBuffer = Buffer.allocUnsafe(6); // Number of bytes received for the current incomplete multi-byte character. this.charReceived = 0; // Number of bytes expected for the current incomplete multi-byte character. -- cgit v1.2.3