From ee17fcd6f334813fedefe7a75677dda124d70436 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 7 Nov 2024 23:21:50 +0000 Subject: [PATCH] lib: prefer symbol to number in webidl `type` function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/55737 Reviewed-By: James M Snell Reviewed-By: LiviaMedeiros Reviewed-By: Filip Skokan Reviewed-By: Michaƫl Zasso Reviewed-By: Jason Zhang --- lib/internal/webidl.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/internal/webidl.js b/lib/internal/webidl.js index a96f3ff72e198c..dcec441169d116 100644 --- a/lib/internal/webidl.js +++ b/lib/internal/webidl.js @@ -15,6 +15,7 @@ const { ObjectAssign, SafeSet, String, + Symbol, SymbolIterator, TypeError, } = primordials; @@ -28,14 +29,14 @@ const { kEmptyObject } = require('internal/util'); const converters = { __proto__: null }; -const UNDEFINED = 1; -const BOOLEAN = 2; -const STRING = 3; -const SYMBOL = 4; -const NUMBER = 5; -const BIGINT = 6; -const NULL = 7; -const OBJECT = 8; +const UNDEFINED = Symbol('undefined'); +const BOOLEAN = Symbol('boolean'); +const STRING = Symbol('string'); +const SYMBOL = Symbol('symbol'); +const NUMBER = Symbol('number'); +const BIGINT = Symbol('bigint'); +const NULL = Symbol('null'); +const OBJECT = Symbol('object'); /** * @see https://webidl.spec.whatwg.org/#es-any