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