gulpjs / vinyl

Virtual file format.
MIT License
1.28k stars 105 forks source link

Reading buffers on demand #6

Closed nfroidure closed 9 years ago

nfroidure commented 10 years ago

Something like that in the Vinyl setters of https://github.com/nfroidure/vinyl/blob/master/index.js#L119 :

(function(cache) {
Object.defineProperty(File.prototype, 'contents', {
  get: function() {
      return cache || (cache = Fs.readFileSync(this.path));
  },
  set: function(value) {
      cache = value;
  }
});
})(null)

So it would read files only when required. Another way of moving null contents out of Vinyl.

A side effect: https://github.com/gulpjs/gulp/issues/79#issuecomment-31580992

yocontra commented 10 years ago

the readFile is non-blocking right now though. If I spin up a glob that has 200 files it will be faster currently than it would be if we added this