@bgord/tools 0.12.22 → 0.12.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,9 +5,12 @@ var StopwatchState;
|
|
|
5
5
|
StopwatchState["stopped"] = "finished";
|
|
6
6
|
})(StopwatchState || (StopwatchState = {}));
|
|
7
7
|
export class Stopwatch {
|
|
8
|
+
startMs;
|
|
8
9
|
state = StopwatchState.started;
|
|
9
|
-
startMs = Timestamp.parse(Date.now());
|
|
10
10
|
stopMs;
|
|
11
|
+
constructor(startMs) {
|
|
12
|
+
this.startMs = startMs;
|
|
13
|
+
}
|
|
11
14
|
stop() {
|
|
12
15
|
if (this.state === StopwatchState.stopped) {
|
|
13
16
|
throw new Error("Stopwatch is already stopped");
|
package/package.json
CHANGED
package/src/stopwatch.service.ts
CHANGED
|
@@ -11,10 +11,10 @@ export type StopwatchResultType = { durationMs: TimestampType };
|
|
|
11
11
|
export class Stopwatch {
|
|
12
12
|
private state: StopwatchState = StopwatchState.started;
|
|
13
13
|
|
|
14
|
-
private readonly startMs: TimestampType = Timestamp.parse(Date.now());
|
|
15
|
-
|
|
16
14
|
private stopMs: Falsy<TimestampType>;
|
|
17
15
|
|
|
16
|
+
constructor(private readonly startMs: TimestampType) {}
|
|
17
|
+
|
|
18
18
|
stop(): StopwatchResultType {
|
|
19
19
|
if (this.state === StopwatchState.stopped) {
|
|
20
20
|
throw new Error("Stopwatch is already stopped");
|