UNPKG

foxts

Version:

Opinionated collection of common TypeScript utils by @SukkaW

1 lines 491 B
"use strict";exports.LazyPromise=class e extends Promise{executor;promise;constructor(e){super(e=>e()),this.executor=e}static from(t){return new e(e=>{e(t())})}static resolve(t){return new e(e=>e(t))}static reject(t){return new e((e,r)=>r(t))}then(e,t){return this.promise??=new Promise(this.executor),this.promise.then(e,t)}catch(e){return this.promise??=new Promise(this.executor),this.promise.catch(e)}finally(e){return this.promise??=new Promise(this.executor),this.promise.finally(e)}};