Compare commits

..

2 Commits

Author SHA1 Message Date
151465aa65 Cache localstorage fix
All checks were successful
Build / Build NPM Project (push) Successful in 39s
Build / Tag Version (push) Successful in 7s
Build / Publish Documentation (push) Successful in 36s
2024-10-15 16:39:29 -04:00
b103b6f786 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 34s
2024-10-15 16:35:11 -04:00
2 changed files with 3 additions and 3 deletions

View File

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

View File

@ -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 && window?.localStorage)
options.storage = window.localStorage;
if(options.storageKey && options.storage) {
const stored = options.storage.getItem(options.storageKey);
if(stored) {