Last active
June 10, 2020 00:13
-
-
Save sle-c/71e4c1984761433d18fa7ee0d4ae3843 to your computer and use it in GitHub Desktop.
Wrap a function and count how many time it's being invoked
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createFnCounter(fn, invokeBeforeExecution) { | |
let count = 0; | |
return (snapshot) => { | |
count++; | |
if (count <= invokeBeforeExecution) { | |
return null; | |
} | |
return fn(snapshot, count); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment