Promise._race = promises => new Promise((resolve, reject) => { promises.forEach(promise => { promise.then(resolve, reject) }) })
基本和上面的例子差不多,不同点是每个传入值使用Promise. resolve转为Promise对象,兼容非Promise对象
const _race = (p) => { return new Promise((resolve, reject) => { p.forEach((item) => { Promise.resolve(item).then(resolve, reject) }) }) }