@fluid-topics/ft-wc-utils 1.1.26 → 1.1.28

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.
@@ -1,7 +1,7 @@
1
1
  import { Optional, Provider } from "./generic-types";
2
2
  export declare const delay: (ms: number) => Promise<unknown>;
3
- export declare function waitUntil(condition: Provider<boolean | Promise<boolean>>, interval?: number, timeout?: number): Promise<void>;
4
- export declare function waitFor<T>(provider: Provider<Optional<T> | Promise<Optional<T>>>, interval?: number, timeout?: number): Promise<T>;
3
+ export declare function waitUntil(condition: Provider<boolean | Promise<boolean>>, interval?: number, timeout?: Optional<number>): Promise<void>;
4
+ export declare function waitFor<T>(provider: Provider<Optional<T> | Promise<Optional<T>>>, interval?: number, timeout?: Optional<number>): Promise<T>;
5
5
  export declare function flatDeep<T>(arr: Array<T>, getChildren: (o: T) => Array<T>): Array<T>;
6
6
  export declare function dateReviver(...dateKeys: string[]): (key: string, value: any) => any;
7
7
  export declare function parseDate(value: string): Date;
package/build/helpers.js CHANGED
@@ -1,20 +1,20 @@
1
1
  export const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
2
- export async function waitUntil(condition, interval = 5, timeout) {
3
- let value = await condition();
2
+ export async function waitUntil(condition, interval = 10, timeout = 20000) {
3
+ await waitFor(async () => await condition() || undefined, interval, timeout);
4
+ }
5
+ export async function waitFor(provider, interval = 10, timeout = 20000) {
6
+ let value = await provider();
4
7
  let start, now;
5
8
  start = now = performance.now();
6
- while (!value && (!timeout || now - start < timeout)) {
9
+ while (value == null && (!timeout || now - start < timeout)) {
7
10
  await delay(interval);
8
- value = await condition();
11
+ value = await provider();
9
12
  now = performance.now();
10
13
  }
11
14
  if (value == null) {
12
15
  throw new Error("Timeout exceeded");
13
16
  }
14
- }
15
- export async function waitFor(provider, interval = 5, timeout) {
16
- await waitUntil(async () => (await provider()) != null, interval, timeout);
17
- return (await provider());
17
+ return value;
18
18
  }
19
19
  export function flatDeep(arr, getChildren) {
20
20
  return arr.flatMap(o => [o, ...flatDeep(getChildren(o), getChildren)]);
package/build/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export declare const isSafari: boolean;
3
3
  export declare const isTouchScreen: boolean;
4
4
  export * from "./CacheRegistry";
5
5
  export * from "./CancelablePromise";
6
+ export * from "./ClusteringHelper";
6
7
  export * from "./Debouncer";
7
8
  export * from "./decorators";
8
9
  export * from "./designSystemVariables";
package/build/index.js CHANGED
@@ -8,6 +8,7 @@ export const isTouchScreen = (('ontouchstart' in window)
8
8
  || (navigator.msMaxTouchPoints > 0));
9
9
  export * from "./CacheRegistry";
10
10
  export * from "./CancelablePromise";
11
+ export * from "./ClusteringHelper";
11
12
  export * from "./Debouncer";
12
13
  export * from "./decorators";
13
14
  export * from "./designSystemVariables";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-wc-utils",
3
- "version": "1.1.26",
3
+ "version": "1.1.28",
4
4
  "description": "Internal web components tools",
5
5
  "author": "Fluid Topics <devtopics@antidot.net>",
6
6
  "license": "ISC",
@@ -14,8 +14,8 @@
14
14
  ],
15
15
  "dependencies": {
16
16
  "@floating-ui/dom": "1.5.3",
17
- "@fluid-topics/design-system-variables": "0.0.18",
18
- "@fluid-topics/public-api": "1.0.56",
17
+ "@fluid-topics/design-system-variables": "0.0.20",
18
+ "@fluid-topics/public-api": "1.0.57",
19
19
  "@reduxjs/toolkit": "1.9.5",
20
20
  "@types/mark.js": "8.11.12",
21
21
  "@webcomponents/scoped-custom-element-registry": "0.0.9",
@@ -23,5 +23,5 @@
23
23
  "lit": "3.1.0",
24
24
  "mark.js": "8.11.1"
25
25
  },
26
- "gitHead": "6734976f5a7f6b986917a085be0c38ca3ae562a0"
26
+ "gitHead": "8c1055ddd23e83efa3833f033a507aa1ab32fecc"
27
27
  }