@ztimson/utils 0.23.12 → 0.23.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -417,11 +417,11 @@ class Cache {
417
417
  return new Proxy(this, {
418
418
  get: (target, prop2) => {
419
419
  if (prop2 in target) return target[prop2];
420
- return target.store[prop2];
420
+ return deepCopy(target.store[prop2]);
421
421
  },
422
422
  set: (target, prop2, value2) => {
423
423
  if (prop2 in target) target[prop2] = value2;
424
- else target.store[prop2] = value2;
424
+ else this.set(prop2, value2);
425
425
  return true;
426
426
  }
427
427
  });
@@ -436,7 +436,7 @@ class Cache {
436
436
  * @return {T[]} Array of items
437
437
  */
438
438
  all() {
439
- return Object.values(this.store);
439
+ return deepCopy(Object.values(this.store));
440
440
  }
441
441
  /**
442
442
  * Add a new item to the cache. Like set, but finds key automatically
@@ -491,7 +491,7 @@ class Cache {
491
491
  * @return {T} Cached item
492
492
  */
493
493
  get(key) {
494
- return this.store[key];
494
+ return deepCopy(this.store[key]);
495
495
  }
496
496
  /**
497
497
  * Get a list of cached keys
@@ -507,7 +507,7 @@ class Cache {
507
507
  * @return {Record<K, T>}
508
508
  */
509
509
  map() {
510
- return structuredClone(this.store);
510
+ return deepCopy(this.store);
511
511
  }
512
512
  /**
513
513
  * Add an item to the cache manually specifying the key