alinea
Version:
[](https://npmjs.org/package/alinea) [](https://packagephobia.com/result?p=alinea)
37 lines (35 loc) • 810 B
JavaScript
// 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
};