()
| 60 | ) {} |
| 61 | |
| 62 | get(): T { |
| 63 | const raw = this.adapter.getItem(this.key); |
| 64 | if (raw === null) { |
| 65 | return this.defaultValue; |
| 66 | } |
| 67 | try { |
| 68 | return JSON.parse(raw) as T; |
| 69 | } catch { |
| 70 | return this.defaultValue; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | set(value: T): void { |
| 75 | this.adapter.setItem(this.key, JSON.stringify(value)); |