Skip to content

the-brewery/q-loop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published