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 <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • 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 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 dfdf742

Please sign in to comment.