之前写的一个promise太多了,面试写下来的话。。。。emmm,所以在复习时又写一个简单的。
promise
class Promsie {
constructor(fn) {
//三个状态
this.status = 'pending',
this.resolve = undefined;
this.reject = undefined;
let resolve = value => {
if (this.status === 'pending') {
this.status = 'resolved';
this.resolve = value;
}
};
let reject = value => {
if (this.status === 'pending'