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

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.20240904040710",
3
+ "version": "4.18.3-next.20240906040640",
4
4
  "description": "TypeDefinitions for ct-mapapps",
5
5
  "author": "conterra",
6
6
  "license": "Apache-2.0"
@@ -16,7 +16,7 @@ import Promise$1 from 'apprt-core/Promise';
16
16
  * // check state
17
17
  * });
18
18
  * }
19
- * @deprecated use {@link waitFor} instead.
19
+ * @deprecated use {@link test-utils/waitFor} instead.
20
20
  */
21
21
  declare function later(cb?: number | Function | undefined, delay?: number | undefined): Promise$1<any>;
22
22
  /**
@@ -36,7 +36,7 @@ declare function later(cb?: number | Function | undefined, delay?: number | unde
36
36
  * // check state
37
37
  * });
38
38
  * }
39
- * @deprecated use {@link waitFor} instead.
39
+ * @deprecated use {@link test-utils/waitFor} instead.
40
40
  */
41
41
  declare function customDelay(delay: number): Function;
42
42
 
@@ -1,17 +1,27 @@
1
+ /** Options supported by {@link waitFor} and {@link waitUntil}. */
2
+ interface WaitOptions {
3
+ /** The maximum time to wait for the resolver to be fulfilled. Default is 150ms. */
4
+ timeout?: number;
5
+ /** The interval in milliseconds to check the resolver. Default is 5ms. */
6
+ interval?: number;
7
+ /** The maximum number of checks to perform. */
8
+ maxChecks?: number;
9
+ }
1
10
  /**
2
- * Waits for a resolver to return a thing.
11
+ * Waits for a resolver to return a value.
12
+ * Continues checking until `resolver` does _not_ throw an error.
13
+ *
3
14
  * @param resolver The condition/resolver to be fulfilled.
4
15
  * 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}.
16
+ *
11
17
  * @returns A promise that transports the value of the resolver.
18
+ *
12
19
  * @throws An error if the condition is not fulfilled within the specified timeout.
20
+ *
13
21
  * @example
14
22
  * ```ts
23
+ * import { waitFor } from "test-utils/waitFor";
24
+ *
15
25
  * const result = await waitFor(() => {
16
26
  * const value = getValue();
17
27
  * if (value === undefined) {
@@ -22,25 +32,21 @@
22
32
  * assert.equal(result, "myValue");
23
33
  * ```
24
34
  */
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>;
35
+ declare function waitFor<T>(resolver: () => Promise<T> | T, options?: WaitOptions): Promise<T>;
36
+ type Falsy = false | 0 | null | undefined;
37
+ type NonFalsy<T> = Exclude<T, Falsy>;
31
38
  /**
32
- * This function behaves like {@link waitFor} but it will reject the promise if the resolver throws an error.
39
+ * This function is similar to like {@link waitFor} but it will wait until the `resolver` returns a truthy value.
40
+ * If the `resolver` throws an error, the function rejects immediately.
41
+ *
33
42
  * @see waitFor
34
43
  */
35
- declare function waitUntil<T>(resolver: () => Promise<T> | T, options?: {
36
- timeout?: number;
37
- interval?: number;
38
- maxChecks?: number;
39
- }): Promise<T>;
44
+ declare function waitUntil<T>(resolver: () => Promise<T> | T, options?: WaitOptions): Promise<NonFalsy<T>>;
40
45
  /**
41
- * Waits for a certain amount of time.
42
- * @param timeout The time to wait in seconds.
46
+ * Sleeps for a certain amount of time.
47
+ *
48
+ * @param timeout The time to wait in milliseconds.
43
49
  */
44
- declare function wait(timeout?: number): Promise<void>;
50
+ declare function sleep(timeout?: number): Promise<void>;
45
51
 
46
- export { wait, waitFor, waitUntil };
52
+ export { type WaitOptions, sleep, waitFor, waitUntil };
@@ -23,6 +23,7 @@ import Promise$1 from 'apprt-core/CancelablePromise';
23
23
  * (v) => v === 1,
24
24
  * {timeout:100});
25
25
  * assert.equal(value, 1);
26
+ * @deprecated use {@link test-utils/waitFor} instead.
26
27
  */
27
28
  declare function waitForProperty(mutable: Mutable | Accessor | Stateful, property: string, comparatorOrExpectedValue?: Function | undefined | value, { timeout }?: Object | undefined): Promise$1<any>;
28
29