@waiting/shared-core
Advanced tools
Comparing version 20.11.1 to 20.11.2
@@ -19,2 +19,4 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
}; | ||
// Save original Error.prepareStackTrace | ||
const origPrepareStackTrace = Error.prepareStackTrace; | ||
/** | ||
@@ -112,13 +114,12 @@ * the dep "source-map-support" should be installed | ||
export function getStack() { | ||
// Save original Error.prepareStackTrace | ||
let origPrepareStackTrace = Error.prepareStackTrace; | ||
/* istanbul ignore else */ | ||
if (!origPrepareStackTrace) { | ||
let fn = origPrepareStackTrace; | ||
/* c8 ignore else */ | ||
if (!fn) { | ||
// MUST installing inner getStack() | ||
install(); | ||
/* istanbul ignore else */ | ||
/* c8 ignore else */ | ||
if (!Error.prepareStackTrace) { | ||
throw new Error('Error.prepareStackTrace not defined'); | ||
} | ||
origPrepareStackTrace = Error.prepareStackTrace; | ||
fn = Error.prepareStackTrace; | ||
} | ||
@@ -129,3 +130,3 @@ // void else in debug hooked by source-map-support already | ||
// @ts-expect-error | ||
const ret = origPrepareStackTrace(err, target); | ||
const ret = fn(err, target); | ||
return ret; | ||
@@ -146,6 +147,7 @@ }; | ||
export function getStackCallerSites(stackTraceLimit = 10) { | ||
// Save original Error.prepareStackTrace | ||
let origPrepareStackTrace = Error.prepareStackTrace; | ||
let fn = origPrepareStackTrace; | ||
/* c8 ignore else */ | ||
if (!origPrepareStackTrace) { | ||
if (!fn) { | ||
// MUST installing inner getStack() | ||
install(); | ||
/* c8 ignore else */ | ||
@@ -155,3 +157,3 @@ if (!Error.prepareStackTrace) { | ||
} | ||
origPrepareStackTrace = Error.prepareStackTrace; | ||
fn = Error.prepareStackTrace; | ||
} | ||
@@ -168,3 +170,3 @@ // void else in debug hooked by source-map-support already | ||
// Restore original `Error.prepareStackTrace` | ||
Error.prepareStackTrace = origPrepareStackTrace; | ||
Error.prepareStackTrace = fn; | ||
Error.stackTraceLimit = limit; | ||
@@ -171,0 +173,0 @@ if (!stacks) { |
{ | ||
"name": "@waiting/shared-core", | ||
"author": "waiting", | ||
"version": "20.11.1", | ||
"version": "20.11.2", | ||
"description": "node core function re export with Promise or Observable", | ||
@@ -72,3 +72,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "f439646f318a37e924d8b9442d59bcb468bfcf02" | ||
"gitHead": "30b35acb1b9229010212a1b885845b342dbdd671" | ||
} |
@@ -26,3 +26,6 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
// Save original Error.prepareStackTrace | ||
const origPrepareStackTrace = Error.prepareStackTrace | ||
/** | ||
@@ -135,15 +138,13 @@ * the dep "source-map-support" should be installed | ||
export function getStack(): string { | ||
// Save original Error.prepareStackTrace | ||
let origPrepareStackTrace = Error.prepareStackTrace | ||
/* istanbul ignore else */ | ||
if (! origPrepareStackTrace) { | ||
let fn = origPrepareStackTrace | ||
/* c8 ignore else */ | ||
if (! fn) { | ||
// MUST installing inner getStack() | ||
install() | ||
/* istanbul ignore else */ | ||
/* c8 ignore else */ | ||
if (! Error.prepareStackTrace) { | ||
throw new Error('Error.prepareStackTrace not defined') | ||
} | ||
origPrepareStackTrace = Error.prepareStackTrace | ||
fn = Error.prepareStackTrace | ||
} | ||
@@ -155,3 +156,3 @@ // void else in debug hooked by source-map-support already | ||
// @ts-expect-error | ||
const ret = origPrepareStackTrace(err, target) as string | ||
const ret = fn(err, target) as string | ||
return ret | ||
@@ -179,7 +180,8 @@ } | ||
export function getStackCallerSites(stackTraceLimit = 10): NodeJS.CallSite[] { | ||
// Save original Error.prepareStackTrace | ||
let origPrepareStackTrace = Error.prepareStackTrace | ||
let fn = origPrepareStackTrace | ||
/* c8 ignore else */ | ||
if (! fn) { | ||
// MUST installing inner getStack() | ||
install() | ||
/* c8 ignore else */ | ||
if (! origPrepareStackTrace) { | ||
/* c8 ignore else */ | ||
@@ -189,3 +191,3 @@ if (! Error.prepareStackTrace) { | ||
} | ||
origPrepareStackTrace = Error.prepareStackTrace | ||
fn = Error.prepareStackTrace | ||
} | ||
@@ -206,3 +208,3 @@ // void else in debug hooked by source-map-support already | ||
// Restore original `Error.prepareStackTrace` | ||
Error.prepareStackTrace = origPrepareStackTrace | ||
Error.prepareStackTrace = fn | ||
Error.stackTraceLimit = limit | ||
@@ -209,0 +211,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3495
180777
908
1
0