feat: reduce file exporter size
parent
a210395975
commit
dbc0985211
|
|
@ -10,6 +10,15 @@ type FileExporterType = {
|
|||
data: VsBattle;
|
||||
};
|
||||
|
||||
/**
|
||||
* Don't save url in exported file
|
||||
*/
|
||||
function replacer(key: string, value: unknown): unknown {
|
||||
return ["url", "maskImageUrl", "overlayImageUrl"].includes(key)
|
||||
? undefined
|
||||
: value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exporter to file.
|
||||
*
|
||||
|
|
@ -26,6 +35,10 @@ export class FileExporter implements BattleExporter<VsBattle> {
|
|||
fullId.slice(fullId.length - 52, fullId.length - 37),
|
||||
);
|
||||
|
||||
if (!/\d{8}T\d{6}/.test(ts)) {
|
||||
throw new Error("Invalid battle ID");
|
||||
}
|
||||
|
||||
return `${ts}Z.json`;
|
||||
}
|
||||
async exportBattle(battle: VsBattle) {
|
||||
|
|
@ -42,7 +55,10 @@ export class FileExporter implements BattleExporter<VsBattle> {
|
|||
data: battle,
|
||||
};
|
||||
|
||||
await Deno.writeTextFile(filepath, JSON.stringify(body));
|
||||
await Deno.writeTextFile(
|
||||
filepath,
|
||||
JSON.stringify(body, replacer),
|
||||
);
|
||||
}
|
||||
async notExported(list: string[]): Promise<string[]> {
|
||||
const out: string[] = [];
|
||||
|
|
|
|||
Loading…
Reference in New Issue