Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
lib: replace charCodeAt with fixed Unicode
  • Loading branch information
rickyes committed Apr 10, 2020
commit dd9e5108e45ea7ce3ce80ebdb7acd7c6d274cefd
18 changes: 10 additions & 8 deletions lib/internal/console/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ const {
const {
isTypedArray, isSet, isMap, isSetIterator, isMapIterator,
} = require('internal/util/types');
const {
CHAR_LOWERCASE_B,
CHAR_LOWERCASE_E,
CHAR_LOWERCASE_N,
CHAR_UPPERCASE_C,
} = require('internal/constants');
const kCounts = Symbol('counts');

const kTraceConsoleCategory = 'node,node.console';
// `C` Unicode
const kTraceCount = 67;
// `b` Unicode
const kTraceBegin = 98;
// `e` Unicode
const kTraceEnd = 101;
// `n` Unicode
const kTraceInstant = 110;
const kTraceCount = CHAR_UPPERCASE_C;
const kTraceBegin = CHAR_LOWERCASE_B;
const kTraceEnd = CHAR_LOWERCASE_E;
const kTraceInstant = CHAR_LOWERCASE_N;

const kSecond = 1000;
const kMinute = 60 * kSecond;
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ module.exports = {
CHAR_LOWERCASE_A: 97, /* a */
CHAR_UPPERCASE_Z: 90, /* Z */
CHAR_LOWERCASE_Z: 122, /* z */
CHAR_UPPERCASE_C: 67, /* C */
CHAR_LOWERCASE_B: 98, /* b */
CHAR_LOWERCASE_E: 101, /* e */
CHAR_LOWERCASE_N: 110, /* n */

// Non-alphabetic chars.
CHAR_DOT: 46, /* . */
Expand Down
11 changes: 6 additions & 5 deletions lib/internal/trace_events_async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ const {
const { trace } = internalBinding('trace_events');
const async_wrap = internalBinding('async_wrap');
const async_hooks = require('async_hooks');
const {
CHAR_LOWERCASE_B,
CHAR_LOWERCASE_E,
} = require('internal/constants');

// Use small letters such that chrome://tracing groups by the name.
// The behavior is not only useful but the same as the events emitted using
// the specific C++ macros.

// `b` Unicode
const kBeforeEvent = 98;
// `e` Unicode
const kEndEvent = 101;
const kBeforeEvent = CHAR_LOWERCASE_B;
const kEndEvent = CHAR_LOWERCASE_E;
const kTraceEventCategory = 'node,node.async_hooks';

const kEnabled = Symbol('enabled');
Expand Down