src/Reader.js
function Reader(buf, filePath) {
  // Allow instantiating without `new`
  if (!(this instanceof Reader)) {
    return new Reader(buf);
  }

  // Allow passing either a path to a file or a raw buffer
  if (typeof buf === 'string') {
    filePath = buf;
    buf = fs.readFileSync(buf);
  }

  // LRU cache that'll hold objects we read from the data section.
  // 5000 seems to be roughly the sweet spot between mem vs hit-rate
  this._pointerCache = new LRU(LRU_SIZE);

  this._buf = buf;

  // Stash the file path for if we want to reload it later
  this.filePath = filePath;

  this.setup();
}
function Reader(buf, filePath) {
  // Allow instantiating without `new`
  if (!(this instanceof Reader)) {
    return new Reader(buf);
  }

  // Allow passing either a path to a file or a raw buffer
  if (typeof buf === 'string') {
    filePath = buf;
    buf = fs.readFileSync(buf);
  }

  // LRU cache that'll hold objects we read from the data section.
  // 5000 seems to be roughly the sweet spot between mem vs hit-rate
  this._pointerCache = new LRU(LRU_SIZE);

  this._buf = buf;

  // Stash the file path for if we want to reload it later
  this.filePath = filePath;

  this.setup();
}
function Reader ( buf , filePath ) { // Allow instantiating without `new` if ( ! ( this instanceof Reader ) ) { return new Reader ( buf ) ; } // Allow passing either a path to a file or a raw buffer if ( typeof buf === 'string' ) { filePath = buf ; buf = fs . readFileSync ( buf ) ; } // LRU cache that'll hold objects we read from the data section. // 5000 seems to be roughly the sweet spot between mem vs hit-rate this . _pointerCache = new LRU ( LRU_SIZE ) ; this . _buf = buf ; // Stash the file path for if we want to reload it later this . filePath = filePath ; this . setup ( ) ; }
Main reader constructor
Main reader constructor