Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

normalize-exception

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

normalize-exception - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

56

build/src/stack.js

@@ -10,3 +10,3 @@ import{setErrorProperty}from"./descriptors.js";

export const setStack=function(error){
const stack=[getStackHeader(error),...getStackTrace()].join("\n");
const stack=getStack(error.message,error.name);
setErrorProperty(error,"stack",stack);

@@ -18,52 +18,36 @@ };

const getStackHeader=function(error){
return`${error.name}: ${error.message}`;
};
const getStackTrace=function(){
const{stack=""}=new Error(" ");
const lines=stack===""?[]:stack.split("\n");
const index=findInternalIndex(lines);
return lines.slice(index);
const getStack=function(message="",name="Error"){
const StackError=getErrorType(name);
const{stack}=new StackError(message);
return stack===undefined||stack===""?
`${name}: ${message}`:
stack.split("\n").filter(isNotInternalLine).join("\n");
};
const getErrorType=function(name){
class StackError extends Error{}
const descriptor={
value:name,
enumerable:true,
writable:true,
configurable:true};
const findInternalIndex=function(lines){
const index=findLastIndex(lines,isInternalStackLine);
Object.defineProperty(StackError,"name",descriptor);
if(index===-1){
return 1;
}
return lines.length-1===index?index:index+1;
Object.defineProperty(StackError.prototype,"name",descriptor);
return StackError;
};
const findLastIndex=function(array,condition){
for(let index=array.length-1;index>=0;index-=1){
if(condition(array[index])){
return index;
}
}
return-1;
const isNotInternalLine=function(line){
return!line.includes(INTERNAL_LINE);
};
const isInternalStackLine=function(line){
return line.includes(NORMALIZE_ERROR_LINE);
};
const NORMALIZE_ERROR_LINE="normalizeException";
const INTERNAL_LINE="normalize-exception";
//# sourceMappingURL=stack.js.map
{
"name": "normalize-exception",
"version": "2.0.0",
"version": "2.1.0",
"type": "module",

@@ -5,0 +5,0 @@ "exports": "./build/src/main.js",

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