Correct Writing

suggest change
var pipeline = {};
// (...) adding things in pipeline

var processOneFile = function(key) {    
  fs.stat(pipeline[key].path, function(err, stats) {
    if (err) {
      // clear that one
      delete pipeline[key];
      return;
    }
    // (...)
    pipeline[key].count++;
  });
};
    
// verify it is not growing
for(var key in pipeline) {
  processOneFileInPipeline(key);
}

By creating a new function, we are scoping key inside a function so all callback have their own key instance.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents