2.0.1 • Published 9 years ago

@amphibian/iterate v2.0.1

Weekly downloads
11
License
ISC
Repository
gitlab
Last release
9 years ago

iterate

build status

functional while loop abstraction to return iterators on an increment

npm install @amphibian/iterate
var iterate = require('@amphibian/iterate');

// Iterate 5 times from 0
var iterateUp = iterate(+1);

iterateUp(5, function (i) {
    console.log(i); // 0, 1, 2, 3, 4
});

// Iterate on even numbers from 0 to 5
var iterateEven = iterate(+2);

iterateEven(5, function (i) {
    console.log(i); // 0, 2, 4
});

// Iterate towards 0 from 5, but end at 3
var iterateDown = iterate(-1);
var greeting = iterateDown(5, function (i, end) {
    console.log(i);

    if (i === 3) {
        end('hola que tal');
    }
});

console.log(greeting); // > hola que tal
2.0.1

9 years ago

2.0.0

9 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago