node-multispinner
node-multispinner copied to clipboard
Add `stop` method
I'm using async for my async tasks and have 2 scenarios where a stop method would be helpful:
- I already know when the tasks are done and don't want to listen to
multiprocessfordone(so I can have 1 function to handle next case) - Tasks are cancelled due to an fail fast error
- I need to be able to log an error without worry of it being overwritten by a pending
setTimeout
- I need to be able to log an error without worry of it being overwritten by a pending
This should be plausible via a stop method which runs clearTimeout and loop()'s success case (i.e. this.update.done();)
For those curious, this is a monkey-patch workaround that is equally effective:
// Monkey-patch over multispinner instance to prevent waiting for it to finish
// https://github.com/codekirei/node-multispinner/blob/318a09dd41acd41eab90ca543f61eff25a12a860/index.js#L94-L112
multispinner.allCompleted = function () { return true; };
multispinner.loop();
multispinner.loop = function () {};