@elliemae/pui-app-sdk 5.25.1 → 5.26.0

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.
@@ -24,6 +24,7 @@ __export(functionDecorators_exports, {
24
24
  ImmutableArgs: () => ImmutableArgs,
25
25
  Memoize: () => Memoize,
26
26
  MemoizeAsync: () => MemoizeAsync,
27
+ MemoizeSingleArgPrimitive: () => MemoizeSingleArgPrimitive,
27
28
  QueueTask: () => QueueTask,
28
29
  RetryAsync: () => RetryAsync,
29
30
  Throttle: () => Throttle
@@ -214,3 +215,22 @@ function RetryAsync(retries = 3, interval = 2e3, reThrowException = true) {
214
215
  return descriptor;
215
216
  };
216
217
  }
218
+ function MemoizeSingleArgPrimitive(_target, _propertyKey, descriptor) {
219
+ const originalMethod = descriptor.value;
220
+ const cache = {};
221
+ descriptor.value = function(arg) {
222
+ const type = typeof arg;
223
+ const isPrimitive = arg === null || type === "string" || type === "number" || type === "boolean" || type === "symbol" || type === "undefined";
224
+ if (!isPrimitive) {
225
+ return originalMethod.call(this, arg);
226
+ }
227
+ const key = String(arg);
228
+ if (Object.prototype.hasOwnProperty.call(cache, key)) {
229
+ return cache[key];
230
+ }
231
+ const result = originalMethod.call(this, arg);
232
+ cache[key] = result;
233
+ return result;
234
+ };
235
+ return descriptor;
236
+ }
@@ -183,6 +183,25 @@ function RetryAsync(retries = 3, interval = 2e3, reThrowException = true) {
183
183
  return descriptor;
184
184
  };
185
185
  }
186
+ function MemoizeSingleArgPrimitive(_target, _propertyKey, descriptor) {
187
+ const originalMethod = descriptor.value;
188
+ const cache = {};
189
+ descriptor.value = function(arg) {
190
+ const type = typeof arg;
191
+ const isPrimitive = arg === null || type === "string" || type === "number" || type === "boolean" || type === "symbol" || type === "undefined";
192
+ if (!isPrimitive) {
193
+ return originalMethod.call(this, arg);
194
+ }
195
+ const key = String(arg);
196
+ if (Object.prototype.hasOwnProperty.call(cache, key)) {
197
+ return cache[key];
198
+ }
199
+ const result = originalMethod.call(this, arg);
200
+ cache[key] = result;
201
+ return result;
202
+ };
203
+ return descriptor;
204
+ }
186
205
  export {
187
206
  AsyncSingleExecution,
188
207
  CacheUntilResolved,
@@ -190,6 +209,7 @@ export {
190
209
  ImmutableArgs,
191
210
  Memoize,
192
211
  MemoizeAsync,
212
+ MemoizeSingleArgPrimitive,
193
213
  QueueTask,
194
214
  RetryAsync,
195
215
  Throttle
@@ -159,3 +159,19 @@ export declare function AsyncSingleExecution(_target: any, _propertyKey: string,
159
159
  * // Error: Fetch failed
160
160
  */
161
161
  export declare function RetryAsync(retries?: number, interval?: number, reThrowException?: boolean): MethodDecorator;
162
+ /**
163
+ * Memoizes the result of a function with a single primitive argument.
164
+ * Only works for functions that take exactly one primitive argument (string, number, boolean, symbol, null, or undefined).
165
+ * Uses a simple object as the cache.
166
+ * @param _target
167
+ * @param _propertyKey
168
+ * @param descriptor
169
+ * @example
170
+ * class Example {
171
+ * @MemoizeSingleArgPrimitive
172
+ * double(x: number) {
173
+ * return x * 2;
174
+ * }
175
+ * }
176
+ */
177
+ export declare function MemoizeSingleArgPrimitive<T extends string | number | boolean | symbol | null | undefined, R>(_target: any, _propertyKey: string, descriptor: TypedPropertyDescriptor<(arg: T) => R>): TypedPropertyDescriptor<(arg: T) => R>;