From 4d20097d49d378705046bc7554a95295f9163a9e Mon Sep 17 00:00:00 2001 From: VoltrexMaster Date: Wed, 26 Jan 2022 00:58:12 +0330 Subject: [PATCH] lib: refactor source map stack trace prepare MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Make use of the logical OR operator (`||`) for better readability. • Remove unnecessary conditional and wrapping. --- lib/internal/source_map/prepare_stack_trace.js | 6 +++--- 1 file 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 9502cfef6fe029..9492de2283322f 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 : ''}`; + `${t.getTypeName()}.` : ''}${fnName || ''}`; // 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 '^'.