n2words 1.16.2 → 1.16.3
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/dist/n2words.d.ts +3 -0
- package/dist/n2words.js +2 -1
- package/dist/n2words.js.map +1 -0
- package/lib/classes/AbstractLanguage.d.ts +53 -0
- package/lib/classes/BaseLanguage.d.ts +59 -0
- package/lib/i18n/ar.d.ts +27 -0
- package/lib/i18n/ar.js +28 -13
- package/lib/i18n/az.d.ts +15 -0
- package/lib/i18n/az.js +4 -3
- package/lib/i18n/cz.d.ts +12 -0
- package/lib/i18n/cz.js +2 -2
- package/lib/i18n/de.d.ts +17 -0
- package/lib/i18n/de.js +3 -3
- package/lib/i18n/dk.d.ts +14 -0
- package/lib/i18n/dk.js +3 -3
- package/lib/i18n/en.d.ts +22 -0
- package/lib/i18n/en.js +1 -1
- package/lib/i18n/es.d.ts +16 -0
- package/lib/i18n/es.js +5 -5
- package/lib/i18n/fa.d.ts +54 -0
- package/lib/i18n/fa.js +1 -1
- package/lib/i18n/fr.d.ts +15 -0
- package/lib/i18n/fr.js +6 -6
- package/lib/i18n/he.d.ts +28 -0
- package/lib/i18n/he.js +2 -2
- package/lib/i18n/hr.d.ts +35 -0
- package/lib/i18n/hr.js +2 -2
- package/lib/i18n/hu.d.ts +17 -0
- package/lib/i18n/hu.js +1 -1
- package/lib/i18n/id.d.ts +43 -0
- package/lib/i18n/id.js +6 -6
- package/lib/i18n/it.d.ts +29 -0
- package/lib/i18n/it.js +24 -14
- package/lib/i18n/ko.d.ts +15 -0
- package/lib/i18n/ko.js +3 -3
- package/lib/i18n/lt.d.ts +12 -0
- package/lib/i18n/lt.js +2 -2
- package/lib/i18n/lv.d.ts +12 -0
- package/lib/i18n/lv.js +3 -3
- package/lib/i18n/nl.d.ts +20 -0
- package/lib/i18n/nl.js +5 -5
- package/lib/i18n/no.d.ts +15 -0
- package/lib/i18n/no.js +3 -3
- package/lib/i18n/pl.d.ts +11 -0
- package/lib/i18n/pl.js +2 -2
- package/lib/i18n/pt.d.ts +26 -0
- package/lib/i18n/pt.js +1 -1
- package/lib/i18n/ru.d.ts +84 -0
- package/lib/i18n/ru.js +1 -1
- package/lib/i18n/sr.d.ts +35 -0
- package/lib/i18n/sr.js +2 -2
- package/lib/i18n/tr.d.ts +15 -0
- package/lib/i18n/tr.js +3 -3
- package/lib/i18n/uk.d.ts +11 -0
- package/lib/i18n/uk.js +2 -2
- package/lib/i18n/vi.d.ts +70 -0
- package/lib/i18n/zh.d.ts +18 -0
- package/lib/i18n/zh.js +3 -3
- package/lib/n2words.d.ts +7 -0
- package/lib/n2words.js +1 -1
- package/package.json +15 -7
package/lib/i18n/hr.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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 N2WordsHR extends N2WordsRU {
|
|
10
|
+
ones: {
|
|
11
|
+
1: string[];
|
|
12
|
+
2: string[];
|
|
13
|
+
3: string[];
|
|
14
|
+
4: string[];
|
|
15
|
+
5: string[];
|
|
16
|
+
6: string[];
|
|
17
|
+
7: string[];
|
|
18
|
+
8: string[];
|
|
19
|
+
9: string[];
|
|
20
|
+
};
|
|
21
|
+
SCALE: {
|
|
22
|
+
0: (string | boolean)[];
|
|
23
|
+
1: (string | boolean)[];
|
|
24
|
+
2: (string | boolean)[];
|
|
25
|
+
3: (string | boolean)[];
|
|
26
|
+
4: (string | boolean)[];
|
|
27
|
+
5: (string | boolean)[];
|
|
28
|
+
6: (string | boolean)[];
|
|
29
|
+
7: (string | boolean)[];
|
|
30
|
+
8: (string | boolean)[];
|
|
31
|
+
9: (string | boolean)[];
|
|
32
|
+
10: (string | boolean)[];
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
import { N2WordsRU } from './ru.js';
|
package/lib/i18n/hr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {N2WordsRU} from './ru.js';
|
|
1
|
+
import { N2WordsRU } from './ru.js';
|
|
2
2
|
|
|
3
3
|
export class N2WordsHR extends N2WordsRU {
|
|
4
4
|
ones = {
|
|
@@ -123,6 +123,6 @@ export class N2WordsHR extends N2WordsRU {
|
|
|
123
123
|
* @throws {Error} Value cannot be invalid.
|
|
124
124
|
* @returns {string} Value in cardinal (written) format.
|
|
125
125
|
*/
|
|
126
|
-
export default function(value, options) {
|
|
126
|
+
export default function (value, options) {
|
|
127
127
|
return new N2WordsHR(options).floatToCardinal(value);
|
|
128
128
|
}
|
package/lib/i18n/hu.d.ts
ADDED
|
@@ -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 N2WordsHU extends BaseLanguage {
|
|
10
|
+
constructor(options: any);
|
|
11
|
+
tensToCardinal(number: any): string;
|
|
12
|
+
hundredsToCardinal(number: any): string;
|
|
13
|
+
thousandsToCardinal(number: any): string;
|
|
14
|
+
bigNumberToCardinal(number: any): string;
|
|
15
|
+
toCardinal(number: any, zero?: string): string;
|
|
16
|
+
}
|
|
17
|
+
import BaseLanguage from '../classes/BaseLanguage.js';
|
package/lib/i18n/hu.js
CHANGED
|
@@ -128,6 +128,6 @@ export class N2WordsHU extends BaseLanguage {
|
|
|
128
128
|
* @throws {Error} Value cannot be invalid.
|
|
129
129
|
* @returns {string} Value in cardinal (written) format.
|
|
130
130
|
*/
|
|
131
|
-
export default function(value, options) {
|
|
131
|
+
export default function (value, options) {
|
|
132
132
|
return new N2WordsHU(options).floatToCardinal(value);
|
|
133
133
|
}
|
package/lib/i18n/id.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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 N2WordsID extends AbstractLanguage {
|
|
10
|
+
constructor(options: any);
|
|
11
|
+
base: {
|
|
12
|
+
0: any[];
|
|
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
|
+
};
|
|
23
|
+
thousands: {
|
|
24
|
+
3: string;
|
|
25
|
+
6: string;
|
|
26
|
+
9: string;
|
|
27
|
+
12: string;
|
|
28
|
+
15: string;
|
|
29
|
+
18: string;
|
|
30
|
+
21: string;
|
|
31
|
+
24: string;
|
|
32
|
+
27: string;
|
|
33
|
+
30: string;
|
|
34
|
+
33: string;
|
|
35
|
+
};
|
|
36
|
+
splitBy3(number: any): any[][];
|
|
37
|
+
spell(blocks: any): any[];
|
|
38
|
+
getHundreds(number: any): any;
|
|
39
|
+
getTens(number: any): any;
|
|
40
|
+
join(wordBlocks: any): string;
|
|
41
|
+
toCardinal(number: any): string;
|
|
42
|
+
}
|
|
43
|
+
import AbstractLanguage from '../classes/AbstractLanguage.js';
|
package/lib/i18n/id.js
CHANGED
|
@@ -72,7 +72,7 @@ export class N2WordsID extends AbstractLanguage {
|
|
|
72
72
|
if (firstBlock[0] == '0') {
|
|
73
73
|
spelling = ['nol'];
|
|
74
74
|
} else {
|
|
75
|
-
spelling = this.base[
|
|
75
|
+
spelling = this.base[Math.trunc(firstBlock[0])];
|
|
76
76
|
}
|
|
77
77
|
} else if (firstBlock[0].length == 2) {
|
|
78
78
|
spelling = this.getTens(firstBlock[0]);
|
|
@@ -99,7 +99,7 @@ export class N2WordsID extends AbstractLanguage {
|
|
|
99
99
|
} else if (number == '0') {
|
|
100
100
|
return [];
|
|
101
101
|
} else {
|
|
102
|
-
return this.base[
|
|
102
|
+
return this.base[Math.trunc(number)].concat(['ratus']);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -110,13 +110,13 @@ export class N2WordsID extends AbstractLanguage {
|
|
|
110
110
|
} else if (number[1] == '1') {
|
|
111
111
|
return ['sebelas'];
|
|
112
112
|
} else {
|
|
113
|
-
return this.base[
|
|
113
|
+
return this.base[Math.trunc(number[1])].concat(['belas']);
|
|
114
114
|
}
|
|
115
115
|
} else if (number[0] == '0') {
|
|
116
|
-
return this.base[
|
|
116
|
+
return this.base[Math.trunc(number[1])];
|
|
117
117
|
} else {
|
|
118
|
-
return this.base[
|
|
119
|
-
[this.base[
|
|
118
|
+
return this.base[Math.trunc(number[0])].concat(['puluh']).concat(
|
|
119
|
+
[this.base[Math.trunc(number[1])]]
|
|
120
120
|
);
|
|
121
121
|
}
|
|
122
122
|
}
|
package/lib/i18n/it.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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 N2WordsIT extends BaseLanguage {
|
|
10
|
+
constructor(options: any);
|
|
11
|
+
cardinalWords: string[];
|
|
12
|
+
strTens: {
|
|
13
|
+
'2': string;
|
|
14
|
+
'3': string;
|
|
15
|
+
'4': string;
|
|
16
|
+
'6': string;
|
|
17
|
+
};
|
|
18
|
+
exponentPrefixes: string[];
|
|
19
|
+
accentuate(string: any): any;
|
|
20
|
+
omitIfZero(numberToString: any): any;
|
|
21
|
+
phoneticContraction(string: any): any;
|
|
22
|
+
tensToCardinal(number: any): any;
|
|
23
|
+
hundredsToCardinal(number: any): any;
|
|
24
|
+
thousandsToCardinal(number: any): string;
|
|
25
|
+
exponentLengthToString(exponentLength: any): string;
|
|
26
|
+
bigNumberToCardinal(number: any): string;
|
|
27
|
+
toCardinal(number: any): any;
|
|
28
|
+
}
|
|
29
|
+
import BaseLanguage from '../classes/BaseLanguage.js';
|
package/lib/i18n/it.js
CHANGED
|
@@ -7,7 +7,7 @@ export class N2WordsIT extends BaseLanguage {
|
|
|
7
7
|
'sedici', 'diciassette', 'diciotto', 'diciannove',
|
|
8
8
|
];
|
|
9
9
|
|
|
10
|
-
strTens = {'2': 'venti', '3': 'trenta', '4': 'quaranta', '6': 'sessanta'};
|
|
10
|
+
strTens = { '2': 'venti', '3': 'trenta', '4': 'quaranta', '6': 'sessanta' };
|
|
11
11
|
|
|
12
12
|
exponentPrefixes = [this.zero, 'm', 'b', 'tr', 'quadr', 'quint', 'sest', 'sett', 'ott', 'nov', 'dec'];
|
|
13
13
|
|
|
@@ -88,21 +88,30 @@ export class N2WordsIT extends BaseLanguage {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
bigNumberToCardinal(number) {
|
|
91
|
-
const digits =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
const digits = number.toString().split('');
|
|
92
|
+
|
|
93
|
+
let preDigits = digits.length % 3;
|
|
94
|
+
if (preDigits == 0) {
|
|
95
|
+
preDigits = 3;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const multiplier = digits.slice(0, preDigits); // first `preDigits` elements
|
|
99
|
+
const exponent = digits.slice(preDigits); // without the first `preDigits` elements
|
|
100
|
+
|
|
101
|
+
let prefix, postfix;
|
|
96
102
|
let infix = this.exponentLengthToString(exponent.length);
|
|
97
|
-
|
|
103
|
+
|
|
104
|
+
if (multiplier == '1') {
|
|
98
105
|
prefix = 'un ';
|
|
99
106
|
} else {
|
|
100
|
-
prefix = this.toCardinal(
|
|
107
|
+
prefix = this.toCardinal(Math.trunc(Number(multiplier.join(''))));
|
|
101
108
|
infix = ' ' + infix.slice(0, -1) + 'i'; // without last element
|
|
102
109
|
}
|
|
110
|
+
|
|
103
111
|
const isSetsEqual = (a, b) => a.size == b.size && [...a].every(value => b.has(value));
|
|
104
112
|
if (!isSetsEqual(new Set(exponent), new Set(['0']))) {
|
|
105
|
-
postfix = this.toCardinal(
|
|
113
|
+
postfix = this.toCardinal(Math.trunc(exponent.join('')));
|
|
114
|
+
|
|
106
115
|
if (postfix.includes(' e ')) {
|
|
107
116
|
infix += ', '; // for very large numbers
|
|
108
117
|
} else {
|
|
@@ -111,19 +120,20 @@ export class N2WordsIT extends BaseLanguage {
|
|
|
111
120
|
} else {
|
|
112
121
|
postfix = '';
|
|
113
122
|
}
|
|
123
|
+
|
|
114
124
|
return prefix + infix + postfix;
|
|
115
125
|
}
|
|
116
126
|
|
|
117
127
|
toCardinal(number) {
|
|
118
128
|
let words = '';
|
|
119
129
|
|
|
120
|
-
if (number <
|
|
130
|
+
if (number < 20) {
|
|
121
131
|
words = this.cardinalWords[number];
|
|
122
|
-
} else if (number <
|
|
132
|
+
} else if (number < 100) {
|
|
123
133
|
words = this.tensToCardinal(Number(number));
|
|
124
|
-
} else if (number <
|
|
134
|
+
} else if (number < 1000) {
|
|
125
135
|
words = this.hundredsToCardinal(Number(number));
|
|
126
|
-
} else if (number <
|
|
136
|
+
} else if (number < 1000000) {
|
|
127
137
|
words = this.thousandsToCardinal(Number(number));
|
|
128
138
|
} else {
|
|
129
139
|
words = this.bigNumberToCardinal(number);
|
|
@@ -140,6 +150,6 @@ export class N2WordsIT extends BaseLanguage {
|
|
|
140
150
|
* @throws {Error} Value cannot be invalid.
|
|
141
151
|
* @returns {string} Value in cardinal (written) format.
|
|
142
152
|
*/
|
|
143
|
-
export default function(value, options) {
|
|
153
|
+
export default function (value, options) {
|
|
144
154
|
return new N2WordsIT(options).floatToCardinal(value);
|
|
145
155
|
}
|
package/lib/i18n/ko.d.ts
ADDED
|
@@ -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 N2WordsKO 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/ko.js
CHANGED
|
@@ -33,8 +33,8 @@ export class N2WordsKO extends BaseLanguage {
|
|
|
33
33
|
merge(lPair, rPair) {
|
|
34
34
|
const lText = Object.keys(lPair)[0];
|
|
35
35
|
const rText = Object.keys(rPair)[0];
|
|
36
|
-
const lNum =
|
|
37
|
-
const rNum =
|
|
36
|
+
const lNum = BigInt(Object.values(lPair)[0]);
|
|
37
|
+
const rNum = BigInt(Object.values(rPair)[0]);
|
|
38
38
|
if (lNum == 1 && rNum <= 10000) return { [rText]: rNum };
|
|
39
39
|
else if (10000 > lNum && lNum > rNum) return { [`${lText}${rText}`]: lNum + rNum };
|
|
40
40
|
else if (lNum >= 10000 && lNum > rNum) return { [`${lText} ${rText}`]: lNum + rNum };
|
|
@@ -49,6 +49,6 @@ export class N2WordsKO extends BaseLanguage {
|
|
|
49
49
|
* @throws {Error} Value cannot be invalid.
|
|
50
50
|
* @returns {string} Value in cardinal (written) format.
|
|
51
51
|
*/
|
|
52
|
-
export default function(value, options) {
|
|
52
|
+
export default function (value, options) {
|
|
53
53
|
return new N2WordsKO(options).floatToCardinal(value);
|
|
54
54
|
}
|
package/lib/i18n/lt.d.ts
ADDED
|
@@ -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 N2WordsLT extends N2WordsRU {
|
|
10
|
+
hundreds: string[];
|
|
11
|
+
}
|
|
12
|
+
import { N2WordsRU } from './ru.js';
|
package/lib/i18n/lt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {N2WordsRU} from './ru.js';
|
|
1
|
+
import { N2WordsRU } from './ru.js';
|
|
2
2
|
|
|
3
3
|
export class N2WordsLT extends N2WordsRU {
|
|
4
4
|
ones = {
|
|
@@ -132,6 +132,6 @@ export class N2WordsLT extends N2WordsRU {
|
|
|
132
132
|
* @throws {Error} Value cannot be invalid.
|
|
133
133
|
* @returns {string} Value in cardinal (written) format.
|
|
134
134
|
*/
|
|
135
|
-
export default function(value, options) {
|
|
135
|
+
export default function (value, options) {
|
|
136
136
|
return new N2WordsLT(options).floatToCardinal(value);
|
|
137
137
|
}
|
package/lib/i18n/lv.d.ts
ADDED
|
@@ -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 N2WordsLV extends N2WordsRU {
|
|
10
|
+
hundreds: string[];
|
|
11
|
+
}
|
|
12
|
+
import { N2WordsRU } from './ru.js';
|
package/lib/i18n/lv.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {N2WordsRU} from './ru.js';
|
|
1
|
+
import { N2WordsRU } from './ru.js';
|
|
2
2
|
|
|
3
|
-
export class N2WordsLV extends N2WordsRU{
|
|
3
|
+
export class N2WordsLV extends N2WordsRU {
|
|
4
4
|
ones = {
|
|
5
5
|
1: 'viens',
|
|
6
6
|
2: 'divi',
|
|
@@ -119,6 +119,6 @@ export class N2WordsLV extends N2WordsRU{
|
|
|
119
119
|
* @throws {Error} Value cannot be invalid.
|
|
120
120
|
* @returns {string} Value in cardinal (written) format.
|
|
121
121
|
*/
|
|
122
|
-
export default function(value, options) {
|
|
122
|
+
export default function (value, options) {
|
|
123
123
|
return new N2WordsLV(options).floatToCardinal(value);
|
|
124
124
|
}
|
package/lib/i18n/nl.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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 N2WordsNL extends BaseLanguage {
|
|
10
|
+
constructor(options: any);
|
|
11
|
+
includeOptionalAnd: any;
|
|
12
|
+
noHundredPairs: any;
|
|
13
|
+
merge(curr: any, next: any): {
|
|
14
|
+
[x: string]: bigint;
|
|
15
|
+
} | {
|
|
16
|
+
[x: string]: number;
|
|
17
|
+
};
|
|
18
|
+
toCardinal(value: any): string;
|
|
19
|
+
}
|
|
20
|
+
import BaseLanguage from '../classes/BaseLanguage.js';
|
package/lib/i18n/nl.js
CHANGED
|
@@ -61,11 +61,11 @@ export class N2WordsNL extends BaseLanguage {
|
|
|
61
61
|
merge(curr, next) {
|
|
62
62
|
let cText = Object.keys(curr)[0];
|
|
63
63
|
let nText = Object.keys(next)[0];
|
|
64
|
-
const cNum =
|
|
65
|
-
const nNum =
|
|
64
|
+
const cNum = BigInt(Object.values(curr)[0]);
|
|
65
|
+
const nNum = BigInt(Object.values(next)[0]);
|
|
66
66
|
if (cNum == 1) {
|
|
67
67
|
if (nNum < 1000000) {
|
|
68
|
-
return {[nText]: nNum};
|
|
68
|
+
return { [nText]: nNum };
|
|
69
69
|
}
|
|
70
70
|
cText = 'een';
|
|
71
71
|
}
|
|
@@ -97,7 +97,7 @@ export class N2WordsNL extends BaseLanguage {
|
|
|
97
97
|
}
|
|
98
98
|
val = cNum + nNum;
|
|
99
99
|
}
|
|
100
|
-
return {[`${cText}${nText}`]: val};
|
|
100
|
+
return { [`${cText}${nText}`]: val };
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
toCardinal(value) {
|
|
@@ -120,6 +120,6 @@ export class N2WordsNL extends BaseLanguage {
|
|
|
120
120
|
* @throws {Error} Value cannot be invalid.
|
|
121
121
|
* @returns {string} Value in cardinal (written) format.
|
|
122
122
|
*/
|
|
123
|
-
export default function(value, options) {
|
|
123
|
+
export default function (value, options) {
|
|
124
124
|
return new N2WordsNL(options).floatToCardinal(value);
|
|
125
125
|
}
|
package/lib/i18n/no.d.ts
ADDED
|
@@ -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 N2WordsNO 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/no.js
CHANGED
|
@@ -53,8 +53,8 @@ export class N2WordsNO extends BaseLanguage {
|
|
|
53
53
|
merge(lPair, rPair) { // {'one':1}, {'hundred':100}
|
|
54
54
|
const lText = Object.keys(lPair)[0];
|
|
55
55
|
const rText = Object.keys(rPair)[0];
|
|
56
|
-
const lNum =
|
|
57
|
-
const rNum =
|
|
56
|
+
const lNum = BigInt(Object.values(lPair)[0]);
|
|
57
|
+
const rNum = BigInt(Object.values(rPair)[0]);
|
|
58
58
|
if (lNum == 1 && rNum < 100) return { [rText]: rNum };
|
|
59
59
|
else if (lNum < 100 && lNum > rNum) return { [`${lText}-${rText}`]: lNum + rNum };
|
|
60
60
|
else if (lNum >= 100 && rNum < 100) return { [`${lText} og ${rText}`]: lNum + rNum };
|
|
@@ -70,6 +70,6 @@ export class N2WordsNO extends BaseLanguage {
|
|
|
70
70
|
* @throws {Error} Value cannot be invalid.
|
|
71
71
|
* @returns {string} Value in cardinal (written) format.
|
|
72
72
|
*/
|
|
73
|
-
export default function(value, options) {
|
|
73
|
+
export default function (value, options) {
|
|
74
74
|
return new N2WordsNO(options).floatToCardinal(value);
|
|
75
75
|
}
|
package/lib/i18n/pl.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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 N2WordsPL extends N2WordsRU {
|
|
10
|
+
}
|
|
11
|
+
import { N2WordsRU } from './ru.js';
|
package/lib/i18n/pl.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {N2WordsRU} from './ru.js';
|
|
1
|
+
import { N2WordsRU } from './ru.js';
|
|
2
2
|
|
|
3
3
|
export class N2WordsPL extends N2WordsRU {
|
|
4
4
|
ones = {
|
|
@@ -120,6 +120,6 @@ export class N2WordsPL extends N2WordsRU {
|
|
|
120
120
|
* @throws {Error} Value cannot be invalid.
|
|
121
121
|
* @returns {string} Value in cardinal (written) format.
|
|
122
122
|
*/
|
|
123
|
-
export default function(value, options) {
|
|
123
|
+
export default function (value, options) {
|
|
124
124
|
return new N2WordsPL(options).floatToCardinal(value);
|
|
125
125
|
}
|
package/lib/i18n/pt.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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 N2WordsPT extends BaseLanguage {
|
|
10
|
+
constructor(options: any);
|
|
11
|
+
hundreds: {
|
|
12
|
+
1: string;
|
|
13
|
+
2: string;
|
|
14
|
+
3: string;
|
|
15
|
+
4: string;
|
|
16
|
+
5: string;
|
|
17
|
+
6: string;
|
|
18
|
+
7: string;
|
|
19
|
+
8: string;
|
|
20
|
+
9: string;
|
|
21
|
+
};
|
|
22
|
+
merge(curr: any, next: any): {
|
|
23
|
+
[x: string]: bigint;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
import BaseLanguage from '../classes/BaseLanguage.js';
|
package/lib/i18n/pt.js
CHANGED
|
@@ -111,6 +111,6 @@ export class N2WordsPT extends BaseLanguage {
|
|
|
111
111
|
* @throws {Error} Value cannot be invalid.
|
|
112
112
|
* @returns {string} Value in cardinal (written) format.
|
|
113
113
|
*/
|
|
114
|
-
export default function(value, options) {
|
|
114
|
+
export default function (value, options) {
|
|
115
115
|
return new N2WordsPT(options).floatToCardinal(value);
|
|
116
116
|
}
|
package/lib/i18n/ru.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
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 N2WordsRU extends AbstractLanguage {
|
|
10
|
+
constructor(options: any);
|
|
11
|
+
feminine: any;
|
|
12
|
+
ones: {
|
|
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
|
+
};
|
|
23
|
+
onesFeminine: {
|
|
24
|
+
1: string;
|
|
25
|
+
2: string;
|
|
26
|
+
3: string;
|
|
27
|
+
4: string;
|
|
28
|
+
5: string;
|
|
29
|
+
6: string;
|
|
30
|
+
7: string;
|
|
31
|
+
8: string;
|
|
32
|
+
9: string;
|
|
33
|
+
};
|
|
34
|
+
tens: {
|
|
35
|
+
0: string;
|
|
36
|
+
1: string;
|
|
37
|
+
2: string;
|
|
38
|
+
3: string;
|
|
39
|
+
4: string;
|
|
40
|
+
5: string;
|
|
41
|
+
6: string;
|
|
42
|
+
7: string;
|
|
43
|
+
8: string;
|
|
44
|
+
9: string;
|
|
45
|
+
};
|
|
46
|
+
twenties: {
|
|
47
|
+
2: string;
|
|
48
|
+
3: string;
|
|
49
|
+
4: string;
|
|
50
|
+
5: string;
|
|
51
|
+
6: string;
|
|
52
|
+
7: string;
|
|
53
|
+
8: string;
|
|
54
|
+
9: string;
|
|
55
|
+
};
|
|
56
|
+
hundreds: {
|
|
57
|
+
1: string;
|
|
58
|
+
2: string;
|
|
59
|
+
3: string;
|
|
60
|
+
4: string;
|
|
61
|
+
5: string;
|
|
62
|
+
6: string;
|
|
63
|
+
7: string;
|
|
64
|
+
8: string;
|
|
65
|
+
9: string;
|
|
66
|
+
};
|
|
67
|
+
thousands: {
|
|
68
|
+
1: string[];
|
|
69
|
+
2: string[];
|
|
70
|
+
3: string[];
|
|
71
|
+
4: string[];
|
|
72
|
+
5: string[];
|
|
73
|
+
6: string[];
|
|
74
|
+
7: string[];
|
|
75
|
+
8: string[];
|
|
76
|
+
9: string[];
|
|
77
|
+
10: string[];
|
|
78
|
+
};
|
|
79
|
+
toCardinal(number: any): string;
|
|
80
|
+
splitByX(n: any, x: any, formatInt?: boolean): any[];
|
|
81
|
+
getDigits(value: any): bigint[];
|
|
82
|
+
pluralize(n: any, forms: any): any;
|
|
83
|
+
}
|
|
84
|
+
import AbstractLanguage from '../classes/AbstractLanguage.js';
|
package/lib/i18n/ru.js
CHANGED
|
@@ -198,6 +198,6 @@ export class N2WordsRU extends AbstractLanguage {
|
|
|
198
198
|
* @throws {Error} Value cannot be invalid.
|
|
199
199
|
* @returns {string} Value in cardinal (written) format.
|
|
200
200
|
*/
|
|
201
|
-
export default function(value, options) {
|
|
201
|
+
export default function (value, options) {
|
|
202
202
|
return new N2WordsRU(options).floatToCardinal(value);
|
|
203
203
|
}
|
package/lib/i18n/sr.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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 N2WordsSR extends N2WordsRU {
|
|
10
|
+
ones: {
|
|
11
|
+
1: string[];
|
|
12
|
+
2: string[];
|
|
13
|
+
3: string[];
|
|
14
|
+
4: string[];
|
|
15
|
+
5: string[];
|
|
16
|
+
6: string[];
|
|
17
|
+
7: string[];
|
|
18
|
+
8: string[];
|
|
19
|
+
9: string[];
|
|
20
|
+
};
|
|
21
|
+
SCALE: {
|
|
22
|
+
0: (string | boolean)[];
|
|
23
|
+
1: (string | boolean)[];
|
|
24
|
+
2: (string | boolean)[];
|
|
25
|
+
3: (string | boolean)[];
|
|
26
|
+
4: (string | boolean)[];
|
|
27
|
+
5: (string | boolean)[];
|
|
28
|
+
6: (string | boolean)[];
|
|
29
|
+
7: (string | boolean)[];
|
|
30
|
+
8: (string | boolean)[];
|
|
31
|
+
9: (string | boolean)[];
|
|
32
|
+
10: (string | boolean)[];
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
import { N2WordsRU } from './ru.js';
|
package/lib/i18n/sr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {N2WordsRU} from './ru.js';
|
|
1
|
+
import { N2WordsRU } from './ru.js';
|
|
2
2
|
|
|
3
3
|
export class N2WordsSR extends N2WordsRU {
|
|
4
4
|
ones = {
|
|
@@ -123,6 +123,6 @@ export class N2WordsSR extends N2WordsRU {
|
|
|
123
123
|
* @throws {Error} Value cannot be invalid.
|
|
124
124
|
* @returns {string} Value in cardinal (written) format.
|
|
125
125
|
*/
|
|
126
|
-
export default function(value, options) {
|
|
126
|
+
export default function (value, options) {
|
|
127
127
|
return new N2WordsSR(options).floatToCardinal(value);
|
|
128
128
|
}
|