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/tr.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 N2WordsTR extends BaseLanguage {
|
|
10
|
+
constructor(options?: {});
|
|
11
|
+
merge(lPair: any, rPair: any): {
|
|
12
|
+
[x: string]: bigint;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
import BaseLanguage from '../classes/BaseLanguage.js';
|
package/lib/i18n/tr.js
CHANGED
|
@@ -40,8 +40,8 @@ export class N2WordsTR extends BaseLanguage {
|
|
|
40
40
|
merge(lPair, rPair) {
|
|
41
41
|
const lText = Object.keys(lPair)[0];
|
|
42
42
|
const rText = Object.keys(rPair)[0];
|
|
43
|
-
const lNum =
|
|
44
|
-
const rNum =
|
|
43
|
+
const lNum = BigInt(Object.values(lPair)[0]);
|
|
44
|
+
const rNum = BigInt(Object.values(rPair)[0]);
|
|
45
45
|
if (lNum == 1 && (rNum <= 100 || rNum == 1000)) {
|
|
46
46
|
return { [rText]: rNum };
|
|
47
47
|
} else if (rNum > lNum) {
|
|
@@ -59,6 +59,6 @@ export class N2WordsTR extends BaseLanguage {
|
|
|
59
59
|
* @throws {Error} Value cannot be invalid.
|
|
60
60
|
* @returns {string} Value in cardinal (written) format.
|
|
61
61
|
*/
|
|
62
|
-
export default function(value, options) {
|
|
62
|
+
export default function (value, options) {
|
|
63
63
|
return new N2WordsTR(options).floatToCardinal(value);
|
|
64
64
|
}
|
package/lib/i18n/uk.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 N2WordsUK extends N2WordsRU {
|
|
10
|
+
}
|
|
11
|
+
import { N2WordsRU } from './ru.js';
|
package/lib/i18n/uk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {N2WordsRU} from './ru.js';
|
|
1
|
+
import { N2WordsRU } from './ru.js';
|
|
2
2
|
|
|
3
3
|
export class N2WordsUK extends N2WordsRU {
|
|
4
4
|
ones = {
|
|
@@ -90,6 +90,6 @@ export class N2WordsUK extends N2WordsRU {
|
|
|
90
90
|
* @throws {Error} Value cannot be invalid.
|
|
91
91
|
* @returns {string} Value in cardinal (written) format.
|
|
92
92
|
*/
|
|
93
|
-
export default function(value, options) {
|
|
93
|
+
export default function (value, options) {
|
|
94
94
|
return new N2WordsUK(options).floatToCardinal(value);
|
|
95
95
|
}
|
package/lib/i18n/vi.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
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: 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
|
+
};
|
|
33
|
+
tens: {
|
|
34
|
+
20: string;
|
|
35
|
+
30: string;
|
|
36
|
+
40: string;
|
|
37
|
+
50: string;
|
|
38
|
+
60: string;
|
|
39
|
+
70: string;
|
|
40
|
+
80: string;
|
|
41
|
+
90: string;
|
|
42
|
+
};
|
|
43
|
+
thousands: {
|
|
44
|
+
1: string;
|
|
45
|
+
2: string;
|
|
46
|
+
3: string;
|
|
47
|
+
4: string;
|
|
48
|
+
5: string;
|
|
49
|
+
6: string;
|
|
50
|
+
7: string;
|
|
51
|
+
8: string;
|
|
52
|
+
9: string;
|
|
53
|
+
10: string;
|
|
54
|
+
11: string;
|
|
55
|
+
12: string;
|
|
56
|
+
13: string;
|
|
57
|
+
14: string;
|
|
58
|
+
15: string;
|
|
59
|
+
16: string;
|
|
60
|
+
17: string;
|
|
61
|
+
18: string;
|
|
62
|
+
19: string;
|
|
63
|
+
20: string;
|
|
64
|
+
};
|
|
65
|
+
convertLess100(number: any): any;
|
|
66
|
+
convertLess1000(number: any): any;
|
|
67
|
+
convertMore1000(number: any): any;
|
|
68
|
+
toCardinal(number: any): any;
|
|
69
|
+
}
|
|
70
|
+
import AbstractLanguage from '../classes/AbstractLanguage.js';
|
package/lib/i18n/zh.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 N2WordsZH extends BaseLanguage {
|
|
10
|
+
constructor(options: any);
|
|
11
|
+
merge(lPair: any, rPair: any): {
|
|
12
|
+
[x: string]: bigint;
|
|
13
|
+
};
|
|
14
|
+
decimalToCardinal(decimal: any): any;
|
|
15
|
+
digit(num: any): any;
|
|
16
|
+
zeroDigit(num: any): number;
|
|
17
|
+
}
|
|
18
|
+
import BaseLanguage from '../classes/BaseLanguage.js';
|
package/lib/i18n/zh.js
CHANGED
|
@@ -30,9 +30,9 @@ export class N2WordsZH extends BaseLanguage {
|
|
|
30
30
|
merge(lPair, rPair) {
|
|
31
31
|
// {'one':1}, {'hundred':100}
|
|
32
32
|
const ltext = Object.keys(lPair)[0];
|
|
33
|
-
const lnum =
|
|
33
|
+
const lnum = BigInt(Object.values(lPair)[0]);
|
|
34
34
|
const rtext = Object.keys(rPair)[0];
|
|
35
|
-
const rnum =
|
|
35
|
+
const rnum = BigInt(Object.values(rPair)[0]);
|
|
36
36
|
|
|
37
37
|
let result = { [`${ltext}${rtext}`]: lnum + rnum };
|
|
38
38
|
|
|
@@ -73,6 +73,6 @@ export class N2WordsZH extends BaseLanguage {
|
|
|
73
73
|
* @throws {Error} Value cannot be invalid.
|
|
74
74
|
* @returns {string} Value in cardinal (written) format.
|
|
75
75
|
*/
|
|
76
|
-
export default function(value, options) {
|
|
76
|
+
export default function (value, options) {
|
|
77
77
|
return new N2WordsZH(options).floatToCardinal(value);
|
|
78
78
|
}
|
package/lib/n2words.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a number to written form.
|
|
3
|
+
* @param {number|string} value The number to convert.
|
|
4
|
+
* @param {object} [options] User options.
|
|
5
|
+
* @returns {string} Value in written format.
|
|
6
|
+
*/
|
|
7
|
+
export default function _default(value: number | string, options?: object): string;
|
package/lib/n2words.js
CHANGED
|
@@ -32,7 +32,7 @@ import n2wordsZH from './i18n/zh.js';
|
|
|
32
32
|
* @param {object} [options] User options.
|
|
33
33
|
* @returns {string} Value in written format.
|
|
34
34
|
*/
|
|
35
|
-
export default function(value, options = {lang: 'en'}) {
|
|
35
|
+
export default function (value, options = { lang: 'en' }) {
|
|
36
36
|
switch (options.lang) {
|
|
37
37
|
case 'en': return n2wordsEN(value, options); // default
|
|
38
38
|
case 'ar': return n2wordsAR(value, options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n2words",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.3",
|
|
4
4
|
"description": "n2words converts a numerical number into a written one, supports 27 languages and has zero dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n2words",
|
|
@@ -59,19 +59,25 @@
|
|
|
59
59
|
"unpkg": "dist/n2words.js",
|
|
60
60
|
"files": [
|
|
61
61
|
"lib/*",
|
|
62
|
-
"dist/*"
|
|
62
|
+
"dist/*",
|
|
63
|
+
"types/*"
|
|
63
64
|
],
|
|
64
65
|
"scripts": {
|
|
65
66
|
"bench": "node bench.js",
|
|
66
67
|
"build": "webpack --config webpack.config.js --progress",
|
|
68
|
+
"build:types": "npx -p typescript tsc lib/n2words.js dist/n2words.js --declaration --allowJs --emitDeclarationOnly",
|
|
67
69
|
"coverage": "c8 ava",
|
|
68
70
|
"lint": "eslint --config .eslintrc.json lib/ test/ bench.js",
|
|
69
|
-
"test": "ava --verbose"
|
|
71
|
+
"test": "ava --verbose",
|
|
72
|
+
"test:cjs": "ava --verbose test/import.cjs",
|
|
73
|
+
"test:core": "ava --verbose test/core.js",
|
|
74
|
+
"test:i18n": "ava --verbose test/i18n.js",
|
|
75
|
+
"test:web": "ava --verbose test/web.js"
|
|
70
76
|
},
|
|
71
77
|
"ava": {
|
|
72
78
|
"files": [
|
|
73
|
-
"test
|
|
74
|
-
"!test/
|
|
79
|
+
"test/*",
|
|
80
|
+
"!test/web.js"
|
|
75
81
|
]
|
|
76
82
|
},
|
|
77
83
|
"c8": {
|
|
@@ -91,14 +97,16 @@
|
|
|
91
97
|
"babel-loader": "^9.1.2",
|
|
92
98
|
"benchmark": "^2.1.4",
|
|
93
99
|
"c8": "^7.14.0",
|
|
100
|
+
"chromedriver": "^114.0.1",
|
|
94
101
|
"core-js": "^3.30.2",
|
|
95
102
|
"eslint": "^8.42.0",
|
|
96
103
|
"eslint-plugin-ava": "^14.0.0",
|
|
97
104
|
"eslint-plugin-import": "^2.27.5",
|
|
98
|
-
"eslint-plugin-jsdoc": "^46.2.
|
|
105
|
+
"eslint-plugin-jsdoc": "^46.2.5",
|
|
99
106
|
"eslint-plugin-node": "^11.1.0",
|
|
100
107
|
"microtime": "^3.1.1",
|
|
101
|
-
"
|
|
108
|
+
"selenium-webdriver": "^4.9.2",
|
|
109
|
+
"webpack": "^5.85.1",
|
|
102
110
|
"webpack-cli": "^5.1.3"
|
|
103
111
|
},
|
|
104
112
|
"engines": {
|