From 9d4ab9011796902a086ca12b0a18088e2fb35cd4 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. PR-URL: https://github.com/nodejs/node/pull/19524 Refs: https://github.com/nodejs/node/issues/19079#issuecomment-375121443 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 2ea989e7fe5e11..fbd7ace6b63a3a 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -304,6 +304,10 @@ It can be constructed in a variety of ways.