UNPKG

packdir-cli

Version:
20 lines 725 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.type = void 0; /// <reference lib="DOM" /> exports.type = 'blob'; const fetchable = async (url, timeout) => { const controller = typeof AbortController !== "undefined" ? new AbortController() : {}; const out = setTimeout(() => controller.abort && controller.abort(), timeout); try { const res = await fetch(url, { signal: controller.signal }); if (!res.ok) throw new Error(`Got error ${res.status} (${res.statusText}) while fetching ${url}`); return res.blob(); } finally { clearTimeout(out); } }; exports.default = fetchable; //# sourceMappingURL=fetchable-browser.js.map