From 332271dbbb6c0823f3382b891cafeed273940f91 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 22 Mar 2018 00:30:21 +0100 Subject: [PATCH] buffer: do deprecation warning outside `node_modules` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In addition to `--pending-deprecation`, emit a deprecation warning for usage of the `Buffer()` constructor for call sites that are outside of `node_modules`. The goal of this is to better target developers, rather than burdening users with an omnipresent and quickly ignored warning. This implements the result of a TSC meeting discussion from March 22, 2018. Refs: https://github.com/nodejs/node/issues/19079#issuecomment-375121443 PR-URL: https://github.com/nodejs/node/pull/19524 Reviewed-By: Rich Trott Reviewed-By: Rod Vagg Reviewed-By: Michaƫl Zasso Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Michael Dawson Reviewed-By: Gibson Fahnestock Reviewed-By: Colin Ihrig Reviewed-By: Evan Lucas Reviewed-By: Myles Borins --- doc/api/buffer.md | 20 +++++++ doc/api/deprecations.md | 6 +- lib/buffer.js | 31 +++++----- lib/internal/util.js | 56 +++++++++++++++++++ ...t-buffer-constructor-node-modules-paths.js | 35 ++++++++++++ ...buffer-constructor-outside-node-modules.js | 29 ++++++++++ 6 files changed, 163 insertions(+), 14 deletions(-) create mode 100644 test/parallel/test-buffer-constructor-node-modules-paths.js create mode 100644 test/parallel/test-buffer-constructor-outside-node-modules.js diff --git a/doc/api/buffer.md b/doc/api/buffer.md index eb3b93e0f0c3a8..402e3684713ea6 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -304,6 +304,10 @@ It can be constructed in a variety of ways.