@elliemae/pui-app-sdk 5.17.3 → 5.17.4

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.
@@ -75,13 +75,21 @@ function ImmutableArgs(_target, _propertyKey, descriptor) {
75
75
  function Memoize(_target, _key, descriptor) {
76
76
  const originalMethod = descriptor.value;
77
77
  const cache = /* @__PURE__ */ new Map();
78
+ const maxSize = 500;
78
79
  descriptor.value = function value(...args) {
79
80
  const key = JSON.stringify(args);
80
81
  if (cache.has(key)) {
81
- return cache.get(key);
82
+ const cacheValue = cache.get(key);
83
+ cache.delete(key);
84
+ cache.set(key, cacheValue);
85
+ return cacheValue;
82
86
  }
83
87
  const result = originalMethod.call(this, ...args);
84
88
  cache.set(key, result);
89
+ if (cache.size > maxSize) {
90
+ const firstKey = cache.keys().next().value;
91
+ cache.delete(firstKey);
92
+ }
85
93
  return result;
86
94
  };
87
95
  }
@@ -46,13 +46,21 @@ function ImmutableArgs(_target, _propertyKey, descriptor) {
46
46
  function Memoize(_target, _key, descriptor) {
47
47
  const originalMethod = descriptor.value;
48
48
  const cache = /* @__PURE__ */ new Map();
49
+ const maxSize = 500;
49
50
  descriptor.value = function value(...args) {
50
51
  const key = JSON.stringify(args);
51
52
  if (cache.has(key)) {
52
- return cache.get(key);
53
+ const cacheValue = cache.get(key);
54
+ cache.delete(key);
55
+ cache.set(key, cacheValue);
56
+ return cacheValue;
53
57
  }
54
58
  const result = originalMethod.call(this, ...args);
55
59
  cache.set(key, result);
60
+ if (cache.size > maxSize) {
61
+ const firstKey = cache.keys().next().value;
62
+ cache.delete(firstKey);
63
+ }
56
64
  return result;
57
65
  };
58
66
  }