This repository has been archived on 2023-10-27. You can view files and clone it, but cannot push or open issues or pull requests.
current-kwh-cost/node_modules/asynckit/lib/defer.js

27 lines
441 B
JavaScript
Raw Normal View History

2022-11-17 16:42:35 +00:00
module.exports = defer;
/**
* Runs provided function on next iteration of the event loop
*
* @param {function} fn - function to run
*/
function defer(fn)
{
var nextTick = typeof setImmediate == 'function'
? setImmediate
: (
typeof process == 'object' && typeof process.nextTick == 'function'
? process.nextTick
: null
);
if (nextTick)
{
nextTick(fn);
}
else
{
setTimeout(fn, 0);
}
}