MCPcopy
hub / github.com/gildas-lormeau/zip.js / add

Method add

index.cjs:4493–4526  ·  view source on GitHub ↗
(name = "", reader, options = {})

Source from the content-addressed store, hash-verified

4491 }
4492
4493 async add(name = "", reader, options = {}) {
4494 const zipWriter = this;
4495 const {
4496 pendingAddFileCalls,
4497 config
4498 } = zipWriter;
4499 if (workers < config.maxWorkers) {
4500 workers++;
4501 } else {
4502 await new Promise(resolve => pendingEntries.push(resolve));
4503 }
4504 let promiseAddFile;
4505 try {
4506 name = name.trim();
4507 if (zipWriter.filenames.has(name)) {
4508 throw new Error(ERR_DUPLICATED_NAME);
4509 }
4510 zipWriter.filenames.add(name);
4511 promiseAddFile = addFile(zipWriter, name, reader, options);
4512 pendingAddFileCalls.add(promiseAddFile);
4513 return await promiseAddFile;
4514 } catch (error) {
4515 zipWriter.filenames.delete(name);
4516 throw error;
4517 } finally {
4518 pendingAddFileCalls.delete(promiseAddFile);
4519 const pendingEntry = pendingEntries.shift();
4520 if (pendingEntry) {
4521 pendingEntry();
4522 } else {
4523 workers--;
4524 }
4525 }
4526 }
4527
4528 remove(entry) {
4529 const { filenames, files } = this;

Callers 15

testFunction · 0.95
testFunction · 0.95
testFunction · 0.95
testFunction · 0.95
testFunction · 0.95
testFunction · 0.95
testFunction · 0.95
testFunction · 0.95
testFunction · 0.95
testFunction · 0.95
testFunction · 0.95
testFunction · 0.95

Calls 1

addFileFunction · 0.70

Tested by 15

testFunction · 0.76
testFunction · 0.76
testFunction · 0.76
testFunction · 0.76
testFunction · 0.76
testFunction · 0.76
testFunction · 0.76
testFunction · 0.76
testFunction · 0.76
testFunction · 0.76
testFunction · 0.76
testFunction · 0.76