n2words 1.16.3 → 1.17.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/README.md +1 -1
- package/dist/n2words.js +1 -1
- package/dist/n2words.js.map +1 -1
- package/lib/classes/AbstractLanguage.d.ts +2 -2
- package/lib/classes/AbstractLanguage.js +16 -7
- package/lib/classes/BaseLanguage.d.ts +0 -1
- package/lib/classes/BaseLanguage.js +0 -4
- package/lib/i18n/ar.d.ts +8 -7
- package/lib/i18n/ar.js +82 -44
- package/lib/i18n/az.d.ts +2 -2
- package/lib/i18n/az.js +6 -4
- package/lib/i18n/cz.d.ts +58 -2
- package/lib/i18n/cz.js +6 -4
- package/lib/i18n/de.d.ts +2 -2
- package/lib/i18n/de.js +6 -4
- package/lib/i18n/dk.d.ts +2 -2
- package/lib/i18n/dk.js +3 -3
- package/lib/i18n/en.d.ts +2 -2
- package/lib/i18n/en.js +6 -4
- package/lib/i18n/es.d.ts +2 -2
- package/lib/i18n/es.js +2 -2
- package/lib/i18n/fa.d.ts +2 -2
- package/lib/i18n/fa.js +6 -4
- package/lib/i18n/fr.d.ts +2 -2
- package/lib/i18n/fr.js +6 -4
- package/lib/i18n/he.d.ts +35 -2
- package/lib/i18n/he.js +11 -6
- package/lib/i18n/hr.d.ts +35 -2
- package/lib/i18n/hr.js +6 -4
- package/lib/i18n/hu.d.ts +2 -2
- package/lib/i18n/hu.js +6 -4
- package/lib/i18n/id.d.ts +2 -2
- package/lib/i18n/id.js +6 -4
- package/lib/i18n/it.d.ts +2 -2
- package/lib/i18n/it.js +6 -4
- package/lib/i18n/ko.d.ts +2 -2
- package/lib/i18n/ko.js +6 -4
- package/lib/i18n/lt.d.ts +58 -2
- package/lib/i18n/lt.js +6 -4
- package/lib/i18n/lv.d.ts +47 -2
- package/lib/i18n/lv.js +6 -4
- package/lib/i18n/nl.d.ts +2 -2
- package/lib/i18n/nl.js +2 -2
- package/lib/i18n/no.d.ts +2 -2
- package/lib/i18n/no.js +6 -4
- package/lib/i18n/pl.d.ts +58 -2
- package/lib/i18n/pl.js +6 -4
- package/lib/i18n/pt.d.ts +2 -2
- package/lib/i18n/pt.js +6 -4
- package/lib/i18n/ru.d.ts +17 -71
- package/lib/i18n/ru.js +18 -24
- package/lib/i18n/sr.d.ts +35 -14
- package/lib/i18n/sr.js +15 -15
- package/lib/i18n/tr.d.ts +2 -2
- package/lib/i18n/tr.js +2 -2
- package/lib/i18n/uk.d.ts +69 -2
- package/lib/i18n/uk.js +2 -2
- package/lib/i18n/vi.d.ts +2 -2
- package/lib/i18n/vi.js +2 -2
- package/lib/i18n/zh.d.ts +2 -2
- package/lib/i18n/zh.js +2 -2
- package/package.json +18 -17
|
@@ -38,10 +38,10 @@ export default class _default {
|
|
|
38
38
|
get wholeNumber(): number;
|
|
39
39
|
/**
|
|
40
40
|
* Convert decimal number to a string array of cardinal numbers.
|
|
41
|
-
* @param {
|
|
41
|
+
* @param {string} decimal Decimal string to convert.
|
|
42
42
|
* @returns {string} Value in written format.
|
|
43
43
|
*/
|
|
44
|
-
decimalToCardinal(decimal:
|
|
44
|
+
decimalToCardinal(decimal: string): string;
|
|
45
45
|
/**
|
|
46
46
|
* Converts a number to written form.
|
|
47
47
|
* @param {number|string} value Number to be convert.
|
|
@@ -21,7 +21,7 @@ export default class {
|
|
|
21
21
|
options = Object.assign({
|
|
22
22
|
negativeWord: '',
|
|
23
23
|
separatorWord: undefined,
|
|
24
|
-
|
|
24
|
+
zero: undefined,
|
|
25
25
|
spaceSeparator: ' '
|
|
26
26
|
}, options);
|
|
27
27
|
|
|
@@ -69,21 +69,30 @@ export default class {
|
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Convert decimal number to a string array of cardinal numbers.
|
|
72
|
-
* @param {
|
|
72
|
+
* @param {string} decimal Decimal string to convert.
|
|
73
73
|
* @returns {string} Value in written format.
|
|
74
74
|
*/
|
|
75
75
|
decimalToCardinal(decimal) {
|
|
76
76
|
const words = [];
|
|
77
|
+
let allZero = true;
|
|
77
78
|
|
|
78
79
|
// Split decimal portion into an array of characters in reverse
|
|
79
|
-
const chars = decimal.split('')
|
|
80
|
+
const chars = decimal.split('');
|
|
81
|
+
|
|
82
|
+
// Loop through array (from the end) adding leading zeros to output array
|
|
83
|
+
chars.forEach(char => {
|
|
84
|
+
if (char === '0') {
|
|
85
|
+
words.push(this.zero);
|
|
86
|
+
} else {
|
|
87
|
+
allZero = false;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
80
90
|
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
words
|
|
91
|
+
// Add decimal number to word array
|
|
92
|
+
if (allZero) {
|
|
93
|
+
return words;
|
|
84
94
|
}
|
|
85
95
|
|
|
86
|
-
// Add decimal number to word array
|
|
87
96
|
return words.concat(this.toCardinal(BigInt(decimal)));
|
|
88
97
|
}
|
|
89
98
|
|
package/lib/i18n/ar.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string} value Number to be convert.
|
|
4
|
-
* @param {object} options Options for class.
|
|
4
|
+
* @param {object} [options] Options for class.
|
|
5
5
|
* @throws {Error} Value cannot be invalid.
|
|
6
6
|
* @returns {string} Value in cardinal (written) format.
|
|
7
7
|
*/
|
|
8
|
-
export default function _default(value: number | string, options
|
|
8
|
+
export default function _default(value: number | string, options?: object): string;
|
|
9
9
|
export class Arabic extends AbstractLanguage {
|
|
10
10
|
constructor(options: any);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
number: any;
|
|
12
|
+
feminine: any;
|
|
13
|
+
ones: {
|
|
14
|
+
masculine: string[];
|
|
15
|
+
feminine: string[];
|
|
16
|
+
};
|
|
16
17
|
arabicTens: string[];
|
|
17
18
|
arabicHundreds: string[];
|
|
18
19
|
arabicAppendedTwos: string[];
|
package/lib/i18n/ar.js
CHANGED
|
@@ -1,27 +1,54 @@
|
|
|
1
1
|
import AbstractLanguage from '../classes/AbstractLanguage.js';
|
|
2
2
|
|
|
3
3
|
export class Arabic extends AbstractLanguage {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
number;
|
|
5
|
+
|
|
6
|
+
feminine;
|
|
7
|
+
|
|
8
|
+
ones = {
|
|
9
|
+
masculine: [
|
|
10
|
+
'واحد',
|
|
11
|
+
'اثنان',
|
|
12
|
+
'ثلاثة',
|
|
13
|
+
'أربعة',
|
|
14
|
+
'خمسة',
|
|
15
|
+
'ستة',
|
|
16
|
+
'سبعة',
|
|
17
|
+
'ثمانية',
|
|
18
|
+
'تسعة',
|
|
19
|
+
'عشرة',
|
|
20
|
+
'أحد عشر',
|
|
21
|
+
'اثنا عشر',
|
|
22
|
+
'ثلاثة عشر',
|
|
23
|
+
'أربعة عشر',
|
|
24
|
+
'خمسة عشر',
|
|
25
|
+
'ستة عشر',
|
|
26
|
+
'سبعة عشر',
|
|
27
|
+
'ثمانية عشر',
|
|
28
|
+
'تسعة عشر',
|
|
29
|
+
],
|
|
30
|
+
feminine: [
|
|
31
|
+
'إحدى',
|
|
32
|
+
'اثنتان',
|
|
33
|
+
'ثلاث',
|
|
34
|
+
'أربع',
|
|
35
|
+
'خمس',
|
|
36
|
+
'ست',
|
|
37
|
+
'سبع',
|
|
38
|
+
'ثمان',
|
|
39
|
+
'تسع',
|
|
40
|
+
'عشر',
|
|
41
|
+
'إحدى عشرة',
|
|
42
|
+
'اثنتا عشرة',
|
|
43
|
+
'ثلاث عشرة',
|
|
44
|
+
'أربع عشرة',
|
|
45
|
+
'خمس عشرة',
|
|
46
|
+
'ست عشرة',
|
|
47
|
+
'سبع عشرة',
|
|
48
|
+
'ثماني عشرة',
|
|
49
|
+
'تسع عشرة',
|
|
50
|
+
]
|
|
51
|
+
};
|
|
25
52
|
|
|
26
53
|
arabicTens = ['عشرون', 'ثلاثون', 'أربعون', 'خمسون', 'ستون', 'سبعون', 'ثمانون', 'تسعون'];
|
|
27
54
|
|
|
@@ -42,18 +69,23 @@ export class Arabic extends AbstractLanguage {
|
|
|
42
69
|
// isCurrencyNameFeminine = false
|
|
43
70
|
|
|
44
71
|
constructor(options) {
|
|
45
|
-
|
|
72
|
+
options = Object.assign({
|
|
46
73
|
negativeWord: 'ناقص',
|
|
47
74
|
separatorWord: 'فاصلة',
|
|
48
|
-
zero: 'صفر'
|
|
49
|
-
|
|
75
|
+
zero: 'صفر',
|
|
76
|
+
feminine: false,
|
|
77
|
+
}, options);
|
|
78
|
+
|
|
79
|
+
super(options);
|
|
80
|
+
|
|
81
|
+
this.feminine = options.feminine;
|
|
50
82
|
}
|
|
51
83
|
|
|
52
|
-
digitFeminineStatus(digit
|
|
84
|
+
digitFeminineStatus(digit) {
|
|
53
85
|
// if ((groupLevel == -1 && this.isCurrencyPartNameFeminine) || (groupLevel == 0 && this.isCurrencyNameFeminine)) {
|
|
54
86
|
// return this.arabicFeminineOnes[digit]
|
|
55
87
|
// }
|
|
56
|
-
return this.
|
|
88
|
+
return this.ones[this.feminine ? 'feminine' : 'masculine'][digit - 1];
|
|
57
89
|
}
|
|
58
90
|
|
|
59
91
|
processArabicGroup(groupNumber, groupLevel, remainingNumber) {
|
|
@@ -61,10 +93,8 @@ export class Arabic extends AbstractLanguage {
|
|
|
61
93
|
const hundreds = groupNumber / 100;
|
|
62
94
|
let retVal = '';
|
|
63
95
|
|
|
64
|
-
if (
|
|
65
|
-
retVal = (
|
|
66
|
-
tens == 0 && Math.trunc(hundreds) == 2
|
|
67
|
-
) ? this.arabicAppendedTwos[0] : this.arabicHundreds[Math.trunc(hundreds)];
|
|
96
|
+
if (hundreds > 0) {
|
|
97
|
+
retVal = (tens == 0 && Math.trunc(hundreds) == 2 ? this.arabicAppendedTwos[0] : this.arabicHundreds[Math.trunc(hundreds)]);
|
|
68
98
|
}
|
|
69
99
|
|
|
70
100
|
if (tens > 0) {
|
|
@@ -72,13 +102,13 @@ export class Arabic extends AbstractLanguage {
|
|
|
72
102
|
if (tens == 2 && Math.trunc(hundreds) == 0 && groupLevel > 0) {
|
|
73
103
|
retVal = ([
|
|
74
104
|
2000, 2000000, 2000000000, 2000000000000, 2000000000000000, 2000000000000000000
|
|
75
|
-
].indexOf(this.
|
|
76
|
-
Math.trunc(groupLevel)] : this.arabicTwos[Math.trunc(groupLevel)
|
|
77
|
-
];
|
|
105
|
+
].indexOf(this.number) != -1) ? this.arabicAppendedTwos[groupLevel] : this.arabicTwos[groupLevel];
|
|
78
106
|
} else {
|
|
107
|
+
// Add divider
|
|
79
108
|
if (retVal != '') {
|
|
80
109
|
retVal += ' و ';
|
|
81
110
|
}
|
|
111
|
+
|
|
82
112
|
if (tens == 1 && groupLevel > 0 && hundreds == 0) {
|
|
83
113
|
retVal += '';
|
|
84
114
|
} else if (
|
|
@@ -114,30 +144,35 @@ export class Arabic extends AbstractLanguage {
|
|
|
114
144
|
}
|
|
115
145
|
|
|
116
146
|
toCardinal(number) {
|
|
117
|
-
/** @todo Convert class to work with BigInt */
|
|
118
|
-
number = Number(number);
|
|
119
|
-
|
|
120
147
|
if (number == 0) {
|
|
121
148
|
return this.zero;
|
|
122
149
|
}
|
|
123
150
|
|
|
151
|
+
this.number = number;
|
|
124
152
|
let tempNumber = number;
|
|
125
|
-
this.integerValue = number;
|
|
126
|
-
let retVal = '';
|
|
127
153
|
let group = 0;
|
|
154
|
+
let retVal = '';
|
|
128
155
|
|
|
156
|
+
// Loop until number has been reduced to zero or less
|
|
129
157
|
while (tempNumber > 0) {
|
|
130
|
-
|
|
131
|
-
|
|
158
|
+
// Get the remaining value after dividing by 1000
|
|
159
|
+
const numberToProcess = Number(tempNumber % 1000n); // Maximum: 999
|
|
160
|
+
// Divide number by 1000
|
|
161
|
+
tempNumber = tempNumber / 1000n;
|
|
132
162
|
|
|
133
|
-
|
|
163
|
+
// Process "group"
|
|
164
|
+
const groupDescription = this.processArabicGroup(numberToProcess, group, tempNumber);
|
|
134
165
|
|
|
166
|
+
// Did the group return anything?
|
|
135
167
|
if (groupDescription != '') {
|
|
168
|
+
// Is this after the first "group"?
|
|
136
169
|
if (group > 0) {
|
|
170
|
+
// Is the return value still empty?
|
|
137
171
|
if (retVal != '') {
|
|
138
172
|
retVal = ' و ' + retVal;
|
|
139
173
|
}
|
|
140
174
|
|
|
175
|
+
// Process every number other than 2
|
|
141
176
|
if (numberToProcess != 2) {
|
|
142
177
|
if (numberToProcess % 100 != 1) {
|
|
143
178
|
if (numberToProcess >= 3 && numberToProcess <= 10) {
|
|
@@ -155,10 +190,13 @@ export class Arabic extends AbstractLanguage {
|
|
|
155
190
|
}
|
|
156
191
|
}
|
|
157
192
|
|
|
193
|
+
// Add "group" return to output variable
|
|
194
|
+
// NOTE: Language is right-to-left
|
|
158
195
|
retVal = groupDescription + ' ' + retVal;
|
|
159
196
|
}
|
|
160
197
|
|
|
161
|
-
group
|
|
198
|
+
// Increase group level/number
|
|
199
|
+
group++;
|
|
162
200
|
}
|
|
163
201
|
|
|
164
202
|
return retVal.trim();
|
|
@@ -168,10 +206,10 @@ export class Arabic extends AbstractLanguage {
|
|
|
168
206
|
/**
|
|
169
207
|
* Converts a value to cardinal (written) form.
|
|
170
208
|
* @param {number|string} value Number to be convert.
|
|
171
|
-
* @param {object} options Options for class.
|
|
209
|
+
* @param {object} [options] Options for class.
|
|
172
210
|
* @throws {Error} Value cannot be invalid.
|
|
173
211
|
* @returns {string} Value in cardinal (written) format.
|
|
174
212
|
*/
|
|
175
|
-
export default function (value, options) {
|
|
213
|
+
export default function (value, options = {}) {
|
|
176
214
|
return new Arabic(options).floatToCardinal(value);
|
|
177
215
|
}
|
package/lib/i18n/az.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string} value Number to be convert.
|
|
4
|
-
* @param {object} options Options for class.
|
|
4
|
+
* @param {object} [options] Options for class.
|
|
5
5
|
* @throws {Error} Value cannot be invalid.
|
|
6
6
|
* @returns {string} Value in cardinal (written) format.
|
|
7
7
|
*/
|
|
8
|
-
export default function _default(value: number | string, options
|
|
8
|
+
export default function _default(value: number | string, options?: object): string;
|
|
9
9
|
export class N2WordsAZ extends BaseLanguage {
|
|
10
10
|
constructor(options: any);
|
|
11
11
|
merge(lPair: any, rPair: any): {
|
package/lib/i18n/az.js
CHANGED
|
@@ -2,11 +2,13 @@ import BaseLanguage from '../classes/BaseLanguage.js';
|
|
|
2
2
|
|
|
3
3
|
export class N2WordsAZ extends BaseLanguage {
|
|
4
4
|
constructor(options) {
|
|
5
|
-
|
|
5
|
+
options = Object.assign({
|
|
6
6
|
negativeWord: 'mənfi',
|
|
7
7
|
separatorWord: 'nöqtə',
|
|
8
8
|
zero: 'sıfır'
|
|
9
|
-
}, options)
|
|
9
|
+
}, options);
|
|
10
|
+
|
|
11
|
+
super(options, [
|
|
10
12
|
[1000000000000000000n, 'kentilyon'],
|
|
11
13
|
[1000000000000000n, 'katrilyon'],
|
|
12
14
|
[1000000000000n, 'trilyon'],
|
|
@@ -55,10 +57,10 @@ export class N2WordsAZ extends BaseLanguage {
|
|
|
55
57
|
/**
|
|
56
58
|
* Converts a value to cardinal (written) form.
|
|
57
59
|
* @param {number|string} value Number to be convert.
|
|
58
|
-
* @param {object} options Options for class.
|
|
60
|
+
* @param {object} [options] Options for class.
|
|
59
61
|
* @throws {Error} Value cannot be invalid.
|
|
60
62
|
* @returns {string} Value in cardinal (written) format.
|
|
61
63
|
*/
|
|
62
|
-
export default function (value, options) {
|
|
64
|
+
export default function (value, options = {}) {
|
|
63
65
|
return new N2WordsAZ(options).floatToCardinal(value);
|
|
64
66
|
}
|
package/lib/i18n/cz.d.ts
CHANGED
|
@@ -1,12 +1,68 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string} value Number to be convert.
|
|
4
|
-
* @param {object} options Options for class.
|
|
4
|
+
* @param {object} [options] Options for class.
|
|
5
5
|
* @throws {Error} Value cannot be invalid.
|
|
6
6
|
* @returns {string} Value in cardinal (written) format.
|
|
7
7
|
*/
|
|
8
|
-
export default function _default(value: number | string, options
|
|
8
|
+
export default function _default(value: number | string, options?: object): string;
|
|
9
9
|
export class N2WordsCZ 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: {
|
|
44
|
+
1: string;
|
|
45
|
+
2: string;
|
|
46
|
+
3: string;
|
|
47
|
+
4: string;
|
|
48
|
+
5: string;
|
|
49
|
+
6: string;
|
|
50
|
+
7: string;
|
|
51
|
+
8: string;
|
|
52
|
+
9: string;
|
|
53
|
+
};
|
|
54
|
+
thousands: {
|
|
55
|
+
1: string[];
|
|
56
|
+
2: string[];
|
|
57
|
+
3: string[];
|
|
58
|
+
4: string[];
|
|
59
|
+
5: string[];
|
|
60
|
+
6: string[];
|
|
61
|
+
7: string[];
|
|
62
|
+
8: string[];
|
|
63
|
+
9: string[];
|
|
64
|
+
10: string[];
|
|
65
|
+
};
|
|
10
66
|
get separatorWord(): "celá" | "celé" | "celých";
|
|
11
67
|
}
|
|
12
68
|
import { N2WordsRU } from './ru.js';
|
package/lib/i18n/cz.js
CHANGED
|
@@ -63,10 +63,12 @@ export class N2WordsCZ extends N2WordsRU {
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
constructor(options) {
|
|
66
|
-
|
|
66
|
+
options = Object.assign({
|
|
67
67
|
negativeWord: 'mínus',
|
|
68
68
|
zero: 'nula'
|
|
69
|
-
}, options)
|
|
69
|
+
}, options);
|
|
70
|
+
|
|
71
|
+
super(options);
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
get separatorWord() {
|
|
@@ -125,10 +127,10 @@ export class N2WordsCZ extends N2WordsRU {
|
|
|
125
127
|
/**
|
|
126
128
|
* Converts a value to cardinal (written) form.
|
|
127
129
|
* @param {number|string} value Number to be convert.
|
|
128
|
-
* @param {object} options Options for class.
|
|
130
|
+
* @param {object} [options] Options for class.
|
|
129
131
|
* @throws {Error} Value cannot be invalid.
|
|
130
132
|
* @returns {string} Value in cardinal (written) format.
|
|
131
133
|
*/
|
|
132
|
-
export default function (value, options) {
|
|
134
|
+
export default function (value, options = {}) {
|
|
133
135
|
return new N2WordsCZ(options).floatToCardinal(value);
|
|
134
136
|
}
|
package/lib/i18n/de.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string} value Number to be convert.
|
|
4
|
-
* @param {object} options Options for class.
|
|
4
|
+
* @param {object} [options] Options for class.
|
|
5
5
|
* @throws {Error} Value cannot be invalid.
|
|
6
6
|
* @returns {string} Value in cardinal (written) format.
|
|
7
7
|
*/
|
|
8
|
-
export default function _default(value: number | string, options
|
|
8
|
+
export default function _default(value: number | string, options?: object): string;
|
|
9
9
|
export class N2WordsDE extends BaseLanguage {
|
|
10
10
|
constructor(options: any);
|
|
11
11
|
merge(curr: any, next: any): {
|
package/lib/i18n/de.js
CHANGED
|
@@ -2,11 +2,13 @@ import BaseLanguage from '../classes/BaseLanguage.js';
|
|
|
2
2
|
|
|
3
3
|
export class N2WordsDE extends BaseLanguage {
|
|
4
4
|
constructor(options) {
|
|
5
|
-
|
|
5
|
+
options = Object.assign({
|
|
6
6
|
negativeWord: 'minus',
|
|
7
7
|
separatorWord: 'komma',
|
|
8
8
|
zero: 'null'
|
|
9
|
-
}, options)
|
|
9
|
+
}, options);
|
|
10
|
+
|
|
11
|
+
super(options, [
|
|
10
12
|
[1000000000000000000000000000n, 'Quadrilliarde'],
|
|
11
13
|
[1000000000000000000000000n, 'Quadrillion'],
|
|
12
14
|
[1000000000000000000000n, 'Trilliarde'],
|
|
@@ -96,10 +98,10 @@ export class N2WordsDE extends BaseLanguage {
|
|
|
96
98
|
/**
|
|
97
99
|
* Converts a value to cardinal (written) form.
|
|
98
100
|
* @param {number|string} value Number to be convert.
|
|
99
|
-
* @param {object} options Options for class.
|
|
101
|
+
* @param {object} [options] Options for class.
|
|
100
102
|
* @throws {Error} Value cannot be invalid.
|
|
101
103
|
* @returns {string} Value in cardinal (written) format.
|
|
102
104
|
*/
|
|
103
|
-
export default function (value, options) {
|
|
105
|
+
export default function (value, options = {}) {
|
|
104
106
|
return new N2WordsDE(options).floatToCardinal(value);
|
|
105
107
|
}
|
package/lib/i18n/dk.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string} value Number to be convert.
|
|
4
|
-
* @param {object} options Options for class.
|
|
4
|
+
* @param {object} [options] Options for class.
|
|
5
5
|
* @throws {Error} Value cannot be invalid.
|
|
6
6
|
* @returns {string} Value in cardinal (written) format.
|
|
7
7
|
*/
|
|
8
|
-
export default function _default(value: number | string, options
|
|
8
|
+
export default function _default(value: number | string, options?: object): string;
|
|
9
9
|
export class N2WordsDK extends BaseLanguage {
|
|
10
10
|
constructor(options: any);
|
|
11
11
|
ordFlag: any;
|
package/lib/i18n/dk.js
CHANGED
|
@@ -60,7 +60,7 @@ export class N2WordsDK extends BaseLanguage {
|
|
|
60
60
|
let nText = Object.keys(next)[0];
|
|
61
61
|
const cNum = BigInt(Object.values(curr)[0]);
|
|
62
62
|
const nNum = BigInt(Object.values(next)[0]);
|
|
63
|
-
let val
|
|
63
|
+
let val;
|
|
64
64
|
if (nNum == 100 || nNum == 1000) {
|
|
65
65
|
next = { [`et${nText}`]: nNum };
|
|
66
66
|
}
|
|
@@ -101,10 +101,10 @@ export class N2WordsDK extends BaseLanguage {
|
|
|
101
101
|
/**
|
|
102
102
|
* Converts a value to cardinal (written) form.
|
|
103
103
|
* @param {number|string} value Number to be convert.
|
|
104
|
-
* @param {object} options Options for class.
|
|
104
|
+
* @param {object} [options] Options for class.
|
|
105
105
|
* @throws {Error} Value cannot be invalid.
|
|
106
106
|
* @returns {string} Value in cardinal (written) format.
|
|
107
107
|
*/
|
|
108
|
-
export default function (value, options) {
|
|
108
|
+
export default function (value, options = {}) {
|
|
109
109
|
return new N2WordsDK(options).floatToCardinal(value);
|
|
110
110
|
}
|
package/lib/i18n/en.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string} value Number to be convert.
|
|
4
|
-
* @param {object} options Options for class.
|
|
4
|
+
* @param {object} [options] Options for class.
|
|
5
5
|
* @throws {Error} Value cannot be invalid.
|
|
6
6
|
* @returns {string} Value in cardinal (written) format.
|
|
7
7
|
*/
|
|
8
|
-
export default function _default(value: number | string, options
|
|
8
|
+
export default function _default(value: number | string, options?: object): string;
|
|
9
9
|
/**
|
|
10
10
|
* This class is for converting numbers to english words.
|
|
11
11
|
*/
|
package/lib/i18n/en.js
CHANGED
|
@@ -5,11 +5,13 @@ import BaseLanguage from '../classes/BaseLanguage.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export class English extends BaseLanguage {
|
|
7
7
|
constructor(options) {
|
|
8
|
-
|
|
8
|
+
options = Object.assign({
|
|
9
9
|
negativeWord: 'minus',
|
|
10
10
|
separatorWord: 'point',
|
|
11
11
|
zero: 'zero'
|
|
12
|
-
}, options)
|
|
12
|
+
}, options);
|
|
13
|
+
|
|
14
|
+
super(options, [
|
|
13
15
|
[1000000000000000000000000000n, 'octillion'],
|
|
14
16
|
[1000000000000000000000000n, 'septillion'],
|
|
15
17
|
[1000000000000000000000n, 'sextillion'],
|
|
@@ -75,10 +77,10 @@ export class English extends BaseLanguage {
|
|
|
75
77
|
/**
|
|
76
78
|
* Converts a value to cardinal (written) form.
|
|
77
79
|
* @param {number|string} value Number to be convert.
|
|
78
|
-
* @param {object} options Options for class.
|
|
80
|
+
* @param {object} [options] Options for class.
|
|
79
81
|
* @throws {Error} Value cannot be invalid.
|
|
80
82
|
* @returns {string} Value in cardinal (written) format.
|
|
81
83
|
*/
|
|
82
|
-
export default function (value, options) {
|
|
84
|
+
export default function (value, options = {}) {
|
|
83
85
|
return new English(options).floatToCardinal(value);
|
|
84
86
|
}
|
package/lib/i18n/es.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string} value Number to be convert.
|
|
4
|
-
* @param {object} options Options for class.
|
|
4
|
+
* @param {object} [options] Options for class.
|
|
5
5
|
* @throws {Error} Value cannot be invalid.
|
|
6
6
|
* @returns {string} Value in cardinal (written) format.
|
|
7
7
|
*/
|
|
8
|
-
export default function _default(value: number | string, options
|
|
8
|
+
export default function _default(value: number | string, options?: object): string;
|
|
9
9
|
export class N2WordsES extends BaseLanguage {
|
|
10
10
|
constructor(options: any);
|
|
11
11
|
genderStem: any;
|
package/lib/i18n/es.js
CHANGED
|
@@ -101,10 +101,10 @@ export class N2WordsES extends BaseLanguage {
|
|
|
101
101
|
/**
|
|
102
102
|
* Converts a value to cardinal (written) form.
|
|
103
103
|
* @param {number|string} value Number to be convert.
|
|
104
|
-
* @param {object} options Options for class.
|
|
104
|
+
* @param {object} [options] Options for class.
|
|
105
105
|
* @throws {Error} Value cannot be invalid.
|
|
106
106
|
* @returns {string} Value in cardinal (written) format.
|
|
107
107
|
*/
|
|
108
|
-
export default function (value, options) {
|
|
108
|
+
export default function (value, options = {}) {
|
|
109
109
|
return new N2WordsES(options).floatToCardinal(value);
|
|
110
110
|
}
|
package/lib/i18n/fa.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string} value Number to be convert.
|
|
4
|
-
* @param {object} options Options for class.
|
|
4
|
+
* @param {object} [options] Options for class.
|
|
5
5
|
* @throws {Error} Value cannot be invalid.
|
|
6
6
|
* @returns {string} Value in cardinal (written) format.
|
|
7
7
|
*/
|
|
8
|
-
export default function _default(value: number | string, options
|
|
8
|
+
export default function _default(value: number | string, options?: object): string;
|
|
9
9
|
export class N2WordsFA extends AbstractLanguage {
|
|
10
10
|
constructor(options: any);
|
|
11
11
|
namedNumbers: {
|
package/lib/i18n/fa.js
CHANGED
|
@@ -44,11 +44,13 @@ export class N2WordsFA extends AbstractLanguage {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
constructor(options) {
|
|
47
|
-
|
|
47
|
+
options = Object.assign({
|
|
48
48
|
negativeWord: 'منفى',
|
|
49
49
|
separatorWord: 'ممیّز',
|
|
50
50
|
zero: 'صفر'
|
|
51
|
-
}, options)
|
|
51
|
+
}, options);
|
|
52
|
+
|
|
53
|
+
super(options);
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
toCardinal(number) {
|
|
@@ -95,10 +97,10 @@ export class N2WordsFA extends AbstractLanguage {
|
|
|
95
97
|
/**
|
|
96
98
|
* Converts a value to cardinal (written) form.
|
|
97
99
|
* @param {number|string} value Number to be convert.
|
|
98
|
-
* @param {object} options Options for class.
|
|
100
|
+
* @param {object} [options] Options for class.
|
|
99
101
|
* @throws {Error} Value cannot be invalid.
|
|
100
102
|
* @returns {string} Value in cardinal (written) format.
|
|
101
103
|
*/
|
|
102
|
-
export default function (value, options) {
|
|
104
|
+
export default function (value, options = {}) {
|
|
103
105
|
return new N2WordsFA(options).floatToCardinal(value);
|
|
104
106
|
}
|