I have a function that takes another function that generates consecuitive numbers
(numbers can be generated from any start point)
also the function takes a value which it should stop before
i can get it to work from zero up to the required limit but not if for expample it starts at 1
these are requirements:
returns a function on first invocation
✓ returns given value on first call
✓ Subsequent invocations emits consecutive integers (1 ms)
✓ exclusively emits undefined when surpassed limit (not inclusive) (1 ms)
✕ exclusively emits undefined when surpassed limit (not inclusive) when generator does not start at 0
hof.to = function (funcfrom, n) {
counter = n;
return function () {
if (counter > 0) {
counter--;
return funcfrom();
}
};
};