Created
January 30, 2017 03:00
-
-
Save liondancer/de29f44d4ee3228ea13172d4bcf0189b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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