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.
Files changed (127) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/dist/ar.js +2 -0
  4. package/dist/ar.js.map +1 -0
  5. package/dist/az.js +2 -0
  6. package/dist/az.js.map +1 -0
  7. package/dist/cz.js +2 -0
  8. package/dist/cz.js.map +1 -0
  9. package/dist/de.js +2 -0
  10. package/dist/de.js.map +1 -0
  11. package/dist/dk.js +2 -0
  12. package/dist/dk.js.map +1 -0
  13. package/dist/en.js +2 -0
  14. package/dist/en.js.map +1 -0
  15. package/dist/es.js +2 -0
  16. package/dist/es.js.map +1 -0
  17. package/dist/fa.js +2 -0
  18. package/dist/fa.js.map +1 -0
  19. package/dist/fr-BE.js +2 -0
  20. package/dist/fr-BE.js.map +1 -0
  21. package/dist/fr.js +2 -0
  22. package/dist/fr.js.map +1 -0
  23. package/dist/he.js +2 -0
  24. package/dist/he.js.map +1 -0
  25. package/dist/hr.js +2 -0
  26. package/dist/hr.js.map +1 -0
  27. package/dist/hu.js +2 -0
  28. package/dist/hu.js.map +1 -0
  29. package/dist/id.js +2 -0
  30. package/dist/id.js.map +1 -0
  31. package/dist/it.js +2 -0
  32. package/dist/it.js.map +1 -0
  33. package/dist/ko.js +2 -0
  34. package/dist/ko.js.map +1 -0
  35. package/dist/lt.js +2 -0
  36. package/dist/lt.js.map +1 -0
  37. package/dist/lv.js +2 -0
  38. package/dist/lv.js.map +1 -0
  39. package/dist/n2words.js +1 -1
  40. package/dist/n2words.js.map +1 -1
  41. package/dist/nl.js +2 -0
  42. package/dist/nl.js.map +1 -0
  43. package/dist/no.js +2 -0
  44. package/dist/no.js.map +1 -0
  45. package/dist/pl.js +2 -0
  46. package/dist/pl.js.map +1 -0
  47. package/dist/pt.js +2 -0
  48. package/dist/pt.js.map +1 -0
  49. package/dist/ro.js +2 -0
  50. package/dist/ro.js.map +1 -0
  51. package/dist/ru.js +2 -0
  52. package/dist/ru.js.map +1 -0
  53. package/dist/sr.js +2 -0
  54. package/dist/sr.js.map +1 -0
  55. package/dist/tr.js +2 -0
  56. package/dist/tr.js.map +1 -0
  57. package/dist/uk.js +2 -0
  58. package/dist/uk.js.map +1 -0
  59. package/dist/vi.js +2 -0
  60. package/dist/vi.js.map +1 -0
  61. package/dist/zh.js +2 -0
  62. package/dist/zh.js.map +1 -0
  63. package/lib/classes/{AbstractLanguage.d.ts → abstract-language.d.ts} +4 -3
  64. package/lib/classes/{AbstractLanguage.js → abstract-language.js} +14 -12
  65. package/lib/classes/{BaseLanguage.d.ts → base-language.d.ts} +6 -10
  66. package/lib/classes/{BaseLanguage.js → base-language.js} +23 -28
  67. package/lib/i18n/ar.d.ts +6 -6
  68. package/lib/i18n/ar.js +37 -45
  69. package/lib/i18n/az.d.ts +3 -3
  70. package/lib/i18n/az.js +15 -15
  71. package/lib/i18n/cz.d.ts +2 -2
  72. package/lib/i18n/cz.js +8 -9
  73. package/lib/i18n/de.d.ts +4 -4
  74. package/lib/i18n/de.js +33 -37
  75. package/lib/i18n/dk.d.ts +4 -4
  76. package/lib/i18n/dk.js +32 -32
  77. package/lib/i18n/en.d.ts +3 -3
  78. package/lib/i18n/en.js +18 -18
  79. package/lib/i18n/es.d.ts +4 -4
  80. package/lib/i18n/es.js +24 -24
  81. package/lib/i18n/fa.d.ts +3 -3
  82. package/lib/i18n/fa.js +9 -9
  83. package/lib/i18n/fr-BE.d.ts +2 -2
  84. package/lib/i18n/fr-BE.js +2 -2
  85. package/lib/i18n/fr.d.ts +4 -4
  86. package/lib/i18n/fr.js +29 -29
  87. package/lib/i18n/he.d.ts +2 -2
  88. package/lib/i18n/he.js +9 -12
  89. package/lib/i18n/hr.d.ts +2 -2
  90. package/lib/i18n/hr.js +10 -11
  91. package/lib/i18n/hu.d.ts +3 -3
  92. package/lib/i18n/hu.js +14 -14
  93. package/lib/i18n/id.d.ts +4 -4
  94. package/lib/i18n/id.js +25 -35
  95. package/lib/i18n/it.d.ts +3 -3
  96. package/lib/i18n/it.js +18 -38
  97. package/lib/i18n/ko.d.ts +3 -3
  98. package/lib/i18n/ko.js +16 -16
  99. package/lib/i18n/lt.d.ts +2 -2
  100. package/lib/i18n/lt.js +8 -9
  101. package/lib/i18n/lv.d.ts +2 -2
  102. package/lib/i18n/lv.js +10 -16
  103. package/lib/i18n/nl.d.ts +4 -4
  104. package/lib/i18n/nl.js +34 -34
  105. package/lib/i18n/no.d.ts +3 -3
  106. package/lib/i18n/no.js +20 -20
  107. package/lib/i18n/pl.d.ts +2 -2
  108. package/lib/i18n/pl.js +8 -9
  109. package/lib/i18n/pt.d.ts +4 -4
  110. package/lib/i18n/pt.js +25 -25
  111. package/lib/i18n/ro.d.ts +109 -0
  112. package/lib/i18n/ro.js +360 -0
  113. package/lib/i18n/ru.d.ts +4 -4
  114. package/lib/i18n/ru.js +15 -14
  115. package/lib/i18n/sr.d.ts +2 -2
  116. package/lib/i18n/sr.js +10 -11
  117. package/lib/i18n/tr.d.ts +3 -3
  118. package/lib/i18n/tr.js +15 -15
  119. package/lib/i18n/uk.d.ts +2 -2
  120. package/lib/i18n/uk.js +2 -2
  121. package/lib/i18n/vi.d.ts +3 -3
  122. package/lib/i18n/vi.js +4 -8
  123. package/lib/i18n/zh.d.ts +6 -6
  124. package/lib/i18n/zh.js +11 -11
  125. package/lib/n2words.d.ts +3 -1
  126. package/lib/n2words.js +17 -7
  127. 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 _default(value: number | string | bigint, options?: object): string;
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. From 1 to 999.
28
- * @param {number} groupLevel - The level of the group.
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/AbstractLanguage.js';
41
+ import AbstractLanguage from '../classes/abstract-language.js';
package/lib/i18n/ar.js CHANGED
@@ -1,4 +1,4 @@
1
- import AbstractLanguage from '../classes/AbstractLanguage.js';
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. From 1 to 999.
87
- * @param {number} groupLevel - The level of the group.
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 retVal = '';
94
+ let returnValue = '';
95
95
 
96
96
  if (Math.trunc(hundreds) > 0) {
97
97
  if (tens == 0 && Math.trunc(hundreds) == 2) {
98
- retVal = this.arabicTwos[0];
98
+ returnValue = this.arabicTwos[0];
99
99
  } else {
100
- retVal = this.arabicHundreds[Math.trunc(hundreds)];
101
- if (retVal != '' && tens != 0) {
102
- retVal += ' و';
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
- if (groupNumber === 2) {
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
- retVal = this.arabicTwos[Math.trunc(groupLevel)];
113
+ returnValue = this.arabicTwos[Math.trunc(groupLevel)];
118
114
  }
119
115
  } else if (tens === 1 && groupLevel > 0) {
120
- retVal += this.arabicGroup[Math.trunc(groupLevel)];
116
+ returnValue += this.arabicGroup[Math.trunc(groupLevel)];
121
117
  } else {
122
- retVal += this.digitFeminineStatus(Math.trunc(tens), groupLevel);
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
- retVal += this.digitFeminineStatus(ones, groupLevel);
124
+ returnValue += this.digitFeminineStatus(ones, groupLevel);
129
125
  }
130
- if (retVal != '' && ones != 0) {
131
- retVal += ' و';
126
+ if (returnValue != '' && ones != 0) {
127
+ returnValue += ' و';
132
128
  }
133
- retVal += this.arabicTens[Math.trunc(tensIndex)];
129
+ returnValue += this.arabicTens[Math.trunc(tensIndex)];
134
130
  }
135
131
 
136
- return retVal;
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 tempNumber = number;
152
- let tempNumberDec;
147
+ let temporaryNumber = number;
148
+ let temporaryNumberDec;
153
149
  let group = 0;
154
- let retVal = '';
150
+ let returnValue = '';
155
151
 
156
152
  // Loop until number has been reduced to zero or less
157
- while (tempNumber > 0) {
158
- tempNumberDec = tempNumber;
153
+ while (temporaryNumber > 0) {
154
+ temporaryNumberDec = temporaryNumber;
159
155
  // Get the remaining value after dividing by 1000
160
- const numberToProcess = Number(tempNumberDec % 1000n); // Maximum: 999
161
- tempNumber = tempNumberDec / 1000n;
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 (retVal != '') {
172
- retVal = ' و' + retVal;
167
+ if (returnValue != '') {
168
+ returnValue = ' و' + returnValue;
173
169
  }
174
170
 
175
171
  if (numberToProcess > 2) {
176
- if (numberToProcess % 100 != 1) {
172
+ if (numberToProcess % 100 == 1) {
173
+ returnValue = this.arabicGroup[group] + ' ' + returnValue;
174
+ } else {
177
175
  if (numberToProcess >= 3 && numberToProcess <= 10) {
178
- retVal = this.arabicPluralGroups[group] + ' ' + retVal;
176
+ returnValue = this.arabicPluralGroups[group] + ' ' + returnValue;
179
177
  } else {
180
- if (retVal != '') {
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
- retVal = groupDescription + ' ' + retVal;
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
- retVal = retVal.replace(/ +/g, ' ');
194
+ returnValue = returnValue.replaceAll(/ +/g, ' ');
203
195
 
204
- return retVal.trim();
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 _default(value: number | string | bigint, options?: object): string;
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/BaseLanguage.js';
15
+ import BaseLanguage from '../classes/base-language.js';
package/lib/i18n/az.js CHANGED
@@ -1,4 +1,4 @@
1
- import BaseLanguage from '../classes/BaseLanguage.js';
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
- [1000000000000000000n, 'kentilyon'],
13
- [1000000000000000n, 'katrilyon'],
14
- [1000000000000n, 'trilyon'],
15
- [1000000000n, 'milyar'],
16
- [1000000n, 'milyon'],
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 lNum = BigInt(Object.values(lPair)[0]);
45
- const rNum = BigInt(Object.values(rPair)[0]);
44
+ const lNumber = BigInt(Object.values(lPair)[0]);
45
+ const rNumber = BigInt(Object.values(rPair)[0]);
46
46
 
47
- if (lNum == 1 && (rNum <= 100 || rNum == 1000)) {
48
- return { [rText]: rNum };
49
- } else if (rNum > lNum) {
50
- return { [`${lText}${this.spaceSeparator}${rText}`]: lNum * rNum };
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}`]: lNum + rNum };
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 _default(value: number | string | bigint, options?: object): string;
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 i = chunks.length;
101
- for (let j = 0; j < chunks.length; j++) {
102
- const x = chunks[j];
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 && !(i > 0 && x == 1)) {
115
+ } else if (n1 > 0 && !(index > 0 && x == 1)) {
117
116
  words.push(this.ones[n1]);
118
117
  }
119
- if (i > 0) {
120
- words.push(this.pluralize(x, this.thousands[i]));
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 _default(value: number | string | bigint, options?: object): string;
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(curr: any, next: any): {
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/BaseLanguage.js';
17
+ import BaseLanguage from '../classes/base-language.js';
package/lib/i18n/de.js CHANGED
@@ -1,4 +1,4 @@
1
- import BaseLanguage from '../classes/BaseLanguage.js';
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
- [1000000000000000000000000000n, 'Quadrilliarde'],
13
- [1000000000000000000000000n, 'Quadrillion'],
14
- [1000000000000000000000n, 'Trilliarde'],
15
- [1000000000000000000n, 'Trillion'],
16
- [1000000000000000n, 'Billiarde'],
17
- [1000000000000n, 'Billion'],
18
- [1000000000n, 'Milliarde'],
19
- [1000000n, 'Million'],
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(curr, next) {
54
- let cText = Object.keys(curr)[0];
53
+ merge(current, next) {
54
+ let cText = Object.keys(current)[0];
55
55
  let nText = Object.keys(next)[0];
56
- const cNum = BigInt(Object.values(curr)[0]);
57
- const nNum = BigInt(Object.values(next)[0]);
58
- if (cNum == 1) {
59
- if (nNum == 100 || nNum == 1000) {
60
- return { [`ein${nText}`]: nNum };
61
- } else if (nNum < 1000000) {
62
- return { [nText]: nNum };
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 val = 0;
68
- if (nNum > cNum) {
69
- if (nNum >= 1000000) {
70
- if (cNum > 1) {
71
- if (nText[nText.length - 1] == 'e') {
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
- val = cNum * nNum;
75
+ value = cNumber * nNumber;
80
76
  } else {
81
- if (nNum < 10 && cNum > 10 && cNum < 100) {
82
- if (nNum == 1) {
77
+ if (nNumber < 10 && cNumber > 10 && cNumber < 100) {
78
+ if (nNumber == 1) {
83
79
  nText = 'ein';
84
80
  }
85
- const temp = nText;
81
+ const temporary = nText;
86
82
  nText = cText;
87
- cText = `${temp}und`;
88
- } else if (cNum >= 1000000) {
83
+ cText = `${temporary}und`;
84
+ } else if (cNumber >= 1_000_000) {
89
85
  cText += ' ';
90
86
  }
91
- val = cNum + nNum;
87
+ value = cNumber + nNumber;
92
88
  }
93
89
 
94
- return { [`${cText}${nText}`]: val };
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 _default(value: number | string | bigint, options?: object): string;
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(curr: any, next: any): any;
12
+ merge(current: any, next: any): any;
13
13
  }
14
- import BaseLanguage from '../classes/BaseLanguage.js';
14
+ import BaseLanguage from '../classes/base-language.js';
package/lib/i18n/dk.js CHANGED
@@ -1,4 +1,4 @@
1
- import BaseLanguage from '../classes/BaseLanguage.js';
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
- [1000000000000000000000000000n, 'quadrillarder'],
16
- [1000000000000000000000000n, 'quadrillioner'],
17
- [1000000000000000000000n, 'trillarder'],
18
- [1000000000000000000n, 'trillioner'],
19
- [1000000000000000n, 'billarder'],
20
- [1000000000000n, 'billioner'],
21
- [1000000000n, 'millarder'],
22
- [1000000n, 'millioner'],
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(curr, next) {
59
- let cText = Object.keys(curr)[0];
58
+ merge(current, next) {
59
+ let cText = Object.keys(current)[0];
60
60
  let nText = Object.keys(next)[0];
61
- const cNum = BigInt(Object.values(curr)[0]);
62
- const nNum = BigInt(Object.values(next)[0]);
63
- let val;
64
- if (nNum == 100 || nNum == 1000) {
65
- next = { [`et${nText}`]: nNum };
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 (cNum == 1) {
68
- if (nNum < 1000000 || this.ordFlag) {
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 (nNum > cNum) {
74
- if (nNum >= 1000000) {
73
+ if (nNumber > cNumber) {
74
+ if (nNumber >= 1_000_000) {
75
75
  cText += ' ';
76
76
  }
77
- val = cNum * nNum;
77
+ value = cNumber * nNumber;
78
78
  } else {
79
- if (cNum >= 100 && cNum < 1000) {
79
+ if (cNumber >= 100 && cNumber < 1000) {
80
80
  cText += ' og ';
81
- } else if (cNum >= 1000 && cNum <= 100000) {
81
+ } else if (cNumber >= 1000 && cNumber <= 100_000) {
82
82
  cText += 'e og ';
83
83
  }
84
- if ((nNum < 10) && (10 < cNum) && (cNum < 100)) {
85
- if (nNum == 1) {
84
+ if ((nNumber < 10) && (10 < cNumber) && (cNumber < 100)) {
85
+ if (nNumber == 1) {
86
86
  nText = 'en';
87
87
  }
88
- const temp = nText;
88
+ const temporary = nText;
89
89
  nText = cText;
90
- cText = temp + 'og';
91
- } else if (cNum >= 1000000) {
90
+ cText = temporary + 'og';
91
+ } else if (cNumber >= 1_000_000) {
92
92
  cText += ' ';
93
93
  }
94
- val = cNum + nNum;
94
+ value = cNumber + nNumber;
95
95
  }
96
96
  const word = cText + nText;
97
- return { [`${word}`]: val };
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 _default(value: number | string | bigint, options?: object): string;
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/BaseLanguage.js';
22
+ import BaseLanguage from '../classes/base-language.js';