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