UNPKG

electronmon

Version:

watch and reload your electron app the easy way

30 lines (22 loc) 420 B
const queue = (() => { const pending = []; let inFlight = false; const send = (msg, cb) => { if (inFlight) { pending.push([msg, cb]); return; } inFlight = true; process.send(msg, (e) => { inFlight = false; if (cb) { cb(e); } if (pending.length) { send(...pending.shift()); } }); }; return send; })(); module.exports = queue;