util: use Set to store deprecation codes
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
7105bbc710
commit
0c1fd20693
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user