| 7 | * @public |
| 8 | */ |
| 9 | export class InMemoryWebStorage implements Storage { |
| 10 | private readonly _logger = new Logger("InMemoryWebStorage"); |
| 11 | private _data: Record<string, string> = {}; |
| 12 | |
| 13 | public clear(): void { |
| 14 | this._logger.create("clear"); |
| 15 | this._data = {}; |
| 16 | } |
| 17 | |
| 18 | public getItem(key: string): string { |
| 19 | this._logger.create(`getItem('${key}')`); |
| 20 | return this._data[key]; |
| 21 | } |
| 22 | |
| 23 | public setItem(key: string, value: string): void { |
| 24 | this._logger.create(`setItem('${key}')`); |
| 25 | this._data[key] = value; |
| 26 | } |
| 27 | |
| 28 | public removeItem(key: string): void { |
| 29 | this._logger.create(`removeItem('${key}')`); |
| 30 | delete this._data[key]; |
| 31 | } |
| 32 | |
| 33 | public get length(): number { |
| 34 | return Object.getOwnPropertyNames(this._data).length; |
| 35 | } |
| 36 | |
| 37 | public key(index: number): string { |
| 38 | return Object.getOwnPropertyNames(this._data)[index]; |
| 39 | } |
| 40 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…