Safe assignment (?=) alternative for promises
BlobKat

BlobKat @blobkat

About: 410 bio gone

Joined:
Feb 1, 2021

Safe assignment (?=) alternative for promises

Publish Date: Aug 22 '24
0 0
Promise.prototype.safe = function(){
  return this.then(
    res => [null, res],
    err = [err, null]
  );
}

const [err, res] = await fetch("https://blobk.at/").safe()
Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment