MCPcopy Create free account
hub / github.com/Snapchat/Valdi / removeSync

Function removeSync

src/valdi_modules/src/valdi/file_system/web/FileSystem.ts:52–76  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

50 if (typeof data === "string") return encUtf8.encode(data);
51 if (data instanceof Uint8Array) return data.slice();
52 return new Uint8Array(data).slice();
53}
54
55/* -------- implementation -------- */
56
57const fsStub: FileSystemModule = {
58 existsSync(path: string): boolean {
59 const p = norm(path);
60 return files.has(p) || dirs.has(p);
61 },
62
63 removeSync(path: string): boolean {
64 const p = norm(path);
65 if (files.delete(p)) return true;
66 if (dirs.has(p)) {
67 // recursive remove directory
68 let removed = false;
69 // remove all nested files/dirs
70 for (const f of Array.from(files.keys())) {
71 if (f === p || f.startsWith(p + "/")) {
72 files.delete(f);
73 removed = true;
74 }
75 }
76 for (const d of Array.from(dirs.values())) {
77 if (d !== ROOT && (d === p || d.startsWith(p + "/"))) {
78 dirs.delete(d);
79 removed = true;

Callers

nothing calls this directly

Calls 7

normFunction · 0.85
startsWithMethod · 0.80
valuesMethod · 0.80
deleteMethod · 0.65
hasMethod · 0.65
keysMethod · 0.65
fromMethod · 0.45

Tested by

no test coverage detected