promise-by-need
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Lazily evaluated promise

It's just like a normal promise, a bit lazier.

let state = false;
const p = new LazyPromise<number>(resolve => {
    state = true;
    resolve(1);
});
 
// at this point `state` is still false.
// if it evaluate eagerly it will be true.
await p;
// `now state is true`

There are many lazily evaluated promise libraries on github, and there implementation are all very similar. This library is just one of them but combined some features I feel useful.

Readme

Keywords

Package Sidebar

Install

npm i promise-by-need

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

11.5 kB

Total Files

9

Last publish

Collaborators

  • jummy123good