24 lines
582 B
JavaScript
24 lines
582 B
JavaScript
import dayjs from "dayjs";
|
|
import parseTwtxt from "./parseTwtxt.js";
|
|
async function loadAndParseTwtxtFile(url = "") {
|
|
if (!url) throw new Error("URL is required");
|
|
try {
|
|
const response = await fetch(url);
|
|
const twtxtFile = await response.text();
|
|
const lastModified = dayjs(
|
|
response.headers.get("Last-Modified")
|
|
).toISOString();
|
|
return {
|
|
...parseTwtxt(twtxtFile),
|
|
lastModified
|
|
};
|
|
} catch (err) {
|
|
console.error(err);
|
|
throw err;
|
|
}
|
|
}
|
|
export {
|
|
loadAndParseTwtxtFile as default
|
|
};
|
|
//# sourceMappingURL=loadAndParseTwtxt.js.map
|