UNPKG

538 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.requestTimeout = void 0;
4function requestTimeout(timeoutInMs = 0) {
5 return new Promise((resolve, reject) => {
6 if (timeoutInMs) {
7 setTimeout(() => {
8 const timeoutError = new Error(`Request did not complete within ${timeoutInMs} ms`);
9 timeoutError.name = "TimeoutError";
10 reject(timeoutError);
11 }, timeoutInMs);
12 }
13 });
14}
15exports.requestTimeout = requestTimeout;