chore(lib/utils/errors): make getCurrentStack a little more performant
This commit is contained in:
parent
2852211a91
commit
7953056b94
1 changed files with 8 additions and 1 deletions
|
|
@ -4,5 +4,12 @@ export function getErrorStack(e: unknown) {
|
|||
|
||||
export function getCurrentStack() {
|
||||
const { stack } = new Error()
|
||||
return stack!.split('\n').slice(2).join('\n')
|
||||
|
||||
let newlineCount = 0
|
||||
|
||||
for (let i = 0; i < stack!.length; i++)
|
||||
if (stack![i] === '\n' && newlineCount++ === 1)
|
||||
return stack!.slice(i + 1)
|
||||
|
||||
return stack!.slice(stack!.indexOf('\n') + 1)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue