Save promise result and update it from time to time.
$ npm install --save memorize-promise
const got = require('got');
const memorizePromise = require('memorize-promise');
const cache = memorizePromise(() => got('google.com'));
cache.then(res => console.log(res.body)); // Content 1
cache.then(res => console.log(res.body)); // Content 1
setTimeout(function () {
cache.then(res => console.log(res.body)); // Content 2
cache.then(res => console.log(res.body)); // Content 2
cache.stop(); // Stops updates
}, 5005);Type: Function
Factory of promises. It will be called for new promise with data every updateInterval milliseconds.
Type: Number
Default: 5000
Update interval in milliseconds.
Type: Number
Default: 60000
Lifetime of update timeout after last hit.
MIT © Vsevolod Strukchinsky