Cache localstorage fix
This commit is contained in:
parent
3b486310de
commit
b103b6f786
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.20.4",
|
||||
"version": "0.20.5",
|
||||
"description": "Utility library",
|
||||
"author": "Zak Timson",
|
||||
"license": "MIT",
|
||||
|
@ -25,8 +25,8 @@ export class Cache<K extends string | number | symbol, T> {
|
||||
* @param options
|
||||
*/
|
||||
constructor(public readonly key?: keyof T, public readonly options: CacheOptions = {}) {
|
||||
if(options.storageKey && !options.storage && localStorage)
|
||||
options.storage = localStorage;
|
||||
if(options.storageKey && !options.storage && window?.localStorage)
|
||||
options.storage = window.localStorage;
|
||||
if(options.storageKey && options.storage) {
|
||||
const stored = options.storage.getItem(options.storageKey);
|
||||
if(stored) {
|
||||
|
Loading…
Reference in New Issue
Block a user