diff options
author | Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> | 2022-01-30 01:01:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-30 01:01:55 +0300 |
commit | 85eca3d2c75fc89034216e86c88f1f5fe2398172 (patch) | |
tree | f02fafb2f2faec474f4e39d024bd65d1e911062e /lib | |
parent | 05e9cb6f22930bf7332fc0dee6766b6578682c02 (diff) |
lib: refactor source map stack trace prepare
• Make use of the logical OR operator (`||`) for better
readability.
• Remove unnecessary conditional and wrapping.
PR-URL: https://github.com/nodejs/node/pull/41698
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/source_map/prepare_stack_trace.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/internal/source_map/prepare_stack_trace.js b/lib/internal/source_map/prepare_stack_trace.js index 9502cfef6fe..9492de22833 100644 --- a/lib/internal/source_map/prepare_stack_trace.js +++ b/lib/internal/source_map/prepare_stack_trace.js @@ -89,12 +89,12 @@ const prepareStackTrace = (globalThis, error, trace) => { // Construct call site name based on: v8.dev/docs/stack-trace-api: const fnName = t.getFunctionName() ?? t.getMethodName(); const originalName = `${t.getTypeName() !== 'global' ? - `${t.getTypeName()}.` : ''}${fnName ? fnName : '<anonymous>'}`; + `${t.getTypeName()}.` : ''}${fnName || '<anonymous>'}`; // The original call site may have a different symbol name // associated with it, use it: const prefix = (name && name !== originalName) ? `${name}` : - `${originalName ? originalName : ''}`; + `${originalName}`; const hasName = !!(name || originalName); const originalSourceNoScheme = StringPrototypeStartsWith(originalSource, 'file://') ? @@ -160,7 +160,7 @@ function getErrorSource( let prefix = ''; for (const character of new SafeStringIterator( StringPrototypeSlice(line, 0, originalColumn + 1))) { - prefix += (character === '\t') ? '\t' : + prefix += character === '\t' ? '\t' : StringPrototypeRepeat(' ', getStringWidth(character)); } prefix = StringPrototypeSlice(prefix, 0, -1); // The last character is '^'. |