MCPcopy
hub / github.com/jvilk/BrowserFS / IsoFSFactory

Function IsoFSFactory

test/harness/factories/isofs_factory.ts:7–47  ·  view source on GitHub ↗
(cb: (name: string, objs: FileSystem[]) => void)

Source from the content-addressed store, hash-verified

5
6const isodir = "/test/fixtures/isofs";
7export default function IsoFSFactory(cb: (name: string, objs: FileSystem[]) => void): void {
8 if (IsoFS.isAvailable()) {
9 XHRFSFactory((_, xhrfs) => {
10 if (xhrfs.length === 0) {
11 return cb('IsoFS', xhrfs);
12 }
13
14 // Leverage the XHRFS to download the fixtures for this FS.
15 BrowserFS.initialize(xhrfs[0]);
16 let fs = BrowserFS.BFSRequire('fs');
17
18 // Add three Zip FS variants for different zip files.
19 let isoFiles = fs.readdirSync(isodir);
20 let rv: FileSystem[] = [];
21 let countdown = isoFiles.length;
22 function fetchIso(isoFilename: string): void {
23 fs.readFile(isoFilename, (e, data?) => {
24 if (e) throw e;
25 IsoFS.Create({
26 data: data,
27 name: isoFilename
28 }, (e, fs?) => {
29 if (e) {
30 throw e;
31 }
32 rv.push(fs);
33 countdown--;
34 if (countdown === 0) {
35 cb('IsoFS', rv);
36 }
37 });
38 });
39 }
40 for (let i = 0; i < isoFiles.length; i++) {
41 fetchIso(`${isodir}/${isoFiles[i]}`);
42 }
43 });
44 } else {
45 cb('IsoFS', []);
46 }
47}

Callers

nothing calls this directly

Calls 6

XHRFSFactoryFunction · 0.85
cbFunction · 0.85
fetchIsoFunction · 0.85
isAvailableMethod · 0.65
initializeMethod · 0.65
readdirSyncMethod · 0.65

Tested by

no test coverage detected