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.
- 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 +29 -14
- package/lib/i18n/az.d.ts +15 -0
- package/lib/i18n/az.js +5 -4
- package/lib/i18n/cz.d.ts +12 -0
- package/lib/i18n/cz.js +3 -3
- package/lib/i18n/de.d.ts +17 -0
- package/lib/i18n/de.js +4 -4
- package/lib/i18n/dk.d.ts +14 -0
- package/lib/i18n/dk.js +4 -4
- package/lib/i18n/en.d.ts +22 -0
- package/lib/i18n/en.js +2 -2
- package/lib/i18n/es.d.ts +16 -0
- package/lib/i18n/es.js +6 -6
- package/lib/i18n/fa.d.ts +54 -0
- package/lib/i18n/fa.js +2 -2
- package/lib/i18n/fr.d.ts +15 -0
- package/lib/i18n/fr.js +7 -7
- package/lib/i18n/he.d.ts +28 -0
- package/lib/i18n/he.js +3 -3
- package/lib/i18n/hr.d.ts +35 -0
- package/lib/i18n/hr.js +3 -3
- package/lib/i18n/hu.d.ts +17 -0
- package/lib/i18n/hu.js +2 -2
- package/lib/i18n/id.d.ts +43 -0
- package/lib/i18n/id.js +8 -8
- package/lib/i18n/it.d.ts +29 -0
- package/lib/i18n/it.js +25 -15
- package/lib/i18n/ko.d.ts +15 -0
- package/lib/i18n/ko.js +4 -4
- package/lib/i18n/lt.d.ts +12 -0
- package/lib/i18n/lt.js +3 -3
- package/lib/i18n/lv.d.ts +12 -0
- package/lib/i18n/lv.js +4 -4
- package/lib/i18n/nl.d.ts +20 -0
- package/lib/i18n/nl.js +6 -6
- package/lib/i18n/no.d.ts +15 -0
- package/lib/i18n/no.js +4 -4
- package/lib/i18n/pl.d.ts +11 -0
- package/lib/i18n/pl.js +3 -3
- package/lib/i18n/pt.d.ts +26 -0
- package/lib/i18n/pt.js +2 -2
- package/lib/i18n/ru.d.ts +84 -0
- package/lib/i18n/ru.js +2 -2
- package/lib/i18n/sr.d.ts +35 -0
- package/lib/i18n/sr.js +3 -3
- package/lib/i18n/tr.d.ts +15 -0
- package/lib/i18n/tr.js +4 -4
- package/lib/i18n/uk.d.ts +11 -0
- package/lib/i18n/uk.js +3 -3
- package/lib/i18n/vi.d.ts +70 -0
- package/lib/i18n/vi.js +2 -2
- package/lib/i18n/zh.d.ts +18 -0
- package/lib/i18n/zh.js +4 -4
- package/lib/n2words.d.ts +7 -0
- package/lib/n2words.js +1 -1
- package/package.json +15 -7
package/lib/i18n/he.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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 N2WordsHE extends N2WordsRU {
|
|
10
|
+
and: any;
|
|
11
|
+
hundreds: {
|
|
12
|
+
1: string;
|
|
13
|
+
2: string;
|
|
14
|
+
3: string;
|
|
15
|
+
};
|
|
16
|
+
thousands: {
|
|
17
|
+
1: string;
|
|
18
|
+
2: string;
|
|
19
|
+
3: string;
|
|
20
|
+
4: string;
|
|
21
|
+
5: string;
|
|
22
|
+
6: string;
|
|
23
|
+
7: string;
|
|
24
|
+
8: string;
|
|
25
|
+
9: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
import { N2WordsRU } from './ru.js';
|
package/lib/i18n/he.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {N2WordsRU} from './ru.js';
|
|
1
|
+
import { N2WordsRU } from './ru.js';
|
|
2
2
|
|
|
3
3
|
export class N2WordsHE extends N2WordsRU {
|
|
4
4
|
and;
|
|
@@ -121,10 +121,10 @@ export class N2WordsHE extends N2WordsRU {
|
|
|
121
121
|
/**
|
|
122
122
|
* Converts a value to cardinal (written) form.
|
|
123
123
|
* @param {number|string} value Number to be convert.
|
|
124
|
-
* @param {object} options Options for class.
|
|
124
|
+
* @param {object} [options] Options for class.
|
|
125
125
|
* @throws {Error} Value cannot be invalid.
|
|
126
126
|
* @returns {string} Value in cardinal (written) format.
|
|
127
127
|
*/
|
|
128
|
-
export default function(value, options) {
|
|
128
|
+
export default function (value, options = {}) {
|
|
129
129
|
return new N2WordsHE(options).floatToCardinal(value);
|
|
130
130
|
}
|
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 = {
|
|
@@ -119,10 +119,10 @@ export class N2WordsHR extends N2WordsRU {
|
|
|
119
119
|
/**
|
|
120
120
|
* Converts a value to cardinal (written) form.
|
|
121
121
|
* @param {number|string} value Number to be convert.
|
|
122
|
-
* @param {object} options Options for class.
|
|
122
|
+
* @param {object} [options] Options for class.
|
|
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
|
@@ -124,10 +124,10 @@ export class N2WordsHU extends BaseLanguage {
|
|
|
124
124
|
/**
|
|
125
125
|
* Converts a value to cardinal (written) form.
|
|
126
126
|
* @param {number|string} value Number to be convert.
|
|
127
|
-
* @param {object} options Options for class.
|
|
127
|
+
* @param {object} [options] Options for class.
|
|
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
|
}
|
|
@@ -155,10 +155,10 @@ export class N2WordsID extends AbstractLanguage {
|
|
|
155
155
|
/**
|
|
156
156
|
* Converts a value to cardinal (written) form.
|
|
157
157
|
* @param {number|string} value Number to be convert.
|
|
158
|
-
* @param {object} options Options for class.
|
|
158
|
+
* @param {object} [options] Options for class.
|
|
159
159
|
* @throws {Error} Value cannot be invalid.
|
|
160
160
|
* @returns {string} Value in cardinal (written) format.
|
|
161
161
|
*/
|
|
162
|
-
export default function (value, options) {
|
|
162
|
+
export default function (value, options = {}) {
|
|
163
163
|
return new N2WordsID(options).floatToCardinal(value);
|
|
164
164
|
}
|
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);
|
|
@@ -136,10 +146,10 @@ export class N2WordsIT extends BaseLanguage {
|
|
|
136
146
|
/**
|
|
137
147
|
* Converts a value to cardinal (written) form.
|
|
138
148
|
* @param {number|string} value Number to be convert.
|
|
139
|
-
* @param {object} options Options for class.
|
|
149
|
+
* @param {object} [options] Options for class.
|
|
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 };
|
|
@@ -45,10 +45,10 @@ export class N2WordsKO extends BaseLanguage {
|
|
|
45
45
|
/**
|
|
46
46
|
* Converts a value to cardinal (written) form.
|
|
47
47
|
* @param {number|string} value Number to be convert.
|
|
48
|
-
* @param {object} options Options for class.
|
|
48
|
+
* @param {object} [options] Options for class.
|
|
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 = {
|
|
@@ -128,10 +128,10 @@ export class N2WordsLT extends N2WordsRU {
|
|
|
128
128
|
/**
|
|
129
129
|
* Converts a value to cardinal (written) form.
|
|
130
130
|
* @param {number|string} value Number to be convert.
|
|
131
|
-
* @param {object} options Options for class.
|
|
131
|
+
* @param {object} [options] Options for class.
|
|
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',
|
|
@@ -115,10 +115,10 @@ export class N2WordsLV extends N2WordsRU{
|
|
|
115
115
|
/**
|
|
116
116
|
* Converts a value to cardinal (written) form.
|
|
117
117
|
* @param {number|string} value Number to be convert.
|
|
118
|
-
* @param {object} options Options for class.
|
|
118
|
+
* @param {object} [options] Options for class.
|
|
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) {
|
|
@@ -116,10 +116,10 @@ export class N2WordsNL extends BaseLanguage {
|
|
|
116
116
|
/**
|
|
117
117
|
* Converts a value to cardinal (written) form.
|
|
118
118
|
* @param {number|string} value Number to be convert.
|
|
119
|
-
* @param {object} options Options for class.
|
|
119
|
+
* @param {object} [options] Options for class.
|
|
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 };
|
|
@@ -66,10 +66,10 @@ export class N2WordsNO extends BaseLanguage {
|
|
|
66
66
|
/**
|
|
67
67
|
* Converts a value to cardinal (written) form.
|
|
68
68
|
* @param {number|string} value Number to be convert.
|
|
69
|
-
* @param {object} options Options for class.
|
|
69
|
+
* @param {object} [options] Options for class.
|
|
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 = {
|
|
@@ -116,10 +116,10 @@ export class N2WordsPL extends N2WordsRU {
|
|
|
116
116
|
/**
|
|
117
117
|
* Converts a value to cardinal (written) form.
|
|
118
118
|
* @param {number|string} value Number to be convert.
|
|
119
|
-
* @param {object} options Options for class.
|
|
119
|
+
* @param {object} [options] Options for class.
|
|
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
|
@@ -107,10 +107,10 @@ export class N2WordsPT extends BaseLanguage {
|
|
|
107
107
|
/**
|
|
108
108
|
* Converts a value to cardinal (written) form.
|
|
109
109
|
* @param {number|string} value Number to be convert.
|
|
110
|
-
* @param {object} options Options for class.
|
|
110
|
+
* @param {object} [options] Options for class.
|
|
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
|
}
|