n2words 1.14.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +13 -29
- package/lib/classes/{AbstractLanguage.mjs → AbstractLanguage.js} +2 -2
- package/lib/classes/{BaseLanguage.mjs → BaseLanguage.js} +3 -3
- package/lib/i18n/{AR.mjs → AR.js} +47 -33
- package/lib/i18n/{AZ.mjs → AZ.js} +7 -6
- package/lib/i18n/{CZ.mjs → CZ.js} +7 -6
- package/lib/i18n/{DE.mjs → DE.js} +7 -6
- package/lib/i18n/{DK.mjs → DK.js} +13 -7
- package/lib/i18n/{EN.mjs → EN.js} +7 -6
- package/lib/i18n/{ES.mjs → ES.js} +14 -8
- package/lib/i18n/{FA.mjs → FA.js} +7 -6
- package/lib/i18n/{FR.mjs → FR.js} +7 -6
- package/lib/i18n/{HE.mjs → HE.js} +14 -8
- package/lib/i18n/{HR.mjs → HR.js} +7 -8
- package/lib/i18n/{HU.mjs → HU.js} +7 -6
- package/lib/i18n/{ID.mjs → ID.js} +34 -32
- package/lib/i18n/{IT.mjs → IT.js} +17 -14
- package/lib/i18n/{KO.mjs → KO.js} +7 -6
- package/lib/i18n/{LT.mjs → LT.js} +7 -8
- package/lib/i18n/{LV.mjs → LV.js} +7 -6
- package/lib/i18n/{NL.mjs → NL.js} +13 -14
- package/lib/i18n/{NO.mjs → NO.js} +7 -6
- package/lib/i18n/{PL.mjs → PL.js} +7 -8
- package/lib/i18n/{PT.mjs → PT.js} +19 -18
- package/lib/i18n/{RU.mjs → RU.js} +12 -5
- package/lib/i18n/{SR.mjs → SR.js} +7 -8
- package/lib/i18n/{TR.mjs → TR.js} +5 -5
- package/lib/i18n/UK.js +95 -0
- package/lib/i18n/{VI.mjs → VI.js} +64 -61
- package/lib/i18n/{ZH.mjs → ZH.js} +7 -6
- package/lib/n2words.js +67 -0
- package/package.json +44 -36
- package/.editorconfig +0 -13
- package/.eslintrc.json +0 -105
- package/.gitattributes +0 -5
- package/bench.mjs +0 -94
- package/dist/n2words.js +0 -1
- package/examples/node.mjs +0 -10
- package/lib/i18n/UK.mjs +0 -90
- package/lib/n2words.mjs +0 -67
- package/webpack.config.js +0 -31
|
@@ -1,67 +1,69 @@
|
|
|
1
|
-
import AbstractLanguage from '../classes/AbstractLanguage.
|
|
1
|
+
import AbstractLanguage from '../classes/AbstractLanguage.js';
|
|
2
2
|
|
|
3
3
|
export class N2WordsID extends AbstractLanguage {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
base = {
|
|
5
|
+
0: 'không',
|
|
6
|
+
1: 'một',
|
|
7
|
+
2: 'hai',
|
|
8
|
+
3: 'ba',
|
|
9
|
+
4: 'bốn',
|
|
10
|
+
5: 'năm',
|
|
11
|
+
6: 'sáu',
|
|
12
|
+
7: 'bảy',
|
|
13
|
+
8: 'tám',
|
|
14
|
+
9: 'chín',
|
|
15
|
+
10: 'mười',
|
|
16
|
+
11: 'mười một',
|
|
17
|
+
12: 'mười hai',
|
|
18
|
+
13: 'mười ba',
|
|
19
|
+
14: 'mười bốn',
|
|
20
|
+
15: 'mười lăm',
|
|
21
|
+
16: 'mười sáu',
|
|
22
|
+
17: 'mười bảy',
|
|
23
|
+
18: 'mười tám',
|
|
24
|
+
19: 'mười chín',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
tens = {
|
|
28
|
+
20: 'hai mươi',
|
|
29
|
+
30: 'ba mươi',
|
|
30
|
+
40: 'bốn mươi',
|
|
31
|
+
50: 'năm mươi',
|
|
32
|
+
60: 'sáu mươi',
|
|
33
|
+
70: 'bảy mươi',
|
|
34
|
+
80: 'tám mươi',
|
|
35
|
+
90: 'chín mươi',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
thousands = {
|
|
39
|
+
1: 'nghìn', // 10^1
|
|
40
|
+
2: 'triệu', // 10^2
|
|
41
|
+
3: 'tỷ', // 10^3
|
|
42
|
+
4: 'nghìn tỷ',
|
|
43
|
+
5: 'trăm nghìn tỷ',
|
|
44
|
+
6: 'Quintillion',
|
|
45
|
+
7: 'Sextillion',
|
|
46
|
+
8: 'Septillion',
|
|
47
|
+
9: 'Octillion',
|
|
48
|
+
10: 'Nonillion',
|
|
49
|
+
11: 'Decillion',
|
|
50
|
+
12: 'Undecillion',
|
|
51
|
+
13: 'Duodecillion',
|
|
52
|
+
14: 'Tredecillion',
|
|
53
|
+
15: 'Quattuordecillion',
|
|
54
|
+
16: 'Sexdecillion',
|
|
55
|
+
17: 'Septendecillion',
|
|
56
|
+
18: 'Octodecillion',
|
|
57
|
+
19: 'Novemdecillion',
|
|
58
|
+
20: 'Vigintillion',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
constructor(options) {
|
|
62
|
+
super(Object.assign({
|
|
6
63
|
negativeWord: 'âm',
|
|
7
64
|
separatorWord: 'phẩy',
|
|
8
65
|
zero: 'không'
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
this.base = {
|
|
12
|
-
0: 'không',
|
|
13
|
-
1: 'một',
|
|
14
|
-
2: 'hai',
|
|
15
|
-
3: 'ba',
|
|
16
|
-
4: 'bốn',
|
|
17
|
-
5: 'năm',
|
|
18
|
-
6: 'sáu',
|
|
19
|
-
7: 'bảy',
|
|
20
|
-
8: 'tám',
|
|
21
|
-
9: 'chín',
|
|
22
|
-
10: 'mười',
|
|
23
|
-
11: 'mười một',
|
|
24
|
-
12: 'mười hai',
|
|
25
|
-
13: 'mười ba',
|
|
26
|
-
14: 'mười bốn',
|
|
27
|
-
15: 'mười lăm',
|
|
28
|
-
16: 'mười sáu',
|
|
29
|
-
17: 'mười bảy',
|
|
30
|
-
18: 'mười tám',
|
|
31
|
-
19: 'mười chín',
|
|
32
|
-
};
|
|
33
|
-
this.tens = {
|
|
34
|
-
20: 'hai mươi',
|
|
35
|
-
30: 'ba mươi',
|
|
36
|
-
40: 'bốn mươi',
|
|
37
|
-
50: 'năm mươi',
|
|
38
|
-
60: 'sáu mươi',
|
|
39
|
-
70: 'bảy mươi',
|
|
40
|
-
80: 'tám mươi',
|
|
41
|
-
90: 'chín mươi',
|
|
42
|
-
};
|
|
43
|
-
this.thousands = {
|
|
44
|
-
1: 'nghìn', // 10^1
|
|
45
|
-
2: 'triệu', // 10^2
|
|
46
|
-
3: 'tỷ', // 10^3
|
|
47
|
-
4: 'nghìn tỷ',
|
|
48
|
-
5: 'trăm nghìn tỷ',
|
|
49
|
-
6: 'Quintillion',
|
|
50
|
-
7: 'Sextillion',
|
|
51
|
-
8: 'Septillion',
|
|
52
|
-
9: 'Octillion',
|
|
53
|
-
10: 'Nonillion',
|
|
54
|
-
11: 'Decillion',
|
|
55
|
-
12: 'Undecillion',
|
|
56
|
-
13: 'Duodecillion',
|
|
57
|
-
14: 'Tredecillion',
|
|
58
|
-
15: 'Quattuordecillion',
|
|
59
|
-
16: 'Sexdecillion',
|
|
60
|
-
17: 'Septendecillion',
|
|
61
|
-
18: 'Octodecillion',
|
|
62
|
-
19: 'Novemdecillion',
|
|
63
|
-
20: 'Vigintillion',
|
|
64
|
-
};
|
|
66
|
+
}, options));
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
convertLess100(number) {
|
|
@@ -144,9 +146,10 @@ export class N2WordsID extends AbstractLanguage {
|
|
|
144
146
|
/**
|
|
145
147
|
* Converts a value to cardinal (written) form.
|
|
146
148
|
* @param {number|string} value Number to be convert.
|
|
149
|
+
* @param {object} options Options for class.
|
|
147
150
|
* @throws {Error} Value cannot be invalid.
|
|
148
151
|
* @returns {string} Value in cardinal (written) format.
|
|
149
152
|
*/
|
|
150
|
-
export default function (value) {
|
|
151
|
-
return new N2WordsID().floatToCardinal(value);
|
|
153
|
+
export default function (value, options) {
|
|
154
|
+
return new N2WordsID(options).floatToCardinal(value);
|
|
152
155
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import BaseLanguage from '../classes/BaseLanguage.
|
|
1
|
+
import BaseLanguage from '../classes/BaseLanguage.js';
|
|
2
2
|
|
|
3
3
|
export class N2WordsZH extends BaseLanguage {
|
|
4
|
-
constructor() {
|
|
5
|
-
super({
|
|
4
|
+
constructor(options) {
|
|
5
|
+
super(Object.assign({
|
|
6
6
|
negativeWord: '负',
|
|
7
7
|
separatorWord: '点',
|
|
8
8
|
zero: '零',
|
|
9
9
|
spaceSeparator: ''
|
|
10
|
-
},[
|
|
10
|
+
}, options), [
|
|
11
11
|
[1000000000000n, '万'],
|
|
12
12
|
[100000000n, '亿'],
|
|
13
13
|
[10000n, '万'],
|
|
@@ -69,9 +69,10 @@ export class N2WordsZH extends BaseLanguage {
|
|
|
69
69
|
/**
|
|
70
70
|
* Converts a value to cardinal (written) form.
|
|
71
71
|
* @param {number|string} value Number to be convert.
|
|
72
|
+
* @param {object} options Options for class.
|
|
72
73
|
* @throws {Error} Value cannot be invalid.
|
|
73
74
|
* @returns {string} Value in cardinal (written) format.
|
|
74
75
|
*/
|
|
75
|
-
export default function(value) {
|
|
76
|
-
return new N2WordsZH().floatToCardinal(value);
|
|
76
|
+
export default function(value, options) {
|
|
77
|
+
return new N2WordsZH(options).floatToCardinal(value);
|
|
77
78
|
}
|
package/lib/n2words.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* eslint-disable import/max-dependencies */
|
|
2
|
+
import n2wordsAR from './i18n/AR.js';
|
|
3
|
+
import n2wordsAZ from './i18n/AZ.js';
|
|
4
|
+
import n2wordsCZ from './i18n/CZ.js';
|
|
5
|
+
import n2wordsDE from './i18n/DE.js';
|
|
6
|
+
import n2wordsDK from './i18n/DK.js';
|
|
7
|
+
import n2wordsEN from './i18n/EN.js';
|
|
8
|
+
import n2wordsES from './i18n/ES.js';
|
|
9
|
+
import n2wordsFA from './i18n/FA.js';
|
|
10
|
+
import n2wordsFR from './i18n/FR.js';
|
|
11
|
+
import n2wordsHE from './i18n/HE.js';
|
|
12
|
+
import n2wordsHR from './i18n/HR.js';
|
|
13
|
+
import n2wordsHU from './i18n/HU.js';
|
|
14
|
+
import n2wordsID from './i18n/ID.js';
|
|
15
|
+
import n2wordsIT from './i18n/IT.js';
|
|
16
|
+
import n2wordsKO from './i18n/KO.js';
|
|
17
|
+
import n2wordsLT from './i18n/LT.js';
|
|
18
|
+
import n2wordsLV from './i18n/LV.js';
|
|
19
|
+
import n2wordsNL from './i18n/NL.js';
|
|
20
|
+
import n2wordsNO from './i18n/NO.js';
|
|
21
|
+
import n2wordsPL from './i18n/PL.js';
|
|
22
|
+
import n2wordsPT from './i18n/PT.js';
|
|
23
|
+
import n2wordsRU from './i18n/RU.js';
|
|
24
|
+
import n2wordsSR from './i18n/SR.js';
|
|
25
|
+
import n2wordsTR from './i18n/TR.js';
|
|
26
|
+
import n2wordsUK from './i18n/UK.js';
|
|
27
|
+
import n2wordsVI from './i18n/VI.js';
|
|
28
|
+
import n2wordsZH from './i18n/ZH.js';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Converts a number to written form.
|
|
32
|
+
* @param {number|string} value The number to convert.
|
|
33
|
+
* @param {object} [options] User options.
|
|
34
|
+
* @returns {string} Value in written format.
|
|
35
|
+
*/
|
|
36
|
+
export default function(value, options = {lang: 'en'}) {
|
|
37
|
+
switch (options.lang) {
|
|
38
|
+
case 'en': return n2wordsEN(value, options); // default
|
|
39
|
+
case 'ar': return n2wordsAR(value, options);
|
|
40
|
+
case 'az': return n2wordsAZ(value, options);
|
|
41
|
+
case 'cz': return n2wordsCZ(value, options);
|
|
42
|
+
case 'de': return n2wordsDE(value, options);
|
|
43
|
+
case 'dk': return n2wordsDK(value, options);
|
|
44
|
+
case 'es': return n2wordsES(value, options);
|
|
45
|
+
case 'fa': return n2wordsFA(value, options);
|
|
46
|
+
case 'fr': return n2wordsFR(value, options);
|
|
47
|
+
case 'he': return n2wordsHE(value, options); // only for numbers <= 9999
|
|
48
|
+
case 'hr': return n2wordsHR(value, options);
|
|
49
|
+
case 'hu': return n2wordsHU(value, options);
|
|
50
|
+
case 'id': return n2wordsID(value, options);
|
|
51
|
+
case 'it': return n2wordsIT(value, options);
|
|
52
|
+
case 'ko': return n2wordsKO(value, options);
|
|
53
|
+
case 'lt': return n2wordsLT(value, options);
|
|
54
|
+
case 'lv': return n2wordsLV(value, options);
|
|
55
|
+
case 'nl': return n2wordsNL(value, options);
|
|
56
|
+
case 'no': return n2wordsNO(value, options);
|
|
57
|
+
case 'pl': return n2wordsPL(value, options);
|
|
58
|
+
case 'pt': return n2wordsPT(value, options);
|
|
59
|
+
case 'ru': return n2wordsRU(value, options);
|
|
60
|
+
case 'sr': return n2wordsSR(value, options);
|
|
61
|
+
case 'tr': return n2wordsTR(value, options);
|
|
62
|
+
case 'uk': return n2wordsUK(value, options);
|
|
63
|
+
case 'vi': return n2wordsVI(value, options);
|
|
64
|
+
case 'zh': return n2wordsZH(value, options);
|
|
65
|
+
default: throw Error('Unsupported language: ' + value + '.');
|
|
66
|
+
}
|
|
67
|
+
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n2words",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "dist/n2words.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"lint": "eslint --config .eslintrc.json lib/ test/",
|
|
8
|
-
"test": "ava --verbose",
|
|
9
|
-
"coverage": "c8 ava",
|
|
10
|
-
"build": "webpack --config webpack.config.js --progress",
|
|
11
|
-
"bench": "node bench.mjs"
|
|
12
|
-
},
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/forzagreen/n2words.git"
|
|
16
|
-
},
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": "16 || >=18"
|
|
19
|
-
},
|
|
3
|
+
"version": "1.16.0",
|
|
4
|
+
"description": "n2words converts a numerical number into a written one, supports 27 languages and has zero dependencies.",
|
|
20
5
|
"keywords": [
|
|
21
6
|
"n2words",
|
|
22
7
|
"convert",
|
|
@@ -54,28 +39,31 @@
|
|
|
54
39
|
"vietnamese",
|
|
55
40
|
"azerbaijani"
|
|
56
41
|
],
|
|
57
|
-
"
|
|
58
|
-
"license": "MIT",
|
|
42
|
+
"homepage": "https://github.com/forzagreen/n2words#readme",
|
|
59
43
|
"bugs": {
|
|
60
44
|
"url": "https://github.com/forzagreen/n2words/issues"
|
|
61
45
|
},
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
46
|
+
"repository": "github:forzagreen/n2words",
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"author": "Wael TELLAT",
|
|
49
|
+
"contributors": [
|
|
50
|
+
"Tyler Vigario <TylerVigario90@gmail.com>"
|
|
51
|
+
],
|
|
52
|
+
"type": "module",
|
|
53
|
+
"exports": {
|
|
54
|
+
".": "./lib/n2words.js",
|
|
55
|
+
"./i18n/": "./lib/i18n/"
|
|
56
|
+
},
|
|
57
|
+
"files": [
|
|
58
|
+
"lib/*",
|
|
59
|
+
"build/*"
|
|
60
|
+
],
|
|
61
|
+
"scripts": {
|
|
62
|
+
"bench": "node bench.js",
|
|
63
|
+
"build": "webpack --config webpack.config.js --progress",
|
|
64
|
+
"coverage": "c8 ava",
|
|
65
|
+
"lint": "eslint --config .eslintrc.json lib/ test/",
|
|
66
|
+
"test": "ava --verbose"
|
|
79
67
|
},
|
|
80
68
|
"ava": {
|
|
81
69
|
"files": [
|
|
@@ -92,5 +80,25 @@
|
|
|
92
80
|
"lcov",
|
|
93
81
|
"text"
|
|
94
82
|
]
|
|
83
|
+
},
|
|
84
|
+
"devDependencies": {
|
|
85
|
+
"@babel/core": "^7.22.1",
|
|
86
|
+
"@babel/preset-env": "^7.22.4",
|
|
87
|
+
"ava": "^5.3.0",
|
|
88
|
+
"babel-loader": "^9.1.2",
|
|
89
|
+
"benchmark": "^2.1.4",
|
|
90
|
+
"c8": "^7.14.0",
|
|
91
|
+
"core-js": "^3.30.2",
|
|
92
|
+
"eslint": "^8.41.0",
|
|
93
|
+
"eslint-plugin-ava": "^14.0.0",
|
|
94
|
+
"eslint-plugin-import": "^2.27.5",
|
|
95
|
+
"eslint-plugin-jsdoc": "^46.0.0",
|
|
96
|
+
"eslint-plugin-node": "^11.1.0",
|
|
97
|
+
"microtime": "^3.1.1",
|
|
98
|
+
"webpack": "^5.84.1",
|
|
99
|
+
"webpack-cli": "^5.1.1"
|
|
100
|
+
},
|
|
101
|
+
"engines": {
|
|
102
|
+
"node": "16 || >=18"
|
|
95
103
|
}
|
|
96
104
|
}
|
package/.editorconfig
DELETED
package/.eslintrc.json
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"commonjs": true,
|
|
5
|
-
"es6": true,
|
|
6
|
-
"es2017": true,
|
|
7
|
-
"es2020": true,
|
|
8
|
-
"es2021": true,
|
|
9
|
-
"es2022": true,
|
|
10
|
-
"node": true
|
|
11
|
-
},
|
|
12
|
-
"plugins": [
|
|
13
|
-
"ava",
|
|
14
|
-
"node",
|
|
15
|
-
"import",
|
|
16
|
-
"jsdoc"
|
|
17
|
-
],
|
|
18
|
-
"extends": [
|
|
19
|
-
"eslint:recommended",
|
|
20
|
-
"plugin:ava/recommended",
|
|
21
|
-
"plugin:node/recommended",
|
|
22
|
-
"plugin:import/errors",
|
|
23
|
-
"plugin:import/warnings",
|
|
24
|
-
"plugin:jsdoc/recommended"
|
|
25
|
-
],
|
|
26
|
-
"overrides": [{
|
|
27
|
-
"files": ["*.js", "*.mjs"]
|
|
28
|
-
}],
|
|
29
|
-
"parserOptions": {
|
|
30
|
-
"ecmaVersion": "latest",
|
|
31
|
-
"sourceType": "module"
|
|
32
|
-
},
|
|
33
|
-
"rules": {
|
|
34
|
-
// Ignore platform dependent linebreak
|
|
35
|
-
"linebreak-style": "off",
|
|
36
|
-
// Remove maximum length limit
|
|
37
|
-
"max-len": "off",
|
|
38
|
-
// Enforce camelCase for variable names
|
|
39
|
-
"camelcase": ["error", {
|
|
40
|
-
"properties": "never"
|
|
41
|
-
}],
|
|
42
|
-
// Enforce indent of two spaces
|
|
43
|
-
"indent": [
|
|
44
|
-
"error", 2, {
|
|
45
|
-
"SwitchCase": 1
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
|
-
// Remove trailing whitespace
|
|
49
|
-
"no-trailing-spaces": "error",
|
|
50
|
-
// Enforce use of single quotes
|
|
51
|
-
"quotes": ["error", "single"],
|
|
52
|
-
// Enforce use of semicolon to end lines
|
|
53
|
-
"semi": "error",
|
|
54
|
-
// Enforce consistent spacing before & after arrow function
|
|
55
|
-
"arrow-spacing": "error",
|
|
56
|
-
// Enforce omitting parentheses when unnecessary for arrow functions
|
|
57
|
-
"arrow-parens": ["error", "as-needed"],
|
|
58
|
-
// Disallow multiple imports of same module
|
|
59
|
-
"no-duplicate-imports": "error",
|
|
60
|
-
// Enforce let or const instead of var
|
|
61
|
-
"no-var": "error",
|
|
62
|
-
// Enforce consistent brace style usage (1TBS default)
|
|
63
|
-
"brace-style": "error",
|
|
64
|
-
//
|
|
65
|
-
// -- IMPORT RULES --
|
|
66
|
-
//
|
|
67
|
-
// Report any invalid exports, i.e. re-export of the same name
|
|
68
|
-
"import/export": "error",
|
|
69
|
-
// Report modules without exports, or exports without matching import in another module
|
|
70
|
-
"import/no-unused-modules": "error",
|
|
71
|
-
// Report potentially ambiguous parse goal (script vs. module)
|
|
72
|
-
"import/unambiguous": "error",
|
|
73
|
-
// Report CommonJS require calls and module.exports or exports.*
|
|
74
|
-
"import/no-commonjs": "error",
|
|
75
|
-
// Report AMD require and define calls
|
|
76
|
-
"import/no-amd": "error",
|
|
77
|
-
// No Node.js builtin modules
|
|
78
|
-
"import/no-nodejs-modules": "error",
|
|
79
|
-
// Report imported names marked with @deprecated documentation tag
|
|
80
|
-
"import/no-deprecated": "error",
|
|
81
|
-
// Ensure all imports appear before other statements
|
|
82
|
-
"import/first": "error",
|
|
83
|
-
// Ensure consistent use of file extension within the import path
|
|
84
|
-
"import/extensions": ["error", "always"],
|
|
85
|
-
// Enforce a newline after import statements
|
|
86
|
-
"import/newline-after-import": "error",
|
|
87
|
-
// Ensure imports point to a file/module that can be resolved
|
|
88
|
-
"import/no-unresolved": ["error", {
|
|
89
|
-
"commonjs": true
|
|
90
|
-
}],
|
|
91
|
-
// Limit the maximum number of dependencies a module can have
|
|
92
|
-
"import/max-dependencies": "error",
|
|
93
|
-
// Prefer a default export if module exports a single name
|
|
94
|
-
"import/prefer-default-export": "error",
|
|
95
|
-
// Forbid unassigned imports
|
|
96
|
-
"import/no-unassigned-import": ["error", {
|
|
97
|
-
"allow": ["**/app.mjs"]
|
|
98
|
-
}]
|
|
99
|
-
//
|
|
100
|
-
// -- JSDOC RULES --
|
|
101
|
-
//
|
|
102
|
-
// Checks for presence of jsdoc comments, on class declarations as well as functions
|
|
103
|
-
//"jsdoc/require-jsdoc": "off"
|
|
104
|
-
}
|
|
105
|
-
}
|
package/.gitattributes
DELETED
package/bench.mjs
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import Benchmark from 'benchmark';
|
|
2
|
-
/* eslint-disable import/max-dependencies */
|
|
3
|
-
import n2wordsAR from './lib/i18n/AR.mjs';
|
|
4
|
-
import n2wordsAZ from './lib/i18n/AZ.mjs';
|
|
5
|
-
import n2wordsCZ from './lib/i18n/CZ.mjs';
|
|
6
|
-
import n2wordsDE from './lib/i18n/DE.mjs';
|
|
7
|
-
import n2wordsDK from './lib/i18n/DK.mjs';
|
|
8
|
-
import n2wordsEN from './lib/i18n/EN.mjs';
|
|
9
|
-
import n2wordsES from './lib/i18n/ES.mjs';
|
|
10
|
-
import n2wordsFA from './lib/i18n/FA.mjs';
|
|
11
|
-
import n2wordsFR from './lib/i18n/FR.mjs';
|
|
12
|
-
import n2wordsHE from './lib/i18n/HE.mjs';
|
|
13
|
-
import n2wordsHR from './lib/i18n/HR.mjs';
|
|
14
|
-
import n2wordsHU from './lib/i18n/HU.mjs';
|
|
15
|
-
import n2wordsID from './lib/i18n/ID.mjs';
|
|
16
|
-
import n2wordsIT from './lib/i18n/IT.mjs';
|
|
17
|
-
import n2wordsKO from './lib/i18n/KO.mjs';
|
|
18
|
-
import n2wordsLT from './lib/i18n/LT.mjs';
|
|
19
|
-
import n2wordsLV from './lib/i18n/LV.mjs';
|
|
20
|
-
import n2wordsNL from './lib/i18n/NL.mjs';
|
|
21
|
-
import n2wordsNO from './lib/i18n/NO.mjs';
|
|
22
|
-
import n2wordsPL from './lib/i18n/PL.mjs';
|
|
23
|
-
import n2wordsPT from './lib/i18n/PT.mjs';
|
|
24
|
-
import n2wordsRU from './lib/i18n/RU.mjs';
|
|
25
|
-
import n2wordsSR from './lib/i18n/SR.mjs';
|
|
26
|
-
import n2wordsTR from './lib/i18n/TR.mjs';
|
|
27
|
-
import n2wordsUK from './lib/i18n/UK.mjs';
|
|
28
|
-
import n2wordsVI from './lib/i18n/VI.mjs';
|
|
29
|
-
import n2wordsZH from './lib/i18n/ZH.mjs';
|
|
30
|
-
|
|
31
|
-
const suite = new Benchmark.Suite();
|
|
32
|
-
|
|
33
|
-
const i18n = {
|
|
34
|
-
'ar': n2wordsAR,
|
|
35
|
-
'az': n2wordsAZ,
|
|
36
|
-
'cz': n2wordsCZ,
|
|
37
|
-
'de': n2wordsDE,
|
|
38
|
-
'dk': n2wordsDK,
|
|
39
|
-
'en': n2wordsEN,
|
|
40
|
-
'es': n2wordsES,
|
|
41
|
-
'fa': n2wordsFA,
|
|
42
|
-
'fr': n2wordsFR,
|
|
43
|
-
'he': n2wordsHE,
|
|
44
|
-
'hr': n2wordsHR,
|
|
45
|
-
'hu': n2wordsHU,
|
|
46
|
-
'id': n2wordsID,
|
|
47
|
-
'it': n2wordsIT,
|
|
48
|
-
'ko': n2wordsKO,
|
|
49
|
-
'lt': n2wordsLT,
|
|
50
|
-
'lv': n2wordsLV,
|
|
51
|
-
'nl': n2wordsNL,
|
|
52
|
-
'no': n2wordsNO,
|
|
53
|
-
'pl': n2wordsPL,
|
|
54
|
-
'pt': n2wordsPT,
|
|
55
|
-
'ru': n2wordsRU,
|
|
56
|
-
'sr': n2wordsSR,
|
|
57
|
-
'tr': n2wordsTR,
|
|
58
|
-
'uk': n2wordsUK,
|
|
59
|
-
'vi': n2wordsVI,
|
|
60
|
-
'zh': n2wordsZH
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const args = process.argv;
|
|
64
|
-
args.slice(2);
|
|
65
|
-
|
|
66
|
-
let language;
|
|
67
|
-
let value = 9007199254740991;
|
|
68
|
-
|
|
69
|
-
for (let i = 1; i < args.length; i++) {
|
|
70
|
-
if (args[i] == '--lang' || args[i] == '--language') {
|
|
71
|
-
language = args[i + 1];
|
|
72
|
-
} else if (args[i] == '--value') {
|
|
73
|
-
value = args[i + 1];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (language) {
|
|
78
|
-
suite.add(language, () => {
|
|
79
|
-
i18n[language](value);
|
|
80
|
-
});
|
|
81
|
-
} else {
|
|
82
|
-
Object.keys(i18n).forEach(language => {
|
|
83
|
-
suite.add(language, () => {
|
|
84
|
-
i18n[language](value);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
suite
|
|
90
|
-
.on('cycle', event => {
|
|
91
|
-
// Output benchmark result by converting benchmark result to string
|
|
92
|
-
console.log(String(event.target));
|
|
93
|
-
})
|
|
94
|
-
.run();
|