"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.timeoutPromise = exports.isCatchable = exports.isPromise = void 0;
function isPromise(value) {
    return value && typeof value.then === 'function';
}
exports.isPromise = isPromise;
function isCatchable(value) {
    return value && typeof value.catch === 'function';
}
exports.isCatchable = isCatchable;
function timeoutPromise(promise, timeoutMs) {
    let timer;
    return Promise.race([
        promise,
        new Promise((_res, rej) => {
            timer = setTimeout(() => rej(new Error('Timeout')), timeoutMs);
        })
    ]).finally(() => clearTimeout(timer));
}
exports.timeoutPromise = timeoutPromise;
//# sourceMappingURL=promises.js.map