@amphibian/iterate-down
v2.0.2
Published
while loop abstraction for iterating down with -1 as increment
Downloads
19
Readme
iterate-down
while loop abstraction for iterating down with -1 as increment
npm install @amphibian/iterate-down
var iterateDown = require('@amphibian/iterate-down');
// Iterate 5 times from 5
iterateDown(5, function (i) {
console.log(i); // 4, 3, 2, 1, 0
});
// Iterate 5 times, but stop at 1
var question = iterateDown(5, function (i, end) {
if (i === 1) {
end('hola que tal');
}
console.log(i); // 4, 3, 2
});
console.log(question); // > hola que hora es