Skip to content

Commit cedd26a

Browse files
VoltrexKeyvaruyadorno
authored andcommitted
lib: refactor source map stack trace prepare
• Make use of the logical OR operator (`||`) for better readability. • Remove unnecessary conditional and wrapping. PR-URL: #41698 Reviewed-By: Mestery <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 5f1a59c commit cedd26a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/internal/source_map/prepare_stack_trace.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ const prepareStackTrace = (globalThis, error, trace) => {
8989
// Construct call site name based on: v8.dev/docs/stack-trace-api:
9090
const fnName = t.getFunctionName() ?? t.getMethodName();
9191
const originalName = `${t.getTypeName() !== 'global' ?
92-
`${t.getTypeName()}.` : ''}${fnName ? fnName : '<anonymous>'}`;
92+
`${t.getTypeName()}.` : ''}${fnName || '<anonymous>'}`;
9393
// The original call site may have a different symbol name
9494
// associated with it, use it:
9595
const prefix = (name && name !== originalName) ?
9696
`${name}` :
97-
`${originalName ? originalName : ''}`;
97+
`${originalName}`;
9898
const hasName = !!(name || originalName);
9999
const originalSourceNoScheme =
100100
StringPrototypeStartsWith(originalSource, 'file://') ?
@@ -160,7 +160,7 @@ function getErrorSource(
160160
let prefix = '';
161161
for (const character of new SafeStringIterator(
162162
StringPrototypeSlice(line, 0, originalColumn + 1))) {
163-
prefix += (character === '\t') ? '\t' :
163+
prefix += character === '\t' ? '\t' :
164164
StringPrototypeRepeat(' ', getStringWidth(character));
165165
}
166166
prefix = StringPrototypeSlice(prefix, 0, -1); // The last character is '^'.

0 commit comments

Comments
 (0)