Line data Source code
1 1 : export class ProgressCounter {
2 1 : public started: number;
3 1 : public succeeded: number;
4 1 : public skipped: number;
5 1 : public failed: number;
6 1 : public total: number | null;
7 :
8 1 : constructor(total: number | null = null) {
9 1 : this.started = 0;
10 1 : this.succeeded = 0;
11 1 : this.skipped = 0;
12 1 : this.failed = 0;
13 1 : this.total = total;
14 1 : }
15 :
16 1 : public clone(): ProgressCounter {
17 1 : const out = new ProgressCounter(this.total);
18 1 : out.started = this.started;
19 1 : out.succeeded = this.succeeded;
20 1 : out.skipped = this.skipped;
21 1 : out.failed = this.failed;
22 1 : return out;
23 1 : }
24 1 : public addStarted(n: number = 1): ProgressCounter {
25 1 : this.started += n;
26 1 : return this;
27 1 : }
28 1 : public addSucceeded(n: number = 1): ProgressCounter {
29 1 : this.succeeded += n;
30 1 : return this;
31 1 : }
32 1 : public addSkipped(n: number = 1): ProgressCounter {
33 1 : this.skipped += n;
34 1 : return this;
35 1 : }
36 1 : public addFailed(n: number = 1): ProgressCounter {
37 1 : this.failed += n;
38 1 : return this;
39 1 : }
40 1 : public addTotal(n: number = 1): ProgressCounter {
41 1 : this.total = (this.total ?? 0) + n;
42 1 : return this;
43 1 : }
44 1 : }
|