import { Injectable } from '@angular/core' ; import { Storage } from './storage.interface' ; @ Injectable ( { providedIn : 'root' } ) export class LocalStorageService implements Storage { getItem ( key ) { return localStorage . getItem ( key ) ; } setItem ( key , value ) { const normalizedValue = typeof value === 'string' ? value : JSON . stringify ( value ) ; localStorage . setItem ( key , normalizedValue ) ; } removeItem ( key ) { localStorage . removeItem ( key ) ; } }