function writeZipRecords(writer, records, comment = '') {
  // Write records with local headers.
  const locators = [];
  for (let i = 0; i < records.length; i += 1) {
    locators.push(writeFile(writer, records[i]));
  }

  // writeCentralDirectory
  const centralDirectoryStart = writer.index;
  for (let i = 0; i < locators.length; i += 1) {
    writeCentralFileHeader(writer, records[i], locators[i]);
  }
  const centralDirectoryLength = writer.index - centralDirectoryStart;

  const commentBytes = textEncoder.encode(comment);

  // Write central directory end.
  writeEndOfCentralDirectoryRecord(
    writer,
    records.length,
    centralDirectoryStart,
    centralDirectoryLength,
    commentBytes,
  );
}
@param {BufferWriter} writer
@param {Array<FileRecord>} records
@param {string} comment