|
| 1 | +// Type definitions for stacktrace.js |
| 2 | +// Project: https://github.com/stacktracejs/stacktrace.js |
| 3 | +// Definitions by: Exceptionless <https://github.com/exceptionless> |
| 4 | +// Definitions: https://github.com/borisyankov/DefinitelyTyped |
| 5 | + |
| 6 | +/// <reference path="../es6-promise/es6-promise.d.ts"/> |
| 7 | + |
| 8 | +declare module StackTrace { |
| 9 | + export interface StackTraceOptions { |
| 10 | + filter?: (stackFrame:StackFrame) => boolean; |
| 11 | + sourceCache?: { URL:string }; |
| 12 | + offline?: boolean; |
| 13 | + } |
| 14 | + |
| 15 | + export interface StackFrame { |
| 16 | + constructor(functionName:string, args:any, fileName:string, lineNumber:number, columnNumber:number): StackFrame; |
| 17 | + |
| 18 | + functionName?:string; |
| 19 | + args?:any; |
| 20 | + fileName?:string; |
| 21 | + lineNumber?:number; |
| 22 | + columnNumber?:number; |
| 23 | + toString():string; |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * Get a backtrace from invocation point. |
| 28 | + * @param options Options Object |
| 29 | + * @return Array[StackFrame] |
| 30 | + */ |
| 31 | + export function get(options?: StackTraceOptions): Promise<StackFrame[]>; |
| 32 | + |
| 33 | + /** |
| 34 | + * Given an error object, parse it. |
| 35 | + * @param error Error object |
| 36 | + * @param options Object for options |
| 37 | + * @return Array[StackFrame] |
| 38 | + */ |
| 39 | + export function fromError(error:Error, options?:StackTraceOptions): Promise<StackFrame[]>; |
| 40 | + |
| 41 | + /** |
| 42 | + * Use StackGenerator to generate a backtrace. |
| 43 | + * @param options Object options |
| 44 | + * @returns Array[StackFrame] |
| 45 | + */ |
| 46 | + export function generateArtificially(options?: StackTraceOptions): Promise<StackFrame[]>; |
| 47 | + |
| 48 | + /** |
| 49 | + * Given a function, wrap it such that invocations trigger a callback that |
| 50 | + * is called with a stack trace. |
| 51 | + * |
| 52 | + * @param {Function} fn to be instrumented |
| 53 | + * @param {Function} callback function to call with a stack trace on invocation |
| 54 | + * @param {Function} errorCallback optional function to call with error if unable to get stack trace. |
| 55 | + * @param {Object} thisArg optional context object (e.g. window) |
| 56 | + */ |
| 57 | + export function instrument(fn:() => void, callback:(stackFrames:StackFrame[]) => void, errorCallback:(error:Error) => void, thisArg?:any): void; |
| 58 | + |
| 59 | + /** |
| 60 | + * Given a function that has been instrumented, |
| 61 | + * revert the function to it's original (non-instrumented) state. |
| 62 | + * |
| 63 | + * @param fn {Function} |
| 64 | + */ |
| 65 | + export function deinstrument(fn:() => void): void; |
| 66 | +} |
0 commit comments