n2words 1.23.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +317 -59
- package/dist/ArabicConverter.js +3 -0
- package/dist/ArabicConverter.js.map +1 -0
- package/dist/AzerbaijaniConverter.js +3 -0
- package/dist/AzerbaijaniConverter.js.map +1 -0
- package/dist/BanglaConverter.js +3 -0
- package/dist/BanglaConverter.js.map +1 -0
- package/dist/BiblicalHebrewConverter.js +3 -0
- package/dist/BiblicalHebrewConverter.js.map +1 -0
- package/dist/CroatianConverter.js +3 -0
- package/dist/CroatianConverter.js.map +1 -0
- package/dist/CzechConverter.js +3 -0
- package/dist/CzechConverter.js.map +1 -0
- package/dist/DanishConverter.js +3 -0
- package/dist/DanishConverter.js.map +1 -0
- package/dist/DutchConverter.js +3 -0
- package/dist/DutchConverter.js.map +1 -0
- package/dist/EnglishConverter.js +3 -0
- package/dist/EnglishConverter.js.map +1 -0
- package/dist/FilipinoConverter.js +3 -0
- package/dist/FilipinoConverter.js.map +1 -0
- package/dist/FrenchBelgiumConverter.js +3 -0
- package/dist/FrenchBelgiumConverter.js.map +1 -0
- package/dist/FrenchConverter.js +3 -0
- package/dist/FrenchConverter.js.map +1 -0
- package/dist/GermanConverter.js +3 -0
- package/dist/GermanConverter.js.map +1 -0
- package/dist/GreekConverter.js +3 -0
- package/dist/GreekConverter.js.map +1 -0
- package/dist/GujaratiConverter.js +3 -0
- package/dist/GujaratiConverter.js.map +1 -0
- package/dist/HebrewConverter.js +3 -0
- package/dist/HebrewConverter.js.map +1 -0
- package/dist/HindiConverter.js +3 -0
- package/dist/HindiConverter.js.map +1 -0
- package/dist/HungarianConverter.js +3 -0
- package/dist/HungarianConverter.js.map +1 -0
- package/dist/IndonesianConverter.js +3 -0
- package/dist/IndonesianConverter.js.map +1 -0
- package/dist/ItalianConverter.js +3 -0
- package/dist/ItalianConverter.js.map +1 -0
- package/dist/JapaneseConverter.js +3 -0
- package/dist/JapaneseConverter.js.map +1 -0
- package/dist/KannadaConverter.js +3 -0
- package/dist/KannadaConverter.js.map +1 -0
- package/dist/KoreanConverter.js +3 -0
- package/dist/KoreanConverter.js.map +1 -0
- package/dist/LatvianConverter.js +3 -0
- package/dist/LatvianConverter.js.map +1 -0
- package/dist/LithuanianConverter.js +3 -0
- package/dist/LithuanianConverter.js.map +1 -0
- package/dist/MalayConverter.js +3 -0
- package/dist/MalayConverter.js.map +1 -0
- package/dist/MarathiConverter.js +3 -0
- package/dist/MarathiConverter.js.map +1 -0
- package/dist/NorwegianBokmalConverter.js +3 -0
- package/dist/NorwegianBokmalConverter.js.map +1 -0
- package/dist/PersianConverter.js +3 -0
- package/dist/PersianConverter.js.map +1 -0
- package/dist/PolishConverter.js +3 -0
- package/dist/PolishConverter.js.map +1 -0
- package/dist/PortugueseConverter.js +3 -0
- package/dist/PortugueseConverter.js.map +1 -0
- package/dist/PunjabiConverter.js +3 -0
- package/dist/PunjabiConverter.js.map +1 -0
- package/dist/RomanianConverter.js +3 -0
- package/dist/RomanianConverter.js.map +1 -0
- package/dist/RussianConverter.js +3 -0
- package/dist/RussianConverter.js.map +1 -0
- package/dist/SerbianCyrillicConverter.js +3 -0
- package/dist/SerbianCyrillicConverter.js.map +1 -0
- package/dist/SerbianLatinConverter.js +3 -0
- package/dist/SerbianLatinConverter.js.map +1 -0
- package/dist/SimplifiedChineseConverter.js +3 -0
- package/dist/SimplifiedChineseConverter.js.map +1 -0
- package/dist/SpanishConverter.js +3 -0
- package/dist/SpanishConverter.js.map +1 -0
- package/dist/SwahiliConverter.js +3 -0
- package/dist/SwahiliConverter.js.map +1 -0
- package/dist/SwedishConverter.js +3 -0
- package/dist/SwedishConverter.js.map +1 -0
- package/dist/TamilConverter.js +3 -0
- package/dist/TamilConverter.js.map +1 -0
- package/dist/TeluguConverter.js +3 -0
- package/dist/TeluguConverter.js.map +1 -0
- package/dist/ThaiConverter.js +3 -0
- package/dist/ThaiConverter.js.map +1 -0
- package/dist/TraditionalChineseConverter.js +3 -0
- package/dist/TraditionalChineseConverter.js.map +1 -0
- package/dist/TurkishConverter.js +3 -0
- package/dist/TurkishConverter.js.map +1 -0
- package/dist/UkrainianConverter.js +3 -0
- package/dist/UkrainianConverter.js.map +1 -0
- package/dist/UrduConverter.js +3 -0
- package/dist/UrduConverter.js.map +1 -0
- package/dist/VietnameseConverter.js +3 -0
- package/dist/VietnameseConverter.js.map +1 -0
- package/dist/n2words.js +3 -2
- package/dist/n2words.js.map +1 -1
- package/lib/classes/abstract-language.d.ts +158 -34
- package/lib/classes/abstract-language.js +223 -115
- package/lib/classes/greedy-scale-language.d.ts +109 -0
- package/lib/classes/greedy-scale-language.js +201 -0
- package/lib/classes/slavic-language.d.ts +148 -0
- package/lib/classes/slavic-language.js +281 -0
- package/lib/classes/south-asian-language.d.ts +70 -0
- package/lib/classes/south-asian-language.js +154 -0
- package/lib/classes/turkic-language.d.ts +26 -0
- package/lib/classes/turkic-language.js +59 -0
- package/lib/languages/ar.d.ts +30 -0
- package/lib/languages/ar.js +159 -0
- package/lib/languages/az.d.ts +12 -0
- package/lib/languages/az.js +42 -0
- package/lib/languages/bn.d.ts +11 -0
- package/lib/languages/bn.js +131 -0
- package/lib/languages/cs.d.ts +88 -0
- package/lib/languages/cs.js +143 -0
- package/lib/languages/da.d.ts +15 -0
- package/lib/languages/da.js +120 -0
- package/lib/languages/de.d.ts +14 -0
- package/lib/languages/de.js +101 -0
- package/lib/languages/el.d.ts +14 -0
- package/lib/languages/el.js +90 -0
- package/lib/languages/en.d.ts +16 -0
- package/lib/languages/en.js +86 -0
- package/lib/languages/es.d.ts +15 -0
- package/lib/languages/es.js +121 -0
- package/lib/languages/fa.d.ts +47 -0
- package/lib/languages/fa.js +144 -0
- package/lib/languages/fil.d.ts +16 -0
- package/lib/languages/fil.js +121 -0
- package/lib/languages/fr-BE.d.ts +11 -0
- package/lib/languages/fr-BE.js +25 -0
- package/lib/languages/fr.d.ts +15 -0
- package/lib/languages/fr.js +106 -0
- package/lib/languages/gu.d.ts +11 -0
- package/lib/languages/gu.js +132 -0
- package/lib/languages/hbo.d.ts +113 -0
- package/lib/languages/hbo.js +251 -0
- package/lib/languages/he.d.ts +80 -0
- package/lib/languages/he.js +206 -0
- package/lib/languages/hi.d.ts +11 -0
- package/lib/languages/hi.js +131 -0
- package/lib/languages/hr.d.ts +80 -0
- package/lib/languages/hr.js +113 -0
- package/lib/languages/hu.d.ts +22 -0
- package/lib/languages/hu.js +137 -0
- package/lib/languages/id.d.ts +37 -0
- package/lib/languages/id.js +159 -0
- package/lib/languages/it.d.ts +37 -0
- package/lib/languages/it.js +132 -0
- package/lib/languages/ja.d.ts +17 -0
- package/lib/languages/ja.js +137 -0
- package/lib/languages/kn.d.ts +11 -0
- package/lib/languages/kn.js +42 -0
- package/lib/languages/ko.d.ts +14 -0
- package/lib/languages/ko.js +55 -0
- package/lib/{i18n/pl.d.ts → languages/lt.d.ts} +18 -15
- package/lib/languages/lt.js +136 -0
- package/lib/{i18n/lt.d.ts → languages/lv.d.ts} +16 -14
- package/lib/languages/lv.js +130 -0
- package/lib/languages/mr.d.ts +11 -0
- package/lib/languages/mr.js +132 -0
- package/lib/languages/ms.d.ts +31 -0
- package/lib/languages/ms.js +150 -0
- package/lib/languages/nb.d.ts +12 -0
- package/lib/languages/nb.js +100 -0
- package/lib/languages/nl.d.ts +16 -0
- package/lib/languages/nl.js +155 -0
- package/lib/languages/pa.d.ts +11 -0
- package/lib/languages/pa.js +131 -0
- package/lib/{i18n/uk.d.ts → languages/pl.d.ts} +16 -14
- package/lib/languages/pl.js +110 -0
- package/lib/languages/pt.d.ts +29 -0
- package/lib/languages/pt.js +112 -0
- package/lib/languages/ro.d.ts +158 -0
- package/lib/languages/ro.js +273 -0
- package/lib/languages/ru.d.ts +85 -0
- package/lib/languages/ru.js +96 -0
- package/lib/languages/sr-Cyrl.d.ts +80 -0
- package/lib/languages/sr-Cyrl.js +113 -0
- package/lib/{i18n/cz.d.ts → languages/sr-Latn.d.ts} +26 -14
- package/lib/languages/sr-Latn.js +113 -0
- package/lib/languages/sv.d.ts +14 -0
- package/lib/languages/sv.js +90 -0
- package/lib/languages/sw.d.ts +39 -0
- package/lib/languages/sw.js +126 -0
- package/lib/languages/ta.d.ts +20 -0
- package/lib/languages/ta.js +226 -0
- package/lib/languages/te.d.ts +22 -0
- package/lib/languages/te.js +219 -0
- package/lib/languages/th.d.ts +17 -0
- package/lib/languages/th.js +117 -0
- package/lib/languages/tr.d.ts +12 -0
- package/lib/languages/tr.js +56 -0
- package/lib/languages/uk.d.ts +85 -0
- package/lib/{i18n → languages}/uk.js +33 -32
- package/lib/languages/ur.d.ts +11 -0
- package/lib/languages/ur.js +131 -0
- package/lib/{i18n → languages}/vi.d.ts +15 -13
- package/lib/languages/vi.js +147 -0
- package/lib/languages/zh-Hans.d.ts +21 -0
- package/lib/languages/zh-Hans.js +111 -0
- package/lib/languages/zh-Hant.d.ts +21 -0
- package/lib/languages/zh-Hant.js +111 -0
- package/lib/n2words.d.ts +207 -7
- package/lib/n2words.js +535 -81
- package/package.json +126 -79
- package/dist/ar.js +0 -2
- package/dist/ar.js.map +0 -1
- package/dist/az.js +0 -2
- package/dist/az.js.map +0 -1
- package/dist/cz.js +0 -2
- package/dist/cz.js.map +0 -1
- package/dist/de.js +0 -2
- package/dist/de.js.map +0 -1
- package/dist/dk.js +0 -2
- package/dist/dk.js.map +0 -1
- package/dist/en.js +0 -2
- package/dist/en.js.map +0 -1
- package/dist/es.js +0 -2
- package/dist/es.js.map +0 -1
- package/dist/fa.js +0 -2
- package/dist/fa.js.map +0 -1
- package/dist/fr-BE.js +0 -2
- package/dist/fr-BE.js.map +0 -1
- package/dist/fr.js +0 -2
- package/dist/fr.js.map +0 -1
- package/dist/he.js +0 -2
- package/dist/he.js.map +0 -1
- package/dist/hr.js +0 -2
- package/dist/hr.js.map +0 -1
- package/dist/hu.js +0 -2
- package/dist/hu.js.map +0 -1
- package/dist/id.js +0 -2
- package/dist/id.js.map +0 -1
- package/dist/it.js +0 -2
- package/dist/it.js.map +0 -1
- package/dist/ko.js +0 -2
- package/dist/ko.js.map +0 -1
- package/dist/lt.js +0 -2
- package/dist/lt.js.map +0 -1
- package/dist/lv.js +0 -2
- package/dist/lv.js.map +0 -1
- package/dist/n2words.d.ts +0 -2
- package/dist/nl.js +0 -2
- package/dist/nl.js.map +0 -1
- package/dist/no.js +0 -2
- package/dist/no.js.map +0 -1
- package/dist/pl.js +0 -2
- package/dist/pl.js.map +0 -1
- package/dist/pt.js +0 -2
- package/dist/pt.js.map +0 -1
- package/dist/ro.js +0 -2
- package/dist/ro.js.map +0 -1
- package/dist/ru.js +0 -2
- package/dist/ru.js.map +0 -1
- package/dist/sr.js +0 -2
- package/dist/sr.js.map +0 -1
- package/dist/tr.js +0 -2
- package/dist/tr.js.map +0 -1
- package/dist/uk.js +0 -2
- package/dist/uk.js.map +0 -1
- package/dist/vi.js +0 -2
- package/dist/vi.js.map +0 -1
- package/dist/zh.js +0 -2
- package/dist/zh.js.map +0 -1
- package/lib/classes/base-language.d.ts +0 -58
- package/lib/classes/base-language.js +0 -172
- package/lib/i18n/ar.d.ts +0 -41
- package/lib/i18n/ar.js +0 -209
- package/lib/i18n/az.d.ts +0 -15
- package/lib/i18n/az.js +0 -66
- package/lib/i18n/cz.js +0 -135
- package/lib/i18n/de.d.ts +0 -17
- package/lib/i18n/de.js +0 -103
- package/lib/i18n/dk.d.ts +0 -14
- package/lib/i18n/dk.js +0 -110
- package/lib/i18n/en.d.ts +0 -22
- package/lib/i18n/en.js +0 -86
- package/lib/i18n/es.d.ts +0 -16
- package/lib/i18n/es.js +0 -110
- package/lib/i18n/fa.d.ts +0 -54
- package/lib/i18n/fa.js +0 -106
- package/lib/i18n/fr-BE.d.ts +0 -11
- package/lib/i18n/fr-BE.js +0 -20
- package/lib/i18n/fr.d.ts +0 -15
- package/lib/i18n/fr.js +0 -99
- package/lib/i18n/he.d.ts +0 -61
- package/lib/i18n/he.js +0 -132
- package/lib/i18n/hr.d.ts +0 -68
- package/lib/i18n/hr.js +0 -129
- package/lib/i18n/hu.d.ts +0 -17
- package/lib/i18n/hu.js +0 -135
- package/lib/i18n/id.d.ts +0 -43
- package/lib/i18n/id.js +0 -156
- package/lib/i18n/it.d.ts +0 -29
- package/lib/i18n/it.js +0 -137
- package/lib/i18n/ko.d.ts +0 -15
- package/lib/i18n/ko.js +0 -56
- package/lib/i18n/lt.js +0 -138
- package/lib/i18n/lv.d.ts +0 -57
- package/lib/i18n/lv.js +0 -120
- package/lib/i18n/nl.d.ts +0 -20
- package/lib/i18n/nl.js +0 -125
- package/lib/i18n/no.d.ts +0 -15
- package/lib/i18n/no.js +0 -77
- package/lib/i18n/pl.js +0 -126
- package/lib/i18n/pt.d.ts +0 -26
- package/lib/i18n/pt.js +0 -118
- package/lib/i18n/ro.d.ts +0 -109
- package/lib/i18n/ro.js +0 -360
- package/lib/i18n/ru.d.ts +0 -30
- package/lib/i18n/ru.js +0 -198
- package/lib/i18n/sr.d.ts +0 -56
- package/lib/i18n/sr.js +0 -127
- package/lib/i18n/tr.d.ts +0 -15
- package/lib/i18n/tr.js +0 -64
- package/lib/i18n/vi.js +0 -151
- package/lib/i18n/zh.d.ts +0 -18
- package/lib/i18n/zh.js +0 -78
package/lib/i18n/it.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a value to cardinal (written) form.
|
|
3
|
-
* @param {number|string|bigint} value Number to be convert.
|
|
4
|
-
* @param {object} [options] Options for class.
|
|
5
|
-
* @returns {string} Value in cardinal (written) format.
|
|
6
|
-
* @throws {Error} Value cannot be invalid.
|
|
7
|
-
*/
|
|
8
|
-
export default function floatToCardinal(value: number | string | bigint, options?: object): string;
|
|
9
|
-
export class N2WordsIT extends BaseLanguage {
|
|
10
|
-
constructor(options: any);
|
|
11
|
-
cardinalWords: string[];
|
|
12
|
-
strTens: {
|
|
13
|
-
'2': string;
|
|
14
|
-
'3': string;
|
|
15
|
-
'4': string;
|
|
16
|
-
'6': string;
|
|
17
|
-
};
|
|
18
|
-
exponentPrefixes: string[];
|
|
19
|
-
accentuate(string: any): any;
|
|
20
|
-
omitIfZero(numberToString: any): any;
|
|
21
|
-
phoneticContraction(string: any): any;
|
|
22
|
-
tensToCardinal(number: any): any;
|
|
23
|
-
hundredsToCardinal(number: any): any;
|
|
24
|
-
thousandsToCardinal(number: any): string;
|
|
25
|
-
exponentLengthToString(exponentLength: any): string;
|
|
26
|
-
bigNumberToCardinal(number: any): string;
|
|
27
|
-
toCardinal(number: any): any;
|
|
28
|
-
}
|
|
29
|
-
import BaseLanguage from '../classes/base-language.js';
|
package/lib/i18n/it.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import BaseLanguage from '../classes/base-language.js';
|
|
2
|
-
|
|
3
|
-
// TODO Adapt language to work with {@link BaseLanguage} better
|
|
4
|
-
export class N2WordsIT extends BaseLanguage {
|
|
5
|
-
cardinalWords = [
|
|
6
|
-
this.zero, 'uno', 'due', 'tre', 'quattro', 'cinque', 'sei', 'sette', 'otto',
|
|
7
|
-
'nove', 'dieci', 'undici', 'dodici', 'tredici', 'quattordici', 'quindici',
|
|
8
|
-
'sedici', 'diciassette', 'diciotto', 'diciannove',
|
|
9
|
-
];
|
|
10
|
-
|
|
11
|
-
strTens = { '2': 'venti', '3': 'trenta', '4': 'quaranta', '6': 'sessanta' };
|
|
12
|
-
|
|
13
|
-
exponentPrefixes = [this.zero, 'm', 'b', 'tr', 'quadr', 'quint', 'sest', 'sett', 'ott', 'nov', 'dec'];
|
|
14
|
-
|
|
15
|
-
constructor(options) {
|
|
16
|
-
options = Object.assign({
|
|
17
|
-
negativeWord: 'meno',
|
|
18
|
-
separatorWord: 'virgola',
|
|
19
|
-
zero: 'zero'
|
|
20
|
-
}, options);
|
|
21
|
-
|
|
22
|
-
super(options, []);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
accentuate(string) {
|
|
26
|
-
const splittedString = string.split(' ');
|
|
27
|
-
|
|
28
|
-
const result = splittedString.map(word => {
|
|
29
|
-
return word.slice(-3) == 'tre' && word.length > 3 ? word.replaceAll('tré', 'tre').slice(0, -3) + 'tré' : word.replaceAll('tré', 'tre');
|
|
30
|
-
});
|
|
31
|
-
return result.join(' ');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
omitIfZero(numberToString) {
|
|
35
|
-
return numberToString == this.zero ? '' : numberToString;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
phoneticContraction(string) {
|
|
39
|
-
return string.replaceAll('oo', 'o').replaceAll('ao', 'o').replaceAll('io', 'o').replaceAll('au', 'u').replaceAll('iu', 'u');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
tensToCardinal(number) {
|
|
43
|
-
const tens = Math.floor(number / 10);
|
|
44
|
-
const units = number % 10;
|
|
45
|
-
let prefix;
|
|
46
|
-
prefix = Object.prototype.hasOwnProperty.call(this.strTens, tens) ? this.strTens[tens] : this.cardinalWords[tens].slice(0, -1) + 'anta';
|
|
47
|
-
const postfix = this.omitIfZero(this.cardinalWords[units]);
|
|
48
|
-
return this.phoneticContraction(prefix + postfix);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
hundredsToCardinal(number) {
|
|
52
|
-
const hundreds = Math.floor(number / 100);
|
|
53
|
-
let prefix = 'cento';
|
|
54
|
-
if (hundreds != 1) {
|
|
55
|
-
prefix = this.cardinalWords[hundreds] + prefix;
|
|
56
|
-
}
|
|
57
|
-
const postfix = this.omitIfZero(this.toCardinal(number % 100));
|
|
58
|
-
return this.phoneticContraction(prefix + postfix);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
thousandsToCardinal(number) {
|
|
62
|
-
const thousands = Math.floor(number / 1000);
|
|
63
|
-
let prefix;
|
|
64
|
-
prefix = thousands == 1 ? 'mille' : this.toCardinal(thousands) + 'mila';
|
|
65
|
-
const postfix = this.omitIfZero(this.toCardinal(number % 1000));
|
|
66
|
-
return prefix + postfix;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
exponentLengthToString(exponentLength) {
|
|
70
|
-
const prefix = this.exponentPrefixes[Math.floor(exponentLength / 6)];
|
|
71
|
-
return exponentLength % 6 == 0 ? prefix + 'ilione' : prefix + 'iliardo';
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
bigNumberToCardinal(number) {
|
|
75
|
-
const digits = [...number.toString()];
|
|
76
|
-
|
|
77
|
-
let preDigits = digits.length % 3;
|
|
78
|
-
if (preDigits == 0) {
|
|
79
|
-
preDigits = 3;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const multiplier = digits.slice(0, preDigits); // first `preDigits` elements
|
|
83
|
-
const exponent = digits.slice(preDigits); // without the first `preDigits` elements
|
|
84
|
-
|
|
85
|
-
let prefix, postfix;
|
|
86
|
-
let infix = this.exponentLengthToString(exponent.length);
|
|
87
|
-
|
|
88
|
-
if (multiplier == '1') {
|
|
89
|
-
prefix = 'un ';
|
|
90
|
-
} else {
|
|
91
|
-
prefix = this.toCardinal(Math.trunc(Number(multiplier.join(''))));
|
|
92
|
-
infix = ' ' + infix.slice(0, -1) + 'i'; // without last element
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// TODO ESLint suggestion
|
|
96
|
-
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
97
|
-
const isSetsEqual = (a, b) => a.size == b.size && [...a].every(value => b.has(value));
|
|
98
|
-
if (isSetsEqual(new Set(exponent), new Set(['0']))) {
|
|
99
|
-
postfix = '';
|
|
100
|
-
} else {
|
|
101
|
-
postfix = this.toCardinal(Math.trunc(exponent.join('')));
|
|
102
|
-
|
|
103
|
-
infix += (postfix.includes(' e ') ? ', ' : ' e ');
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return prefix + infix + postfix;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
toCardinal(number) {
|
|
110
|
-
let words = '';
|
|
111
|
-
|
|
112
|
-
if (number < 20) {
|
|
113
|
-
words = this.cardinalWords[number];
|
|
114
|
-
} else if (number < 100) {
|
|
115
|
-
words = this.tensToCardinal(Number(number));
|
|
116
|
-
} else if (number < 1000) {
|
|
117
|
-
words = this.hundredsToCardinal(Number(number));
|
|
118
|
-
} else if (number < 1_000_000) {
|
|
119
|
-
words = this.thousandsToCardinal(Number(number));
|
|
120
|
-
} else {
|
|
121
|
-
words = this.bigNumberToCardinal(number);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return this.accentuate(words);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Converts a value to cardinal (written) form.
|
|
130
|
-
* @param {number|string|bigint} value Number to be convert.
|
|
131
|
-
* @param {object} [options] Options for class.
|
|
132
|
-
* @returns {string} Value in cardinal (written) format.
|
|
133
|
-
* @throws {Error} Value cannot be invalid.
|
|
134
|
-
*/
|
|
135
|
-
export default function floatToCardinal (value, options = {}) {
|
|
136
|
-
return new N2WordsIT(options).floatToCardinal(value);
|
|
137
|
-
}
|
package/lib/i18n/ko.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a value to cardinal (written) form.
|
|
3
|
-
* @param {number|string|bigint} value Number to be convert.
|
|
4
|
-
* @param {object} [options] Options for class.
|
|
5
|
-
* @returns {string} Value in cardinal (written) format.
|
|
6
|
-
* @throws {Error} Value cannot be invalid.
|
|
7
|
-
*/
|
|
8
|
-
export default function floatToCardinal(value: number | string | bigint, options?: object): string;
|
|
9
|
-
export class N2WordsKO extends BaseLanguage {
|
|
10
|
-
constructor(options: any);
|
|
11
|
-
merge(lPair: any, rPair: any): {
|
|
12
|
-
[x: string]: bigint;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
import BaseLanguage from '../classes/base-language.js';
|
package/lib/i18n/ko.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import BaseLanguage from '../classes/base-language.js';
|
|
2
|
-
|
|
3
|
-
export class N2WordsKO extends BaseLanguage {
|
|
4
|
-
constructor(options) {
|
|
5
|
-
options = Object.assign({
|
|
6
|
-
negativeWord: '마이너스',
|
|
7
|
-
separatorWord: '점',
|
|
8
|
-
zero: '영'
|
|
9
|
-
}, options);
|
|
10
|
-
|
|
11
|
-
super(options, [
|
|
12
|
-
[10_000_000_000_000_000_000_000_000_000n, '양'],
|
|
13
|
-
[1_000_000_000_000_000_000_000_000n, '자'],
|
|
14
|
-
[100_000_000_000_000_000_000n, '해'],
|
|
15
|
-
[10_000_000_000_000_000n, '경'],
|
|
16
|
-
[1_000_000_000_000n, '조'],
|
|
17
|
-
[100_000_000n, '억'],
|
|
18
|
-
[10_000n, '만'],
|
|
19
|
-
[1000n, '천'],
|
|
20
|
-
[100n, '백'],
|
|
21
|
-
[10n, '십'],
|
|
22
|
-
[9n, '구'],
|
|
23
|
-
[8n, '팔'],
|
|
24
|
-
[7n, '칠'],
|
|
25
|
-
[6n, '육'],
|
|
26
|
-
[5n, '오'],
|
|
27
|
-
[4n, '사'],
|
|
28
|
-
[3n, '삼'],
|
|
29
|
-
[2n, '이'],
|
|
30
|
-
[1n, '일'],
|
|
31
|
-
[0n, '영']
|
|
32
|
-
]);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
merge(lPair, rPair) {
|
|
36
|
-
const lText = Object.keys(lPair)[0];
|
|
37
|
-
const rText = Object.keys(rPair)[0];
|
|
38
|
-
const lNumber = BigInt(Object.values(lPair)[0]);
|
|
39
|
-
const rNumber = BigInt(Object.values(rPair)[0]);
|
|
40
|
-
if (lNumber == 1 && rNumber <= 10_000) return { [rText]: rNumber };
|
|
41
|
-
else if (10_000 > lNumber && lNumber > rNumber) return { [`${lText}${rText}`]: lNumber + rNumber };
|
|
42
|
-
else if (lNumber >= 10_000 && lNumber > rNumber) return { [`${lText} ${rText}`]: lNumber + rNumber };
|
|
43
|
-
else return { [`${lText}${rText}`]: lNumber * rNumber };
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Converts a value to cardinal (written) form.
|
|
49
|
-
* @param {number|string|bigint} value Number to be convert.
|
|
50
|
-
* @param {object} [options] Options for class.
|
|
51
|
-
* @returns {string} Value in cardinal (written) format.
|
|
52
|
-
* @throws {Error} Value cannot be invalid.
|
|
53
|
-
*/
|
|
54
|
-
export default function floatToCardinal (value, options = {}) {
|
|
55
|
-
return new N2WordsKO(options).floatToCardinal(value);
|
|
56
|
-
}
|
package/lib/i18n/lt.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { N2WordsRU } from './ru.js';
|
|
2
|
-
|
|
3
|
-
export class N2WordsLT extends N2WordsRU {
|
|
4
|
-
ones = {
|
|
5
|
-
1: 'vienas',
|
|
6
|
-
2: 'du',
|
|
7
|
-
3: 'trys',
|
|
8
|
-
4: 'keturi',
|
|
9
|
-
5: 'penki',
|
|
10
|
-
6: 'šeši',
|
|
11
|
-
7: 'septyni',
|
|
12
|
-
8: 'aštuoni',
|
|
13
|
-
9: 'devyni'
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
onesFeminine = {
|
|
17
|
-
1: 'viena',
|
|
18
|
-
2: 'dvi',
|
|
19
|
-
3: 'trys',
|
|
20
|
-
4: 'keturios',
|
|
21
|
-
5: 'penkios',
|
|
22
|
-
6: 'šešios',
|
|
23
|
-
7: 'septynios',
|
|
24
|
-
8: 'aštuonios',
|
|
25
|
-
9: 'devynios'
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
tens = {
|
|
29
|
-
0: 'dešimt',
|
|
30
|
-
1: 'vienuolika',
|
|
31
|
-
2: 'dvylika',
|
|
32
|
-
3: 'trylika',
|
|
33
|
-
4: 'keturiolika',
|
|
34
|
-
5: 'penkiolika',
|
|
35
|
-
6: 'šešiolika',
|
|
36
|
-
7: 'septyniolika',
|
|
37
|
-
8: 'aštuoniolika',
|
|
38
|
-
9: 'devyniolika'
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
twenties = {
|
|
42
|
-
2: 'dvidešimt',
|
|
43
|
-
3: 'trisdešimt',
|
|
44
|
-
4: 'keturiasdešimt',
|
|
45
|
-
5: 'penkiasdešimt',
|
|
46
|
-
6: 'šešiasdešimt',
|
|
47
|
-
7: 'septyniasdešimt',
|
|
48
|
-
8: 'aštuoniasdešimt',
|
|
49
|
-
9: 'devyniasdešimt'
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
hundreds = ['šimtas', 'šimtai'];
|
|
53
|
-
|
|
54
|
-
thousands = {
|
|
55
|
-
1: ['tūkstantis', 'tūkstančiai', 'tūkstančių'],
|
|
56
|
-
2: ['milijonas', 'milijonai', 'milijonų'],
|
|
57
|
-
3: ['milijardas', 'milijardai', 'milijardų'],
|
|
58
|
-
4: ['trilijonas', 'trilijonai', 'trilijonų'],
|
|
59
|
-
5: ['kvadrilijonas', 'kvadrilijonai', 'kvadrilijonų'],
|
|
60
|
-
6: ['kvintilijonas', 'kvintilijonai', 'kvintilijonų'],
|
|
61
|
-
7: ['sikstilijonas', 'sikstilijonai', 'sikstilijonų'],
|
|
62
|
-
8: ['septilijonas', 'septilijonai', 'septilijonų'],
|
|
63
|
-
9: ['oktilijonas', 'oktilijonai', 'oktilijonų'],
|
|
64
|
-
10: ['naintilijonas', 'naintilijonai', 'naintilijonų'],
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
constructor(options) {
|
|
68
|
-
options = Object.assign({
|
|
69
|
-
negativeWord: 'minus',
|
|
70
|
-
separatorWord: 'kablelis',
|
|
71
|
-
zero: 'nulis'
|
|
72
|
-
}, options);
|
|
73
|
-
|
|
74
|
-
super(options);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
pluralize(n, forms) {
|
|
78
|
-
let form = 1;
|
|
79
|
-
const [n1, n2] = this.getDigits(n);
|
|
80
|
-
if (n2 == 1 || n1 == 0 || n == 0) {
|
|
81
|
-
form = 2;
|
|
82
|
-
} else if (n1 == 1) {
|
|
83
|
-
form = 0;
|
|
84
|
-
}
|
|
85
|
-
return forms[form];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
toCardinal(number) {
|
|
89
|
-
if (number == 0) {
|
|
90
|
-
return this.zero;
|
|
91
|
-
}
|
|
92
|
-
const words = [];
|
|
93
|
-
const chunks = this.splitByX(number.toString(), 3);
|
|
94
|
-
let index = chunks.length;
|
|
95
|
-
for (const x of chunks) {
|
|
96
|
-
index = index - 1;
|
|
97
|
-
if (x == 0) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
const [n1, n2, n3] = this.getDigits(x);
|
|
101
|
-
if (n3 > 0) {
|
|
102
|
-
words.push(this.ones[n3]);
|
|
103
|
-
if (n3 > 1) {
|
|
104
|
-
words.push(this.hundreds[1]);
|
|
105
|
-
} else {
|
|
106
|
-
words.push(this.hundreds[0]);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (n2 > 1) {
|
|
110
|
-
words.push(this.twenties[n2]);
|
|
111
|
-
}
|
|
112
|
-
if (n2 == 1) {
|
|
113
|
-
words.push(this.tens[n1]);
|
|
114
|
-
} else if (n1 > 0) {
|
|
115
|
-
if ((index == 1 || this.feminine && index == 0) && number < 1000) {
|
|
116
|
-
words.push(this.onesFeminine[n1]);
|
|
117
|
-
} else {
|
|
118
|
-
words.push(this.ones[n1]);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (index > 0) {
|
|
122
|
-
words.push(this.pluralize(x, this.thousands[index]));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return words.join(' ');
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Converts a value to cardinal (written) form.
|
|
131
|
-
* @param {number|string|bigint} value Number to be convert.
|
|
132
|
-
* @param {object} [options] Options for class.
|
|
133
|
-
* @returns {string} Value in cardinal (written) format.
|
|
134
|
-
* @throws {Error} Value cannot be invalid.
|
|
135
|
-
*/
|
|
136
|
-
export default function floatToCardinal (value, options = {}) {
|
|
137
|
-
return new N2WordsLT(options).floatToCardinal(value);
|
|
138
|
-
}
|
package/lib/i18n/lv.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a value to cardinal (written) form.
|
|
3
|
-
* @param {number|string|bigint} value Number to be convert.
|
|
4
|
-
* @param {object} [options] Options for class.
|
|
5
|
-
* @returns {string} Value in cardinal (written) format.
|
|
6
|
-
* @throws {Error} Value cannot be invalid.
|
|
7
|
-
*/
|
|
8
|
-
export default function floatToCardinal(value: number | string | bigint, options?: object): string;
|
|
9
|
-
export class N2WordsLV extends N2WordsRU {
|
|
10
|
-
ones: {
|
|
11
|
-
1: string;
|
|
12
|
-
2: string;
|
|
13
|
-
3: string;
|
|
14
|
-
4: string;
|
|
15
|
-
5: string;
|
|
16
|
-
6: string;
|
|
17
|
-
7: string;
|
|
18
|
-
8: string;
|
|
19
|
-
9: string;
|
|
20
|
-
};
|
|
21
|
-
tens: {
|
|
22
|
-
0: string;
|
|
23
|
-
1: string;
|
|
24
|
-
2: string;
|
|
25
|
-
3: string;
|
|
26
|
-
4: string;
|
|
27
|
-
5: string;
|
|
28
|
-
6: string;
|
|
29
|
-
7: string;
|
|
30
|
-
8: string;
|
|
31
|
-
9: string;
|
|
32
|
-
};
|
|
33
|
-
twenties: {
|
|
34
|
-
2: string;
|
|
35
|
-
3: string;
|
|
36
|
-
4: string;
|
|
37
|
-
5: string;
|
|
38
|
-
6: string;
|
|
39
|
-
7: string;
|
|
40
|
-
8: string;
|
|
41
|
-
9: string;
|
|
42
|
-
};
|
|
43
|
-
hundreds: string[];
|
|
44
|
-
thousands: {
|
|
45
|
-
1: string[];
|
|
46
|
-
2: string[];
|
|
47
|
-
3: string[];
|
|
48
|
-
4: string[];
|
|
49
|
-
5: string[];
|
|
50
|
-
6: string[];
|
|
51
|
-
7: string[];
|
|
52
|
-
8: string[];
|
|
53
|
-
9: string[];
|
|
54
|
-
10: string[];
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
import { N2WordsRU } from './ru.js';
|
package/lib/i18n/lv.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { N2WordsRU } from './ru.js';
|
|
2
|
-
|
|
3
|
-
export class N2WordsLV extends N2WordsRU {
|
|
4
|
-
ones = {
|
|
5
|
-
1: 'viens',
|
|
6
|
-
2: 'divi',
|
|
7
|
-
3: 'trīs',
|
|
8
|
-
4: 'četri',
|
|
9
|
-
5: 'pieci',
|
|
10
|
-
6: 'seši',
|
|
11
|
-
7: 'septiņi',
|
|
12
|
-
8: 'astoņi',
|
|
13
|
-
9: 'deviņi'
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
tens = {
|
|
17
|
-
0: 'desmit',
|
|
18
|
-
1: 'vienpadsmit',
|
|
19
|
-
2: 'divpadsmit',
|
|
20
|
-
3: 'trīspadsmit',
|
|
21
|
-
4: 'četrpadsmit',
|
|
22
|
-
5: 'piecpadsmit',
|
|
23
|
-
6: 'sešpadsmit',
|
|
24
|
-
7: 'septiņpadsmit',
|
|
25
|
-
8: 'astoņpadsmit',
|
|
26
|
-
9: 'deviņpadsmit'
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
twenties = {
|
|
30
|
-
2: 'divdesmit',
|
|
31
|
-
3: 'trīsdesmit',
|
|
32
|
-
4: 'četrdesmit',
|
|
33
|
-
5: 'piecdesmit',
|
|
34
|
-
6: 'sešdesmit',
|
|
35
|
-
7: 'septiņdesmit',
|
|
36
|
-
8: 'astoņdesmit',
|
|
37
|
-
9: 'deviņdesmit'
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
hundreds = ['simts', 'simti', 'simtu'];
|
|
41
|
-
|
|
42
|
-
thousands = {
|
|
43
|
-
1: ['tūkstotis', 'tūkstoši', 'tūkstošu'],
|
|
44
|
-
2: ['miljons', 'miljoni', 'miljonu'],
|
|
45
|
-
3: ['miljards', 'miljardi', 'miljardu'],
|
|
46
|
-
4: ['triljons', 'triljoni', 'triljonu'],
|
|
47
|
-
5: ['kvadriljons', 'kvadriljoni', 'kvadriljonu'],
|
|
48
|
-
6: ['kvintiljons', 'kvintiljoni', 'kvintiljonu'],
|
|
49
|
-
7: ['sikstiljons', 'sikstiljoni', 'sikstiljonu'],
|
|
50
|
-
8: ['septiljons', 'septiljoni', 'septiljonu'],
|
|
51
|
-
9: ['oktiljons', 'oktiljoni', 'oktiljonu'],
|
|
52
|
-
10: ['nontiljons', 'nontiljoni', 'nontiljonu'],
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
constructor(options) {
|
|
56
|
-
options = Object.assign({
|
|
57
|
-
negativeWord: 'mīnus',
|
|
58
|
-
separatorWord: 'komats',
|
|
59
|
-
zero: 'nulle'
|
|
60
|
-
}, options);
|
|
61
|
-
|
|
62
|
-
super(options);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
pluralize(n, forms) {
|
|
66
|
-
let form = 2;
|
|
67
|
-
if (n != 0n) {
|
|
68
|
-
form = n % 10n == 1n && n % 100n != 11n ? 0 : 1;
|
|
69
|
-
}
|
|
70
|
-
return forms[form];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
toCardinal(number) {
|
|
74
|
-
if (number == 0) {
|
|
75
|
-
return this.zero;
|
|
76
|
-
}
|
|
77
|
-
const words = [];
|
|
78
|
-
const chunks = this.splitByX(number.toString(), 3);
|
|
79
|
-
let index = chunks.length;
|
|
80
|
-
for (const x of chunks) {
|
|
81
|
-
index = index - 1;
|
|
82
|
-
if (x == 0) {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
const [n1, n2, n3] = this.getDigits(x);
|
|
86
|
-
if (n3 > 0) {
|
|
87
|
-
if (n3 == 1 && n2 == 0 && n1 > 0) {
|
|
88
|
-
words.push(this.hundreds[2]);
|
|
89
|
-
} else if (n3 > 1) {
|
|
90
|
-
words.push(this.ones[n3], this.hundreds[1]);
|
|
91
|
-
} else {
|
|
92
|
-
words.push(this.hundreds[0]);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (n2 > 1) {
|
|
96
|
-
words.push(this.twenties[n2]);
|
|
97
|
-
}
|
|
98
|
-
if (n2 == 1) {
|
|
99
|
-
words.push(this.tens[n1]);
|
|
100
|
-
} else if (n1 > 0 && !(index > 0 && x == 1)) {
|
|
101
|
-
words.push(this.ones[n1]);
|
|
102
|
-
}
|
|
103
|
-
if (index > 0) {
|
|
104
|
-
words.push(this.pluralize(x, this.thousands[index]));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return words.join(' ');
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Converts a value to cardinal (written) form.
|
|
113
|
-
* @param {number|string|bigint} value Number to be convert.
|
|
114
|
-
* @param {object} [options] Options for class.
|
|
115
|
-
* @returns {string} Value in cardinal (written) format.
|
|
116
|
-
* @throws {Error} Value cannot be invalid.
|
|
117
|
-
*/
|
|
118
|
-
export default function floatToCardinal (value, options = {}) {
|
|
119
|
-
return new N2WordsLV(options).floatToCardinal(value);
|
|
120
|
-
}
|
package/lib/i18n/nl.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a value to cardinal (written) form.
|
|
3
|
-
* @param {number|string|bigint} value Number to be convert.
|
|
4
|
-
* @param {object} [options] Options for class.
|
|
5
|
-
* @returns {string} Value in cardinal (written) format.
|
|
6
|
-
* @throws {Error} Value cannot be invalid.
|
|
7
|
-
*/
|
|
8
|
-
export default function floatToCardinal(value: number | string | bigint, options?: object): string;
|
|
9
|
-
export class N2WordsNL extends BaseLanguage {
|
|
10
|
-
constructor(options: any);
|
|
11
|
-
includeOptionalAnd: any;
|
|
12
|
-
noHundredPairs: any;
|
|
13
|
-
merge(current: any, next: any): {
|
|
14
|
-
[x: string]: bigint;
|
|
15
|
-
} | {
|
|
16
|
-
[x: string]: number;
|
|
17
|
-
};
|
|
18
|
-
toCardinal(value: any): string;
|
|
19
|
-
}
|
|
20
|
-
import BaseLanguage from '../classes/base-language.js';
|
package/lib/i18n/nl.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import BaseLanguage from '../classes/base-language.js';
|
|
2
|
-
|
|
3
|
-
export class N2WordsNL extends BaseLanguage {
|
|
4
|
-
includeOptionalAnd;
|
|
5
|
-
noHundredPairs;
|
|
6
|
-
|
|
7
|
-
constructor(options) {
|
|
8
|
-
options = Object.assign({
|
|
9
|
-
negativeWord: 'min',
|
|
10
|
-
separatorWord: 'komma',
|
|
11
|
-
zero: 'nul',
|
|
12
|
-
includeOptionalAnd: false,
|
|
13
|
-
noHundredPairs: false
|
|
14
|
-
}, options);
|
|
15
|
-
|
|
16
|
-
super(options, [
|
|
17
|
-
[1_000_000_000_000_000_000_000_000_000n, 'quadriljard'],
|
|
18
|
-
[1_000_000_000_000_000_000_000_000n, 'quadriljoen'],
|
|
19
|
-
[1_000_000_000_000_000_000_000n, 'triljard'],
|
|
20
|
-
[1_000_000_000_000_000_000n, 'triljoen'],
|
|
21
|
-
[1_000_000_000_000_000n, 'biljard'],
|
|
22
|
-
[1_000_000_000_000n, 'biljoen'],
|
|
23
|
-
[1_000_000_000n, 'miljard'],
|
|
24
|
-
[1_000_000n, 'miljoen'],
|
|
25
|
-
[1000n, 'duizend'],
|
|
26
|
-
[100n, 'honderd'],
|
|
27
|
-
[90n, 'negentig'],
|
|
28
|
-
[80n, 'tachtig'],
|
|
29
|
-
[70n, 'zeventig'],
|
|
30
|
-
[60n, 'zestig'],
|
|
31
|
-
[50n, 'vijftig'],
|
|
32
|
-
[40n, 'veertig'],
|
|
33
|
-
[30n, 'dertig'],
|
|
34
|
-
[20n, 'twintig'],
|
|
35
|
-
[19n, 'negentien'],
|
|
36
|
-
[18n, 'achttien'],
|
|
37
|
-
[17n, 'zeventien'],
|
|
38
|
-
[16n, 'zestien'],
|
|
39
|
-
[15n, 'vijftien'],
|
|
40
|
-
[14n, 'veertien'],
|
|
41
|
-
[13n, 'dertien'],
|
|
42
|
-
[12n, 'twaalf'],
|
|
43
|
-
[11n, 'elf'],
|
|
44
|
-
[10n, 'tien'],
|
|
45
|
-
[9n, 'negen'],
|
|
46
|
-
[8n, 'acht'],
|
|
47
|
-
[7n, 'zeven'],
|
|
48
|
-
[6n, 'zes'],
|
|
49
|
-
[5n, 'vijf'],
|
|
50
|
-
[4n, 'vier'],
|
|
51
|
-
[3n, 'drie'],
|
|
52
|
-
[2n, 'twee'],
|
|
53
|
-
[1n, 'een'],
|
|
54
|
-
[0n, 'nul'],
|
|
55
|
-
]);
|
|
56
|
-
|
|
57
|
-
this.includeOptionalAnd = options.includeOptionalAnd;
|
|
58
|
-
this.noHundredPairs = options.noHundredPairs;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
merge(current, next) {
|
|
62
|
-
let cText = Object.keys(current)[0];
|
|
63
|
-
let nText = Object.keys(next)[0];
|
|
64
|
-
const cNumber = BigInt(Object.values(current)[0]);
|
|
65
|
-
const nNumber = BigInt(Object.values(next)[0]);
|
|
66
|
-
if (cNumber == 1) {
|
|
67
|
-
if (nNumber < 1_000_000) {
|
|
68
|
-
return { [nText]: nNumber };
|
|
69
|
-
}
|
|
70
|
-
cText = 'een';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
let value = 0;
|
|
74
|
-
if (nNumber > cNumber) {
|
|
75
|
-
if (nNumber >= 1_000_000) {
|
|
76
|
-
cText += ' ';
|
|
77
|
-
} else if (nNumber > 100) {
|
|
78
|
-
nText += ' ';
|
|
79
|
-
}
|
|
80
|
-
value = cNumber * nNumber;
|
|
81
|
-
} else {
|
|
82
|
-
if (nNumber < 10 && cNumber > 10 && cNumber < 100) {
|
|
83
|
-
const temporary = nText;
|
|
84
|
-
nText = cText;
|
|
85
|
-
const andTxt = temporary.endsWith('e') ? 'ën' : 'en';
|
|
86
|
-
cText = `${temporary}${andTxt}`;
|
|
87
|
-
} else if (nNumber < 13 && cNumber < 1000 && this.includeOptionalAnd) {
|
|
88
|
-
cText = `${cText}en`;
|
|
89
|
-
} else if (nNumber < 13 && cNumber >= 1000 && this.includeOptionalAnd) {
|
|
90
|
-
nText = ` en ${nText}`;
|
|
91
|
-
} else if (cNumber >= 1_000_000) {
|
|
92
|
-
cText += ' ';
|
|
93
|
-
} else {
|
|
94
|
-
if (cNumber == 1000) {
|
|
95
|
-
cText += ' ';
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
value = cNumber + nNumber;
|
|
99
|
-
}
|
|
100
|
-
return { [`${cText}${nText}`]: value };
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
toCardinal(value) {
|
|
104
|
-
if (value >= 1100n && value < 10_000n && !this.noHundredPairs) {
|
|
105
|
-
const high = value / 100n;
|
|
106
|
-
const low = value % 100n;
|
|
107
|
-
if (high % 10n !== 0n) {
|
|
108
|
-
return super.toCardinal(high) + 'honderd' +
|
|
109
|
-
(low ? (this.includeOptionalAnd ? ' en ' : ' ') + super.toCardinal(low) : '');
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return super.toCardinal(value);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Converts a value to cardinal (written) form.
|
|
118
|
-
* @param {number|string|bigint} value Number to be convert.
|
|
119
|
-
* @param {object} [options] Options for class.
|
|
120
|
-
* @returns {string} Value in cardinal (written) format.
|
|
121
|
-
* @throws {Error} Value cannot be invalid.
|
|
122
|
-
*/
|
|
123
|
-
export default function floatToCardinal (value, options = {}) {
|
|
124
|
-
return new N2WordsNL(options).floatToCardinal(value);
|
|
125
|
-
}
|