fn-getter

1.0.0 • Public • Published

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(...)
})

Package Sidebar

Install

npm i fn-getter

Weekly Downloads

1,483

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jongleberry