Kinzi / lazy-value

Create a lazily evaluated value

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 --save lazy-value

Usage

const lazyValue = require('lazy-value');

const val = lazyValue(() => expensiveComputation());

app.on('user-action', () => {
	doSomething(val());
});

API

lazyValue(fn)

fn

Type: Function

Expected to return a value.

Related

License

MIT © Sindre Sorhus

About

Create a lazily evaluated value

License:MIT License


Languages

Language:JavaScript 100.0%