kitten-cloud-function
Version:
用于编程猫源码云功能(云变量、云列表等)的客户端工具
38 lines (37 loc) • 1.08 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.CodemaoUserSex = void 0;
/** 用户性别。*/ class CodemaoUserSex {
static from(argument) {
if (argument instanceof CodemaoUserSex) {
return argument;
}
return CodemaoUserSex.parse(argument);
}
static parse(type) {
if (typeof type == "number") {
type = type.toString();
}
type = type.toUpperCase();
if (!(type in sexMap)) {
throw new Error(`无法识别的用户性别:${type}`);
}
return sexMap[type];
}
constructor(name) {
this.name = name;
this.symbol = Symbol(name);
}
toString() {
return this.name;
}
}
exports.CodemaoUserSex = CodemaoUserSex;
/** 男性。*/ CodemaoUserSex.MALE = new CodemaoUserSex("男");
/** 女性。*/ CodemaoUserSex.FEMALE = new CodemaoUserSex("女");
const sexMap = {
"1": CodemaoUserSex.MALE,
"MALE": CodemaoUserSex.MALE,
"0": CodemaoUserSex.FEMALE,
"FEMALE": CodemaoUserSex.FEMALE
};
;