| 131 | } |
| 132 | |
| 133 | export class InMemorySpendControlStorage implements SpendControlStorage { |
| 134 | private data: { limits: SpendLimits; history: SpendRecord[] } | null = null; |
| 135 | |
| 136 | load(): { limits: SpendLimits; history: SpendRecord[] } | null { |
| 137 | return this.data |
| 138 | ? { |
| 139 | limits: { ...this.data.limits }, |
| 140 | history: this.data.history.map((r) => ({ ...r })), |
| 141 | } |
| 142 | : null; |
| 143 | } |
| 144 | |
| 145 | save(data: { limits: SpendLimits; history: SpendRecord[] }): void { |
| 146 | this.data = { |
| 147 | limits: { ...data.limits }, |
| 148 | history: data.history.map((r) => ({ ...r })), |
| 149 | }; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | export interface SpendControlOptions { |
| 154 | storage?: SpendControlStorage; |
nothing calls this directly
no outgoing calls
no test coverage detected