hold
Ensures async function is only called once and caches results for other calls.
When multiple calls are made simulateously, only the first call is allowed to perform the work.
All other callers are held until the caller doing work has completed and shares the results to all held callers.
var Hold = ;var hold = ;;
Installation
$ npm install hold
Usage
code example:
var Hold = ;var hold = ; ; { ;}
Usage With Key
If multiple holds are required based on a key, a key
parameter can be passed as first argument.
var Hold = ;var hold = ; ; { ;}
options
options
in an object with the following possible properties:
expire
: time in milliseconds indicating how long to cache the results of the caller that did the work. default is to never expire.timeout
: if specified, will timeout work callers and return timeout error, and let the next caller perform the work.
var Hold = ;var hold = ;
var Hold = ;var hold = ; // expire cache in 60 seconds