Skip to content

Commit

Permalink
type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yyc committed Aug 28, 2018
1 parent 1a7805d commit 3285d00
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
var table = {};
// to stop typescript complaining
const globalAny:any = global;

/**
Utility function that wraps a function and provides two tracking functions
to allow you to track whether a function has been called
Type: (fn) -> fn
**/
var table = {};
const track_function = (name: String) => {
const track_function = (name: string) => {
if (table[name] !== undefined) {
reset_count(name);
return;
Expand All @@ -18,14 +21,14 @@ const track_function = (name: String) => {
global[name] = wrapped_function;
};

const reset_count = (name: String) => {
const reset_count = (name: string) => {
table[name] = 0;
};

const get_count = (name: String) => {
const get_count = (name: string) => {
return table[name];
};

global.__track_function = track_function;
global.__reset_function_count = reset_count;
global.__get_function_count = get_count;
globalAny.__track_function = track_function;
globalAny.__reset_function_count = reset_count;
globalAny.__get_function_count = get_count;

0 comments on commit 3285d00

Please sign in to comment.