/** * Copyright 2021 Insta Industries, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. */ /** * A completer provides a `Promise` and handlers to either resolve or fail * the promise. * * It's useful to interop with non-async APIs. e.g. listening for an event * and resolving the promise accordingly. */ export declare class Completer { constructor(); resolve(value: T): any; fail(reason: any): any; get promise(): Promise; get isCompleted(): boolean; get isCompletedSuccessfully(): boolean; private p; private resolveCb; private failCb; private completed; private succeeded; private resolvedValue; } /** * A CompleterGroup allows to register a set of completers, and obtain * a promise that resolves when all the completers promises are resolved. * * It's similar to having your list of Completers, and then calling * `Promise.all` on all the promises. */ export declare class CompleterGroup { add(): () => any; hasPendingWork(): boolean; waitUntilDone(): Promise; private completers; } /** * Sleeps for `timeMs` milliseconds. * * @param setTimeout The timeout function. * @param timeMs The time to sleep in ms. */ export declare function sleep(setTimeout: (hander: TimerHandler, timeout?: number) => any, timeMs: number): Promise;