How to do it...

  1. Open your command-line application and navigate to your workspace.
  2. Create a new folder named 04-06-Promise-all-collect-concurrently.
  3. Create three functions, checkEngines, checkFlightPlan, and checkNavigationSystem that log a message when they start and return a Promise that resolves to true if a random number is higher than a threshold after some timeout:
function checkEngines() { console.log('checking engine'); return new Promise(function (resolve) { setTimeout(function() { console.log('engine check completed'); resolve(Math.random() < 0.9) }, 250) }); } function checkFlightPlan() { console.log('checking flight plan'); return new Promise(function (resolve) { setTimeout(function() { console.log('flight plan check completed'); ...

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.