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.
Files changed (42) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +13 -29
  3. package/lib/classes/{AbstractLanguage.mjs → AbstractLanguage.js} +2 -2
  4. package/lib/classes/{BaseLanguage.mjs → BaseLanguage.js} +3 -3
  5. package/lib/i18n/{AR.mjs → AR.js} +47 -33
  6. package/lib/i18n/{AZ.mjs → AZ.js} +7 -6
  7. package/lib/i18n/{CZ.mjs → CZ.js} +7 -6
  8. package/lib/i18n/{DE.mjs → DE.js} +7 -6
  9. package/lib/i18n/{DK.mjs → DK.js} +13 -7
  10. package/lib/i18n/{EN.mjs → EN.js} +7 -6
  11. package/lib/i18n/{ES.mjs → ES.js} +14 -8
  12. package/lib/i18n/{FA.mjs → FA.js} +7 -6
  13. package/lib/i18n/{FR.mjs → FR.js} +7 -6
  14. package/lib/i18n/{HE.mjs → HE.js} +14 -8
  15. package/lib/i18n/{HR.mjs → HR.js} +7 -8
  16. package/lib/i18n/{HU.mjs → HU.js} +7 -6
  17. package/lib/i18n/{ID.mjs → ID.js} +34 -32
  18. package/lib/i18n/{IT.mjs → IT.js} +17 -14
  19. package/lib/i18n/{KO.mjs → KO.js} +7 -6
  20. package/lib/i18n/{LT.mjs → LT.js} +7 -8
  21. package/lib/i18n/{LV.mjs → LV.js} +7 -6
  22. package/lib/i18n/{NL.mjs → NL.js} +13 -14
  23. package/lib/i18n/{NO.mjs → NO.js} +7 -6
  24. package/lib/i18n/{PL.mjs → PL.js} +7 -8
  25. package/lib/i18n/{PT.mjs → PT.js} +19 -18
  26. package/lib/i18n/{RU.mjs → RU.js} +12 -5
  27. package/lib/i18n/{SR.mjs → SR.js} +7 -8
  28. package/lib/i18n/{TR.mjs → TR.js} +5 -5
  29. package/lib/i18n/UK.js +95 -0
  30. package/lib/i18n/{VI.mjs → VI.js} +64 -61
  31. package/lib/i18n/{ZH.mjs → ZH.js} +7 -6
  32. package/lib/n2words.js +67 -0
  33. package/package.json +44 -36
  34. package/.editorconfig +0 -13
  35. package/.eslintrc.json +0 -105
  36. package/.gitattributes +0 -5
  37. package/bench.mjs +0 -94
  38. package/dist/n2words.js +0 -1
  39. package/examples/node.mjs +0 -10
  40. package/lib/i18n/UK.mjs +0 -90
  41. package/lib/n2words.mjs +0 -67
  42. package/webpack.config.js +0 -31
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018 Wael TELLAT
3
+ Copyright (c) 2018-2023 Wael TELLAT
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -4,12 +4,11 @@
4
4
  [![Coverage Status](https://coveralls.io/repos/github/forzagreen/n2words/badge.svg?branch=master)](https://coveralls.io/github/forzagreen/n2words?branch=master)
5
5
  [![npm](https://img.shields.io/npm/v/n2words.svg)](https://npmjs.com/package/n2words)
6
6
  [![npm](https://img.shields.io/npm/dw/n2words)](https://npmjs.com/package/n2words)
7
+ [![](https://data.jsdelivr.com/v1/package/npm/n2words/badge)](https://www.jsdelivr.com/package/npm/n2words)
7
8
 
8
- n2words is a library that converts a numerical number into a written number.
9
+ __n2words__ converts a numerical number into a written one, supports [27 languages](https://github.com/forzagreen/n2words#supported-languages), and has zero dependencies.
9
10
 
10
- We have support for multiple languages (27 and growing) and our package is lightweight, modular and has no dependencies.
11
-
12
- ## How To
11
+ ## Example
13
12
 
14
13
  ```js
15
14
  n2words(123) // 'one hundred and twenty-three'
@@ -20,6 +19,8 @@ n2words(123, {lang: 'es'}) // 'ciento veintitrés'
20
19
  n2words(123, {lang: 'ar'}) // 'مائة و ثلاثة و عشرون'
21
20
  ```
22
21
 
22
+ See the [Wiki](https://github.com/forzagreen/n2words/wiki) for examples and advanced usage.
23
+
23
24
  ## Install
24
25
 
25
26
  ```sh
@@ -34,42 +35,28 @@ n2words is also available on [jsDelivr](https://jsdelivr.com/package/npm/n2words
34
35
 
35
36
  ```js
36
37
  import n2words from 'n2words'
37
-
38
- // Source file
39
- import n2words from 'n2words/lib/n2words.mjs'
40
-
41
- // Individual languages (recommended)
42
- import n2wordsEN from 'n2words/lib/i18n/EN.mjs'
43
38
  ```
44
39
 
45
40
  ### CommonJS
46
41
 
47
42
  ```js
48
- var n2words = require('n2words')
49
-
50
- // Dynamic Import (source files)
51
- import('n2words/lib/n2words.mjs').then(n2words => {
43
+ // Dynamic Import
44
+ import('n2words').then(n2words => {
52
45
  // Available via "default" method
53
46
  n2words.default(100)
54
47
  })
55
-
56
- // Individual languages
57
- import('n2words/lib/i18n/EN.mjs').then(n2wordsEN => {
58
- n2wordsEN.default(100)
59
- })
60
48
  ```
61
49
 
62
50
  ### Browser
63
51
 
64
52
  ```html
65
53
  <script src="n2words.js"></script>
54
+ <script>
55
+ n2words(100)
56
+ </script>
66
57
  ```
67
58
 
68
- ## Features
69
-
70
- - Cardinal numbers
71
- - Decimal numbers
72
- - Negative numbers
59
+ You can also [import only specific languages](https://github.com/forzagreen/n2words/wiki/Importing-only-specific-languages) if you don't need all of them.
73
60
 
74
61
  ## Supported Languages
75
62
 
@@ -103,10 +90,7 @@ import('n2words/lib/i18n/EN.mjs').then(n2wordsEN => {
103
90
 
104
91
  ## Contributing
105
92
 
106
- You can help by adding new languages or by improving existing ones. Also, reporting issues, verifying the correctness of unit tests or adding more test cases is extremely helpful.
107
-
108
- All help is welcome!
109
-
93
+ __This library is in active development.__ We are looking to improve the design and process for language contributors as well as add more languages.
110
94
  ## License
111
95
 
112
- MIT
96
+ [MIT](https://github.com/forzagreen/n2words/blob/master/LICENSE)
@@ -11,10 +11,10 @@ export default class {
11
11
 
12
12
  /**
13
13
  * @param {object} options Options for class.
14
- * @param {string} [options.negativeWord = ''] Word that precedes a negative number (if any).
14
+ * @param {string} [options.negativeWord] Word that precedes a negative number (if any).
15
15
  * @param {string} options.separatorWord Word that separates cardinal numbers (i.e. "and").
16
16
  * @param {string} options.zero Word for 0 (i.e. "zero").
17
- * @param {string} [options.spaceSeparator = ' '] Character that separates words.
17
+ * @param {string} [options.spaceSeparator] Character that separates words.
18
18
  */
19
19
  constructor(options) {
20
20
  // Merge supplied options with defaults
@@ -1,4 +1,4 @@
1
- import AbstractLanguage from './AbstractLanguage.mjs';
1
+ import AbstractLanguage from './AbstractLanguage.js';
2
2
 
3
3
  /**
4
4
  * Creates new common language class that uses a highest matching word value algorithm.
@@ -11,10 +11,10 @@ export default class extends AbstractLanguage {
11
11
 
12
12
  /**
13
13
  * @param {object} options Options for class.
14
- * @param {string} [options.negativeWord = ''] Word that precedes a negative number (if any).
14
+ * @param {string} [options.negativeWord] Word that precedes a negative number (if any).
15
15
  * @param {string} options.separatorWord Word that separates cardinal numbers (i.e. "and").
16
16
  * @param {string} options.zero Word for 0 (i.e. "zero").
17
- * @param {string} [options.spaceSeparator = ' '] Character that separates words.
17
+ * @param {string} [options.spaceSeparator] Character that separates words.
18
18
  * @param {Array} cards Array of number matching "cards" from highest-to-lowest.
19
19
  */
20
20
  constructor(options, cards) {
@@ -1,39 +1,52 @@
1
- import AbstractLanguage from '../classes/AbstractLanguage.mjs';
1
+ import AbstractLanguage from '../classes/AbstractLanguage.js';
2
2
 
3
3
  export class Arabic extends AbstractLanguage {
4
- constructor() {
5
- super({
4
+ integerValue = 0;
5
+
6
+ decimalValue = 0;
7
+
8
+ number = 0;
9
+
10
+ arabicOnes = [
11
+ '', 'واحد', 'اثنان', 'ثلاثة', 'أربعة', 'خمسة', 'ستة', 'سبعة', 'ثمانية',
12
+ 'تسعة',
13
+ 'عشرة', 'أحد عشر', 'اثنا عشر', 'ثلاثة عشر', 'أربعة عشر', 'خمسة عشر',
14
+ 'ستة عشر', 'سبعة عشر', 'ثمانية عشر',
15
+ 'تسعة عشر',
16
+ ];
17
+
18
+ arabicFeminineOnes = [
19
+ '', 'إحدى', 'اثنتان', 'ثلاث', 'أربع', 'خمس', 'ست', 'سبع', 'ثمان',
20
+ 'تسع',
21
+ 'عشر', 'إحدى عشرة', 'اثنتا عشرة', 'ثلاث عشرة', 'أربع عشرة',
22
+ 'خمس عشرة', 'ست عشرة', 'سبع عشرة', 'ثماني عشرة',
23
+ 'تسع عشرة',
24
+ ];
25
+
26
+ arabicTens = ['عشرون', 'ثلاثون', 'أربعون', 'خمسون', 'ستون', 'سبعون', 'ثمانون', 'تسعون'];
27
+
28
+ arabicHundreds = ['', 'مائة', 'مئتان', 'ثلاثمائة', 'أربعمائة', 'خمسمائة', 'ستمائة', 'سبعمائة', 'ثمانمائة', 'تسعمائة'];
29
+
30
+ arabicAppendedTwos = ['مئتا', 'ألفا', 'مليونا', 'مليارا', 'تريليونا', 'كوادريليونا', 'كوينتليونا', 'سكستيليونا'];
31
+
32
+ arabicTwos = ['مئتان', 'ألفان', 'مليونان', 'ملياران', 'تريليونان', 'كوادريليونان', 'كوينتليونان', 'سكستيليونان'];
33
+
34
+ arabicGroup = ['مائة', 'ألف', 'مليون', 'مليار', 'تريليون', 'كوادريليون', 'كوينتليون', 'سكستيليون'];
35
+
36
+ arabicAppendedGroup = ['', 'ألفاً', 'مليوناً', 'ملياراً', 'تريليوناً', 'كوادريليوناً', 'كوينتليوناً', 'سكستيليوناً'];
37
+
38
+ arabicPluralGroups = ['', 'آلاف', 'ملايين', 'مليارات', 'تريليونات', 'كوادريليونات', 'كوينتليونات', 'سكستيليونات'];
39
+
40
+ // isCurrencyPartNameFeminine = true
41
+
42
+ // isCurrencyNameFeminine = false
43
+
44
+ constructor(options) {
45
+ super(Object.assign({
6
46
  negativeWord: 'ناقص',
7
47
  separatorWord: 'فاصلة',
8
48
  zero: 'صفر'
9
- });
10
-
11
- this.integerValue = 0;
12
- this.decimalValue = 0;
13
- this.number = 0;
14
- // this.isCurrencyPartNameFeminine = true
15
- // this.isCurrencyNameFeminine = false
16
- this.arabicOnes = [
17
- '', 'واحد', 'اثنان', 'ثلاثة', 'أربعة', 'خمسة', 'ستة', 'سبعة', 'ثمانية',
18
- 'تسعة',
19
- 'عشرة', 'أحد عشر', 'اثنا عشر', 'ثلاثة عشر', 'أربعة عشر', 'خمسة عشر',
20
- 'ستة عشر', 'سبعة عشر', 'ثمانية عشر',
21
- 'تسعة عشر',
22
- ];
23
- this.arabicFeminineOnes = [
24
- '', 'إحدى', 'اثنتان', 'ثلاث', 'أربع', 'خمس', 'ست', 'سبع', 'ثمان',
25
- 'تسع',
26
- 'عشر', 'إحدى عشرة', 'اثنتا عشرة', 'ثلاث عشرة', 'أربع عشرة',
27
- 'خمس عشرة', 'ست عشرة', 'سبع عشرة', 'ثماني عشرة',
28
- 'تسع عشرة',
29
- ];
30
- this.arabicTens = ['عشرون', 'ثلاثون', 'أربعون', 'خمسون', 'ستون', 'سبعون', 'ثمانون', 'تسعون'];
31
- this.arabicHundreds = ['', 'مائة', 'مئتان', 'ثلاثمائة', 'أربعمائة', 'خمسمائة', 'ستمائة', 'سبعمائة', 'ثمانمائة', 'تسعمائة'];
32
- this.arabicAppendedTwos = ['مئتا', 'ألفا', 'مليونا', 'مليارا', 'تريليونا', 'كوادريليونا', 'كوينتليونا', 'سكستيليونا'];
33
- this.arabicTwos = ['مئتان', 'ألفان', 'مليونان', 'ملياران', 'تريليونان', 'كوادريليونان', 'كوينتليونان', 'سكستيليونان'];
34
- this.arabicGroup = ['مائة', 'ألف', 'مليون', 'مليار', 'تريليون', 'كوادريليون', 'كوينتليون', 'سكستيليون'];
35
- this.arabicAppendedGroup = ['', 'ألفاً', 'مليوناً', 'ملياراً', 'تريليوناً', 'كوادريليوناً', 'كوينتليوناً', 'سكستيليوناً'];
36
- this.arabicPluralGroups = ['', 'آلاف', 'ملايين', 'مليارات', 'تريليونات', 'كوادريليونات', 'كوينتليونات', 'سكستيليونات'];
49
+ }, options));
37
50
  }
38
51
 
39
52
  digitFeminineStatus(digit/* , groupLevel */) {
@@ -140,9 +153,10 @@ export class Arabic extends AbstractLanguage {
140
153
  /**
141
154
  * Converts a value to cardinal (written) form.
142
155
  * @param {number|string} value Number to be convert.
156
+ * @param {object} options Options for class.
143
157
  * @throws {Error} Value cannot be invalid.
144
158
  * @returns {string} Value in cardinal (written) format.
145
159
  */
146
- export default function(value) {
147
- return new Arabic().floatToCardinal(value);
160
+ export default function(value, options) {
161
+ return new Arabic(options).floatToCardinal(value);
148
162
  }
@@ -1,12 +1,12 @@
1
- import BaseLanguage from '../classes/BaseLanguage.mjs';
1
+ import BaseLanguage from '../classes/BaseLanguage.js';
2
2
 
3
3
  export class N2WordsAZ extends BaseLanguage {
4
- constructor() {
5
- super({
4
+ constructor(options) {
5
+ super(Object.assign({
6
6
  negativeWord: 'mənfi',
7
7
  separatorWord: 'nöqtə',
8
8
  zero: 'sıfır'
9
- },[
9
+ }, options), [
10
10
  [1000000000000000000n, 'kentilyon'],
11
11
  [1000000000000000n, 'katrilyon'],
12
12
  [1000000000000n, 'trilyon'],
@@ -54,9 +54,10 @@ export class N2WordsAZ extends BaseLanguage {
54
54
  /**
55
55
  * Converts a value to cardinal (written) form.
56
56
  * @param {number|string} value Number to be convert.
57
+ * @param {object} options Options for class.
57
58
  * @throws {Error} Value cannot be invalid.
58
59
  * @returns {string} Value in cardinal (written) format.
59
60
  */
60
- export default function(value) {
61
- return new N2WordsAZ().floatToCardinal(value);
61
+ export default function(value, options) {
62
+ return new N2WordsAZ(options).floatToCardinal(value);
62
63
  }
@@ -1,4 +1,4 @@
1
- import {N2WordsRU} from './RU.mjs';
1
+ import {N2WordsRU} from './RU.js';
2
2
 
3
3
  export class N2WordsCZ extends N2WordsRU {
4
4
  ones = {
@@ -62,11 +62,11 @@ export class N2WordsCZ extends N2WordsRU {
62
62
  10: ['quintillion', 'quintilliony', 'quintillionů'], // 10^ 30
63
63
  };
64
64
 
65
- constructor() {
66
- super({
65
+ constructor(options) {
66
+ super(Object.assign({
67
67
  negativeWord: 'mínus',
68
68
  zero: 'nula'
69
- });
69
+ }, options));
70
70
  }
71
71
 
72
72
  get separatorWord() {
@@ -125,9 +125,10 @@ export class N2WordsCZ extends N2WordsRU {
125
125
  /**
126
126
  * Converts a value to cardinal (written) form.
127
127
  * @param {number|string} value Number to be convert.
128
+ * @param {object} options Options for class.
128
129
  * @throws {Error} Value cannot be invalid.
129
130
  * @returns {string} Value in cardinal (written) format.
130
131
  */
131
- export default function(value) {
132
- return new N2WordsCZ().floatToCardinal(value);
132
+ export default function(value, options) {
133
+ return new N2WordsCZ(options).floatToCardinal(value);
133
134
  }
@@ -1,12 +1,12 @@
1
- import BaseLanguage from '../classes/BaseLanguage.mjs';
1
+ import BaseLanguage from '../classes/BaseLanguage.js';
2
2
 
3
3
  export class N2WordsDE extends BaseLanguage {
4
- constructor() {
5
- super({
4
+ constructor(options) {
5
+ super(Object.assign({
6
6
  negativeWord: 'minus',
7
7
  separatorWord: 'komma',
8
8
  zero: 'null'
9
- },[
9
+ }, options), [
10
10
  [1000000000000000000000000000n, 'Quadrilliarde'],
11
11
  [1000000000000000000000000n, 'Quadrillion'],
12
12
  [1000000000000000000000n, 'Trilliarde'],
@@ -96,9 +96,10 @@ export class N2WordsDE extends BaseLanguage {
96
96
  /**
97
97
  * Converts a value to cardinal (written) form.
98
98
  * @param {number|string} value Number to be convert.
99
+ * @param {object} options Options for class.
99
100
  * @throws {Error} Value cannot be invalid.
100
101
  * @returns {string} Value in cardinal (written) format.
101
102
  */
102
- export default function(value) {
103
- return new N2WordsDE().floatToCardinal(value);
103
+ export default function(value, options) {
104
+ return new N2WordsDE(options).floatToCardinal(value);
104
105
  }
@@ -1,14 +1,17 @@
1
- import BaseLanguage from '../classes/BaseLanguage.mjs';
1
+ import BaseLanguage from '../classes/BaseLanguage.js';
2
2
 
3
3
  export class N2WordsDK extends BaseLanguage {
4
- ordFlag = false;
4
+ ordFlag;
5
5
 
6
- constructor() {
7
- super({
6
+ constructor(options) {
7
+ options = Object.assign({
8
8
  negativeWord: 'minus',
9
9
  separatorWord: 'komma',
10
10
  zero: 'nul',
11
- },[
11
+ ordFlag: false
12
+ }, options);
13
+
14
+ super(options, [
12
15
  [1000000000000000000000000000n, 'quadrillarder'],
13
16
  [1000000000000000000000000n, 'quadrillioner'],
14
17
  [1000000000000000000000n, 'trillarder'],
@@ -48,6 +51,8 @@ export class N2WordsDK extends BaseLanguage {
48
51
  [1n, 'et'],
49
52
  [0n, 'nul']
50
53
  ]);
54
+
55
+ this.ordFlag = options.ordFlag;
51
56
  }
52
57
 
53
58
  merge(curr, next) {
@@ -96,9 +101,10 @@ export class N2WordsDK extends BaseLanguage {
96
101
  /**
97
102
  * Converts a value to cardinal (written) form.
98
103
  * @param {number|string} value Number to be convert.
104
+ * @param {object} options Options for class.
99
105
  * @throws {Error} Value cannot be invalid.
100
106
  * @returns {string} Value in cardinal (written) format.
101
107
  */
102
- export default function(value) {
103
- return new N2WordsDK().floatToCardinal(value);
108
+ export default function(value, options) {
109
+ return new N2WordsDK(options).floatToCardinal(value);
104
110
  }
@@ -1,15 +1,15 @@
1
- import BaseLanguage from '../classes/BaseLanguage.mjs';
1
+ import BaseLanguage from '../classes/BaseLanguage.js';
2
2
 
3
3
  /**
4
4
  * This class is for converting numbers to english words.
5
5
  */
6
6
  class English extends BaseLanguage {
7
- constructor() {
8
- super({
7
+ constructor(options) {
8
+ super(Object.assign({
9
9
  negativeWord: 'minus',
10
10
  separatorWord: 'point',
11
11
  zero: 'zero'
12
- },[
12
+ }, options), [
13
13
  [1000000000000000000000000000n, 'octillion'],
14
14
  [1000000000000000000000000n, 'septillion'],
15
15
  [1000000000000000000000n, 'sextillion'],
@@ -75,9 +75,10 @@ class English extends BaseLanguage {
75
75
  /**
76
76
  * Converts a value to cardinal (written) form.
77
77
  * @param {number|string} value Number to be convert.
78
+ * @param {object} options Options for class.
78
79
  * @throws {Error} Value cannot be invalid.
79
80
  * @returns {string} Value in cardinal (written) format.
80
81
  */
81
- export default function(value) {
82
- return new English().floatToCardinal(value);
82
+ export default function(value, options) {
83
+ return new English(options).floatToCardinal(value);
83
84
  }
@@ -1,14 +1,17 @@
1
- import BaseLanguage from '../classes/BaseLanguage.mjs';
1
+ import BaseLanguage from '../classes/BaseLanguage.js';
2
2
 
3
3
  export class N2WordsES extends BaseLanguage {
4
- genderStem = 'o';
4
+ genderStem;
5
5
 
6
- constructor() {
7
- super({
6
+ constructor(options) {
7
+ options = Object.assign({
8
8
  negativeWord: 'menos',
9
9
  separatorWord: 'punto',
10
- zero: 'cero'
11
- },[
10
+ zero: 'cero',
11
+ genderStem: 'o'
12
+ }, options);
13
+
14
+ super(options, [
12
15
  [1000000000000000000000000n, 'cuatrillón'],
13
16
  [1000000000000000000n, 'trillón'],
14
17
  [1000000000000n, 'billón'],
@@ -53,6 +56,8 @@ export class N2WordsES extends BaseLanguage {
53
56
  [1n, 'uno'],
54
57
  [0n, 'cero']
55
58
  ]);
59
+
60
+ this.genderStem = options.genderStem;
56
61
  }
57
62
 
58
63
  merge(curr, next) {
@@ -96,9 +101,10 @@ export class N2WordsES extends BaseLanguage {
96
101
  /**
97
102
  * Converts a value to cardinal (written) form.
98
103
  * @param {number|string} value Number to be convert.
104
+ * @param {object} options Options for class.
99
105
  * @throws {Error} Value cannot be invalid.
100
106
  * @returns {string} Value in cardinal (written) format.
101
107
  */
102
- export default function(value) {
103
- return new N2WordsES().floatToCardinal(value);
108
+ export default function(value, options) {
109
+ return new N2WordsES(options).floatToCardinal(value);
104
110
  }
@@ -1,4 +1,4 @@
1
- import AbstractLanguage from '../classes/AbstractLanguage.mjs';
1
+ import AbstractLanguage from '../classes/AbstractLanguage.js';
2
2
 
3
3
  export class N2WordsFA extends AbstractLanguage {
4
4
  namedNumbers = {
@@ -43,12 +43,12 @@ export class N2WordsFA extends AbstractLanguage {
43
43
  1000000: 'میلیون',
44
44
  };
45
45
 
46
- constructor() {
47
- super({
46
+ constructor(options) {
47
+ super(Object.assign({
48
48
  negativeWord: 'منفى',
49
49
  separatorWord: 'ممیّز',
50
50
  zero: 'صفر'
51
- });
51
+ }, options));
52
52
  }
53
53
 
54
54
  toCardinal(number) {
@@ -95,9 +95,10 @@ export class N2WordsFA extends AbstractLanguage {
95
95
  /**
96
96
  * Converts a value to cardinal (written) form.
97
97
  * @param {number|string} value Number to be convert.
98
+ * @param {object} options Options for class.
98
99
  * @throws {Error} Value cannot be invalid.
99
100
  * @returns {string} Value in cardinal (written) format.
100
101
  */
101
- export default function(value) {
102
- return new N2WordsFA().floatToCardinal(value);
102
+ export default function(value, options) {
103
+ return new N2WordsFA(options).floatToCardinal(value);
103
104
  }
@@ -1,12 +1,12 @@
1
- import BaseLanguage from '../classes/BaseLanguage.mjs';
1
+ import BaseLanguage from '../classes/BaseLanguage.js';
2
2
 
3
3
  export class N2WordsFR extends BaseLanguage {
4
- constructor() {
5
- super({
4
+ constructor(options) {
5
+ super(Object.assign({
6
6
  negativeWord: 'moins',
7
7
  separatorWord: 'virgule',
8
8
  zero: 'zéro'
9
- },[
9
+ }, options), [
10
10
  [1000000000000000000000000000n, 'quadrilliard'],
11
11
  [1000000000000000000000000n, 'quadrillion'],
12
12
  [1000000000000000000000n, 'trilliard'],
@@ -83,9 +83,10 @@ export class N2WordsFR extends BaseLanguage {
83
83
  /**
84
84
  * Converts a value to cardinal (written) form.
85
85
  * @param {number|string} value Number to be convert.
86
+ * @param {object} options Options for class.
86
87
  * @throws {Error} Value cannot be invalid.
87
88
  * @returns {string} Value in cardinal (written) format.
88
89
  */
89
- export default function(value) {
90
- return new N2WordsFR().floatToCardinal(value);
90
+ export default function(value, options) {
91
+ return new N2WordsFR(options).floatToCardinal(value);
91
92
  }
@@ -1,7 +1,7 @@
1
- import {N2WordsRU} from './RU.mjs';
1
+ import {N2WordsRU} from './RU.js';
2
2
 
3
3
  export class N2WordsHE extends N2WordsRU {
4
- and = 'ו';
4
+ and;
5
5
 
6
6
  ones = {
7
7
  1: 'אחת',
@@ -57,16 +57,21 @@ export class N2WordsHE extends N2WordsRU {
57
57
  9: 'תשעת אלפים'
58
58
  };
59
59
 
60
- constructor() {
60
+ constructor(options) {
61
61
  /**
62
62
  * @todo Confirm `negativeWord`
63
63
  * @todo Set `separatorWord`
64
64
  */
65
- super({
65
+ options = Object.assign({
66
66
  negativeWord: 'מינוס',
67
67
  //separatorWord: ,
68
- zero: 'אפס'
69
- });
68
+ zero: 'אפס',
69
+ and: 'ו'
70
+ }, options);
71
+
72
+ super(options);
73
+
74
+ this.and = options.and;
70
75
  }
71
76
 
72
77
  toCardinal(number) {
@@ -116,9 +121,10 @@ export class N2WordsHE extends N2WordsRU {
116
121
  /**
117
122
  * Converts a value to cardinal (written) form.
118
123
  * @param {number|string} value Number to be convert.
124
+ * @param {object} options Options for class.
119
125
  * @throws {Error} Value cannot be invalid.
120
126
  * @returns {string} Value in cardinal (written) format.
121
127
  */
122
- export default function(value) {
123
- return new N2WordsHE().floatToCardinal(value);
128
+ export default function(value, options) {
129
+ return new N2WordsHE(options).floatToCardinal(value);
124
130
  }
@@ -1,4 +1,4 @@
1
- import {N2WordsRU} from './RU.mjs';
1
+ import {N2WordsRU} from './RU.js';
2
2
 
3
3
  export class N2WordsHR extends N2WordsRU {
4
4
  ones = {
@@ -63,14 +63,12 @@ export class N2WordsHR extends N2WordsRU {
63
63
  10: ['kvintilijun', 'kvintilijuna', 'kvintilijuna', false], // 10 ^ 30
64
64
  };
65
65
 
66
- feminine = false;
67
-
68
- constructor() {
69
- super({
66
+ constructor(options) {
67
+ super(Object.assign({
70
68
  negativeWord: 'minus',
71
69
  separatorWord: 'zarez',
72
70
  zero: 'nula'
73
- });
71
+ }, options));
74
72
  }
75
73
 
76
74
  pluralize(n, forms) {
@@ -121,9 +119,10 @@ export class N2WordsHR extends N2WordsRU {
121
119
  /**
122
120
  * Converts a value to cardinal (written) form.
123
121
  * @param {number|string} value Number to be convert.
122
+ * @param {object} options Options for class.
124
123
  * @throws {Error} Value cannot be invalid.
125
124
  * @returns {string} Value in cardinal (written) format.
126
125
  */
127
- export default function(value) {
128
- return new N2WordsHR().floatToCardinal(value);
126
+ export default function(value, options) {
127
+ return new N2WordsHR(options).floatToCardinal(value);
129
128
  }
@@ -1,12 +1,12 @@
1
- import BaseLanguage from '../classes/BaseLanguage.mjs';
1
+ import BaseLanguage from '../classes/BaseLanguage.js';
2
2
 
3
3
  export class N2WordsHU extends BaseLanguage {
4
- constructor() {
5
- super({
4
+ constructor(options) {
5
+ super(Object.assign({
6
6
  negativeWord: 'mínusz',
7
7
  separatorWord: 'egész',
8
8
  zero: 'nulla'
9
- },[
9
+ }, options), [
10
10
  [1000000000000000000000000000n, 'quadrilliárd'],
11
11
  [1000000000000000000000000n, 'quadrillió'],
12
12
  [1000000000000000000000n, 'trilliárd'],
@@ -124,9 +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
128
  * @throws {Error} Value cannot be invalid.
128
129
  * @returns {string} Value in cardinal (written) format.
129
130
  */
130
- export default function(value) {
131
- return new N2WordsHU().floatToCardinal(value);
131
+ export default function(value, options) {
132
+ return new N2WordsHU(options).floatToCardinal(value);
132
133
  }