Skip to content

Commit 0197ea4

Browse files
rickyescodebytere
authored andcommitted
lib: replace charCodeAt with fixed Unicode
PR-URL: #32758 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Zeyu Yang <[email protected]>
1 parent 335f405 commit 0197ea4

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

lib/internal/console/constructor.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,19 @@ const {
4040
const {
4141
isTypedArray, isSet, isMap, isSetIterator, isMapIterator,
4242
} = require('internal/util/types');
43+
const {
44+
CHAR_LOWERCASE_B,
45+
CHAR_LOWERCASE_E,
46+
CHAR_LOWERCASE_N,
47+
CHAR_UPPERCASE_C,
48+
} = require('internal/constants');
4349
const kCounts = Symbol('counts');
4450

4551
const kTraceConsoleCategory = 'node,node.console';
46-
const kTraceCount = 'C'.charCodeAt(0);
47-
const kTraceBegin = 'b'.charCodeAt(0);
48-
const kTraceEnd = 'e'.charCodeAt(0);
49-
const kTraceInstant = 'n'.charCodeAt(0);
52+
const kTraceCount = CHAR_UPPERCASE_C;
53+
const kTraceBegin = CHAR_LOWERCASE_B;
54+
const kTraceEnd = CHAR_LOWERCASE_E;
55+
const kTraceInstant = CHAR_LOWERCASE_N;
5056

5157
const kMaxGroupIndentation = 1000;
5258

lib/internal/constants.js

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ module.exports = {
88
CHAR_LOWERCASE_A: 97, /* a */
99
CHAR_UPPERCASE_Z: 90, /* Z */
1010
CHAR_LOWERCASE_Z: 122, /* z */
11+
CHAR_UPPERCASE_C: 67, /* C */
12+
CHAR_LOWERCASE_B: 98, /* b */
13+
CHAR_LOWERCASE_E: 101, /* e */
14+
CHAR_LOWERCASE_N: 110, /* n */
1115

1216
// Non-alphabetic chars.
1317
CHAR_DOT: 46, /* . */

lib/internal/trace_events_async_hooks.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ const {
1010
const { trace } = internalBinding('trace_events');
1111
const async_wrap = internalBinding('async_wrap');
1212
const async_hooks = require('async_hooks');
13+
const {
14+
CHAR_LOWERCASE_B,
15+
CHAR_LOWERCASE_E,
16+
} = require('internal/constants');
1317

1418
// Use small letters such that chrome://tracing groups by the name.
1519
// The behavior is not only useful but the same as the events emitted using
1620
// the specific C++ macros.
17-
const kBeforeEvent = 'b'.charCodeAt(0);
18-
const kEndEvent = 'e'.charCodeAt(0);
21+
const kBeforeEvent = CHAR_LOWERCASE_B;
22+
const kEndEvent = CHAR_LOWERCASE_E;
1923
const kTraceEventCategory = 'node,node.async_hooks';
2024

2125
const kEnabled = Symbol('enabled');

0 commit comments

Comments
 (0)