MCPcopy Index your code
hub / github.com/monkeytypegame/monkeytype / getMode2

Function getMode2

frontend/src/ts/utils/misc.ts:237–259  ·  view source on GitHub ↗
(
  config: Config,
  randomQuote: { id: number } | null,
)

Source from the content-addressed store, hash-verified

235}
236
237export function getMode2<M extends keyof PersonalBests>(
238 config: Config,
239 randomQuote: { id: number } | null,
240): Mode2<M> {
241 const mode = config.mode;
242 let retVal: string;
243
244 if (mode === "time") {
245 retVal = config.time.toString();
246 } else if (mode === "words") {
247 retVal = config.words.toString();
248 } else if (mode === "custom") {
249 retVal = "custom";
250 } else if (mode === "zen") {
251 retVal = "zen";
252 } else if (mode === "quote") {
253 retVal = `${randomQuote?.id ?? -1}`;
254 } else {
255 throw new Error("Invalid mode");
256 }
257
258 return retVal as Mode2<M>;
259}
260
261export async function downloadResultsCSV(array: Result<Mode>[]): Promise<void> {
262 const csvString = [

Callers 6

urlFunction · 0.90
mode2subtextFunction · 0.90
PbNoticeFunction · 0.90
test.tsFile · 0.90
buildEventLogFunction · 0.90

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected