n2words 1.20.0 → 1.22.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 +1 -1
- package/dist/ar.js +2 -0
- package/dist/ar.js.map +1 -0
- package/dist/az.js +2 -0
- package/dist/az.js.map +1 -0
- package/dist/cz.js +2 -0
- package/dist/cz.js.map +1 -0
- package/dist/de.js +2 -0
- package/dist/de.js.map +1 -0
- package/dist/dk.js +2 -0
- package/dist/dk.js.map +1 -0
- package/dist/en.js +2 -0
- package/dist/en.js.map +1 -0
- package/dist/es.js +2 -0
- package/dist/es.js.map +1 -0
- package/dist/fa.js +2 -0
- package/dist/fa.js.map +1 -0
- package/dist/fr-BE.js +2 -0
- package/dist/fr-BE.js.map +1 -0
- package/dist/fr.js +2 -0
- package/dist/fr.js.map +1 -0
- package/dist/he.js +2 -0
- package/dist/he.js.map +1 -0
- package/dist/hr.js +2 -0
- package/dist/hr.js.map +1 -0
- package/dist/hu.js +2 -0
- package/dist/hu.js.map +1 -0
- package/dist/id.js +2 -0
- package/dist/id.js.map +1 -0
- package/dist/it.js +2 -0
- package/dist/it.js.map +1 -0
- package/dist/ko.js +2 -0
- package/dist/ko.js.map +1 -0
- package/dist/lt.js +2 -0
- package/dist/lt.js.map +1 -0
- package/dist/lv.js +2 -0
- package/dist/lv.js.map +1 -0
- package/dist/n2words.js +1 -1
- package/dist/n2words.js.map +1 -1
- package/dist/nl.js +2 -0
- package/dist/nl.js.map +1 -0
- package/dist/no.js +2 -0
- package/dist/no.js.map +1 -0
- package/dist/pl.js +2 -0
- package/dist/pl.js.map +1 -0
- package/dist/pt.js +2 -0
- package/dist/pt.js.map +1 -0
- package/dist/ro.js +2 -0
- package/dist/ro.js.map +1 -0
- package/dist/ru.js +2 -0
- package/dist/ru.js.map +1 -0
- package/dist/sr.js +2 -0
- package/dist/sr.js.map +1 -0
- package/dist/tr.js +2 -0
- package/dist/tr.js.map +1 -0
- package/dist/uk.js +2 -0
- package/dist/uk.js.map +1 -0
- package/dist/vi.js +2 -0
- package/dist/vi.js.map +1 -0
- package/dist/zh.js +2 -0
- package/dist/zh.js.map +1 -0
- package/lib/classes/{AbstractLanguage.d.ts → abstract-language.d.ts} +4 -3
- package/lib/classes/{AbstractLanguage.js → abstract-language.js} +14 -12
- package/lib/classes/{BaseLanguage.d.ts → base-language.d.ts} +6 -10
- package/lib/classes/{BaseLanguage.js → base-language.js} +23 -28
- package/lib/i18n/ar.d.ts +6 -6
- package/lib/i18n/ar.js +37 -45
- package/lib/i18n/az.d.ts +3 -3
- package/lib/i18n/az.js +15 -15
- package/lib/i18n/cz.d.ts +2 -2
- package/lib/i18n/cz.js +8 -9
- package/lib/i18n/de.d.ts +4 -4
- package/lib/i18n/de.js +33 -37
- package/lib/i18n/dk.d.ts +4 -4
- package/lib/i18n/dk.js +32 -32
- package/lib/i18n/en.d.ts +3 -3
- package/lib/i18n/en.js +18 -18
- package/lib/i18n/es.d.ts +4 -4
- package/lib/i18n/es.js +24 -24
- package/lib/i18n/fa.d.ts +3 -3
- package/lib/i18n/fa.js +9 -9
- package/lib/i18n/fr-BE.d.ts +2 -2
- package/lib/i18n/fr-BE.js +2 -2
- package/lib/i18n/fr.d.ts +4 -4
- package/lib/i18n/fr.js +29 -29
- package/lib/i18n/he.d.ts +2 -2
- package/lib/i18n/he.js +9 -12
- package/lib/i18n/hr.d.ts +2 -2
- package/lib/i18n/hr.js +10 -11
- package/lib/i18n/hu.d.ts +3 -3
- package/lib/i18n/hu.js +14 -14
- package/lib/i18n/id.d.ts +4 -4
- package/lib/i18n/id.js +25 -35
- package/lib/i18n/it.d.ts +3 -3
- package/lib/i18n/it.js +18 -38
- package/lib/i18n/ko.d.ts +3 -3
- package/lib/i18n/ko.js +16 -16
- package/lib/i18n/lt.d.ts +2 -2
- package/lib/i18n/lt.js +8 -9
- package/lib/i18n/lv.d.ts +2 -2
- package/lib/i18n/lv.js +10 -16
- package/lib/i18n/nl.d.ts +4 -4
- package/lib/i18n/nl.js +34 -34
- package/lib/i18n/no.d.ts +3 -3
- package/lib/i18n/no.js +20 -20
- package/lib/i18n/pl.d.ts +2 -2
- package/lib/i18n/pl.js +8 -9
- package/lib/i18n/pt.d.ts +4 -4
- package/lib/i18n/pt.js +25 -25
- package/lib/i18n/ro.d.ts +109 -0
- package/lib/i18n/ro.js +360 -0
- package/lib/i18n/ru.d.ts +4 -4
- package/lib/i18n/ru.js +15 -14
- package/lib/i18n/sr.d.ts +2 -2
- package/lib/i18n/sr.js +10 -11
- package/lib/i18n/tr.d.ts +3 -3
- package/lib/i18n/tr.js +15 -15
- package/lib/i18n/uk.d.ts +2 -2
- package/lib/i18n/uk.js +2 -2
- package/lib/i18n/vi.d.ts +3 -3
- package/lib/i18n/vi.js +4 -8
- package/lib/i18n/zh.d.ts +6 -6
- package/lib/i18n/zh.js +11 -11
- package/lib/n2words.d.ts +3 -1
- package/lib/n2words.js +17 -7
- package/package.json +32 -23
package/lib/i18n/ar.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string|bigint} value Number to be convert.
|
|
4
4
|
* @param {object} [options] Options for class.
|
|
5
|
-
* @throws {Error} Value cannot be invalid.
|
|
6
5
|
* @returns {string} Value in cardinal (written) format.
|
|
6
|
+
* @throws {Error} Value cannot be invalid.
|
|
7
7
|
*/
|
|
8
|
-
export default function
|
|
8
|
+
export default function floatToCardinal(value: number | string | bigint, options?: object): string;
|
|
9
9
|
export class Arabic extends AbstractLanguage {
|
|
10
10
|
constructor(options: any);
|
|
11
11
|
number: any;
|
|
@@ -24,10 +24,10 @@ export class Arabic extends AbstractLanguage {
|
|
|
24
24
|
digitFeminineStatus(digit: any): string;
|
|
25
25
|
/**
|
|
26
26
|
* Processes the Arabic group number and returns the corresponding Arabic representation.
|
|
27
|
-
* @param {number} groupNumber - The number to process.
|
|
28
|
-
* @param {number} groupLevel -
|
|
29
|
-
* Example: 12345678 is processed in blocks: '678' (group 0), '345' (group 1), '12' (group 2)
|
|
27
|
+
* @param {number} groupNumber - The number to process. (Range: 1-999)
|
|
28
|
+
* @param {number} groupLevel - Group level to process. (See example)
|
|
30
29
|
* @returns {string} The Arabic representation of the group number.
|
|
30
|
+
* @example 12345678 is processed in blocks of 3: '678' (group 0), '345' (group 1), '12' (group 2).
|
|
31
31
|
*/
|
|
32
32
|
processArabicGroup(groupNumber: number, groupLevel: number): string;
|
|
33
33
|
/**
|
|
@@ -38,4 +38,4 @@ export class Arabic extends AbstractLanguage {
|
|
|
38
38
|
*/
|
|
39
39
|
toCardinal(number: number): string;
|
|
40
40
|
}
|
|
41
|
-
import AbstractLanguage from '../classes/
|
|
41
|
+
import AbstractLanguage from '../classes/abstract-language.js';
|
package/lib/i18n/ar.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import AbstractLanguage from '../classes/
|
|
1
|
+
import AbstractLanguage from '../classes/abstract-language.js';
|
|
2
2
|
|
|
3
3
|
export class Arabic extends AbstractLanguage {
|
|
4
4
|
number;
|
|
@@ -83,23 +83,23 @@ export class Arabic extends AbstractLanguage {
|
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* Processes the Arabic group number and returns the corresponding Arabic representation.
|
|
86
|
-
* @param {number} groupNumber - The number to process.
|
|
87
|
-
* @param {number} groupLevel -
|
|
88
|
-
* Example: 12345678 is processed in blocks: '678' (group 0), '345' (group 1), '12' (group 2)
|
|
86
|
+
* @param {number} groupNumber - The number to process. (Range: 1-999)
|
|
87
|
+
* @param {number} groupLevel - Group level to process. (See example)
|
|
89
88
|
* @returns {string} The Arabic representation of the group number.
|
|
89
|
+
* @example 12345678 is processed in blocks of 3: '678' (group 0), '345' (group 1), '12' (group 2).
|
|
90
90
|
*/
|
|
91
91
|
processArabicGroup(groupNumber, groupLevel) {
|
|
92
92
|
let tens = groupNumber % 100;
|
|
93
93
|
const hundreds = groupNumber / 100;
|
|
94
|
-
let
|
|
94
|
+
let returnValue = '';
|
|
95
95
|
|
|
96
96
|
if (Math.trunc(hundreds) > 0) {
|
|
97
97
|
if (tens == 0 && Math.trunc(hundreds) == 2) {
|
|
98
|
-
|
|
98
|
+
returnValue = this.arabicTwos[0];
|
|
99
99
|
} else {
|
|
100
|
-
|
|
101
|
-
if (
|
|
102
|
-
|
|
100
|
+
returnValue = this.arabicHundreds[Math.trunc(hundreds)];
|
|
101
|
+
if (returnValue != '' && tens != 0) {
|
|
102
|
+
returnValue += ' و';
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -108,32 +108,28 @@ export class Arabic extends AbstractLanguage {
|
|
|
108
108
|
if (tens === 2 && Math.trunc(hundreds) === 0 && groupLevel > 0) {
|
|
109
109
|
const pow = Math.trunc(Math.log10(Number(this.number)));
|
|
110
110
|
if (pow % 3 === 0 && this.number === 2 * Math.pow(10, pow)) {
|
|
111
|
-
|
|
112
|
-
retVal = this.arabicTwos[Math.trunc(groupLevel)];
|
|
113
|
-
} else {
|
|
114
|
-
retVal = this.arabicAppendedTwos[Math.trunc(groupLevel)];
|
|
115
|
-
}
|
|
111
|
+
returnValue = groupNumber === 2 ? this.arabicTwos[Math.trunc(groupLevel)] : this.arabicAppendedTwos[Math.trunc(groupLevel)];
|
|
116
112
|
} else {
|
|
117
|
-
|
|
113
|
+
returnValue = this.arabicTwos[Math.trunc(groupLevel)];
|
|
118
114
|
}
|
|
119
115
|
} else if (tens === 1 && groupLevel > 0) {
|
|
120
|
-
|
|
116
|
+
returnValue += this.arabicGroup[Math.trunc(groupLevel)];
|
|
121
117
|
} else {
|
|
122
|
-
|
|
118
|
+
returnValue += this.digitFeminineStatus(Math.trunc(tens), groupLevel);
|
|
123
119
|
}
|
|
124
120
|
} else if (tens >= 20) { // 20 -> 99
|
|
125
121
|
const ones = tens % 10;
|
|
126
122
|
const tensIndex = (tens / 10) - 2;
|
|
127
123
|
if (ones > 0) {
|
|
128
|
-
|
|
124
|
+
returnValue += this.digitFeminineStatus(ones, groupLevel);
|
|
129
125
|
}
|
|
130
|
-
if (
|
|
131
|
-
|
|
126
|
+
if (returnValue != '' && ones != 0) {
|
|
127
|
+
returnValue += ' و';
|
|
132
128
|
}
|
|
133
|
-
|
|
129
|
+
returnValue += this.arabicTens[Math.trunc(tensIndex)];
|
|
134
130
|
}
|
|
135
131
|
|
|
136
|
-
return
|
|
132
|
+
return returnValue;
|
|
137
133
|
}
|
|
138
134
|
|
|
139
135
|
/**
|
|
@@ -148,17 +144,17 @@ export class Arabic extends AbstractLanguage {
|
|
|
148
144
|
}
|
|
149
145
|
|
|
150
146
|
this.number = number;
|
|
151
|
-
let
|
|
152
|
-
let
|
|
147
|
+
let temporaryNumber = number;
|
|
148
|
+
let temporaryNumberDec;
|
|
153
149
|
let group = 0;
|
|
154
|
-
let
|
|
150
|
+
let returnValue = '';
|
|
155
151
|
|
|
156
152
|
// Loop until number has been reduced to zero or less
|
|
157
|
-
while (
|
|
158
|
-
|
|
153
|
+
while (temporaryNumber > 0) {
|
|
154
|
+
temporaryNumberDec = temporaryNumber;
|
|
159
155
|
// Get the remaining value after dividing by 1000
|
|
160
|
-
const numberToProcess = Number(
|
|
161
|
-
|
|
156
|
+
const numberToProcess = Number(temporaryNumberDec % 1000n); // Maximum: 999
|
|
157
|
+
temporaryNumber = temporaryNumberDec / 1000n;
|
|
162
158
|
|
|
163
159
|
// Process "group"
|
|
164
160
|
const groupDescription = this.processArabicGroup(numberToProcess, group);
|
|
@@ -168,30 +164,26 @@ export class Arabic extends AbstractLanguage {
|
|
|
168
164
|
// Is this after the first "group" ? Because nothing is appeded after group 0.
|
|
169
165
|
if (group > 0) { // hundreds, thousands, etc...
|
|
170
166
|
// Is the return value still empty ?
|
|
171
|
-
if (
|
|
172
|
-
|
|
167
|
+
if (returnValue != '') {
|
|
168
|
+
returnValue = ' و' + returnValue;
|
|
173
169
|
}
|
|
174
170
|
|
|
175
171
|
if (numberToProcess > 2) {
|
|
176
|
-
if (numberToProcess % 100
|
|
172
|
+
if (numberToProcess % 100 == 1) {
|
|
173
|
+
returnValue = this.arabicGroup[group] + ' ' + returnValue;
|
|
174
|
+
} else {
|
|
177
175
|
if (numberToProcess >= 3 && numberToProcess <= 10) {
|
|
178
|
-
|
|
176
|
+
returnValue = this.arabicPluralGroups[group] + ' ' + returnValue;
|
|
179
177
|
} else {
|
|
180
|
-
|
|
181
|
-
retVal = this.arabicAppendedGroup[group] + ' ' + retVal;
|
|
182
|
-
} else {
|
|
183
|
-
retVal = this.arabicGroup[group] + ' ' + retVal;
|
|
184
|
-
}
|
|
178
|
+
returnValue = returnValue == '' ? this.arabicGroup[group] + ' ' + returnValue : this.arabicAppendedGroup[group] + ' ' + returnValue;
|
|
185
179
|
}
|
|
186
|
-
} else {
|
|
187
|
-
retVal = this.arabicGroup[group] + ' ' + retVal;
|
|
188
180
|
}
|
|
189
181
|
}
|
|
190
182
|
}
|
|
191
183
|
|
|
192
184
|
// Add "group" return to output variable
|
|
193
185
|
// NOTE: Language is right-to-left
|
|
194
|
-
|
|
186
|
+
returnValue = groupDescription + ' ' + returnValue;
|
|
195
187
|
}
|
|
196
188
|
|
|
197
189
|
// Increase group level/number
|
|
@@ -199,9 +191,9 @@ export class Arabic extends AbstractLanguage {
|
|
|
199
191
|
}
|
|
200
192
|
|
|
201
193
|
// Replace multiple spaces with one space
|
|
202
|
-
|
|
194
|
+
returnValue = returnValue.replaceAll(/ +/g, ' ');
|
|
203
195
|
|
|
204
|
-
return
|
|
196
|
+
return returnValue.trim();
|
|
205
197
|
}
|
|
206
198
|
}
|
|
207
199
|
|
|
@@ -209,9 +201,9 @@ export class Arabic extends AbstractLanguage {
|
|
|
209
201
|
* Converts a value to cardinal (written) form.
|
|
210
202
|
* @param {number|string|bigint} value Number to be convert.
|
|
211
203
|
* @param {object} [options] Options for class.
|
|
212
|
-
* @throws {Error} Value cannot be invalid.
|
|
213
204
|
* @returns {string} Value in cardinal (written) format.
|
|
205
|
+
* @throws {Error} Value cannot be invalid.
|
|
214
206
|
*/
|
|
215
|
-
export default function (value, options = {}) {
|
|
207
|
+
export default function floatToCardinal (value, options = {}) {
|
|
216
208
|
return new Arabic(options).floatToCardinal(value);
|
|
217
209
|
}
|
package/lib/i18n/az.d.ts
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string|bigint} value Number to be convert.
|
|
4
4
|
* @param {object} [options] Options for class.
|
|
5
|
-
* @throws {Error} Value cannot be invalid.
|
|
6
5
|
* @returns {string} Value in cardinal (written) format.
|
|
6
|
+
* @throws {Error} Value cannot be invalid.
|
|
7
7
|
*/
|
|
8
|
-
export default function
|
|
8
|
+
export default function floatToCardinal(value: number | string | bigint, options?: object): string;
|
|
9
9
|
export class N2WordsAZ extends BaseLanguage {
|
|
10
10
|
constructor(options: any);
|
|
11
11
|
merge(lPair: any, rPair: any): {
|
|
12
12
|
[x: string]: bigint;
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
import BaseLanguage from '../classes/
|
|
15
|
+
import BaseLanguage from '../classes/base-language.js';
|
package/lib/i18n/az.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import BaseLanguage from '../classes/
|
|
1
|
+
import BaseLanguage from '../classes/base-language.js';
|
|
2
2
|
|
|
3
3
|
export class N2WordsAZ extends BaseLanguage {
|
|
4
4
|
constructor(options) {
|
|
@@ -9,11 +9,11 @@ export class N2WordsAZ extends BaseLanguage {
|
|
|
9
9
|
}, options);
|
|
10
10
|
|
|
11
11
|
super(options, [
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
12
|
+
[1_000_000_000_000_000_000n, 'kentilyon'],
|
|
13
|
+
[1_000_000_000_000_000n, 'katrilyon'],
|
|
14
|
+
[1_000_000_000_000n, 'trilyon'],
|
|
15
|
+
[1_000_000_000n, 'milyar'],
|
|
16
|
+
[1_000_000n, 'milyon'],
|
|
17
17
|
[1000n, 'min'],
|
|
18
18
|
[100n, 'yüz'],
|
|
19
19
|
[90n, 'doxsan'],
|
|
@@ -41,15 +41,15 @@ export class N2WordsAZ extends BaseLanguage {
|
|
|
41
41
|
merge(lPair, rPair) {
|
|
42
42
|
const lText = Object.keys(lPair)[0];
|
|
43
43
|
const rText = Object.keys(rPair)[0];
|
|
44
|
-
const
|
|
45
|
-
const
|
|
44
|
+
const lNumber = BigInt(Object.values(lPair)[0]);
|
|
45
|
+
const rNumber = BigInt(Object.values(rPair)[0]);
|
|
46
46
|
|
|
47
|
-
if (
|
|
48
|
-
return { [rText]:
|
|
49
|
-
} else if (
|
|
50
|
-
return { [`${lText}${this.spaceSeparator}${rText}`]:
|
|
47
|
+
if (lNumber == 1 && (rNumber <= 100 || rNumber == 1000)) {
|
|
48
|
+
return { [rText]: rNumber };
|
|
49
|
+
} else if (rNumber > lNumber) {
|
|
50
|
+
return { [`${lText}${this.spaceSeparator}${rText}`]: lNumber * rNumber };
|
|
51
51
|
} else {
|
|
52
|
-
return { [`${lText}${this.spaceSeparator}${rText}`]:
|
|
52
|
+
return { [`${lText}${this.spaceSeparator}${rText}`]: lNumber + rNumber };
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -58,9 +58,9 @@ export class N2WordsAZ extends BaseLanguage {
|
|
|
58
58
|
* Converts a value to cardinal (written) form.
|
|
59
59
|
* @param {number|string|bigint} value Number to be convert.
|
|
60
60
|
* @param {object} [options] Options for class.
|
|
61
|
-
* @throws {Error} Value cannot be invalid.
|
|
62
61
|
* @returns {string} Value in cardinal (written) format.
|
|
62
|
+
* @throws {Error} Value cannot be invalid.
|
|
63
63
|
*/
|
|
64
|
-
export default function (value, options = {}) {
|
|
64
|
+
export default function floatToCardinal (value, options = {}) {
|
|
65
65
|
return new N2WordsAZ(options).floatToCardinal(value);
|
|
66
66
|
}
|
package/lib/i18n/cz.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string|bigint} value Number to be convert.
|
|
4
4
|
* @param {object} [options] Options for class.
|
|
5
|
-
* @throws {Error} Value cannot be invalid.
|
|
6
5
|
* @returns {string} Value in cardinal (written) format.
|
|
6
|
+
* @throws {Error} Value cannot be invalid.
|
|
7
7
|
*/
|
|
8
|
-
export default function
|
|
8
|
+
export default function floatToCardinal(value: number | string | bigint, options?: object): string;
|
|
9
9
|
export class N2WordsCZ extends N2WordsRU {
|
|
10
10
|
ones: {
|
|
11
11
|
1: string;
|
package/lib/i18n/cz.js
CHANGED
|
@@ -97,10 +97,9 @@ export class N2WordsCZ extends N2WordsRU {
|
|
|
97
97
|
}
|
|
98
98
|
const words = [];
|
|
99
99
|
const chunks = this.splitByX(number.toString(), 3);
|
|
100
|
-
let
|
|
101
|
-
for (
|
|
102
|
-
|
|
103
|
-
i = i - 1;
|
|
100
|
+
let index = chunks.length;
|
|
101
|
+
for (const x of chunks) {
|
|
102
|
+
index = index - 1;
|
|
104
103
|
if (x == 0) {
|
|
105
104
|
continue;
|
|
106
105
|
}
|
|
@@ -113,11 +112,11 @@ export class N2WordsCZ extends N2WordsRU {
|
|
|
113
112
|
}
|
|
114
113
|
if (n2 == 1) {
|
|
115
114
|
words.push(this.tens[n1]);
|
|
116
|
-
} else if (n1 > 0 && !(
|
|
115
|
+
} else if (n1 > 0 && !(index > 0 && x == 1)) {
|
|
117
116
|
words.push(this.ones[n1]);
|
|
118
117
|
}
|
|
119
|
-
if (
|
|
120
|
-
words.push(this.pluralize(x, this.thousands[
|
|
118
|
+
if (index > 0) {
|
|
119
|
+
words.push(this.pluralize(x, this.thousands[index]));
|
|
121
120
|
}
|
|
122
121
|
}
|
|
123
122
|
return words.join(' ');
|
|
@@ -128,9 +127,9 @@ export class N2WordsCZ extends N2WordsRU {
|
|
|
128
127
|
* Converts a value to cardinal (written) form.
|
|
129
128
|
* @param {number|string|bigint} value Number to be convert.
|
|
130
129
|
* @param {object} [options] Options for class.
|
|
131
|
-
* @throws {Error} Value cannot be invalid.
|
|
132
130
|
* @returns {string} Value in cardinal (written) format.
|
|
131
|
+
* @throws {Error} Value cannot be invalid.
|
|
133
132
|
*/
|
|
134
|
-
export default function (value, options = {}) {
|
|
133
|
+
export default function floatToCardinal (value, options = {}) {
|
|
135
134
|
return new N2WordsCZ(options).floatToCardinal(value);
|
|
136
135
|
}
|
package/lib/i18n/de.d.ts
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string|bigint} value Number to be convert.
|
|
4
4
|
* @param {object} [options] Options for class.
|
|
5
|
-
* @throws {Error} Value cannot be invalid.
|
|
6
5
|
* @returns {string} Value in cardinal (written) format.
|
|
6
|
+
* @throws {Error} Value cannot be invalid.
|
|
7
7
|
*/
|
|
8
|
-
export default function
|
|
8
|
+
export default function floatToCardinal(value: number | string | bigint, options?: object): string;
|
|
9
9
|
export class N2WordsDE extends BaseLanguage {
|
|
10
10
|
constructor(options: any);
|
|
11
|
-
merge(
|
|
11
|
+
merge(current: any, next: any): {
|
|
12
12
|
[x: string]: bigint;
|
|
13
13
|
} | {
|
|
14
14
|
[x: string]: number;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
import BaseLanguage from '../classes/
|
|
17
|
+
import BaseLanguage from '../classes/base-language.js';
|
package/lib/i18n/de.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import BaseLanguage from '../classes/
|
|
1
|
+
import BaseLanguage from '../classes/base-language.js';
|
|
2
2
|
|
|
3
3
|
export class N2WordsDE extends BaseLanguage {
|
|
4
4
|
constructor(options) {
|
|
@@ -9,14 +9,14 @@ export class N2WordsDE extends BaseLanguage {
|
|
|
9
9
|
}, options);
|
|
10
10
|
|
|
11
11
|
super(options, [
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
12
|
+
[1_000_000_000_000_000_000_000_000_000n, 'Quadrilliarde'],
|
|
13
|
+
[1_000_000_000_000_000_000_000_000n, 'Quadrillion'],
|
|
14
|
+
[1_000_000_000_000_000_000_000n, 'Trilliarde'],
|
|
15
|
+
[1_000_000_000_000_000_000n, 'Trillion'],
|
|
16
|
+
[1_000_000_000_000_000n, 'Billiarde'],
|
|
17
|
+
[1_000_000_000_000n, 'Billion'],
|
|
18
|
+
[1_000_000_000n, 'Milliarde'],
|
|
19
|
+
[1_000_000n, 'Million'],
|
|
20
20
|
[1000n, 'tausend'],
|
|
21
21
|
[100n, 'hundert'],
|
|
22
22
|
[90n, 'neunzig'],
|
|
@@ -50,48 +50,44 @@ export class N2WordsDE extends BaseLanguage {
|
|
|
50
50
|
]);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
merge(
|
|
54
|
-
let cText = Object.keys(
|
|
53
|
+
merge(current, next) {
|
|
54
|
+
let cText = Object.keys(current)[0];
|
|
55
55
|
let nText = Object.keys(next)[0];
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
if (
|
|
60
|
-
return { [`ein${nText}`]:
|
|
61
|
-
} else if (
|
|
62
|
-
return { [nText]:
|
|
56
|
+
const cNumber = BigInt(Object.values(current)[0]);
|
|
57
|
+
const nNumber = BigInt(Object.values(next)[0]);
|
|
58
|
+
if (cNumber == 1) {
|
|
59
|
+
if (nNumber == 100 || nNumber == 1000) {
|
|
60
|
+
return { [`ein${nText}`]: nNumber };
|
|
61
|
+
} else if (nNumber < 1_000_000) {
|
|
62
|
+
return { [nText]: nNumber };
|
|
63
63
|
}
|
|
64
64
|
cText = 'eine';
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
let
|
|
68
|
-
if (
|
|
69
|
-
if (
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
nText += 'n';
|
|
73
|
-
} else {
|
|
74
|
-
nText += 'en';
|
|
75
|
-
}
|
|
67
|
+
let value = 0;
|
|
68
|
+
if (nNumber > cNumber) {
|
|
69
|
+
if (nNumber >= 1_000_000) {
|
|
70
|
+
if (cNumber > 1) {
|
|
71
|
+
nText += nText.at(-1) == 'e' ? 'n' : 'en';
|
|
76
72
|
}
|
|
77
73
|
cText += ' ';
|
|
78
74
|
}
|
|
79
|
-
|
|
75
|
+
value = cNumber * nNumber;
|
|
80
76
|
} else {
|
|
81
|
-
if (
|
|
82
|
-
if (
|
|
77
|
+
if (nNumber < 10 && cNumber > 10 && cNumber < 100) {
|
|
78
|
+
if (nNumber == 1) {
|
|
83
79
|
nText = 'ein';
|
|
84
80
|
}
|
|
85
|
-
const
|
|
81
|
+
const temporary = nText;
|
|
86
82
|
nText = cText;
|
|
87
|
-
cText = `${
|
|
88
|
-
} else if (
|
|
83
|
+
cText = `${temporary}und`;
|
|
84
|
+
} else if (cNumber >= 1_000_000) {
|
|
89
85
|
cText += ' ';
|
|
90
86
|
}
|
|
91
|
-
|
|
87
|
+
value = cNumber + nNumber;
|
|
92
88
|
}
|
|
93
89
|
|
|
94
|
-
return { [`${cText}${nText}`]:
|
|
90
|
+
return { [`${cText}${nText}`]: value };
|
|
95
91
|
}
|
|
96
92
|
}
|
|
97
93
|
|
|
@@ -99,9 +95,9 @@ export class N2WordsDE extends BaseLanguage {
|
|
|
99
95
|
* Converts a value to cardinal (written) form.
|
|
100
96
|
* @param {number|string|bigint} value Number to be convert.
|
|
101
97
|
* @param {object} [options] Options for class.
|
|
102
|
-
* @throws {Error} Value cannot be invalid.
|
|
103
98
|
* @returns {string} Value in cardinal (written) format.
|
|
99
|
+
* @throws {Error} Value cannot be invalid.
|
|
104
100
|
*/
|
|
105
|
-
export default function (value, options = {}) {
|
|
101
|
+
export default function floatToCardinal (value, options = {}) {
|
|
106
102
|
return new N2WordsDE(options).floatToCardinal(value);
|
|
107
103
|
}
|
package/lib/i18n/dk.d.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string|bigint} value Number to be convert.
|
|
4
4
|
* @param {object} [options] Options for class.
|
|
5
|
-
* @throws {Error} Value cannot be invalid.
|
|
6
5
|
* @returns {string} Value in cardinal (written) format.
|
|
6
|
+
* @throws {Error} Value cannot be invalid.
|
|
7
7
|
*/
|
|
8
|
-
export default function
|
|
8
|
+
export default function floatToCardinal(value: number | string | bigint, options?: object): string;
|
|
9
9
|
export class N2WordsDK extends BaseLanguage {
|
|
10
10
|
constructor(options: any);
|
|
11
11
|
ordFlag: any;
|
|
12
|
-
merge(
|
|
12
|
+
merge(current: any, next: any): any;
|
|
13
13
|
}
|
|
14
|
-
import BaseLanguage from '../classes/
|
|
14
|
+
import BaseLanguage from '../classes/base-language.js';
|
package/lib/i18n/dk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import BaseLanguage from '../classes/
|
|
1
|
+
import BaseLanguage from '../classes/base-language.js';
|
|
2
2
|
|
|
3
3
|
export class N2WordsDK extends BaseLanguage {
|
|
4
4
|
ordFlag;
|
|
@@ -12,14 +12,14 @@ export class N2WordsDK extends BaseLanguage {
|
|
|
12
12
|
}, options);
|
|
13
13
|
|
|
14
14
|
super(options, [
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
15
|
+
[1_000_000_000_000_000_000_000_000_000n, 'quadrillarder'],
|
|
16
|
+
[1_000_000_000_000_000_000_000_000n, 'quadrillioner'],
|
|
17
|
+
[1_000_000_000_000_000_000_000n, 'trillarder'],
|
|
18
|
+
[1_000_000_000_000_000_000n, 'trillioner'],
|
|
19
|
+
[1_000_000_000_000_000n, 'billarder'],
|
|
20
|
+
[1_000_000_000_000n, 'billioner'],
|
|
21
|
+
[1_000_000_000n, 'millarder'],
|
|
22
|
+
[1_000_000n, 'millioner'],
|
|
23
23
|
[1000n, 'tusind'],
|
|
24
24
|
[100n, 'hundrede'],
|
|
25
25
|
[90n, 'halvfems'],
|
|
@@ -55,46 +55,46 @@ export class N2WordsDK extends BaseLanguage {
|
|
|
55
55
|
this.ordFlag = options.ordFlag;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
merge(
|
|
59
|
-
let cText = Object.keys(
|
|
58
|
+
merge(current, next) {
|
|
59
|
+
let cText = Object.keys(current)[0];
|
|
60
60
|
let nText = Object.keys(next)[0];
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
let
|
|
64
|
-
if (
|
|
65
|
-
next = { [`et${nText}`]:
|
|
61
|
+
const cNumber = BigInt(Object.values(current)[0]);
|
|
62
|
+
const nNumber = BigInt(Object.values(next)[0]);
|
|
63
|
+
let value;
|
|
64
|
+
if (nNumber == 100 || nNumber == 1000) {
|
|
65
|
+
next = { [`et${nText}`]: nNumber };
|
|
66
66
|
}
|
|
67
|
-
if (
|
|
68
|
-
if (
|
|
67
|
+
if (cNumber == 1) {
|
|
68
|
+
if (nNumber < 1_000_000 || this.ordFlag) {
|
|
69
69
|
return next;
|
|
70
70
|
}
|
|
71
71
|
cText = 'en';
|
|
72
72
|
}
|
|
73
|
-
if (
|
|
74
|
-
if (
|
|
73
|
+
if (nNumber > cNumber) {
|
|
74
|
+
if (nNumber >= 1_000_000) {
|
|
75
75
|
cText += ' ';
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
value = cNumber * nNumber;
|
|
78
78
|
} else {
|
|
79
|
-
if (
|
|
79
|
+
if (cNumber >= 100 && cNumber < 1000) {
|
|
80
80
|
cText += ' og ';
|
|
81
|
-
} else if (
|
|
81
|
+
} else if (cNumber >= 1000 && cNumber <= 100_000) {
|
|
82
82
|
cText += 'e og ';
|
|
83
83
|
}
|
|
84
|
-
if ((
|
|
85
|
-
if (
|
|
84
|
+
if ((nNumber < 10) && (10 < cNumber) && (cNumber < 100)) {
|
|
85
|
+
if (nNumber == 1) {
|
|
86
86
|
nText = 'en';
|
|
87
87
|
}
|
|
88
|
-
const
|
|
88
|
+
const temporary = nText;
|
|
89
89
|
nText = cText;
|
|
90
|
-
cText =
|
|
91
|
-
} else if (
|
|
90
|
+
cText = temporary + 'og';
|
|
91
|
+
} else if (cNumber >= 1_000_000) {
|
|
92
92
|
cText += ' ';
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
value = cNumber + nNumber;
|
|
95
95
|
}
|
|
96
96
|
const word = cText + nText;
|
|
97
|
-
return { [`${word}`]:
|
|
97
|
+
return { [`${word}`]: value };
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -102,9 +102,9 @@ export class N2WordsDK extends BaseLanguage {
|
|
|
102
102
|
* Converts a value to cardinal (written) form.
|
|
103
103
|
* @param {number|string|bigint} value Number to be convert.
|
|
104
104
|
* @param {object} [options] Options for class.
|
|
105
|
-
* @throws {Error} Value cannot be invalid.
|
|
106
105
|
* @returns {string} Value in cardinal (written) format.
|
|
106
|
+
* @throws {Error} Value cannot be invalid.
|
|
107
107
|
*/
|
|
108
|
-
export default function (value, options = {}) {
|
|
108
|
+
export default function floatToCardinal (value, options = {}) {
|
|
109
109
|
return new N2WordsDK(options).floatToCardinal(value);
|
|
110
110
|
}
|
package/lib/i18n/en.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Converts a value to cardinal (written) form.
|
|
3
3
|
* @param {number|string|bigint} value Number to be convert.
|
|
4
4
|
* @param {object} [options] Options for class.
|
|
5
|
-
* @throws {Error} Value cannot be invalid.
|
|
6
5
|
* @returns {string} Value in cardinal (written) format.
|
|
6
|
+
* @throws {Error} Value cannot be invalid.
|
|
7
7
|
*/
|
|
8
|
-
export default function
|
|
8
|
+
export default function floatToCardinal(value: number | string | bigint, options?: object): string;
|
|
9
9
|
/**
|
|
10
10
|
* This class is for converting numbers to english words.
|
|
11
11
|
*/
|
|
@@ -19,4 +19,4 @@ export class English extends BaseLanguage {
|
|
|
19
19
|
*/
|
|
20
20
|
merge(lPair: object, rPair: object): object;
|
|
21
21
|
}
|
|
22
|
-
import BaseLanguage from '../classes/
|
|
22
|
+
import BaseLanguage from '../classes/base-language.js';
|