_sequence.js 341 B

1234567891011121314
  1. function sequence(iteratee, start, stop, step) {
  2. if (stop == null) {
  3. stop = start || 0;
  4. start = 0;
  5. }
  6. if (!step) {
  7. step = stop < start ? -1 : 1;
  8. }
  9. var rest = (stop - start) % step;
  10. stop += (rest && step - rest);
  11. for ( ; start != stop ; start += step) if (iteratee(start)) return start;
  12. }
  13. module.exports = sequence;