js-dely
Delay execution of callbacks to a given minimum timeframe. Tiny package, has below 50 lines of code.
For what?
Some events on the client happen very fast so that there is no visual feedback of "currently executing action XYZ". This package is an easy and minimalistic appraoch to realize such a feature. Define a minimum amount is miliseoonds the action should take and the callback wont't execute before this timeframe. If the callback took longer than the time - fine, no need to delay anymore.
The amount of time from prior function execution to callback execution is considered, of course.
Installation / usage
Use NPM to install the package via
$ npm install --save dely
Use it to create a delayed callback like so
/** * This could be a server call with callback, a setTimeout or * an IO related function... or anything else with callback */
Or use it to factory-create callbacks like so
const by300 =