@tf2pickup-org/serveme-tf-client
Version:
A serveme.tf API client
17 lines • 594 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.withTimeout = void 0;
const timeout_error_1 = require("./errors/timeout.error");
const withTimeout = async (promise, timeoutMs) => {
let timeout;
return Promise.race([
promise,
new Promise((_resolve, reject) => {
timeout = setTimeout(() => {
reject(new timeout_error_1.TimeoutError(timeoutMs));
}, timeoutMs);
}),
]).finally(() => clearTimeout(timeout));
};
exports.withTimeout = withTimeout;
//# sourceMappingURL=with-timeout.js.map