fn-getter
v1.0.0
Published
Simple, lazyily evaluated values.
Downloads
11,897
Maintainers
Readme
fn-getter
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(...)
})