_indexFile(fileName, index) {
    const stream = fs.createReadStream(fileName, {encoding: 'utf8'});
    return new Promise(done => {
      let prev = '';
      const trigrams = new Set();
      stream.on('error', finished.bind(this));
      stream.on('data', chunk => {
        chunk = prev + chunk;
        chunk = chunk.toLowerCase();
        while (chunk.length > 3) {
          trigrams.add(chunk.substring(0, 3));
          chunk = chunk.substring(1);
        }
        prev = chunk;
      });
      stream.on('end', finished.bind(this));

      function finished() {
        let fileNameIndex;
        if (this._fileNameToIndex.has(fileName)) {
          fileNameIndex = this._fileNameToIndex.get(fileName);
        } else {
          fileNameIndex = ++this._lastFileNameIndex;
          this._indexToFileName.set(fileNameIndex, fileName);
          this._fileNameToIndex.set(fileName, fileNameIndex);
        }
        for (const trigram of trigrams) {
          let values = index.get(trigram);
          if (!values) {
            values = new Set();
            index.set(trigram, values);
          }
          values.add(fileNameIndex);
        }
        done();
      }
    }).then(() => stream.close());
  }
@param {string} fileName
@param {!Map<string,!Set<string>>} index
@return {!Promise}