Assign result array from Promise.all

Date: 2019-02-22
const getTasks = () => Promise.delay(500).then(() => ['task1']);
const getUsers = () => Promise.delay(400).then(() => ['user1', 'user2']);
const getInvoices = () => Promise.delay(300).then(() => ['invoice4']);
const getColors = () => Promise.delay(200).then(() => ['color1', 'color2']);

const run = async () => {
  const [
      tasks, 
      users, 
      invoices, 
      colors
      ] = await Promise.all([
          getTasks(),
          getUsers(),
          getInvoices(),
          getColors()
      ]);              
   return { tasks, users, invoices, colors };
};
      
const t0 = performance.now();
run().then((result) => {
	document.write(`<pre>${JSON.stringify(result, null, 4)}</pre>`);
    const t1 = performance.now();
	console.log(`Call to doSomething took ${(t1 - t0)} ms.`);
});
   
19060cookie-checkAssign result array from Promise.all