Skip to content

Commit ec01867

Browse files
rickyescodebytere
authored andcommitted
lib: replace charCodeAt with fixed Unicode
PR-URL: #32758 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com>
1 parent f151bde commit ec01867

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

‎lib/internal/console/constructor.js‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,19 @@ const {
4242
const{
4343
isTypedArray, isSet, isMap, isSetIterator, isMapIterator,
4444
}=require('internal/util/types');
45+
const{
46+
CHAR_LOWERCASE_B,
47+
CHAR_LOWERCASE_E,
48+
CHAR_LOWERCASE_N,
49+
CHAR_UPPERCASE_C,
50+
}=require('internal/constants');
4551
constkCounts=Symbol('counts');
4652

4753
constkTraceConsoleCategory='node,node.console';
48-
constkTraceCount='C'.charCodeAt(0);
49-
constkTraceBegin='b'.charCodeAt(0);
50-
constkTraceEnd='e'.charCodeAt(0);
51-
constkTraceInstant='n'.charCodeAt(0);
54+
constkTraceCount=CHAR_UPPERCASE_C;
55+
constkTraceBegin=CHAR_LOWERCASE_B;
56+
constkTraceEnd=CHAR_LOWERCASE_E;
57+
constkTraceInstant=CHAR_LOWERCASE_N;
5258

5359
constkSecond=1000;
5460
constkMinute=60*kSecond;

‎lib/internal/constants.js‎

Lines changed: 4 additions & 0 deletions
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‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ const {
1010
const{ trace }=internalBinding('trace_events');
1111
constasync_wrap=internalBinding('async_wrap');
1212
constasync_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-
constkBeforeEvent='b'.charCodeAt(0);
18-
constkEndEvent='e'.charCodeAt(0);
21+
constkBeforeEvent=CHAR_LOWERCASE_B;
22+
constkEndEvent=CHAR_LOWERCASE_E;
1923
constkTraceEventCategory='node,node.async_hooks';
2024

2125
constkEnabled=Symbol('enabled');

0 commit comments

Comments
 (0)