Fixed localStorage access on node environments
Some checks failed
Build / Build NPM Project (push) Failing after 15s
Build / Tag Version (push) Has been skipped
Build / Publish Documentation (push) Has been skipped

This commit is contained in:
Zakary Timson 2024-10-15 13:46:11 -04:00
parent b21f462d35
commit 274c22bb83
3 changed files with 5186 additions and 2 deletions

5184
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

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

View File

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