Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 1.81 KB

File metadata and controls

17 lines (12 loc) · 1.81 KB

Promise.all medium #array #promise

by Anthony Fu @antfu

Take the Challenge    简体中文 日本語

Type the function PromiseAll that accepts an array of PromiseLike objects, the returning value should be Promise<T> where T is the resolved result array.

const promise1 = Promise.resolve(3);
const promise2 = 42;
const promise3 = new Promise<string>((resolve, reject) => {
  setTimeout(resolve, 100, 'foo');
});

// expected to be `Promise<[number, 42, string]>`
const p = PromiseAll([promise1, promise2, promise3] as const)

Back Share your Solutions Check out Solutions