sheets/lib.ts
yourfriendoss f5973ba5a0
Some checks failed
Sheets Deploy Hook / notify (push) Has been cancelled
get rid of sheets frontend, use typescript, use ndjson
2025-12-12 02:22:48 +02:00

57 lines
1.2 KiB
TypeScript

export const thIgnore = [
"🎹Worst Comps & Edits",
"🎹 Yedits",
"🎹 Comps & Edits",
"Comps & Edits",
"Worst Comps & Edits",
"Yedits",
"K4$H K4$$!N0",
"K4HKn0",
"AI Models",
"🎹 BPM & Key Tracker",
"🎹Comps & Edits",
"🎹 Worst Comps & Edits",
"Allegations",
"Rap Disses Timeline",
"Underground Artists",
"bpmkeytracker",
]
export enum TripleBool {
MOSTLY = 2,
YES = 1,
NO = 0
}
const TripleBoolStrings: Record<TripleBool, string> = {
[TripleBool.MOSTLY]: "Mostly",
[TripleBool.YES]: "Yes",
[TripleBool.NO]: "No",
};
export function tripleBoolToString(v: TripleBool): string {
return TripleBoolStrings[v];
}
export function tripleBool(bool: string): TripleBool {
if(bool.toLowerCase() == "mostly") {
return TripleBool.MOSTLY;
} else if(bool.toLowerCase() == "yes") {
return TripleBool.YES
} else if(bool.toLowerCase() == "no") {
return TripleBool.NO
}
throw new Error("tripleBool conversion function errored, mysteriously! Passed in: " + bool)
}
export function ndjsonToJson(ndjson: string): any[] {
return ndjson.split("\n").map(z => {
try {
return JSON.parse(z)
} catch {
return undefined;
}
}).filter(Boolean);
}