@wormss/lazy-promise
v1.0.0
Published
lazy promise execution
Readme
@wormss/lazy-promise
Because sometimes you don't want a promise to run any code until atleast something awaits it
npm i @wormss/lazy-promiseimport { lazyThenable } from '@wormss/lazy-promise';
import { lazyPromise } from '@wormss/lazy-promise';
import { lazy } from '@wormss/lazy-promise';
// Pick your import of choice
async function main() {
const myPromise = lazyThenable(() => {
// some expensive thing maybe
return 'I am lazy';
}); // factory hasn't been called yet..
// .... some more big stuff..
const value = await myPromise; // now factory has been called.
}