@rango-dev/widget-embedded 0.39.1-next.17 → 0.39.1-next.18
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.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/store/middlewares/keepLastUpdated.d.ts +8 -0
- package/dist/store/middlewares/keepLastUpdated.d.ts.map +1 -0
- package/dist/store/slices/wallets.d.ts +5 -7
- package/dist/store/slices/wallets.d.ts.map +1 -1
- package/dist/utils/common.d.ts +5 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +8 -8
- package/src/store/middlewares/keepLastUpdated.ts +19 -0
- package/src/store/slices/wallets.ts +532 -504
- package/src/utils/common.ts +24 -2
package/src/utils/common.ts
CHANGED
|
@@ -26,10 +26,12 @@ export function areEqual(
|
|
|
26
26
|
array1.length === array2.length && array1.every((v, i) => v === array2[i])
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
30
31
|
export function debounce(fn: Function, time: number) {
|
|
31
32
|
let timeoutId: ReturnType<typeof setTimeout> | null;
|
|
32
33
|
return wrapper;
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
35
|
function wrapper(...args: any) {
|
|
34
36
|
if (timeoutId) {
|
|
35
37
|
clearTimeout(timeoutId);
|
|
@@ -42,7 +44,6 @@ export function debounce(fn: Function, time: number) {
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
export function containsText(text: string, searchText: string): boolean {
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
46
47
|
return text.toLowerCase().indexOf(searchText.toLowerCase()) > -1;
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -258,3 +259,24 @@ export function isSingleWalletActive(
|
|
|
258
259
|
);
|
|
259
260
|
return multiWallets === false && atLeastOneWalletIsConnected;
|
|
260
261
|
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* A simple memo implementation
|
|
265
|
+
* you can use it when you want to memoize a value in js space
|
|
266
|
+
*/
|
|
267
|
+
export function memoizedResult(): <R>(fn: () => R, key: number | string) => R {
|
|
268
|
+
let currentKey: number | string;
|
|
269
|
+
|
|
270
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
271
|
+
let result: any;
|
|
272
|
+
|
|
273
|
+
return (fn, key) => {
|
|
274
|
+
if (!result || !currentKey || currentKey !== key) {
|
|
275
|
+
currentKey = key;
|
|
276
|
+
result = fn();
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return result;
|
|
281
|
+
};
|
|
282
|
+
}
|