impress-2020/src/server/util.js

30 lines
661 B
JavaScript
Raw Normal View History

2020-04-25 04:33:05 -07:00
function capitalize(str) {
return str[0].toUpperCase() + str.slice(1);
}
function getEmotion(moodId) {
if (moodId === "1") {
return "HAPPY";
} else if (moodId === "2") {
return "SAD";
} else if (moodId === "4") {
return "SICK";
} else if (moodId === null) {
return null;
} else {
throw new Error(`unrecognized moodId ${JSON.stringify(moodId)}`);
}
}
function getGenderPresentation(modelPetWasFemale) {
if (modelPetWasFemale === 1) {
return "FEMININE";
} else if (modelPetWasFemale === 0) {
return "MASCULINE";
} else {
return null;
}
}
module.exports = { capitalize, getEmotion, getGenderPresentation };