Promise简单实现
调用方式
const p = new MyPromise((resolve, reject) => {
setTimeout(() => resolve('foo'), 500)
})
p.then((res) => { console.log(res) }, (err) => {})
小于 1 分钟
调用方式
const p = new MyPromise((resolve, reject) => {
setTimeout(() => resolve('foo'), 500)
})
p.then((res) => { console.log(res) }, (err) => {})