UNPKG

read-vietnamese-number

Version:
46 lines (45 loc) 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReadingConfig = exports.InvalidNumberError = exports.ReadVietnameseNumberError = void 0; /** * The base error class for all errors in the library. */ class ReadVietnameseNumberError extends Error { } exports.ReadVietnameseNumberError = ReadVietnameseNumberError; /** * The error class used when the input number is invalid. */ class InvalidNumberError extends ReadVietnameseNumberError { } exports.InvalidNumberError = InvalidNumberError; /** * The reading configuration class containing default options for reading numbers. */ class ReadingConfig { constructor() { // Input parsing options this.negativeSign = '-'; this.pointSign = '.'; // point/comma this.thousandSign = ','; // comma/point/space // Output building options this.separator = ' '; // space/newline/tab this.unit = ['đơn', 'vị']; // đơn vị/đồng this.units = [[], ['nghìn'], ['triệu'], ['tỉ']]; // nghìn/ngàn, tỉ/tỷ this.digits = ['không', 'một', 'hai', 'ba', 'bốn', 'năm', 'sáu', 'bảy', 'tám', 'chín']; // bảy/bẩy this.negativeText = 'âm'; // âm/trừ this.pointText = 'chấm'; // chấm/phẩy this.oddText = 'lẻ'; // lẻ/linh this.tenText = 'mười'; this.hundredText = 'trăm'; this.oneToneText = 'mốt'; this.fourToneText = 'tư'; // tư/bốn this.fiveToneText = 'lăm'; this.tenToneText = 'mươi'; // Conditional options this.skipTenTone = false; } } exports.ReadingConfig = ReadingConfig; ReadingConfig.PERIOD_SIZE = 3; ReadingConfig.FILLED_DIGIT = '0';