push
github
774 of 871 branches covered (88.86%)
Branch coverage included in aggregate %.
4759 of 4937 relevant lines covered (96.39%)
1419.15 hits per line
| 1 |
import { stringify } from './json'
|
6✔ |
| 2 |
|
6✔ |
| 3 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
6✔ |
| 4 |
export class JsonableValue<V = Record<string, any>> { |
6✔ |
| 5 |
private _serialized!: string |
6✔ |
| 6 |
private _value!: V
|
6✔ |
| 7 |
|
6✔ |
| 8 |
constructor(value: V) {
|
|
| 9 |
this.value = value
|
192✔ |
| 10 |
} |
192✔ |
| 11 |
|
6✔ |
| 12 |
set value(value: V) {
|
|
| 13 |
this._value = value
|
252✔ |
| 14 |
this._serialized = stringify(value)
|
252✔ |
| 15 |
} |
252✔ |
| 16 |
|
6✔ |
| 17 |
get value(): V {
|
|
| 18 |
return this._value |
1,368✔ |
| 19 |
} |
1,368✔ |
| 20 |
|
6✔ |
| 21 |
get serialized(): string {
|
|
| 22 |
return this._serialized |
468✔ |
| 23 |
} |
468✔ |
| 24 |
|
6✔ |
| 25 |
valueOf(): V {
|
6✔ |
| 26 |
return this._value |
× |
| 27 |
} |
× |
| 28 |
|
6✔ |
| 29 |
toString(): string {
|
6✔ |
| 30 |
return this._serialized |
× |
| 31 |
} |
× |
| 32 |
} |
6✔ |