UNPKG

463 BJavaScriptView Raw
1export function requestTimeout(timeoutInMs) {
2 if (timeoutInMs === void 0) { timeoutInMs = 0; }
3 return new Promise(function (resolve, reject) {
4 if (timeoutInMs) {
5 setTimeout(function () {
6 var timeoutError = new Error("Request did not complete within ".concat(timeoutInMs, " ms"));
7 timeoutError.name = "TimeoutError";
8 reject(timeoutError);
9 }, timeoutInMs);
10 }
11 });
12}