src/fs.js
function readFile(filename, cache, encoding=null) {
  if (cache.has(filename)) return _handleFileInCache(filename, cache);
  _addReadCallbacks(filename, cache);
  fileQueue.push(()=>{
    const contents = [];
    fs.createReadStream(filename, {encoding})
      .on('data', chunk=>contents.push(chunk))
      .on('end', ()=>_readFileOnEnd(filename, contents, cache))
      .on('error', error=>_readFileOnError(filename, error))
  });
  _runFileQueue();
  return _handleFileInCache(filename, cache);
}
function readFile(filename, cache, encoding=null) {
  if (cache.has(filename)) return _handleFileInCache(filename, cache);
  _addReadCallbacks(filename, cache);
  fileQueue.push(()=>{
    const contents = [];
    fs.createReadStream(filename, {encoding})
      .on('data', chunk=>contents.push(chunk))
      .on('end', ()=>_readFileOnEnd(filename, contents, cache))
      .on('error', error=>_readFileOnError(filename, error))
  });
  _runFileQueue();
  return _handleFileInCache(filename, cache);
}
function readFile ( filename , cache , encoding = null ) { if ( cache . has ( filename ) ) return _handleFileInCache ( filename , cache ) ; _addReadCallbacks ( filename , cache ) ; fileQueue . push ( ( ) => { const contents = [ ] ; fs . createReadStream ( filename , { encoding } ) . on ( 'data' , chunk => contents . push ( chunk ) ) . on ( 'end' , ( ) => _readFileOnEnd ( filename , contents , cache ) ) . on ( 'error' , error => _readFileOnError ( filename , error ) ) } ) ; _runFileQueue ( ) ; return _handleFileInCache ( filename , cache ) ; }
Load a file synchronously using a cache.

@public
@param {string} filename               The file to load.
@param {Map} cache                     The cache to use.
@param {null|string} [encoding=null]   The encoding to load as.
@returns {Promise.<Buffer|*>}          The load results.
Load a file synchronously using a cache .