fn-getter

Simple, lazyily evaluated values.


Keywords
lazy, getter, function, value, evaluation
License
MIT
Install
npm install fn-getter@1.0.0

Documentation

fn-getter

NPM version Build status Test coverage Dependency Status License Downloads

Simple, lazyily evaluated values. If a value takes too long to calculate, but you don't need it right away (ex. on startup), then evaluate lazily.

const createGetter = require('fn-getter')

const createS3Client = createGetter(() => {
  const AWS = require('aws-sdk')
  return new AWS.S3()
})

Maybe you want to evaluate it after the first time:

setImmediate(createS3Client)

Then, when you need to use it:

app.use((req, res, next) => {
  createS3Client().putObject(...)
})