lazy-value
v3.0.0
Published
Create a lazily evaluated value
Downloads
4,039
Maintainers
Readme
lazy-value
Create a lazily evaluated value
Useful when a value is expensive to generate, so you want to delay the computation until the value is needed. For example, improving startup performance by deferring nonessential operations.
Install
$ npm install lazy-value
Usage
import lazyValue from 'lazy-value';
const value = lazyValue(() => expensiveComputation());
app.on('user-action', () => {
doSomething(value());
});
API
lazyValue(fn)
fn
Type: Function
Expected to return a value.
Related
- define-lazy-prop - Define a lazily evaluated property on an object
- import-lazy - Import a module lazily
- p-lazy - Create a lazy promise