create / open simulations
This commit is contained in:
parent
057c2268ac
commit
097c44e86e
43 changed files with 596 additions and 84 deletions
src/modules/storage/classes
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue