n2words 1.16.2 → 1.16.4

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 (62) hide show
  1. package/dist/n2words.d.ts +3 -0
  2. package/dist/n2words.js +2 -1
  3. package/dist/n2words.js.map +1 -0
  4. package/lib/classes/AbstractLanguage.d.ts +53 -0
  5. package/lib/classes/BaseLanguage.d.ts +59 -0
  6. package/lib/i18n/ar.d.ts +27 -0
  7. package/lib/i18n/ar.js +29 -14
  8. package/lib/i18n/az.d.ts +15 -0
  9. package/lib/i18n/az.js +5 -4
  10. package/lib/i18n/cz.d.ts +12 -0
  11. package/lib/i18n/cz.js +3 -3
  12. package/lib/i18n/de.d.ts +17 -0
  13. package/lib/i18n/de.js +4 -4
  14. package/lib/i18n/dk.d.ts +14 -0
  15. package/lib/i18n/dk.js +4 -4
  16. package/lib/i18n/en.d.ts +22 -0
  17. package/lib/i18n/en.js +2 -2
  18. package/lib/i18n/es.d.ts +16 -0
  19. package/lib/i18n/es.js +6 -6
  20. package/lib/i18n/fa.d.ts +54 -0
  21. package/lib/i18n/fa.js +2 -2
  22. package/lib/i18n/fr.d.ts +15 -0
  23. package/lib/i18n/fr.js +7 -7
  24. package/lib/i18n/he.d.ts +28 -0
  25. package/lib/i18n/he.js +3 -3
  26. package/lib/i18n/hr.d.ts +35 -0
  27. package/lib/i18n/hr.js +3 -3
  28. package/lib/i18n/hu.d.ts +17 -0
  29. package/lib/i18n/hu.js +2 -2
  30. package/lib/i18n/id.d.ts +43 -0
  31. package/lib/i18n/id.js +8 -8
  32. package/lib/i18n/it.d.ts +29 -0
  33. package/lib/i18n/it.js +25 -15
  34. package/lib/i18n/ko.d.ts +15 -0
  35. package/lib/i18n/ko.js +4 -4
  36. package/lib/i18n/lt.d.ts +12 -0
  37. package/lib/i18n/lt.js +3 -3
  38. package/lib/i18n/lv.d.ts +12 -0
  39. package/lib/i18n/lv.js +4 -4
  40. package/lib/i18n/nl.d.ts +20 -0
  41. package/lib/i18n/nl.js +6 -6
  42. package/lib/i18n/no.d.ts +15 -0
  43. package/lib/i18n/no.js +4 -4
  44. package/lib/i18n/pl.d.ts +11 -0
  45. package/lib/i18n/pl.js +3 -3
  46. package/lib/i18n/pt.d.ts +26 -0
  47. package/lib/i18n/pt.js +2 -2
  48. package/lib/i18n/ru.d.ts +84 -0
  49. package/lib/i18n/ru.js +2 -2
  50. package/lib/i18n/sr.d.ts +35 -0
  51. package/lib/i18n/sr.js +3 -3
  52. package/lib/i18n/tr.d.ts +15 -0
  53. package/lib/i18n/tr.js +4 -4
  54. package/lib/i18n/uk.d.ts +11 -0
  55. package/lib/i18n/uk.js +3 -3
  56. package/lib/i18n/vi.d.ts +70 -0
  57. package/lib/i18n/vi.js +2 -2
  58. package/lib/i18n/zh.d.ts +18 -0
  59. package/lib/i18n/zh.js +4 -4
  60. package/lib/n2words.d.ts +7 -0
  61. package/lib/n2words.js +1 -1
  62. package/package.json +15 -7
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Creates new language class that processes decimals separately.
3
+ * Requires implementing `toCardinal`.
4
+ */
5
+ export default class _default {
6
+ /**
7
+ * @param {object} options Options for class.
8
+ * @param {string} [options.negativeWord] Word that precedes a negative number (if any).
9
+ * @param {string} options.separatorWord Word that separates cardinal numbers (i.e. "and").
10
+ * @param {string} options.zero Word for 0 (i.e. "zero").
11
+ * @param {string} [options.spaceSeparator] Character that separates words.
12
+ */
13
+ constructor(options: {
14
+ negativeWord?: string;
15
+ separatorWord: string;
16
+ zero: string;
17
+ spaceSeparator?: string;
18
+ });
19
+ /**
20
+ * @returns {string} Word that precedes a negative number (if any).
21
+ */
22
+ get negativeWord(): string;
23
+ /**
24
+ * @returns {string} Word that separates cardinal numbers (i.e. "and").
25
+ */
26
+ get separatorWord(): string;
27
+ /**
28
+ * @returns {string} Word for 0 (i.e. "zero").
29
+ */
30
+ get zero(): string;
31
+ /**
32
+ * @returns {string} Character that separates words.
33
+ */
34
+ get spaceSeparator(): string;
35
+ /**
36
+ * @returns {number} Input value without decimal.
37
+ */
38
+ get wholeNumber(): number;
39
+ /**
40
+ * Convert decimal number to a string array of cardinal numbers.
41
+ * @param {number} decimal Decimal number to convert.
42
+ * @returns {string} Value in written format.
43
+ */
44
+ decimalToCardinal(decimal: number): string;
45
+ /**
46
+ * Converts a number to written form.
47
+ * @param {number|string} value Number to be convert.
48
+ * @throws {Error} Value must be a valid number.
49
+ * @returns {string} Value in written format.
50
+ */
51
+ floatToCardinal(value: number | string): string;
52
+ #private;
53
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Creates new common language class that uses a highest matching word value algorithm.
3
+ * Number matching word {@link cards} must be provided for this to work.
4
+ * See {@link AbstractLanguage} for further requirements.
5
+ * @classdesc Common class for (mostly european) languages.
6
+ */
7
+ export default class _default extends AbstractLanguage {
8
+ /**
9
+ * @param {object} options Options for class.
10
+ * @param {string} [options.negativeWord] Word that precedes a negative number (if any).
11
+ * @param {string} options.separatorWord Word that separates cardinal numbers (i.e. "and").
12
+ * @param {string} options.zero Word for 0 (i.e. "zero").
13
+ * @param {string} [options.spaceSeparator] Character that separates words.
14
+ * @param {Array} cards Array of number matching "cards" from highest-to-lowest.
15
+ */
16
+ constructor(options: {
17
+ negativeWord?: string;
18
+ separatorWord: string;
19
+ zero: string;
20
+ spaceSeparator?: string;
21
+ }, cards: any[]);
22
+ /**
23
+ * Get array of number matching "cards" from highest-to-lowest.
24
+ * First element in card array is the number to match while the second is the word to use.
25
+ * @example
26
+ * [
27
+ * ...
28
+ * [100, 'hundred'],
29
+ * ...
30
+ * [1, 'one'],
31
+ * ]
32
+ * @returns {Array} Array of number matching "cards" from highest-to-lowest.
33
+ */
34
+ get cards(): any[];
35
+ /**
36
+ * Get word for number if it matches a language card.
37
+ * @param {number} number Card number value.
38
+ * @returns {string|undefined} Return card word or undefined if no card.
39
+ */
40
+ getCardWord(number: number): string | undefined;
41
+ /**
42
+ * Get array of card matches.
43
+ * @param {number} value The number value to convert to cardinal form.
44
+ * @returns {object} Word sets (and pairs) from value.
45
+ * @todo Simplify return object.
46
+ */
47
+ toCardMatches(value: number): object;
48
+ scanNum(value: any): any;
49
+ clean(words: any): any;
50
+ postClean(out0: any): any;
51
+ /**
52
+ * Convert a whole number to written format.
53
+ * @param {number} value The number value to convert to cardinal form.
54
+ * @returns {string} Value in written format.
55
+ */
56
+ toCardinal(value: number): string;
57
+ #private;
58
+ }
59
+ import AbstractLanguage from './AbstractLanguage.js';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Converts a value to cardinal (written) form.
3
+ * @param {number|string} value Number to be convert.
4
+ * @param {object} [options] Options for class.
5
+ * @throws {Error} Value cannot be invalid.
6
+ * @returns {string} Value in cardinal (written) format.
7
+ */
8
+ export default function _default(value: number | string, options?: object): string;
9
+ export class Arabic extends AbstractLanguage {
10
+ constructor(options: any);
11
+ integerValue: number;
12
+ decimalValue: number;
13
+ number: number;
14
+ arabicOnes: string[];
15
+ arabicFeminineOnes: string[];
16
+ arabicTens: string[];
17
+ arabicHundreds: string[];
18
+ arabicAppendedTwos: string[];
19
+ arabicTwos: string[];
20
+ arabicGroup: string[];
21
+ arabicAppendedGroup: string[];
22
+ arabicPluralGroups: string[];
23
+ digitFeminineStatus(digit: any): string;
24
+ processArabicGroup(groupNumber: any, groupLevel: any, remainingNumber: any): string;
25
+ toCardinal(number: any): string;
26
+ }
27
+ import AbstractLanguage from '../classes/AbstractLanguage.js';
package/lib/i18n/ar.js CHANGED
@@ -51,27 +51,29 @@ export class Arabic extends AbstractLanguage {
51
51
 
52
52
  digitFeminineStatus(digit/* , groupLevel */) {
53
53
  // if ((groupLevel == -1 && this.isCurrencyPartNameFeminine) || (groupLevel == 0 && this.isCurrencyNameFeminine)) {
54
- // return this.arabicFeminineOnes[parseInt(digit)]
54
+ // return this.arabicFeminineOnes[digit]
55
55
  // }
56
- return this.arabicOnes[parseInt(digit)];
56
+ return this.arabicOnes[digit];
57
57
  }
58
58
 
59
59
  processArabicGroup(groupNumber, groupLevel, remainingNumber) {
60
60
  let tens = groupNumber % 100;
61
61
  const hundreds = groupNumber / 100;
62
62
  let retVal = '';
63
- if (parseInt(hundreds) > 0) {
63
+
64
+ if (Math.trunc(hundreds) > 0) {
64
65
  retVal = (
65
- tens == 0 && parseInt(hundreds) == 2
66
- ) ? this.arabicAppendedTwos[0] : this.arabicHundreds[parseInt(hundreds)];
66
+ tens == 0 && Math.trunc(hundreds) == 2
67
+ ) ? this.arabicAppendedTwos[0] : this.arabicHundreds[Math.trunc(hundreds)];
67
68
  }
69
+
68
70
  if (tens > 0) {
69
71
  if (tens < 20) {
70
- if (tens == 2 && parseInt(hundreds) == 0 && groupLevel > 0) {
72
+ if (tens == 2 && Math.trunc(hundreds) == 0 && groupLevel > 0) {
71
73
  retVal = ([
72
74
  2000, 2000000, 2000000000, 2000000000000, 2000000000000000, 2000000000000000000
73
75
  ].indexOf(this.integerValue) != -1) ? this.arabicAppendedTwos[
74
- parseInt(groupLevel)] : this.arabicTwos[parseInt(groupLevel)
76
+ Math.trunc(groupLevel)] : this.arabicTwos[Math.trunc(groupLevel)
75
77
  ];
76
78
  } else {
77
79
  if (retVal != '') {
@@ -80,29 +82,34 @@ export class Arabic extends AbstractLanguage {
80
82
  if (tens == 1 && groupLevel > 0 && hundreds == 0) {
81
83
  retVal += '';
82
84
  } else if (
83
- (tens == 1 || tens == 2) && (groupLevel == 0 || groupLevel == -1) &&
85
+ (tens == 1 || tens == 2) &&
86
+ (groupLevel == 0 || groupLevel == -1) &&
84
87
  (hundreds == 0 && remainingNumber == 0)
85
88
  ) {
86
89
  retVal += '';
87
90
  } else {
88
- retVal += this.digitFeminineStatus(parseInt(tens), groupLevel);
91
+ retVal += this.digitFeminineStatus(Math.trunc(tens), groupLevel);
89
92
  }
90
93
  }
91
94
  } else {
92
95
  const ones = tens % 10;
93
96
  tens = (tens / 10) - 2;
97
+
94
98
  if (ones > 0) {
95
99
  if (retVal != '' && tens < 4) {
96
100
  retVal += ' و ';
97
101
  }
102
+
98
103
  retVal += this.digitFeminineStatus(ones, groupLevel);
99
104
  }
100
105
  if (retVal != '' && ones != 0) {
101
106
  retVal += ' و ';
102
107
  }
103
- retVal += this.arabicTens[parseInt(tens)];
108
+
109
+ retVal += this.arabicTens[Math.trunc(tens)];
104
110
  }
105
111
  }
112
+
106
113
  return retVal;
107
114
  }
108
115
 
@@ -113,19 +120,24 @@ export class Arabic extends AbstractLanguage {
113
120
  if (number == 0) {
114
121
  return this.zero;
115
122
  }
123
+
116
124
  let tempNumber = number;
117
125
  this.integerValue = number;
118
126
  let retVal = '';
119
127
  let group = 0;
128
+
120
129
  while (tempNumber > 0) {
121
- const numberToProcess = parseInt(tempNumber % 1000);
122
- tempNumber = parseInt(tempNumber / 1000);
130
+ const numberToProcess = tempNumber % 1000;
131
+ tempNumber = Math.trunc(tempNumber / 1000);
132
+
123
133
  const groupDescription = this.processArabicGroup(numberToProcess, group, Math.floor(tempNumber));
134
+
124
135
  if (groupDescription != '') {
125
136
  if (group > 0) {
126
137
  if (retVal != '') {
127
138
  retVal = ' و ' + retVal;
128
139
  }
140
+
129
141
  if (numberToProcess != 2) {
130
142
  if (numberToProcess % 100 != 1) {
131
143
  if (numberToProcess >= 3 && numberToProcess <= 10) {
@@ -142,10 +154,13 @@ export class Arabic extends AbstractLanguage {
142
154
  }
143
155
  }
144
156
  }
157
+
145
158
  retVal = groupDescription + ' ' + retVal;
146
159
  }
160
+
147
161
  group += 1;
148
162
  }
163
+
149
164
  return retVal.trim();
150
165
  }
151
166
  }
@@ -153,10 +168,10 @@ export class Arabic extends AbstractLanguage {
153
168
  /**
154
169
  * Converts a value to cardinal (written) form.
155
170
  * @param {number|string} value Number to be convert.
156
- * @param {object} options Options for class.
171
+ * @param {object} [options] Options for class.
157
172
  * @throws {Error} Value cannot be invalid.
158
173
  * @returns {string} Value in cardinal (written) format.
159
174
  */
160
- export default function(value, options) {
175
+ export default function (value, options = {}) {
161
176
  return new Arabic(options).floatToCardinal(value);
162
177
  }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Converts a value to cardinal (written) form.
3
+ * @param {number|string} value Number to be convert.
4
+ * @param {object} [options] Options for class.
5
+ * @throws {Error} Value cannot be invalid.
6
+ * @returns {string} Value in cardinal (written) format.
7
+ */
8
+ export default function _default(value: number | string, options?: object): string;
9
+ export class N2WordsAZ extends BaseLanguage {
10
+ constructor(options: any);
11
+ merge(lPair: any, rPair: any): {
12
+ [x: string]: bigint;
13
+ };
14
+ }
15
+ import BaseLanguage from '../classes/BaseLanguage.js';
package/lib/i18n/az.js CHANGED
@@ -39,8 +39,9 @@ export class N2WordsAZ extends BaseLanguage {
39
39
  merge(lPair, rPair) {
40
40
  const lText = Object.keys(lPair)[0];
41
41
  const rText = Object.keys(rPair)[0];
42
- const lNum = parseInt(Object.values(lPair)[0]);
43
- const rNum = parseInt(Object.values(rPair)[0]);
42
+ const lNum = BigInt(Object.values(lPair)[0]);
43
+ const rNum = BigInt(Object.values(rPair)[0]);
44
+
44
45
  if (lNum == 1 && (rNum <= 100 || rNum == 1000)) {
45
46
  return { [rText]: rNum };
46
47
  } else if (rNum > lNum) {
@@ -54,10 +55,10 @@ export class N2WordsAZ extends BaseLanguage {
54
55
  /**
55
56
  * Converts a value to cardinal (written) form.
56
57
  * @param {number|string} value Number to be convert.
57
- * @param {object} options Options for class.
58
+ * @param {object} [options] Options for class.
58
59
  * @throws {Error} Value cannot be invalid.
59
60
  * @returns {string} Value in cardinal (written) format.
60
61
  */
61
- export default function(value, options) {
62
+ export default function (value, options = {}) {
62
63
  return new N2WordsAZ(options).floatToCardinal(value);
63
64
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Converts a value to cardinal (written) form.
3
+ * @param {number|string} value Number to be convert.
4
+ * @param {object} [options] Options for class.
5
+ * @throws {Error} Value cannot be invalid.
6
+ * @returns {string} Value in cardinal (written) format.
7
+ */
8
+ export default function _default(value: number | string, options?: object): string;
9
+ export class N2WordsCZ extends N2WordsRU {
10
+ get separatorWord(): "celá" | "celé" | "celých";
11
+ }
12
+ import { N2WordsRU } from './ru.js';
package/lib/i18n/cz.js CHANGED
@@ -1,4 +1,4 @@
1
- import {N2WordsRU} from './ru.js';
1
+ import { N2WordsRU } from './ru.js';
2
2
 
3
3
  export class N2WordsCZ extends N2WordsRU {
4
4
  ones = {
@@ -125,10 +125,10 @@ export class N2WordsCZ extends N2WordsRU {
125
125
  /**
126
126
  * Converts a value to cardinal (written) form.
127
127
  * @param {number|string} value Number to be convert.
128
- * @param {object} options Options for class.
128
+ * @param {object} [options] Options for class.
129
129
  * @throws {Error} Value cannot be invalid.
130
130
  * @returns {string} Value in cardinal (written) format.
131
131
  */
132
- export default function(value, options) {
132
+ export default function (value, options = {}) {
133
133
  return new N2WordsCZ(options).floatToCardinal(value);
134
134
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a value to cardinal (written) form.
3
+ * @param {number|string} value Number to be convert.
4
+ * @param {object} [options] Options for class.
5
+ * @throws {Error} Value cannot be invalid.
6
+ * @returns {string} Value in cardinal (written) format.
7
+ */
8
+ export default function _default(value: number | string, options?: object): string;
9
+ export class N2WordsDE extends BaseLanguage {
10
+ constructor(options: any);
11
+ merge(curr: any, next: any): {
12
+ [x: string]: bigint;
13
+ } | {
14
+ [x: string]: number;
15
+ };
16
+ }
17
+ import BaseLanguage from '../classes/BaseLanguage.js';
package/lib/i18n/de.js CHANGED
@@ -51,8 +51,8 @@ export class N2WordsDE extends BaseLanguage {
51
51
  merge(curr, next) {
52
52
  let cText = Object.keys(curr)[0];
53
53
  let nText = Object.keys(next)[0];
54
- const cNum = parseInt(Object.values(curr)[0]);
55
- const nNum = parseInt(Object.values(next)[0]);
54
+ const cNum = BigInt(Object.values(curr)[0]);
55
+ const nNum = BigInt(Object.values(next)[0]);
56
56
  if (cNum == 1) {
57
57
  if (nNum == 100 || nNum == 1000) {
58
58
  return { [`ein${nText}`]: nNum };
@@ -96,10 +96,10 @@ export class N2WordsDE extends BaseLanguage {
96
96
  /**
97
97
  * Converts a value to cardinal (written) form.
98
98
  * @param {number|string} value Number to be convert.
99
- * @param {object} options Options for class.
99
+ * @param {object} [options] Options for class.
100
100
  * @throws {Error} Value cannot be invalid.
101
101
  * @returns {string} Value in cardinal (written) format.
102
102
  */
103
- export default function(value, options) {
103
+ export default function (value, options = {}) {
104
104
  return new N2WordsDE(options).floatToCardinal(value);
105
105
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Converts a value to cardinal (written) form.
3
+ * @param {number|string} value Number to be convert.
4
+ * @param {object} [options] Options for class.
5
+ * @throws {Error} Value cannot be invalid.
6
+ * @returns {string} Value in cardinal (written) format.
7
+ */
8
+ export default function _default(value: number | string, options?: object): string;
9
+ export class N2WordsDK extends BaseLanguage {
10
+ constructor(options: any);
11
+ ordFlag: any;
12
+ merge(curr: any, next: any): any;
13
+ }
14
+ import BaseLanguage from '../classes/BaseLanguage.js';
package/lib/i18n/dk.js CHANGED
@@ -58,8 +58,8 @@ export class N2WordsDK extends BaseLanguage {
58
58
  merge(curr, next) {
59
59
  let cText = Object.keys(curr)[0];
60
60
  let nText = Object.keys(next)[0];
61
- const cNum = parseInt(Object.values(curr)[0]);
62
- const nNum = parseInt(Object.values(next)[0]);
61
+ const cNum = BigInt(Object.values(curr)[0]);
62
+ const nNum = BigInt(Object.values(next)[0]);
63
63
  let val = 1;
64
64
  if (nNum == 100 || nNum == 1000) {
65
65
  next = { [`et${nText}`]: nNum };
@@ -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
  }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Converts a value to cardinal (written) form.
3
+ * @param {number|string} value Number to be convert.
4
+ * @param {object} [options] Options for class.
5
+ * @throws {Error} Value cannot be invalid.
6
+ * @returns {string} Value in cardinal (written) format.
7
+ */
8
+ export default function _default(value: number | string, options?: object): string;
9
+ /**
10
+ * This class is for converting numbers to english words.
11
+ */
12
+ export class English extends BaseLanguage {
13
+ constructor(options: any);
14
+ /**
15
+ * Merge word set pairs
16
+ * @param {object} lPair {'one':1}
17
+ * @param {object} rPair {'hundred':100}
18
+ * @returns {object} {'one hundred': 100}
19
+ */
20
+ merge(lPair: object, rPair: object): object;
21
+ }
22
+ import BaseLanguage from '../classes/BaseLanguage.js';
package/lib/i18n/en.js CHANGED
@@ -75,10 +75,10 @@ export class English extends BaseLanguage {
75
75
  /**
76
76
  * Converts a value to cardinal (written) form.
77
77
  * @param {number|string} value Number to be convert.
78
- * @param {object} options Options for class.
78
+ * @param {object} [options] Options for class.
79
79
  * @throws {Error} Value cannot be invalid.
80
80
  * @returns {string} Value in cardinal (written) format.
81
81
  */
82
- export default function(value, options) {
82
+ export default function (value, options = {}) {
83
83
  return new English(options).floatToCardinal(value);
84
84
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Converts a value to cardinal (written) form.
3
+ * @param {number|string} value Number to be convert.
4
+ * @param {object} [options] Options for class.
5
+ * @throws {Error} Value cannot be invalid.
6
+ * @returns {string} Value in cardinal (written) format.
7
+ */
8
+ export default function _default(value: number | string, options?: object): string;
9
+ export class N2WordsES extends BaseLanguage {
10
+ constructor(options: any);
11
+ genderStem: any;
12
+ merge(curr: any, next: any): {
13
+ [x: string]: bigint;
14
+ };
15
+ }
16
+ import BaseLanguage from '../classes/BaseLanguage.js';
package/lib/i18n/es.js CHANGED
@@ -63,12 +63,12 @@ export class N2WordsES extends BaseLanguage {
63
63
  merge(curr, next) {
64
64
  let cText = Object.keys(curr)[0];
65
65
  let nText = Object.keys(next)[0];
66
- const cNum = parseInt(Object.values(curr)[0]);
67
- const nNum = parseInt(Object.values(next)[0]);
66
+ const cNum = BigInt(Object.values(curr)[0]);
67
+ const nNum = BigInt(Object.values(next)[0]);
68
68
  if (cNum == 1) {
69
69
  if (nNum < 1000000) return { [nText]: nNum };
70
70
  cText = 'un';
71
- } else if (cNum == 100 && nNum % 1000 != 0) {
71
+ } else if (cNum == 100 && nNum % 1000n != 0) {
72
72
  cText += 't' + this.genderStem;
73
73
  }
74
74
 
@@ -77,7 +77,7 @@ export class N2WordsES extends BaseLanguage {
77
77
  return { [`${cText} y ${nText}`]: cNum + nNum };
78
78
  }
79
79
  return { [`${cText} ${nText}`]: cNum + nNum };
80
- } else if (nNum % 1000000 == 0 && cNum > 1) {
80
+ } else if (nNum % 1000000n == 0 && cNum > 1) {
81
81
  nText = nText.slice(0, -3) + 'lones';
82
82
  }
83
83
 
@@ -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
  }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Converts a value to cardinal (written) form.
3
+ * @param {number|string} value Number to be convert.
4
+ * @param {object} [options] Options for class.
5
+ * @throws {Error} Value cannot be invalid.
6
+ * @returns {string} Value in cardinal (written) format.
7
+ */
8
+ export default function _default(value: number | string, options?: object): string;
9
+ export class N2WordsFA extends AbstractLanguage {
10
+ constructor(options: any);
11
+ namedNumbers: {
12
+ 0: string;
13
+ 1: string;
14
+ 2: string;
15
+ 3: string;
16
+ 4: string;
17
+ 5: string;
18
+ 6: string;
19
+ 7: string;
20
+ 8: string;
21
+ 9: string;
22
+ 10: string;
23
+ 11: string;
24
+ 12: string;
25
+ 13: string;
26
+ 14: string;
27
+ 15: string;
28
+ 16: string;
29
+ 17: string;
30
+ 18: string;
31
+ 19: string;
32
+ 20: string;
33
+ 30: string;
34
+ 40: string;
35
+ 50: string;
36
+ 60: string;
37
+ 70: string;
38
+ 80: string;
39
+ 90: string;
40
+ 100: string;
41
+ 200: string;
42
+ 300: string;
43
+ 400: string;
44
+ 500: string;
45
+ 600: string;
46
+ 700: string;
47
+ 800: string;
48
+ 900: string;
49
+ 1000: string;
50
+ 1000000: string;
51
+ };
52
+ toCardinal(number: any): any;
53
+ }
54
+ import AbstractLanguage from '../classes/AbstractLanguage.js';
package/lib/i18n/fa.js CHANGED
@@ -95,10 +95,10 @@ export class N2WordsFA extends AbstractLanguage {
95
95
  /**
96
96
  * Converts a value to cardinal (written) form.
97
97
  * @param {number|string} value Number to be convert.
98
- * @param {object} options Options for class.
98
+ * @param {object} [options] Options for class.
99
99
  * @throws {Error} Value cannot be invalid.
100
100
  * @returns {string} Value in cardinal (written) format.
101
101
  */
102
- export default function(value, options) {
102
+ export default function (value, options = {}) {
103
103
  return new N2WordsFA(options).floatToCardinal(value);
104
104
  }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Converts a value to cardinal (written) form.
3
+ * @param {number|string} value Number to be convert.
4
+ * @param {object} [options] Options for class.
5
+ * @throws {Error} Value cannot be invalid.
6
+ * @returns {string} Value in cardinal (written) format.
7
+ */
8
+ export default function _default(value: number | string, options?: object): string;
9
+ export class N2WordsFR extends BaseLanguage {
10
+ constructor(options: any);
11
+ merge(curr: any, next: any): {
12
+ [x: string]: bigint;
13
+ };
14
+ }
15
+ import BaseLanguage from '../classes/BaseLanguage.js';
package/lib/i18n/fr.js CHANGED
@@ -49,15 +49,15 @@ export class N2WordsFR extends BaseLanguage {
49
49
  merge(curr, next) { // {'cent':100}, {'vingt-cinq':25}
50
50
  let cText = Object.keys(curr)[0];
51
51
  let nText = Object.keys(next)[0];
52
- const cNum = parseInt(Object.values(curr)[0]);
53
- const nNum = parseInt(Object.values(next)[0]);
52
+ const cNum = BigInt(Object.values(curr)[0]);
53
+ const nNum = BigInt(Object.values(next)[0]);
54
54
  if (cNum == 1) {
55
55
  if (nNum < 1000000) {
56
56
  return { [nText]: nNum };
57
57
  }
58
58
  } else {
59
59
  if (
60
- ((cNum - 80) % 100 == 0 || (cNum % 100 == 0 && cNum < 1000)) &&
60
+ ((cNum - 80n) % 100n == 0 || (cNum % 100n == 0 && cNum < 1000)) &&
61
61
  nNum < 1000000 &&
62
62
  cText[cText.length - 1] == 's'
63
63
  ) {
@@ -66,13 +66,13 @@ export class N2WordsFR extends BaseLanguage {
66
66
  if (
67
67
  cNum < 1000 && nNum != 1000 &&
68
68
  nText[nText.length - 1] != 's' &&
69
- nNum % 100 == 0
69
+ nNum % 100n == 0
70
70
  ) {
71
71
  nText += 's';
72
72
  }
73
73
  }
74
74
  if (nNum < cNum && cNum < 100) {
75
- if (nNum % 10 == 1 && cNum != 80) return { [`${cText} et ${nText}`]: cNum + nNum };
75
+ if (nNum % 10n == 1 && cNum != 80) return { [`${cText} et ${nText}`]: cNum + nNum };
76
76
  return { [`${cText}-${nText}`]: cNum + nNum };
77
77
  }
78
78
  if (nNum > cNum) return { [`${cText} ${nText}`]: cNum * nNum };
@@ -83,10 +83,10 @@ export class N2WordsFR extends BaseLanguage {
83
83
  /**
84
84
  * Converts a value to cardinal (written) form.
85
85
  * @param {number|string} value Number to be convert.
86
- * @param {object} options Options for class.
86
+ * @param {object} [options] Options for class.
87
87
  * @throws {Error} Value cannot be invalid.
88
88
  * @returns {string} Value in cardinal (written) format.
89
89
  */
90
- export default function(value, options) {
90
+ export default function (value, options = {}) {
91
91
  return new N2WordsFR(options).floatToCardinal(value);
92
92
  }