fair-share
Node.js module. Interrupts async functions after a short time span (default is 10 ms) so that other code in waiting in the event loop queue can run in between coming back to the function. Thus making it possible for several aync functions to fairly share processor time.
Usage
npm install fair-share
Example
FairShare = require('fair-share');
async function func(){
let share = new FairShare({msBeforeShare: 5});
let randomNumberArray = [];
while(randomNumberArray.length < 1000000){
randomNumberArray.push(Math.random());
share.do();
}
console.log(share.stats);
}
Example stats
{
"iterations": 1000000,
"pauses": 22,
"cyclesBetweenInterrupts": 45455
}