title: Running function once inside node stream pipe chain
body: <p>I'm using <code>vinyl-fs</code> to write a simple pipeline that loads markdown files, converts them to HTML, and saves them to disk. This is all working. </p>
  
  <p>However, in the middle of my <code>pipe()</code> chain, I want to perform an asynchronous task that should just be done <strong>once</strong> for all my files. My current problem relates to loading a file (and it's important that file is loaded in the middle of the chain), but it's a problem I find myself stumbling upon all the time.</p>
  
  <p>To solve this problem, I have started to do this:</p>
  
  <pre><code>vfs.src(*.md).pipe(function() {
  
    var loaded = false;
  
    return through2.obj(function(file, enc, cb) {
      if(!loaded) {
        fs.readFile('myfile', function(err, data) {
          // use data for something
          loaded = true;
          cb(null, file);
        }
      } else {
        // passthrough
        cb(null, file);
      }
    });
  }
  </code></pre>
  
  <p>This feels a bit silly. Am I approaching this all wrong, or is this actually an okay thing to do?</p>