$ gnpm install event-loop-spinner
Tiny helper to prevent blocking Node.js event loop.
import { eventLoopSpinner } from 'event-loop-spinner';
async function cpuIntensiveOperationHandler(hugeArray) {
for (const item of hugeArray) {
// ...
if (eventLoopSpinner.isStarving()) {
await eventLoopSpinner.spin();
}
}
}
Node.js: How even quick async functions can block the Event-Loop, starve I/O
Copyright 2013 - present © cnpmjs.org | Home |