Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 1.92 KB

File metadata and controls

18 lines (13 loc) · 1.92 KB

Promise.all 中等 #array #built-in

by Anthony Fu @antfu

接受挑战    English 日本語

由谷歌自动翻译,欢迎 PR 改进翻译质量。

键入函数PromiseAll,它接受PromiseLike对象数组,返回值应为Promise<T>,其中T是解析的结果数组。

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

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

返回首页 分享你的解答 查看解答