@elliemae/pui-app-sdk 5.25.1 → 5.26.1
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/cjs/utils/decorators/functionDecorators.js +20 -0
- package/dist/cjs/utils/decorators/index.js +1 -0
- package/dist/esm/utils/decorators/functionDecorators.js +20 -0
- package/dist/esm/utils/decorators/index.js +3 -1
- package/dist/types/lib/utils/decorators/functionDecorators.d.ts +16 -0
- package/dist/types/lib/utils/decorators/index.d.ts +2 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -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
|
+
}
|
|
@@ -34,6 +34,7 @@ const decorators = {
|
|
|
34
34
|
ImmutableArgs: import_functionDecorators.ImmutableArgs,
|
|
35
35
|
Memoize: import_functionDecorators.Memoize,
|
|
36
36
|
MemoizeAsync: import_functionDecorators.MemoizeAsync,
|
|
37
|
+
MemoizeSingleArgPrimitive: import_functionDecorators.MemoizeSingleArgPrimitive,
|
|
37
38
|
QueueTask: import_functionDecorators.QueueTask,
|
|
38
39
|
Throttle: import_functionDecorators.Throttle,
|
|
39
40
|
AsyncSingleExecution: import_functionDecorators.AsyncSingleExecution,
|
|
@@ -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
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
MemoizeAsync,
|
|
9
9
|
QueueTask,
|
|
10
10
|
Throttle,
|
|
11
|
-
RetryAsync
|
|
11
|
+
RetryAsync,
|
|
12
|
+
MemoizeSingleArgPrimitive
|
|
12
13
|
} from "./functionDecorators.js";
|
|
13
14
|
const decorators = {
|
|
14
15
|
class: {
|
|
@@ -21,6 +22,7 @@ const decorators = {
|
|
|
21
22
|
ImmutableArgs,
|
|
22
23
|
Memoize,
|
|
23
24
|
MemoizeAsync,
|
|
25
|
+
MemoizeSingleArgPrimitive,
|
|
24
26
|
QueueTask,
|
|
25
27
|
Throttle,
|
|
26
28
|
AsyncSingleExecution,
|
|
@@ -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>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mixins, Singleton } from './classDecorators.js';
|
|
2
|
-
import { AsyncSingleExecution, CacheUntilResolved, Debounce, ImmutableArgs, Memoize, MemoizeAsync, QueueTask, Throttle, RetryAsync } from './functionDecorators.js';
|
|
2
|
+
import { AsyncSingleExecution, CacheUntilResolved, Debounce, ImmutableArgs, Memoize, MemoizeAsync, QueueTask, Throttle, RetryAsync, MemoizeSingleArgPrimitive } from './functionDecorators.js';
|
|
3
3
|
declare const decorators: {
|
|
4
4
|
class: {
|
|
5
5
|
Mixins: typeof Mixins;
|
|
@@ -11,6 +11,7 @@ declare const decorators: {
|
|
|
11
11
|
ImmutableArgs: typeof ImmutableArgs;
|
|
12
12
|
Memoize: typeof Memoize;
|
|
13
13
|
MemoizeAsync: typeof MemoizeAsync;
|
|
14
|
+
MemoizeSingleArgPrimitive: typeof MemoizeSingleArgPrimitive;
|
|
14
15
|
QueueTask: typeof QueueTask;
|
|
15
16
|
Throttle: typeof Throttle;
|
|
16
17
|
AsyncSingleExecution: typeof AsyncSingleExecution;
|