renovate
Version:
Automated dependency updates. Flexible so you don't need to be.
27 lines (26 loc) • 915 B
JavaScript
import { decompressFromBase64, decompressFromBuffer } from "../../compress.js";
import { DateTime } from "luxon";
//#region lib/util/cache/package/legacy.ts
async function decodeLegacyEntry(data) {
if (data[0] === 123) return await decodeLegacyJsonEntry(data);
return await decodeLegacySqliteEntry(data);
}
async function decodeLegacyJsonEntry(data) {
const cached = JSON.parse(data.toString("utf8"));
if (typeof cached.value !== "string" || typeof cached.expiry !== "string") throw new Error("Invalid legacy JSON package cache entry");
const json = await decompressFromBase64(cached.value);
return {
value: JSON.parse(json),
expiry: DateTime.fromISO(cached.expiry)
};
}
async function decodeLegacySqliteEntry(data) {
const json = await decompressFromBuffer(data);
return {
value: JSON.parse(json),
expiry: void 0
};
}
//#endregion
export { decodeLegacyEntry };
//# sourceMappingURL=legacy.js.map