23 lines
571 B
JavaScript
23 lines
571 B
JavaScript
// src/components/include/request.ts
|
|
var includeFiles = /* @__PURE__ */ new Map();
|
|
function requestInclude(src, mode = "cors") {
|
|
const prev = includeFiles.get(src);
|
|
if (prev !== void 0) {
|
|
return Promise.resolve(prev);
|
|
}
|
|
const fileDataPromise = fetch(src, { mode }).then(async (response) => {
|
|
const res = {
|
|
ok: response.ok,
|
|
status: response.status,
|
|
html: await response.text()
|
|
};
|
|
includeFiles.set(src, res);
|
|
return res;
|
|
});
|
|
includeFiles.set(src, fileDataPromise);
|
|
return fileDataPromise;
|
|
}
|
|
|
|
export {
|
|
requestInclude
|
|
};
|