diff --git a/lib/buffer.js b/lib/buffer.js index 4b800039fe6f80..22990aae808508 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -51,9 +51,6 @@ const { isArrayBufferView, isUint8Array } = require('internal/util/types'); -const { - pendingDeprecation -} = process.binding('config'); const errors = require('internal/errors'); const internalBuffer = require('internal/buffer'); @@ -131,33 +128,23 @@ const bufferWarning = 'The Buffer() and new Buffer() constructors are not ' + 'Buffer.allocUnsafe(), or Buffer.from() construction ' + 'methods instead.'; -function showFlaggedDeprecation() { +function showDeprecation() { if (bufferWarn) { - // This is a *pending* deprecation warning. It is not emitted by - // default unless the --pending-deprecation command-line flag is - // used or the NODE_PENDING_DEPRECATION=1 env var is set. process.emitWarning(bufferWarning, 'DeprecationWarning', 'DEP0005'); bufferWarn = false; } } -const doFlaggedDeprecation = - pendingDeprecation ? - showFlaggedDeprecation : - function() {}; - /** - * The Buffer() constructor is deprecated in documentation and should not be - * used moving forward. Rather, developers should use one of the three new - * factory APIs: Buffer.from(), Buffer.allocUnsafe() or Buffer.alloc() based on - * their specific needs. There is no runtime deprecation because of the extent - * to which the Buffer constructor is used in the ecosystem currently -- a - * runtime deprecation would introduce too much breakage at this time. It's not - * likely that the Buffer constructors would ever actually be removed. + * The Buffer() constructor is deprecated and should not be used moving forward. + * Rather, developers should use one of the three new factory APIs: + * Buffer.from(), Buffer.allocUnsafe() or Buffer.alloc() based on their specific + * needs. It's not likely that the Buffer constructors would ever actually be + * removed. * Deprecation Code: DEP0005 **/ function Buffer(arg, encodingOrOffset, length) { - doFlaggedDeprecation(); + showDeprecation(); // Common case. if (typeof arg === 'number') { if (typeof encodingOrOffset === 'string') { diff --git a/test/parallel/test-buffer-pending-deprecation.js b/test/parallel/test-buffer-deprecation.js similarity index 93% rename from test/parallel/test-buffer-pending-deprecation.js rename to test/parallel/test-buffer-deprecation.js index 060eae2a51622e..93eed4d51dc43a 100644 --- a/test/parallel/test-buffer-pending-deprecation.js +++ b/test/parallel/test-buffer-deprecation.js @@ -1,4 +1,4 @@ -// Flags: --pending-deprecation --no-warnings +// Flags: --no-warnings 'use strict'; const common = require('../common'); diff --git a/test/parallel/test-buffer-nopendingdep-map.js b/test/parallel/test-buffer-nodep-map.js similarity index 55% rename from test/parallel/test-buffer-nopendingdep-map.js rename to test/parallel/test-buffer-nodep-map.js index c85d184fbc1246..e72b7f205983b8 100644 --- a/test/parallel/test-buffer-nopendingdep-map.js +++ b/test/parallel/test-buffer-nodep-map.js @@ -1,12 +1,12 @@ -// Flags: --no-warnings --pending-deprecation +// Flags: --no-warnings 'use strict'; const common = require('../common'); process.on('warning', common.mustNotCall('A warning should not be emitted')); -// With the --pending-deprecation flag, the deprecation warning for -// new Buffer() should not be emitted when Uint8Array methods are called. +// The deprecation warning for new Buffer() should not be emitted when +// Uint8Array methods are called. Buffer.from('abc').map((i) => i); Buffer.from('abc').filter((i) => i);