UNPKG

@tf2pickup-org/serveme-tf-client

Version:
17 lines 594 B
"use strict"; 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