read-vietnamese-number
Version:
Đọc số thành chữ trong Tiếng Việt
31 lines (30 loc) • 1.02 kB
JavaScript
export class RvnError extends Error {
}
export class InvalidFormatError extends RvnError {
}
export class InvalidNumberError extends RvnError {
}
export class NotEnoughUnitError extends RvnError {
}
export class ReadingConfig {
constructor() {
this.separator = ' ';
this.unit = ['đơn', 'vị'];
this.negativeSign = '-';
this.pointSign = '.';
this.thousandSign = ',';
this.periodSize = 3;
this.filledDigit = '0';
this.digits = ['không', 'một', 'hai', 'ba', 'bốn', 'năm', 'sáu', 'bảy', 'tám', 'chín'];
this.units = [[], ['nghìn'], ['triệu'], ['tỉ'], ['nghìn', 'tỉ'], ['triệu', 'tỉ'], ['tỉ', 'tỉ']];
this.negativeText = 'âm';
this.pointText = 'chấm';
this.oddText = 'lẻ';
this.tenText = 'mười';
this.hundredText = 'trăm';
this.oneToneText = 'mốt';
this.fourToneText = 'tư';
this.fiveToneText = 'lăm';
this.tenToneText = 'mươi';
}
}