mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-27 08:13:28 +08:00
default values, added throw in case of missing data
This commit is contained in:
parent
d44e4f7a12
commit
e31b708082
1 changed files with 8 additions and 4 deletions
|
@ -68,12 +68,16 @@ function updatePersonalBest(
|
|||
return false;
|
||||
}
|
||||
|
||||
personalBest.acc = result.acc;
|
||||
personalBest.consistency = result.consistency;
|
||||
personalBest.difficulty = result.difficulty;
|
||||
personalBest.language = result.language;
|
||||
if (!result.acc || !result.consistency || !result.rawWpm || !result.wpm) {
|
||||
throw new Error("Missing result data");
|
||||
}
|
||||
|
||||
personalBest.difficulty = result.difficulty ?? "normal";
|
||||
personalBest.language = result.language ?? "english";
|
||||
personalBest.punctuation = result.punctuation ?? false;
|
||||
personalBest.lazyMode = result.lazyMode ?? false;
|
||||
personalBest.acc = result.acc;
|
||||
personalBest.consistency = result.consistency;
|
||||
personalBest.raw = result.rawWpm;
|
||||
personalBest.wpm = result.wpm;
|
||||
personalBest.timestamp = Date.now();
|
||||
|
|
Loading…
Reference in a new issue