How to do it...

  1. Open your command-line application and navigate to your workspace.
  2.  Create a new folder named 3-05-starting-with-resolve.
  3. Copy or create an index.html that loads and runs a main function from main.js.
  4. Create a main.js file that calls Promise.resolve with an empty object as the first argument:
export function main () { 
  Promise.resolve({}) 
} 
  1. Chain a then call off of resolve, and attach rocket boosters to the passed object:
export function main () { 
  Promise.resolve({}).then(function (rocket) {      console.log('attaching boosters');      rocket.boosters = [{        count: 2,        fuelType: 'solid'      }, {        count: 1,        fuelType: 'liquid'      }];      return rocket;    })}
  1. Add a final then call to the chain that lets you know when the boosters have been added: ...

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.