UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

37 lines (35 loc) 810 B
// node_modules/p-lazy/index.js var PLazy = class _PLazy extends Promise { constructor(executor) { super((resolve) => { resolve(); }); this._executor = executor; } static from(function_) { return new _PLazy((resolve) => { resolve(function_()); }); } static resolve(value) { return new _PLazy((resolve) => { resolve(value); }); } static reject(error) { return new _PLazy((resolve, reject) => { reject(error); }); } then(onFulfilled, onRejected) { this._promise = this._promise || new Promise(this._executor); return this._promise.then(onFulfilled, onRejected); } catch(onRejected) { this._promise = this._promise || new Promise(this._executor); return this._promise.catch(onRejected); } }; export { PLazy };