-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buffer: add pending deprecation warning
The pending deprecation warning is off by default. Launch the node process with --pending-deprecation or NODE_PENDING_DEPRECATION=1 env var set. PR-URL: #11968 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Flags: --no-warnings --pending-deprecation | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const Buffer = require('buffer').Buffer; | ||
|
||
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. | ||
|
||
Buffer.from('abc').map((i) => i); | ||
Buffer.from('abc').filter((i) => i); | ||
Buffer.from('abc').slice(1, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Flags: --pending-deprecation --no-warnings | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const Buffer = require('buffer').Buffer; | ||
|
||
const bufferWarning = 'The Buffer() and new Buffer() constructors are not ' + | ||
'recommended for use due to security and usability ' + | ||
'concerns. Please use the new Buffer.alloc(), ' + | ||
'Buffer.allocUnsafe(), or Buffer.from() construction ' + | ||
'methods instead.'; | ||
|
||
common.expectWarning('DeprecationWarning', bufferWarning); | ||
|
||
new Buffer(10); |