On applyPatches() functions the loadFile() option accept a callback that must be called with the content of the file to be patched, but the patched() option don't, forcing to implement it as a sync function. Ironically, just in the next line there's a setTimeout(processIndex, 0) to process the next index!
What I propose is to add a callback argument to patched() function so it can both notify when it has finished and can start processing the next index, and also if there was an error while writting the patch. A more advanced option would be to use async.js for that, that's already a dependency and would make the code a bit cleaner.
On
applyPatches()functions theloadFile()option accept a callback that must be called with the content of the file to be patched, but thepatched()option don't, forcing to implement it as a sync function. Ironically, just in the next line there's asetTimeout(processIndex, 0)to process the next index!What I propose is to add a callback argument to
patched()function so it can both notify when it has finished and can start processing the next index, and also if there was an error while writting the patch. A more advanced option would be to useasync.jsfor that, that's already a dependency and would make the code a bit cleaner.