Socket
Socket
Sign inDemoInstall

error-stack2

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error-stack2 - npm Package Compare versions

Comparing version 1.0.18 to 2.0.1

6

package.json
{
"name": "error-stack2",
"version": "1.0.18",
"version": "2.0.1",
"description": "Parse and manipulate error.stack",

@@ -45,3 +45,3 @@ "keywords": [

"pretest": "echo pretest",
"test": "tsdx test",
"test": "jest",
"posttest": "echo posttest",

@@ -91,5 +91,5 @@ "prebuild": "yarn run test",

"@types/jest": "^27.4.0",
"@types/node": "^17.0.13"
"@types/node": "^17.0.14"
},
"packageManager": "yarn@^1.22.11"
}
import { ITSPickExtra, ITSRequireAtLeastOne } from 'ts-type/lib/type/record';
import { lineSplit, R_CRLF } from 'crlf-normalize';
import { lineSplit, R_CRLF, LF } from 'crlf-normalize';
import { IEvalTrace, IParsed, IParsedWithoutTrace, ISource, ITrace, IRawLineTrace, ITraceValue } from './types';

@@ -12,3 +12,2 @@ import { stringSplitWithLimit } from 'string-split-keep2';

const AT = 'at' as const
const CR = '\n' as const

@@ -19,3 +18,3 @@ // 1.

// TypeError: foo
const REGEX_MATCH_MESSAGE = /^([a-z][a-z0-9_]*)(?: \[(\w+)\])?:(?: ([\s\S]*))?$/i
const REGEX_MATCH_MESSAGE = /^([a-z][a-z0-9_]*)(?:(?: \[(\w+)\])?:(?: ([\s\S]*))?)?$/i

@@ -259,5 +258,5 @@ const REGEX_REMOVE_AT = /^at\s+/

// A error message might have multiple lines
const index = rawTrace.findIndex(line => line.trimLeft().startsWith(AT) && validTrace(parseTrace(trim(line), true)))
const index = rawTrace.findIndex(line => line.trimLeft().startsWith(AT) && validTrace(parseTrace(trim(line), true)));
rawMessage = [rawMessage, ...rawTrace.splice(0, index)].join(CR)
rawMessage = [rawMessage, ...rawTrace.splice(0, index)].join(LF)
}

@@ -391,3 +390,10 @@

{
return `${formatMessagePrefix(parsed)}: ${parsed.message ?? ''}`;
let line = formatMessagePrefix(parsed);
if (typeof parsed.message !== 'undefined')
{
line += `: ${parsed.message ?? ''}`;
}
return line;
}

@@ -479,6 +485,7 @@

const tracesLines = (parsed.traces?.map(formatTraceLine) ?? parsed.rawTrace)
.join(CR)
.join(LF)
;
return tracesLines
? messageLines + CR + tracesLines
? messageLines + LF + tracesLines
: messageLines

@@ -485,0 +492,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc