recounter - Recursion Counter
A simple utility wrapper for recursive functions, adding a callCount
key and
clearCallCount()
method. Requires reassigning the original function, so it's
mostly useful for testing.
Use like this:
const recounter = { ifnumber < 1 console return 0 console number-- return } countDownToZero = console // -> 11 //set the call count to 0countDownToZeroconsole // -> 0 //revert the function back to the original versioncountDownToZero = countDownToZeroconsole // -> undefined