Utility to wrap a function such that it executes it's inner function after n calls.