class Promise{
constructor(executer){
this.status = 'pending';
this.value = undefined
this.reason = undefined
let resolveFn = value =>{
if(this.status == pending){
this.status = 'resolve';
this.value = value;
}
}
let rejectFn = reason =>{
if(this.status == pending){
this.status = 'reject';
this.reason = reason;
}
}
try{
executer(resolve,reject);
}catch(e){
reject(e);
}
}
then(onFufilled,onReject){
if(this.status = 'resolve'){
onFufilled(this.value);
}
if(this.status = 'reject'){
onReject(this.reason);
}
}
}