JSPM

lazy-value

3.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9727
  • Score
    100M100P100Q129115F
  • License MIT

Create a lazily evaluated value

Package Exports

  • lazy-value

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.