Skip to content

Commit

Permalink
lib: refactor source map stack trace prepare
Browse files Browse the repository at this point in the history
• Make use of the logical OR  operator (`||`) for better
readability.
• Remove unnecessary conditional and wrapping.

PR-URL: #41698
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
VoltrexKeyva authored and danielleadams committed Mar 14, 2022
1 parent 951d299 commit c93a9af
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/internal/source_map/prepare_stack_trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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://') ?
Expand Down Expand Up @@ -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 '^'.
Expand Down

0 comments on commit c93a9af

Please sign in to comment.