2 * Waits for specific condition to be true.
3 * The promise is rejected if the signal is aborted.
5 export const waitUntil = (conditionFn: () => boolean, abortSignal?: AbortSignal) => {
6 return new Promise<void>((resolve, reject) => {
7 const waitForCondition = () => {
8 if (abortSignal?.aborted) {
9 return reject(new Error('Wait aborted'));
14 setTimeout(waitForCondition, 50);
21 export const getSuccessfulSettled = <T>(results: PromiseSettledResult<T>[]) => {
22 const values: T[] = [];
23 results.forEach((result) => {
24 if (result.status === 'fulfilled') {
25 values.push(result.value);
27 console.error(result.reason);
33 export const logSettledErrors = <T>(results: PromiseSettledResult<T>[]) => {
34 results.forEach((result) => {
35 if (result.status === 'rejected') {
36 console.error(result.reason);