SOURCE

const fn = () => {
    return  new Promise((resolve, reject) => {
        setTimeout(() => {
            reject('reject')
        }, 1000)
    })
}


function wrapPromise(promise) {
  let status = "pending";
  let result;
  let suspender = promise.then(
    r => {
      status = "success";
      result = r;
    },
    e => {
      status = "error";
      result = e;
    }
  );
  return {
    read() {
      if (status === "pending") {
        throw suspender;
      } else if (status === "error") {
        throw result;
      } else if (status === "success") {
        return result;
      }
    }
  };
}

const obj = wrapPromise(fn())

console.log(obj)
    console.log('执行之前')

// const p = p1.then(res => {
//     console.log(res)
// }, err => {
//     console.log(err)
// })

    // console.log('执行之后', p)


console 命令行工具 X clear

                    
>
console