npm

Need private packages and team management tools?Check out npm Orgs. »

lazy-value

2.0.0 • Public • Published

lazy-value Build Status

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

const lazyValue = require('lazy-value');
 
const value = lazyValue(() => expensiveComputation());
 
app.on('user-action', () => {
    doSomething(value());
});

API

lazyValue(fn)

fn

Type: Function

Expected to return a value.

Related

License

MIT © Sindre Sorhus

install

npm i lazy-value

Downloadsweekly downloads

402

version

2.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability