@conterra/ct-mapapps-typings 4.18.3-next.20240903035319 → 4.18.3-next.20240904040710

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conterra/ct-mapapps-typings",
3
- "version": "4.18.3-next.20240903035319",
3
+ "version": "4.18.3-next.20240904040710",
4
4
  "description": "TypeDefinitions for ct-mapapps",
5
5
  "author": "conterra",
6
6
  "license": "Apache-2.0"
@@ -16,6 +16,7 @@ import Promise$1 from 'apprt-core/Promise';
16
16
  * // check state
17
17
  * });
18
18
  * }
19
+ * @deprecated use {@link waitFor} instead.
19
20
  */
20
21
  declare function later(cb?: number | Function | undefined, delay?: number | undefined): Promise$1<any>;
21
22
  /**
@@ -35,6 +36,7 @@ declare function later(cb?: number | Function | undefined, delay?: number | unde
35
36
  * // check state
36
37
  * });
37
38
  * }
39
+ * @deprecated use {@link waitFor} instead.
38
40
  */
39
41
  declare function customDelay(delay: number): Function;
40
42
 
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Waits for a resolver to return a thing.
3
+ * @param resolver The condition/resolver to be fulfilled.
4
+ * The resolver needs to throw an error to communicate that the value is not yet ready.
5
+ * @param options Options for the wait.
6
+ * @param options.timeout The maximum time to wait for the resolver to be fulfilled. Default is 150ms.
7
+ * @param options.interval The interval in milliseconds to check the resolver. Default is 5ms.
8
+ * @param options.maxChecks The maximum number of checks to perform.
9
+ * @param options.failOnError If true, the promise will be rejected if the resolver throws an error,
10
+ * this behavior is the same as {@link waitUntil}.
11
+ * @returns A promise that transports the value of the resolver.
12
+ * @throws An error if the condition is not fulfilled within the specified timeout.
13
+ * @example
14
+ * ```ts
15
+ * const result = await waitFor(() => {
16
+ * const value = getValue();
17
+ * if (value === undefined) {
18
+ * throw new Error("Value not ready");
19
+ * }
20
+ * return value;
21
+ * });
22
+ * assert.equal(result, "myValue");
23
+ * ```
24
+ */
25
+ declare function waitFor<T>(resolver: () => Promise<T> | T, options?: {
26
+ timeout?: number;
27
+ interval?: number;
28
+ maxChecks?: number;
29
+ failOnError?: boolean;
30
+ }): Promise<T>;
31
+ /**
32
+ * This function behaves like {@link waitFor} but it will reject the promise if the resolver throws an error.
33
+ * @see waitFor
34
+ */
35
+ declare function waitUntil<T>(resolver: () => Promise<T> | T, options?: {
36
+ timeout?: number;
37
+ interval?: number;
38
+ maxChecks?: number;
39
+ }): Promise<T>;
40
+ /**
41
+ * Waits for a certain amount of time.
42
+ * @param timeout The time to wait in seconds.
43
+ */
44
+ declare function wait(timeout?: number): Promise<void>;
45
+
46
+ export { wait, waitFor, waitUntil };