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 Trott committed Jun 9, 2019
1 parent 7105bbc commit 0c1fd20
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/internal/util.js
Original file line number 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
// each one once.
const codesWarned = {};
const codesWarned = new Set();

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

0 comments on commit 0c1fd20

Please sign in to comment.