UNPKG

foxts

Version:

Opinionated collection of common TypeScript utils by @SukkaW

2 lines (1 loc) 518 B
Object.defineProperty(exports,"__esModule",{value:!0});class e extends 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)}}exports.LazyPromise=e;