Fixed unit tests and naming conventions.

This commit is contained in:
Blake Niemyjski
2015-05-14 10:14:44 -05:00
parent a07aca985c
commit f9996b4dda
4 changed files with 11 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
// Type definitions for node-stack-trace
// Project: https://github.com/felixge/node-stack-trace
// Definitions by: [Exceptionless] <https://github.com/exceptionless>
// Definitions by: Exceptionless <https://github.com/exceptionless>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'stack-trace' {
@@ -15,6 +15,6 @@ declare module 'stack-trace' {
isNative():boolean;
}
export function get(belowFn:() => void): StackFrame[];
export function get(belowFn?:() => void): StackFrame[];
export function parse(err:Error): StackFrame[];
}

View File

@@ -1,18 +1,17 @@
import StackTrace = require('StackTrace');
/// <reference path="stacktrace-js.d.ts" />
function interestingFn() {
return 'https://github.com/exceptionless/Exceptionless';
}
var callback = function(stackframes) {
var stringifiedStack = stackframes.map(function(sf) {
var callback = function(stackframes:StackTrace.StackFrame[]) {
var stringifiedStack = stackframes.map(function(sf:StackTrace.StackFrame) {
return sf.toString();
}).join('\n');
console.log(stringifiedStack);
};
var errback = function(err) { console.log(err.message); };
var errorCallback = function(err:Error) { console.log(err.message); };
StackTrace.get();
@@ -21,5 +20,5 @@ var error = new Error('BOOM!');
StackTrace.fromError(error);
StackTrace.generateArtificially();
StackTrace.instrument(interestingFn, callback, errback);
StackTrace.instrument(interestingFn, callback, errorCallback);
StackTrace.deinstrument(interestingFn);

View File

@@ -13,7 +13,7 @@ declare module StackTrace {
}
export interface StackFrame {
constructor(functionName:string, args:any, fileName:string, lineNumber:number, columnNumber:number);
constructor(functionName:string, args:any, fileName:string, lineNumber:number, columnNumber:number): StackFrame;
functionName?:string;
args?:any;
@@ -28,7 +28,7 @@ declare module StackTrace {
* @param options Options Object
* @return Array[StackFrame]
*/
export function get(options: StackTraceOptions): Promise<StackFrame[]>;
export function get(options?: StackTraceOptions): Promise<StackFrame[]>;
/**
* Given an error object, parse it.
@@ -43,7 +43,7 @@ declare module StackTrace {
* @param options Object options
* @returns Array[StackFrame]
*/
export function generateArtificially(options: StackTraceOptions): Promise<StackFrame[]>;
export function generateArtificially(options?: StackTraceOptions): Promise<StackFrame[]>;
/**
* Given a function, wrap it such that invocations trigger a callback that
@@ -54,7 +54,7 @@ declare module StackTrace {
* @param {Function} errorCallback optional function to call with error if unable to get stack trace.
* @param {Object} thisArg optional context object (e.g. window)
*/
export function instrument(fn:() => void, callback:(stackFrames:StackFrame[]) => void, errorCallback:() => void, thisArg:any): void;
export function instrument(fn:() => void, callback:(stackFrames:StackFrame[]) => void, errorCallback:(error:Error) => void, thisArg?:any): void;
/**
* Given a function that has been instrumented,