Skip to content
Permalink
Browse files

util: use Set to store deprecation codes

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 6, 2019
1 parent e6ecc13 commit dfdf742fd1dfc82fbd2b21a5ea0174aa98c99caf
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/internal/util.js
@@ -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.
@@ -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);

0 comments on commit dfdf742

Please sign in to comment.
You can’t perform that action at this time.