@dxos/debug
Advanced tools
Comparing version 2.18.3 to 2.19.0
@@ -1,2 +0,24 @@ | ||
export declare function getStackTrace(): any; | ||
/** | ||
* @deprecated Use StackTrace class to support lazy evaluation. | ||
*/ | ||
export declare function getStackTrace(): string; | ||
/** | ||
* Allows to capture stack-traces. | ||
* | ||
* Will capture the stack trace at the point where the class is created. | ||
* Stack traces are captured lazily only when `getStack` is called. | ||
* | ||
* Stack traces are expesive to capture so only call getStack when you need them. | ||
*/ | ||
export declare class StackTrace { | ||
private _stack; | ||
constructor(); | ||
/** | ||
* Get stack formatted as string. | ||
* | ||
* @param skipFrames Number of frames to skip. By default the first frame would be the invocation of the StackTrace constructor. | ||
* @returns | ||
*/ | ||
getStack(skipFrames?: number): string; | ||
} | ||
//# sourceMappingURL=stack-trace.d.ts.map |
@@ -6,12 +6,35 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getStackTrace = void 0; | ||
exports.StackTrace = exports.getStackTrace = void 0; | ||
/** | ||
* @deprecated Use StackTrace class to support lazy evaluation. | ||
*/ | ||
function getStackTrace() { | ||
try { | ||
throw new Error(); | ||
const stackTrace = new StackTrace(); | ||
return stackTrace.getStack(); | ||
} | ||
exports.getStackTrace = getStackTrace; | ||
/** | ||
* Allows to capture stack-traces. | ||
* | ||
* Will capture the stack trace at the point where the class is created. | ||
* Stack traces are captured lazily only when `getStack` is called. | ||
* | ||
* Stack traces are expesive to capture so only call getStack when you need them. | ||
*/ | ||
class StackTrace { | ||
constructor() { | ||
this._stack = new Error(); | ||
} | ||
catch (err) { | ||
return err.stack.split('\n').slice(1).join('\n'); | ||
/** | ||
* Get stack formatted as string. | ||
* | ||
* @param skipFrames Number of frames to skip. By default the first frame would be the invocation of the StackTrace constructor. | ||
* @returns | ||
*/ | ||
getStack(skipFrames = 0) { | ||
const stack = this._stack.stack.split('\n'); | ||
return stack.slice(skipFrames + 2).join('\n'); | ||
} | ||
} | ||
exports.getStackTrace = getStackTrace; | ||
exports.StackTrace = StackTrace; | ||
//# sourceMappingURL=stack-trace.js.map |
{ | ||
"name": "@dxos/debug", | ||
"version": "2.18.3", | ||
"version": "2.19.0", | ||
"description": "Debug utilities", | ||
@@ -31,3 +31,3 @@ "bugs": { | ||
"devDependencies": { | ||
"@dxos/toolchain-node-library": "2.18.3", | ||
"@dxos/toolchain-node-library": "2.19.0", | ||
"@types/jest": "^26.0.7" | ||
@@ -34,0 +34,0 @@ }, |
@@ -5,8 +5,35 @@ // | ||
/** | ||
* @deprecated Use StackTrace class to support lazy evaluation. | ||
*/ | ||
export function getStackTrace () { | ||
try { | ||
throw new Error(); | ||
} catch (err: any) { | ||
return err.stack.split('\n').slice(1).join('\n'); | ||
const stackTrace = new StackTrace(); | ||
return stackTrace.getStack(); | ||
} | ||
/** | ||
* Allows to capture stack-traces. | ||
* | ||
* Will capture the stack trace at the point where the class is created. | ||
* Stack traces are captured lazily only when `getStack` is called. | ||
* | ||
* Stack traces are expesive to capture so only call getStack when you need them. | ||
*/ | ||
export class StackTrace { | ||
private _stack: Error; | ||
constructor () { | ||
this._stack = new Error(); | ||
} | ||
/** | ||
* Get stack formatted as string. | ||
* | ||
* @param skipFrames Number of frames to skip. By default the first frame would be the invocation of the StackTrace constructor. | ||
* @returns | ||
*/ | ||
getStack (skipFrames = 0) { | ||
const stack = this._stack.stack!.split('\n'); | ||
return stack.slice(skipFrames + 2).join('\n'); | ||
} | ||
} |
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
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
68710
1108