Skip to content

Instantly share code, notes, and snippets.

@liondancer
Created January 30, 2017 03:00
Show Gist options
  • Save liondancer/de29f44d4ee3228ea13172d4bcf0189b to your computer and use it in GitHub Desktop.
Save liondancer/de29f44d4ee3228ea13172d4bcf0189b to your computer and use it in GitHub Desktop.
// nested Loop
.then(() => {
var heaplist = 4;
const whileHeapList = () => {
if (heaplist) {
heaplist--;
var i = 0;
var j = 5;
const innerWhileLoop = () => {
if (i <= j) {
i++;
new Promise(innerWhileLoop);
} else {
new Promise.resolve();
}
}
// first iteration of innerWhileLoop
new Promise(innerWhileLoop);
// Continue looping with whileHeapList
new Promise(whileHeapList);
}
return new Promise.resolve();
}
// first iteration of whileHeapList
return new Promise(whileHeapList);
});
// Sinlge Loop
.then(() => {
var heaplist = 4;
const whileHeapList = () => {
if (heaplist) {
heaplist--;
return new Promise(whileHeapList);
}
return new Promise.resolve();
}
return new Promise(whileHeapList);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment