Skip to content

Commit

Permalink
ref: some minor details
Browse files Browse the repository at this point in the history
  • Loading branch information
Sv443 committed Feb 24, 2025
1 parent 468927d commit 693843a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/serializer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataStoreSerializer } from "@sv443-network/userutils";
import { DataStoreSerializer, type Stringifiable } from "@sv443-network/userutils";

import { configStore } from "./config.js";
import { autoLikeStore } from "./features/input.js";
Expand Down Expand Up @@ -59,10 +59,10 @@ export async function importData(blob: File | Blob) {
export async function downloadData() {
const serializer = getStoreSerializer();

const pad = (num: number, len = 2) => String(num).padStart(len, "0");
const pad = (val: Stringifiable, len = 2) => String(val).padStart(len, "0");

const d = new Date();
const dateStr = `${pad(d.getFullYear(), 4)}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}_${pad(d.getHours())}-${pad(d.getMinutes())}`;
const dateStr = `${pad(d.getFullYear(), 4)}${pad(d.getMonth() + 1)}${pad(d.getDate())}_${pad(d.getHours())}${pad(d.getMinutes())}`;
const fileName = `BetterYTM ${packageJson.version} data export ${dateStr}.json`;

const data = JSON.stringify(JSON.parse(await serializer.serialize()), undefined, 2);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xhr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function constructUrlString(baseUrl: string, params: Record<string, Strin
/**
* Constructs a URL object from a base URL and a record of query parameters.
* If a value is null, the parameter will be valueless. If a value is undefined, the parameter will be omitted.
* All values will be URI-encoded.
* All values will be stringified and then URI-encoded.
* @returns Returns a URL object instead of a string
*/
export function constructUrl(base: string, params: Record<string, Stringifiable | null>) {
Expand Down

0 comments on commit 693843a

Please sign in to comment.