All files / src imageCollector.ts

66.66% Statements 8/12
100% Branches 1/1
50% Functions 4/8
66.66% Lines 8/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 396x 5x 5x           137x 5x   137x               27x                               83x      
export class ImageCollector {
	private images = new Set<string>();
	private isCollecting = false;
 
	private static instance: ImageCollector;
	private constructor() {}
 
	public static getInstance(): ImageCollector {
		if (!ImageCollector.instance) {
			ImageCollector.instance = new ImageCollector();
		}
		return ImageCollector.instance;
	}
 
	public reset() {
		this.images.clear();
	}
 
	public addImage(filePath: string) {
		this.images.add(filePath);
	}
 
	public getAll(): string[] {
		return Array.of(...this.images);
	}
 
	public enable() {
		this.isCollecting = true;
	}
 
	public disable() {
		this.isCollecting = false;
	}
 
	public shouldCollect(): boolean {
		return this.isCollecting;
	}
}