0.1.2 • Published 8 years ago

q-loop v0.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

q-loop

Q extension that loops promises like you would normally do with a 'while'-loop

Install

npm install --save q q-loop

Basic usage

Docs

/**
 * Loops the func until the condition returns true.
 * @param  {func} condition - a function that returns a boolean, loops untill this condition is met.
 * @param  {func} func - Your Q-function that you want to loop
 * @return {promise} A promise for the completion of the loop
 */
 q.loop(condition, func) {
 	..
 }

Code

const q = require('q');
require('q-loop')(q);

var i = 0;
q.loop(
	() => { return i < 5;},
	() => { 
		return q.delay(100)
		.then(() => i++);
	}
)
.done();
0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago