const PENDING = 'pending'
const FULFILLED = 'fulfilled'
const REJECTED = 'rejected'
class MyPromise {
constructor(executor) {
executor(this.resolvue, this.reject)
}
status = PENDING
value = null
reason = null
resolvue = (value) => {
if(this.status === PENDING) {
this.status = FULFILLED
this.value = value
}
}
reject = (reason) => {
if(this.status === PENDING) {
this.status = REJECTED
this.reason = reason
}
}
then(onFulfilled,onRejected) {
if(this.status === FULFILLED) {
onFulfilled(this.value)
} else if(this.status === REJECTED) {
onRejected(this.reason)
}
}
}
module.export = MyPromise;
console