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/id.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 N2WordsID extends AbstractLanguage {
4
4
  base = {
@@ -41,22 +41,22 @@ export class N2WordsID extends AbstractLanguage {
41
41
  splitBy3(number) {
42
42
  // Split to groups of 3 numbers: 1234567 -> [['1'], ['234'], ['567']]
43
43
  let blocks = [];
44
- let strNumber = number.toString();
45
- let length = strNumber.length;
44
+ let stringNumber = number.toString();
45
+ let length = stringNumber.length;
46
46
  let firstBlock;
47
47
 
48
48
  if (length < 3) {
49
- blocks.push([strNumber]);
49
+ blocks.push([stringNumber]);
50
50
  } else {
51
51
  let firstBlockLength = length % 3;
52
52
 
53
53
  if (firstBlockLength > 0) {
54
- firstBlock = [strNumber.slice(0, firstBlockLength)];
54
+ firstBlock = [stringNumber.slice(0, firstBlockLength)];
55
55
  blocks.push(firstBlock);
56
56
  }
57
57
 
58
- for (let i = firstBlockLength; i < length; i += 3) {
59
- let nextBlock = [strNumber.slice(i, i + 3)];
58
+ for (let index = firstBlockLength; index < length; index += 3) {
59
+ let nextBlock = [stringNumber.slice(index, index + 3)];
60
60
  blocks.push(nextBlock);
61
61
  }
62
62
  }
@@ -71,26 +71,18 @@ export class N2WordsID extends AbstractLanguage {
71
71
  let spelling;
72
72
  let firstBlock = blocks[0];
73
73
  if (firstBlock[0].length == 1) {
74
- if (firstBlock[0] == '0') {
75
- spelling = ['nol'];
76
- } else {
77
- spelling = this.base[Math.trunc(firstBlock[0])];
78
- }
74
+ spelling = firstBlock[0] == '0' ? ['nol'] : this.base[Math.trunc(firstBlock[0])];
79
75
  } else if (firstBlock[0].length == 2) {
80
76
  spelling = this.getTens(firstBlock[0]);
81
77
  } else {
82
- spelling = this.getHundreds(
83
- firstBlock[0][0]
84
- ).concat(this.getTens(firstBlock[0].slice(1, 3)));
78
+ spelling = [...this.getHundreds(firstBlock[0][0]), ...this.getTens(firstBlock[0].slice(1, 3))];
85
79
  }
86
- wordBlocks = wordBlocks.concat([[firstBlock[0], spelling]]);
87
- for (let i = 1; i < blocks.length; i++) {
88
- let block = blocks[i];
89
- spelling = this.getHundreds(block[0][0]).concat(
90
- this.getTens(block[0].slice(1, 3))
91
- );
92
- block = block.concat([spelling]);
93
- wordBlocks = wordBlocks.concat([block]);
80
+ wordBlocks = [...wordBlocks, [firstBlock[0], spelling]];
81
+ for (let index = 1; index < blocks.length; index++) {
82
+ let block = blocks[index];
83
+ spelling = [...this.getHundreds(block[0][0]), ...this.getTens(block[0].slice(1, 3))];
84
+ block = [...block, spelling];
85
+ wordBlocks = [...wordBlocks, block];
94
86
  }
95
87
  return wordBlocks;
96
88
  }
@@ -101,7 +93,7 @@ export class N2WordsID extends AbstractLanguage {
101
93
  } else if (number == '0') {
102
94
  return [];
103
95
  } else {
104
- return this.base[Math.trunc(number)].concat(['ratus']);
96
+ return [...this.base[Math.trunc(number)], 'ratus'];
105
97
  }
106
98
  }
107
99
 
@@ -112,14 +104,12 @@ export class N2WordsID extends AbstractLanguage {
112
104
  } else if (number[1] == '1') {
113
105
  return ['sebelas'];
114
106
  } else {
115
- return this.base[Math.trunc(number[1])].concat(['belas']);
107
+ return [...this.base[Math.trunc(number[1])], 'belas'];
116
108
  }
117
109
  } else if (number[0] == '0') {
118
110
  return this.base[Math.trunc(number[1])];
119
111
  } else {
120
- return this.base[Math.trunc(number[0])].concat(['puluh']).concat(
121
- [this.base[Math.trunc(number[1])]]
122
- );
112
+ return [...this.base[Math.trunc(number[0])], 'puluh', this.base[Math.trunc(number[1])]];
123
113
  }
124
114
  }
125
115
 
@@ -132,15 +122,15 @@ export class N2WordsID extends AbstractLanguage {
132
122
  wordList.push('seribu');
133
123
  start = 1;
134
124
  }
135
- for (let i = start; i < length + 1; i++) {
136
- wordList = wordList.concat(wordBlocks[i][1]);
137
- if (!wordBlocks[i][1].length) {
125
+ for (let index = start; index < length + 1; index++) {
126
+ wordList = [...wordList, ...wordBlocks[index][1]];
127
+ if (wordBlocks[index][1].length === 0) {
138
128
  continue;
139
129
  }
140
- if (i == length) {
130
+ if (index == length) {
141
131
  break;
142
132
  }
143
- wordList = wordList.concat([this.thousands[(length - i) * 3]]);
133
+ wordList = [...wordList, this.thousands[(length - index) * 3]];
144
134
  }
145
135
  return wordList.join(' ');
146
136
  }
@@ -158,9 +148,9 @@ export class N2WordsID extends AbstractLanguage {
158
148
  * Converts a value to cardinal (written) form.
159
149
  * @param {number|string|bigint} value Number to be convert.
160
150
  * @param {object} [options] Options for class.
161
- * @throws {Error} Value cannot be invalid.
162
151
  * @returns {string} Value in cardinal (written) format.
152
+ * @throws {Error} Value cannot be invalid.
163
153
  */
164
- export default function (value, options = {}) {
154
+ export default function floatToCardinal (value, options = {}) {
165
155
  return new N2WordsID(options).floatToCardinal(value);
166
156
  }
package/lib/i18n/it.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 N2WordsIT extends BaseLanguage {
10
10
  constructor(options: any);
11
11
  cardinalWords: string[];
@@ -26,4 +26,4 @@ export class N2WordsIT extends BaseLanguage {
26
26
  bigNumberToCardinal(number: any): string;
27
27
  toCardinal(number: any): any;
28
28
  }
29
- import BaseLanguage from '../classes/BaseLanguage.js';
29
+ import BaseLanguage from '../classes/base-language.js';
package/lib/i18n/it.js CHANGED
@@ -1,5 +1,6 @@
1
- import BaseLanguage from '../classes/BaseLanguage.js';
1
+ import BaseLanguage from '../classes/base-language.js';
2
2
 
3
+ // TODO Adapt language to work with {@link BaseLanguage} better
3
4
  export class N2WordsIT extends BaseLanguage {
4
5
  cardinalWords = [
5
6
  this.zero, 'uno', 'due', 'tre', 'quattro', 'cinque', 'sei', 'sette', 'otto',
@@ -19,41 +20,30 @@ export class N2WordsIT extends BaseLanguage {
19
20
  }, options);
20
21
 
21
22
  super(options, []);
22
-
23
- /** @todo Adapt language to work with {@link BaseLanguage} better */
24
23
  }
25
24
 
26
25
  accentuate(string) {
27
26
  const splittedString = string.split(' ');
28
27
 
29
28
  const result = splittedString.map(word => {
30
- if (word.slice(-3) == 'tre' && word.length > 3) return word.replace(/tré/g, 'tre').slice(0, -3) + 'tré';
31
- else return word.replace(/tré/g, 'tre');
29
+ return word.slice(-3) == 'tre' && word.length > 3 ? word.replaceAll('tré', 'tre').slice(0, -3) + 'tré' : word.replaceAll('tré', 'tre');
32
30
  });
33
31
  return result.join(' ');
34
32
  }
35
33
 
36
34
  omitIfZero(numberToString) {
37
- if (numberToString == this.zero) {
38
- return '';
39
- } else {
40
- return numberToString;
41
- }
35
+ return numberToString == this.zero ? '' : numberToString;
42
36
  }
43
37
 
44
38
  phoneticContraction(string) {
45
- return string.replace(/oo/g, 'o').replace(/ao/g, 'o').replace(/io/g, 'o').replace(/au/g, 'u').replace(/iu/g, 'u');
39
+ return string.replaceAll('oo', 'o').replaceAll('ao', 'o').replaceAll('io', 'o').replaceAll('au', 'u').replaceAll('iu', 'u');
46
40
  }
47
41
 
48
42
  tensToCardinal(number) {
49
43
  const tens = Math.floor(number / 10);
50
44
  const units = number % 10;
51
45
  let prefix;
52
- if (Object.prototype.hasOwnProperty.call(this.strTens, tens)) {
53
- prefix = this.strTens[tens];
54
- } else {
55
- prefix = this.cardinalWords[tens].slice(0, -1) + 'anta';
56
- }
46
+ prefix = Object.prototype.hasOwnProperty.call(this.strTens, tens) ? this.strTens[tens] : this.cardinalWords[tens].slice(0, -1) + 'anta';
57
47
  const postfix = this.omitIfZero(this.cardinalWords[units]);
58
48
  return this.phoneticContraction(prefix + postfix);
59
49
  }
@@ -71,26 +61,18 @@ export class N2WordsIT extends BaseLanguage {
71
61
  thousandsToCardinal(number) {
72
62
  const thousands = Math.floor(number / 1000);
73
63
  let prefix;
74
- if (thousands == 1) {
75
- prefix = 'mille';
76
- } else {
77
- prefix = this.toCardinal(thousands) + 'mila';
78
- }
64
+ prefix = thousands == 1 ? 'mille' : this.toCardinal(thousands) + 'mila';
79
65
  const postfix = this.omitIfZero(this.toCardinal(number % 1000));
80
66
  return prefix + postfix;
81
67
  }
82
68
 
83
69
  exponentLengthToString(exponentLength) {
84
70
  const prefix = this.exponentPrefixes[Math.floor(exponentLength / 6)];
85
- if (exponentLength % 6 == 0) {
86
- return prefix + 'ilione';
87
- } else {
88
- return prefix + 'iliardo';
89
- }
71
+ return exponentLength % 6 == 0 ? prefix + 'ilione' : prefix + 'iliardo';
90
72
  }
91
73
 
92
74
  bigNumberToCardinal(number) {
93
- const digits = number.toString().split('');
75
+ const digits = [...number.toString()];
94
76
 
95
77
  let preDigits = digits.length % 3;
96
78
  if (preDigits == 0) {
@@ -110,17 +92,15 @@ export class N2WordsIT extends BaseLanguage {
110
92
  infix = ' ' + infix.slice(0, -1) + 'i'; // without last element
111
93
  }
112
94
 
95
+ // TODO ESLint suggestion
96
+ // eslint-disable-next-line unicorn/consistent-function-scoping
113
97
  const isSetsEqual = (a, b) => a.size == b.size && [...a].every(value => b.has(value));
114
- if (!isSetsEqual(new Set(exponent), new Set(['0']))) {
98
+ if (isSetsEqual(new Set(exponent), new Set(['0']))) {
99
+ postfix = '';
100
+ } else {
115
101
  postfix = this.toCardinal(Math.trunc(exponent.join('')));
116
102
 
117
- if (postfix.includes(' e ')) {
118
- infix += ', '; // for very large numbers
119
- } else {
120
- infix += ' e ';
121
- }
122
- } else {
123
- postfix = '';
103
+ infix += (postfix.includes(' e ') ? ', ' : ' e ');
124
104
  }
125
105
 
126
106
  return prefix + infix + postfix;
@@ -135,7 +115,7 @@ export class N2WordsIT extends BaseLanguage {
135
115
  words = this.tensToCardinal(Number(number));
136
116
  } else if (number < 1000) {
137
117
  words = this.hundredsToCardinal(Number(number));
138
- } else if (number < 1000000) {
118
+ } else if (number < 1_000_000) {
139
119
  words = this.thousandsToCardinal(Number(number));
140
120
  } else {
141
121
  words = this.bigNumberToCardinal(number);
@@ -149,9 +129,9 @@ export class N2WordsIT extends BaseLanguage {
149
129
  * Converts a value to cardinal (written) form.
150
130
  * @param {number|string|bigint} value Number to be convert.
151
131
  * @param {object} [options] Options for class.
152
- * @throws {Error} Value cannot be invalid.
153
132
  * @returns {string} Value in cardinal (written) format.
133
+ * @throws {Error} Value cannot be invalid.
154
134
  */
155
- export default function (value, options = {}) {
135
+ export default function floatToCardinal (value, options = {}) {
156
136
  return new N2WordsIT(options).floatToCardinal(value);
157
137
  }
package/lib/i18n/ko.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 N2WordsKO 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/ko.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 N2WordsKO extends BaseLanguage {
4
4
  constructor(options) {
@@ -9,13 +9,13 @@ export class N2WordsKO extends BaseLanguage {
9
9
  }, options);
10
10
 
11
11
  super(options, [
12
- [10000000000000000000000000000n, '양'],
13
- [1000000000000000000000000n, '자'],
14
- [100000000000000000000n, '해'],
15
- [10000000000000000n, '경'],
16
- [1000000000000n, '조'],
17
- [100000000n, '억'],
18
- [10000n, '만'],
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
19
  [1000n, '천'],
20
20
  [100n, '백'],
21
21
  [10n, '십'],
@@ -35,12 +35,12 @@ export class N2WordsKO extends BaseLanguage {
35
35
  merge(lPair, rPair) {
36
36
  const lText = Object.keys(lPair)[0];
37
37
  const rText = Object.keys(rPair)[0];
38
- const lNum = BigInt(Object.values(lPair)[0]);
39
- const rNum = BigInt(Object.values(rPair)[0]);
40
- if (lNum == 1 && rNum <= 10000) return { [rText]: rNum };
41
- else if (10000 > lNum && lNum > rNum) return { [`${lText}${rText}`]: lNum + rNum };
42
- else if (lNum >= 10000 && lNum > rNum) return { [`${lText} ${rText}`]: lNum + rNum };
43
- else return { [`${lText}${rText}`]: lNum * rNum };
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
44
  }
45
45
  }
46
46
 
@@ -48,9 +48,9 @@ export class N2WordsKO extends BaseLanguage {
48
48
  * Converts a value to cardinal (written) form.
49
49
  * @param {number|string|bigint} value Number to be convert.
50
50
  * @param {object} [options] Options for class.
51
- * @throws {Error} Value cannot be invalid.
52
51
  * @returns {string} Value in cardinal (written) format.
52
+ * @throws {Error} Value cannot be invalid.
53
53
  */
54
- export default function (value, options = {}) {
54
+ export default function floatToCardinal (value, options = {}) {
55
55
  return new N2WordsKO(options).floatToCardinal(value);
56
56
  }
package/lib/i18n/lt.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 N2WordsLT extends N2WordsRU {
10
10
  ones: {
11
11
  1: string;
package/lib/i18n/lt.js CHANGED
@@ -91,10 +91,9 @@ export class N2WordsLT extends N2WordsRU {
91
91
  }
92
92
  const words = [];
93
93
  const chunks = this.splitByX(number.toString(), 3);
94
- let i = chunks.length;
95
- for (let j = 0; j < chunks.length; j++) {
96
- const x = chunks[j];
97
- i = i - 1;
94
+ let index = chunks.length;
95
+ for (const x of chunks) {
96
+ index = index - 1;
98
97
  if (x == 0) {
99
98
  continue;
100
99
  }
@@ -113,14 +112,14 @@ export class N2WordsLT extends N2WordsRU {
113
112
  if (n2 == 1) {
114
113
  words.push(this.tens[n1]);
115
114
  } else if (n1 > 0) {
116
- if ((i == 1 || this.feminine && i == 0) && number < 1000) {
115
+ if ((index == 1 || this.feminine && index == 0) && number < 1000) {
117
116
  words.push(this.onesFeminine[n1]);
118
117
  } else {
119
118
  words.push(this.ones[n1]);
120
119
  }
121
120
  }
122
- if (i > 0) {
123
- words.push(this.pluralize(x, this.thousands[i]));
121
+ if (index > 0) {
122
+ words.push(this.pluralize(x, this.thousands[index]));
124
123
  }
125
124
  }
126
125
  return words.join(' ');
@@ -131,9 +130,9 @@ export class N2WordsLT extends N2WordsRU {
131
130
  * Converts a value to cardinal (written) form.
132
131
  * @param {number|string|bigint} value Number to be convert.
133
132
  * @param {object} [options] Options for class.
134
- * @throws {Error} Value cannot be invalid.
135
133
  * @returns {string} Value in cardinal (written) format.
134
+ * @throws {Error} Value cannot be invalid.
136
135
  */
137
- export default function (value, options = {}) {
136
+ export default function floatToCardinal (value, options = {}) {
138
137
  return new N2WordsLT(options).floatToCardinal(value);
139
138
  }
package/lib/i18n/lv.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 N2WordsLV extends N2WordsRU {
10
10
  ones: {
11
11
  1: string;
package/lib/i18n/lv.js CHANGED
@@ -65,11 +65,7 @@ export class N2WordsLV extends N2WordsRU {
65
65
  pluralize(n, forms) {
66
66
  let form = 2;
67
67
  if (n != 0n) {
68
- if (n % 10n == 1n && n % 100n != 11n) {
69
- form = 0;
70
- } else {
71
- form = 1;
72
- }
68
+ form = n % 10n == 1n && n % 100n != 11n ? 0 : 1;
73
69
  }
74
70
  return forms[form];
75
71
  }
@@ -80,10 +76,9 @@ export class N2WordsLV extends N2WordsRU {
80
76
  }
81
77
  const words = [];
82
78
  const chunks = this.splitByX(number.toString(), 3);
83
- let i = chunks.length;
84
- for (let j = 0; j < chunks.length; j++) {
85
- const x = chunks[j];
86
- i = i - 1;
79
+ let index = chunks.length;
80
+ for (const x of chunks) {
81
+ index = index - 1;
87
82
  if (x == 0) {
88
83
  continue;
89
84
  }
@@ -92,8 +87,7 @@ export class N2WordsLV extends N2WordsRU {
92
87
  if (n3 == 1 && n2 == 0 && n1 > 0) {
93
88
  words.push(this.hundreds[2]);
94
89
  } else if (n3 > 1) {
95
- words.push(this.ones[n3]);
96
- words.push(this.hundreds[1]);
90
+ words.push(this.ones[n3], this.hundreds[1]);
97
91
  } else {
98
92
  words.push(this.hundreds[0]);
99
93
  }
@@ -103,11 +97,11 @@ export class N2WordsLV extends N2WordsRU {
103
97
  }
104
98
  if (n2 == 1) {
105
99
  words.push(this.tens[n1]);
106
- } else if (n1 > 0 && !(i > 0 && x == 1)) {
100
+ } else if (n1 > 0 && !(index > 0 && x == 1)) {
107
101
  words.push(this.ones[n1]);
108
102
  }
109
- if (i > 0) {
110
- words.push(this.pluralize(x, this.thousands[i]));
103
+ if (index > 0) {
104
+ words.push(this.pluralize(x, this.thousands[index]));
111
105
  }
112
106
  }
113
107
  return words.join(' ');
@@ -118,9 +112,9 @@ export class N2WordsLV extends N2WordsRU {
118
112
  * Converts a value to cardinal (written) form.
119
113
  * @param {number|string|bigint} value Number to be convert.
120
114
  * @param {object} [options] Options for class.
121
- * @throws {Error} Value cannot be invalid.
122
115
  * @returns {string} Value in cardinal (written) format.
116
+ * @throws {Error} Value cannot be invalid.
123
117
  */
124
- export default function (value, options = {}) {
118
+ export default function floatToCardinal (value, options = {}) {
125
119
  return new N2WordsLV(options).floatToCardinal(value);
126
120
  }
package/lib/i18n/nl.d.ts CHANGED
@@ -2,19 +2,19 @@
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 N2WordsNL extends BaseLanguage {
10
10
  constructor(options: any);
11
11
  includeOptionalAnd: any;
12
12
  noHundredPairs: any;
13
- merge(curr: any, next: any): {
13
+ merge(current: any, next: any): {
14
14
  [x: string]: bigint;
15
15
  } | {
16
16
  [x: string]: number;
17
17
  };
18
18
  toCardinal(value: any): string;
19
19
  }
20
- import BaseLanguage from '../classes/BaseLanguage.js';
20
+ import BaseLanguage from '../classes/base-language.js';
package/lib/i18n/nl.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 N2WordsNL extends BaseLanguage {
4
4
  includeOptionalAnd;
@@ -14,14 +14,14 @@ export class N2WordsNL extends BaseLanguage {
14
14
  }, options);
15
15
 
16
16
  super(options, [
17
- [1000000000000000000000000000n, 'quadriljard'],
18
- [1000000000000000000000000n, 'quadriljoen'],
19
- [1000000000000000000000n, 'triljard'],
20
- [1000000000000000000n, 'triljoen'],
21
- [1000000000000000n, 'biljard'],
22
- [1000000000000n, 'biljoen'],
23
- [1000000000n, 'miljard'],
24
- [1000000n, 'miljoen'],
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
25
  [1000n, 'duizend'],
26
26
  [100n, 'honderd'],
27
27
  [90n, 'negentig'],
@@ -58,50 +58,50 @@ export class N2WordsNL extends BaseLanguage {
58
58
  this.noHundredPairs = options.noHundredPairs;
59
59
  }
60
60
 
61
- merge(curr, next) {
62
- let cText = Object.keys(curr)[0];
61
+ merge(current, next) {
62
+ let cText = Object.keys(current)[0];
63
63
  let nText = Object.keys(next)[0];
64
- const cNum = BigInt(Object.values(curr)[0]);
65
- const nNum = BigInt(Object.values(next)[0]);
66
- if (cNum == 1) {
67
- if (nNum < 1000000) {
68
- return { [nText]: nNum };
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
69
  }
70
70
  cText = 'een';
71
71
  }
72
72
 
73
- let val = 0;
74
- if (nNum > cNum) {
75
- if (nNum >= 1000000) {
73
+ let value = 0;
74
+ if (nNumber > cNumber) {
75
+ if (nNumber >= 1_000_000) {
76
76
  cText += ' ';
77
- } else if (nNum > 100) {
77
+ } else if (nNumber > 100) {
78
78
  nText += ' ';
79
79
  }
80
- val = cNum * nNum;
80
+ value = cNumber * nNumber;
81
81
  } else {
82
- if (nNum < 10 && cNum > 10 && cNum < 100) {
83
- const temp = nText;
82
+ if (nNumber < 10 && cNumber > 10 && cNumber < 100) {
83
+ const temporary = nText;
84
84
  nText = cText;
85
- const andTxt = temp.endsWith('e') ? 'ën' : 'en';
86
- cText = `${temp}${andTxt}`;
87
- } else if (nNum < 13 && cNum < 1000 && this.includeOptionalAnd) {
85
+ const andTxt = temporary.endsWith('e') ? 'ën' : 'en';
86
+ cText = `${temporary}${andTxt}`;
87
+ } else if (nNumber < 13 && cNumber < 1000 && this.includeOptionalAnd) {
88
88
  cText = `${cText}en`;
89
- } else if (nNum < 13 && cNum >= 1000 && this.includeOptionalAnd) {
89
+ } else if (nNumber < 13 && cNumber >= 1000 && this.includeOptionalAnd) {
90
90
  nText = ` en ${nText}`;
91
- } else if (cNum >= 1000000) {
91
+ } else if (cNumber >= 1_000_000) {
92
92
  cText += ' ';
93
93
  } else {
94
- if (cNum == 1000) {
94
+ if (cNumber == 1000) {
95
95
  cText += ' ';
96
96
  }
97
97
  }
98
- val = cNum + nNum;
98
+ value = cNumber + nNumber;
99
99
  }
100
- return { [`${cText}${nText}`]: val };
100
+ return { [`${cText}${nText}`]: value };
101
101
  }
102
102
 
103
103
  toCardinal(value) {
104
- if (value >= 1100n && value < 10000n && !this.noHundredPairs) {
104
+ if (value >= 1100n && value < 10_000n && !this.noHundredPairs) {
105
105
  const high = value / 100n;
106
106
  const low = value % 100n;
107
107
  if (high % 10n !== 0n) {
@@ -117,9 +117,9 @@ export class N2WordsNL extends BaseLanguage {
117
117
  * Converts a value to cardinal (written) form.
118
118
  * @param {number|string|bigint} value Number to be convert.
119
119
  * @param {object} [options] Options for class.
120
- * @throws {Error} Value cannot be invalid.
121
120
  * @returns {string} Value in cardinal (written) format.
121
+ * @throws {Error} Value cannot be invalid.
122
122
  */
123
- export default function (value, options = {}) {
123
+ export default function floatToCardinal (value, options = {}) {
124
124
  return new N2WordsNL(options).floatToCardinal(value);
125
125
  }
package/lib/i18n/no.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 N2WordsNO 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';