UNPKG

chinese-numbering

Version:
40 lines (36 loc) 1.03 kB
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; } } export { normalizeChineseType, normalizeOptions }; //# sourceMappingURL=options.js.map