@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.
@@ -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
- // eslint-disable-next-line @typescript-eslint/ban-types
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
+ }