MCPcopy Index your code
hub / github.com/angular/angular / MockFilesystem

Class MockFilesystem

packages/service-worker/config/testing/mock.ts:12–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10import {Filesystem} from '../src/filesystem';
11
12export class MockFilesystem implements Filesystem {
13 private files = new Map<string, string>();
14
15 constructor(files: {[name: string]: string | undefined}) {
16 Object.keys(files).forEach((path) => this.files.set(path, files[path]!));
17 }
18
19 async list(dir: string): Promise<string[]> {
20 return Array.from(this.files.keys()).filter((path) => path.startsWith(dir));
21 }
22
23 async read(path: string): Promise<string> {
24 return this.files.get(path)!;
25 }
26
27 async hash(path: string): Promise<string> {
28 return sha1(this.files.get(path)!);
29 }
30
31 async write(path: string, contents: string): Promise<void> {
32 this.files.set(path, contents);
33 }
34}
35
36export class HashTrackingMockFilesystem extends MockFilesystem {
37 public maxConcurrentHashings = 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…