Cache localstorage fix
All checks were successful
Build / Build NPM Project (push) Successful in 38s
Build / Tag Version (push) Successful in 7s
Build / Publish Documentation (push) Successful in 35s

This commit is contained in:
Zakary Timson 2024-10-15 16:44:23 -04:00
parent 151465aa65
commit 3a389de72e
2 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@ztimson/utils", "name": "@ztimson/utils",
"version": "0.20.6", "version": "0.20.7",
"description": "Utility library", "description": "Utility library",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",

View File

@ -25,8 +25,8 @@ export class Cache<K extends string | number | symbol, T> {
* @param options * @param options
*/ */
constructor(public readonly key?: keyof T, public readonly options: CacheOptions = {}) { constructor(public readonly key?: keyof T, public readonly options: CacheOptions = {}) {
if(options.storageKey && !options.storage && window && window?.localStorage) if(options.storageKey && !options.storage && typeof(Storage) !== 'undefined')
options.storage = window.localStorage; options.storage = localStorage;
if(options.storageKey && options.storage) { if(options.storageKey && options.storage) {
const stored = options.storage.getItem(options.storageKey); const stored = options.storage.getItem(options.storageKey);
if(stored) { if(stored) {