/**
 * Races a promise against a timer. Rejects with `message` if the timer
 * fires before the promise settles.
 *
 * @internal Not part of the public `@stigmer/react` API.
 */
export function withTimeout(promise, ms, message) {
    return new Promise((resolve, reject) => {
        const timer = setTimeout(() => reject(new Error(message)), ms);
        promise.then((value) => {
            clearTimeout(timer);
            resolve(value);
        }, (reason) => {
            clearTimeout(timer);
            reject(reason);
        });
    });
}
//# sourceMappingURL=withTimeout.js.map