Skip to content

Instantly share code, notes, and snippets.

@LironHazan
Created November 14, 2018 12:32
Show Gist options
  • Save LironHazan/a7c173bfb07965ce60d219434bb2fc0e to your computer and use it in GitHub Desktop.
Save LironHazan/a7c173bfb07965ce60d219434bb2fc0e to your computer and use it in GitHub Desktop.
import {Injectable} from '@angular/core';
@Injectable()
export class LocalStorageWrapperStubService {
constructor() { }
private localStorage = new Map();
remove(key) {
return this.localStorage.delete(key);
}
get(key) {
try {
return this.localStorage.get(key);
} catch (e) {
return null;
}
}
set(key, value) {
return this.localStorage.set(key, JSON.stringify(value));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment