diff options
author | Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> | 2022-01-30 01:31:55 +0330 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-29 22:01:55 +0000 |
commit | 85eca3d2c75fc89034216e86c88f1f5fe2398172 (patch) | |
tree | f02fafb2f2faec474f4e39d024bd65d1e911062e | |
parent | 05e9cb6f22930bf7332fc0dee6766b6578682c02 (diff) | |
download | node-new-85eca3d2c75fc89034216e86c88f1f5fe2398172.tar.gz |
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>
-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 9502cfef6f..9492de2283 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 '^'. |