Skip to content

Instantly share code, notes, and snippets.

@shibayu36
Created June 24, 2016 14:48
Show Gist options
  • Save shibayu36/c5cc72d0daaf64e4ee992535e6fc8089 to your computer and use it in GitHub Desktop.
Save shibayu36/c5cc72d0daaf64e4ee992535e6fc8089 to your computer and use it in GitHub Desktop.
class FakeStorage implements Storage {
length: number;
[key: string]: any;
[index: number]: string;
constructor() {
this.length = 0;
}
getItem(key: string): any {
return this[key];
}
setItem(key: string, data: string): void {
this[key] = data;
this.length++;
}
removeItem(key: string): void {
delete this[key];
this.length--;
}
key(index: number): string {
// not implement
return 'dummy';
}
clear(): void {
// not implement
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment