create / open simulations

This commit is contained in:
Matei Adriel 2019-07-22 11:59:10 +03:00
parent 057c2268ac
commit 097c44e86e
43 changed files with 596 additions and 84 deletions
src/modules/storage/classes

View file

@ -36,21 +36,18 @@ export class LocalStore<T> {
return this.getAll()[key]
}
public set(key: string | T = 'index', value?: T) {
public set(key: string | T, value?: T) {
let finalKey = key as string
let finalValue = value as T
if (typeof key !== 'string' || value === undefined) {
localStorage.setItem(
this.name,
JSON.stringify({
index: key
})
)
} else {
localStorage.setItem(
this.name,
JSON.stringify({
[key]: value
})
)
finalKey = 'index'
finalValue = key as T
}
const currentData = this.getAll()
currentData[finalKey] = finalValue
localStorage.setItem(this.name, JSON.stringify(currentData))
}
}