Revert codestyle changes (#40)

* Revert "7f7efbb94bab8574e42d942ad82d414e007b2970"

Code style changes should probably be part of a PR
This commit is contained in:
Eliot Partridge
2019-08-30 10:53:14 -05:00
committed by GitHub
parent eefd9e9a2c
commit caf70a864f
446 changed files with 70667 additions and 70655 deletions
+77 -77
View File
@@ -3,82 +3,82 @@ import { Injectable } from '@angular/core';
/* istanbul ignore next */
@Injectable({ providedIn: 'root' })
export class StorageService {
private data?: Map<string, string> = undefined;
constructor() {
try {
if (typeof localStorage === 'undefined') {
this.data = new Map();
}
} catch {
this.data = new Map();
}
}
getItem(key: string) {
if (this.data) {
return this.data.get(key);
} else {
try {
const value = localStorage.getItem(key);
return value == null ? undefined : value;
} catch {
return undefined;
}
}
}
setItem(key: string, data: string) {
try {
localStorage.setItem(key, data);
this.data = undefined;
} catch {
if (!this.data) {
this.data = new Map();
}
private data?: Map<string, string> = undefined;
constructor() {
try {
if (typeof localStorage === 'undefined') {
this.data = new Map();
}
} catch {
this.data = new Map();
}
}
getItem(key: string) {
if (this.data) {
return this.data.get(key);
} else {
try {
const value = localStorage.getItem(key);
return value == null ? undefined : value;
} catch {
return undefined;
}
}
}
setItem(key: string, data: string) {
try {
localStorage.setItem(key, data);
this.data = undefined;
} catch {
if (!this.data) {
this.data = new Map();
}
this.data.set(key, data);
}
}
removeItem(key: string) {
if (this.data) {
this.data.delete(key);
} else {
try {
localStorage.removeItem(key);
} catch { }
}
}
clear() {
if (this.data) {
this.data.clear();
} else {
try {
localStorage.clear();
} catch { }
}
}
getJSON<T>(key: string, defaultValue: T): T {
try {
return JSON.parse(this.getItem(key) || '');
} catch {
return defaultValue;
}
}
setJSON(key: string, value: any) {
this.setItem(key, JSON.stringify(value));
}
getInt(key: string) {
return parseInt(this.getItem(key) || '0', 10) | 0;
}
setInt(key: string, value: number) {
this.setItem(key, value.toString(10));
}
getBoolean(key: string) {
return this.getItem(key) === 'true';
}
setBoolean(key: string, value: boolean) {
if (value) {
this.setItem(key, 'true');
} else {
this.removeItem(key);
}
}
this.data.set(key, data);
}
}
removeItem(key: string) {
if (this.data) {
this.data.delete(key);
} else {
try {
localStorage.removeItem(key);
} catch { }
}
}
clear() {
if (this.data) {
this.data.clear();
} else {
try {
localStorage.clear();
} catch { }
}
}
getJSON<T>(key: string, defaultValue: T): T {
try {
return JSON.parse(this.getItem(key) || '');
} catch {
return defaultValue;
}
}
setJSON(key: string, value: any) {
this.setItem(key, JSON.stringify(value));
}
getInt(key: string) {
return parseInt(this.getItem(key) || '0', 10) | 0;
}
setInt(key: string, value: number) {
this.setItem(key, value.toString(10));
}
getBoolean(key: string) {
return this.getItem(key) === 'true';
}
setBoolean(key: string, value: boolean) {
if (value) {
this.setItem(key, 'true');
} else {
this.removeItem(key);
}
}
}