mirror of https://github.com/nodejs/node.git
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>
This commit is contained in:
parent
05e9cb6f22
commit
85eca3d2c7
|
@ -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 '^'.
|
||||
|
|
Loading…
Reference in New Issue