From 4fffe32a4b3a93548c4d39b1c2531aa38403b5e6 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 9 Nov 2016 17:58:40 +0100 Subject: [PATCH] Revert "buffer: runtime deprecation of calling Buffer without new" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f2fe5583c434e9864a1171209908c3a24b9d54bb (https://github.com/nodejs/node/pull/8169) as the original justification for the runtime-deprecation does not appear to justify the disruption to Node’s existing ecosystem. Futhermore, the possibility of deprecating the Buffer constructor entirely in v8.0 might lead to people having to change their code twice. PR-URL: https://github.com/nodejs/node/pull/9529 Reviewed-By: Roman Reiss Reviewed-By: Myles Borins Reviewed-By: Sam Roberts Reviewed-By: Nikolai Vavilov Reviewed-By: Evan Lucas Reviewed-By: Michaël Zasso Reviewed-By: Rich Trott --- lib/buffer.js | 10 ---------- test/parallel/test-buffer-deprecated.js | 11 ----------- 2 files changed, 21 deletions(-) delete mode 100644 test/parallel/test-buffer-deprecated.js diff --git a/lib/buffer.js b/lib/buffer.js index b2325098bc..f4d16f41fc 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -72,17 +72,7 @@ function alignPool() { * much breakage at this time. It's not likely that the Buffer constructors * would ever actually be removed. **/ -var newBufferWarned = false; function Buffer(arg, encodingOrOffset, length) { - if (!new.target && !newBufferWarned) { - newBufferWarned = true; - process.emitWarning( - 'Using Buffer without `new` will soon stop working. ' + - 'Use `new Buffer()`, or preferably ' + - '`Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.', - 'DeprecationWarning' - ); - } // Common case. if (typeof arg === 'number') { if (typeof encodingOrOffset === 'string') { diff --git a/test/parallel/test-buffer-deprecated.js b/test/parallel/test-buffer-deprecated.js deleted file mode 100644 index ec49321de4..0000000000 --- a/test/parallel/test-buffer-deprecated.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; -const common = require('../common'); - -const expected = - 'Using Buffer without `new` will soon stop working. ' + - 'Use `new Buffer()`, or preferably ' + - '`Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.'; -common.expectWarning('DeprecationWarning', expected); - -Buffer(1); -Buffer(1);