Skip to content

Instantly share code, notes, and snippets.

@sle-c
Last active June 10, 2020 00:13
Show Gist options
  • Save sle-c/71e4c1984761433d18fa7ee0d4ae3843 to your computer and use it in GitHub Desktop.
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
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