n2words 1.16.1 → 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.
Files changed (63) hide show
  1. package/README.md +10 -13
  2. package/dist/n2words.d.ts +3 -0
  3. package/dist/n2words.js +2 -1
  4. package/dist/n2words.js.map +1 -0
  5. package/lib/classes/AbstractLanguage.d.ts +53 -0
  6. package/lib/classes/BaseLanguage.d.ts +59 -0
  7. package/lib/i18n/ar.d.ts +27 -0
  8. package/lib/i18n/{AR.js → ar.js} +28 -13
  9. package/lib/i18n/az.d.ts +15 -0
  10. package/lib/i18n/{AZ.js → az.js} +4 -3
  11. package/lib/i18n/cz.d.ts +12 -0
  12. package/lib/i18n/{CZ.js → cz.js} +2 -2
  13. package/lib/i18n/de.d.ts +17 -0
  14. package/lib/i18n/{DE.js → de.js} +3 -3
  15. package/lib/i18n/dk.d.ts +14 -0
  16. package/lib/i18n/{DK.js → dk.js} +3 -3
  17. package/lib/i18n/en.d.ts +22 -0
  18. package/lib/i18n/{EN.js → en.js} +4 -4
  19. package/lib/i18n/es.d.ts +16 -0
  20. package/lib/i18n/{ES.js → es.js} +5 -5
  21. package/lib/i18n/fa.d.ts +54 -0
  22. package/lib/i18n/{FA.js → fa.js} +1 -1
  23. package/lib/i18n/fr.d.ts +15 -0
  24. package/lib/i18n/{FR.js → fr.js} +6 -6
  25. package/lib/i18n/he.d.ts +28 -0
  26. package/lib/i18n/{HE.js → he.js} +2 -2
  27. package/lib/i18n/hr.d.ts +35 -0
  28. package/lib/i18n/{HR.js → hr.js} +2 -2
  29. package/lib/i18n/hu.d.ts +17 -0
  30. package/lib/i18n/{HU.js → hu.js} +1 -1
  31. package/lib/i18n/id.d.ts +43 -0
  32. package/lib/i18n/{ID.js → id.js} +6 -6
  33. package/lib/i18n/it.d.ts +29 -0
  34. package/lib/i18n/{IT.js → it.js} +24 -14
  35. package/lib/i18n/ko.d.ts +15 -0
  36. package/lib/i18n/{KO.js → ko.js} +3 -3
  37. package/lib/i18n/lt.d.ts +12 -0
  38. package/lib/i18n/{LT.js → lt.js} +2 -2
  39. package/lib/i18n/lv.d.ts +12 -0
  40. package/lib/i18n/{LV.js → lv.js} +3 -3
  41. package/lib/i18n/nl.d.ts +20 -0
  42. package/lib/i18n/{NL.js → nl.js} +5 -5
  43. package/lib/i18n/no.d.ts +15 -0
  44. package/lib/i18n/{NO.js → no.js} +3 -3
  45. package/lib/i18n/pl.d.ts +11 -0
  46. package/lib/i18n/{PL.js → pl.js} +2 -2
  47. package/lib/i18n/pt.d.ts +26 -0
  48. package/lib/i18n/{PT.js → pt.js} +13 -11
  49. package/lib/i18n/ru.d.ts +84 -0
  50. package/lib/i18n/{RU.js → ru.js} +1 -1
  51. package/lib/i18n/sr.d.ts +35 -0
  52. package/lib/i18n/{SR.js → sr.js} +2 -2
  53. package/lib/i18n/tr.d.ts +15 -0
  54. package/lib/i18n/{TR.js → tr.js} +3 -3
  55. package/lib/i18n/uk.d.ts +11 -0
  56. package/lib/i18n/{UK.js → uk.js} +2 -2
  57. package/lib/i18n/vi.d.ts +70 -0
  58. package/lib/i18n/zh.d.ts +18 -0
  59. package/lib/i18n/{ZH.js → zh.js} +3 -3
  60. package/lib/n2words.d.ts +7 -0
  61. package/lib/n2words.js +28 -29
  62. package/package.json +23 -12
  63. /package/lib/i18n/{VI.js → vi.js} +0 -0
@@ -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';
@@ -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
  }
@@ -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';
@@ -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 = parseInt(Object.values(lPair)[0]);
44
- const rNum = parseInt(Object.values(rPair)[0]);
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
  }
@@ -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';
@@ -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
  }
@@ -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';
@@ -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';
@@ -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 = parseInt(Object.values(lPair)[0]);
33
+ const lnum = BigInt(Object.values(lPair)[0]);
34
34
  const rtext = Object.keys(rPair)[0];
35
- const rnum = parseInt(Object.values(rPair)[0]);
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
  }
@@ -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
@@ -1,31 +1,30 @@
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';
1
+ import n2wordsAR from './i18n/ar.js';
2
+ import n2wordsAZ from './i18n/az.js';
3
+ import n2wordsCZ from './i18n/cz.js';
4
+ import n2wordsDE from './i18n/de.js';
5
+ import n2wordsDK from './i18n/dk.js';
6
+ import n2wordsEN from './i18n/en.js';
7
+ import n2wordsES from './i18n/es.js';
8
+ import n2wordsFA from './i18n/fa.js';
9
+ import n2wordsFR from './i18n/fr.js';
10
+ import n2wordsHE from './i18n/he.js';
11
+ import n2wordsHR from './i18n/hr.js';
12
+ import n2wordsHU from './i18n/hu.js';
13
+ import n2wordsID from './i18n/id.js';
14
+ import n2wordsIT from './i18n/it.js';
15
+ import n2wordsKO from './i18n/ko.js';
16
+ import n2wordsLT from './i18n/lt.js';
17
+ import n2wordsLV from './i18n/lv.js';
18
+ import n2wordsNL from './i18n/nl.js';
19
+ import n2wordsNO from './i18n/no.js';
20
+ import n2wordsPL from './i18n/pl.js';
21
+ import n2wordsPT from './i18n/pt.js';
22
+ import n2wordsRU from './i18n/ru.js';
23
+ import n2wordsSR from './i18n/sr.js';
24
+ import n2wordsTR from './i18n/tr.js';
25
+ import n2wordsUK from './i18n/uk.js';
26
+ import n2wordsVI from './i18n/vi.js';
27
+ import n2wordsZH from './i18n/zh.js';
29
28
 
30
29
  /**
31
30
  * Converts a number to written form.
@@ -33,7 +32,7 @@ import n2wordsZH from './i18n/ZH.js';
33
32
  * @param {object} [options] User options.
34
33
  * @returns {string} Value in written format.
35
34
  */
36
- export default function(value, options = {lang: 'en'}) {
35
+ export default function (value, options = { lang: 'en' }) {
37
36
  switch (options.lang) {
38
37
  case 'en': return n2wordsEN(value, options); // default
39
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.1",
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",
@@ -47,28 +47,37 @@
47
47
  "license": "MIT",
48
48
  "author": "Wael TELLAT",
49
49
  "contributors": [
50
- "Tyler Vigario <TylerVigario90@gmail.com>"
50
+ "Tyler Vigario (https://github.com/TylerVigario)"
51
51
  ],
52
+ "sideEffects": false,
52
53
  "type": "module",
53
54
  "exports": {
54
55
  ".": "./lib/n2words.js",
55
- "./i18n/": "./lib/i18n/"
56
+ "./i18n/*.js": "./lib/i18n/*.js"
56
57
  },
58
+ "jsdelivr": "dist/n2words.js",
59
+ "unpkg": "dist/n2words.js",
57
60
  "files": [
58
61
  "lib/*",
59
- "dist/*"
62
+ "dist/*",
63
+ "types/*"
60
64
  ],
61
65
  "scripts": {
62
66
  "bench": "node bench.js",
63
67
  "build": "webpack --config webpack.config.js --progress",
68
+ "build:types": "npx -p typescript tsc lib/n2words.js dist/n2words.js --declaration --allowJs --emitDeclarationOnly",
64
69
  "coverage": "c8 ava",
65
- "lint": "eslint --config .eslintrc.json lib/ test/",
66
- "test": "ava --verbose"
70
+ "lint": "eslint --config .eslintrc.json lib/ test/ bench.js",
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"
67
76
  },
68
77
  "ava": {
69
78
  "files": [
70
- "test/**/*",
71
- "!test/i18n"
79
+ "test/*",
80
+ "!test/web.js"
72
81
  ]
73
82
  },
74
83
  "c8": {
@@ -88,15 +97,17 @@
88
97
  "babel-loader": "^9.1.2",
89
98
  "benchmark": "^2.1.4",
90
99
  "c8": "^7.14.0",
100
+ "chromedriver": "^114.0.1",
91
101
  "core-js": "^3.30.2",
92
- "eslint": "^8.41.0",
102
+ "eslint": "^8.42.0",
93
103
  "eslint-plugin-ava": "^14.0.0",
94
104
  "eslint-plugin-import": "^2.27.5",
95
- "eslint-plugin-jsdoc": "^46.0.0",
105
+ "eslint-plugin-jsdoc": "^46.2.5",
96
106
  "eslint-plugin-node": "^11.1.0",
97
107
  "microtime": "^3.1.1",
98
- "webpack": "^5.84.1",
99
- "webpack-cli": "^5.1.1"
108
+ "selenium-webdriver": "^4.9.2",
109
+ "webpack": "^5.85.1",
110
+ "webpack-cli": "^5.1.3"
100
111
  },
101
112
  "engines": {
102
113
  "node": "16 || >=18"
File without changes