lazy-value
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

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

Package Sidebar

Install

npm i lazy-value

Weekly Downloads

1,656

Version

3.0.0

License

MIT

Unpacked Size

3.33 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus