Skip to content

Commit

Permalink
util: use Set to store deprecation codes
Browse files Browse the repository at this point in the history
PR-URL: #28113
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
dnalborczyk authored and BridgeAR committed Jun 17, 2019
1 parent e6ecc13 commit dfdf742
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/internal/util.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function isError(e) {


// Keep a list of deprecation codes that have been warned on so we only warn on // Keep a list of deprecation codes that have been warned on so we only warn on
// each one once. // each one once.
const codesWarned = {}; const codesWarned = new Set();


// Mark that a method should not be used. // Mark that a method should not be used.
// Returns a modified function which warns once by default. // Returns a modified function which warns once by default.
Expand All @@ -53,9 +53,9 @@ function deprecate(fn, msg, code) {
if (!warned) { if (!warned) {
warned = true; warned = true;
if (code !== undefined) { if (code !== undefined) {
if (!codesWarned[code]) { if (!codesWarned.has(code)) {
process.emitWarning(msg, 'DeprecationWarning', code, deprecated); process.emitWarning(msg, 'DeprecationWarning', code, deprecated);
codesWarned[code] = true; codesWarned.add(code);
} }
} else { } else {
process.emitWarning(msg, 'DeprecationWarning', deprecated); process.emitWarning(msg, 'DeprecationWarning', deprecated);
Expand Down

0 comments on commit dfdf742

Please sign in to comment.