chinese-numbering
Version:
format numbers as chinese words
45 lines (39 loc) • 1.16 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
const DEFAULT_OPTIONS = Object.freeze({
chineseType: "simplified",
keepOne: false
});
function normalizeChineseType(type) {
switch (type) {
case "s":
return "simplified";
case "t":
return "traditional";
default:
return type;
}
}
function normalizeOptions(opts) {
if (typeof opts === "boolean") {
return {
chineseType: opts ? "traditional" : "simplified",
keepOne: DEFAULT_OPTIONS.keepOne
};
} else if (typeof opts === "string") {
return {
chineseType: normalizeChineseType(opts),
keepOne: DEFAULT_OPTIONS.keepOne
};
} else if (typeof opts === "object" && opts !== null) {
return {
chineseType: typeof opts.chineseType === "string" ? normalizeChineseType(opts.chineseType) : DEFAULT_OPTIONS.chineseType,
keepOne: typeof opts.keepOne === "undefined" ? DEFAULT_OPTIONS.keepOne : !!opts.keepOne
};
} else {
return DEFAULT_OPTIONS;
}
}
exports.normalizeChineseType = normalizeChineseType;
exports.normalizeOptions = normalizeOptions;
//# sourceMappingURL=options.js.map