JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//cdn.jsdelivr.net/npm/bluebird@3.7.2/js/browser/bluebird.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
JavaScript
let delay = (millis, value)=>Promise.delay(millis, value)
let getBar = async (i)=>delay(500, i!==10 );//returns true (with a delay) if the provided value is not 10
let getBar3 = async (i)=>delay(100, i%2===0);//returns true (with a delay) if the provided value is even
(async ()=>{
let i=0;
while(await getBar(i)) {
if (await getBar3(i)) {
console.log(`doing something with even value ${i}`)
}
i++;
}
})();