site/dom.js
function fileMapToBuffer(fileMap) {
  return Promise.all(
    Array.from(fileMap.entries()).map(([path, file]) =>
      readArrayBuffer(file).then(buffer => ({ buffer, path }))
    )
  )
    .then(results => {
      const zipFile = new yazl.ZipFile();
      results.forEach(result => {
        zipFile.addBuffer(Buffer.from(result.buffer), result.path);
      });
      zipFile.end();
      return zipFile;
    })
    .then(
      zipFile =>
        new Promise(resolve => {
          const output = new streamBuffers.WritableStreamBuffer();
          output.on("finish", () => {
            resolve(output.getContents());
          });
          zipFile.outputStream.pipe(output);
        })
    );
}
function fileMapToBuffer(fileMap) {
  return Promise.all(
    Array.from(fileMap.entries()).map(([path, file]) =>
      readArrayBuffer(file).then(buffer => ({ buffer, path }))
    )
  )
    .then(results => {
      const zipFile = new yazl.ZipFile();
      results.forEach(result => {
        zipFile.addBuffer(Buffer.from(result.buffer), result.path);
      });
      zipFile.end();
      return zipFile;
    })
    .then(
      zipFile =>
        new Promise(resolve => {
          const output = new streamBuffers.WritableStreamBuffer();
          output.on("finish", () => {
            resolve(output.getContents());
          });
          zipFile.outputStream.pipe(output);
        })
    );
}
function fileMapToBuffer ( fileMap ) { return Promise . all ( Array . from ( fileMap . entries ( ) ) . map ( ( [ path , file ] ) => readArrayBuffer ( file ) . then ( buffer => ( { buffer , path } ) ) ) ) . then ( results => { const zipFile = new yazl . ZipFile ( ) ; results . forEach ( result => { zipFile . addBuffer ( Buffer . from ( result . buffer ) , result . path ) ; } ) ; zipFile . end ( ) ; return zipFile ; } ) . then ( zipFile => new Promise ( resolve => { const output = new streamBuffers . WritableStreamBuffer ( ) ; output . on ( "finish" , ( ) => { resolve ( output . getContents ( ) ) ; } ) ; zipFile . outputStream . pipe ( output ) ; } ) ) ; }
Create a buffer of the zip file
@typedef {{file: File, fullPath: string}} FileEntry
@param {Map<string, File>} fileMap
@return {Promise<Buffer>}
Create a buffer of the zip file