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 nullish coalescing operator (`??`) for better
readability.
• Remove unnecessary wrapping.
  • Loading branch information
VoltrexKeyva committed Jan 25, 2022
1 parent 6fc6ba7 commit 3b1c9e9
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 3b1c9e9

Please sign in to comment.