n2words 1.9.0 → 1.11.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/.eslintrc.json CHANGED
@@ -22,24 +22,83 @@
22
22
  "plugin:import/warnings",
23
23
  "plugin:jsdoc/recommended"
24
24
  ],
25
+ "overrides": [{
26
+ "files": ["*.js", "*.mjs"]
27
+ }],
25
28
  "parserOptions": {
26
29
  "ecmaVersion": 2021,
27
30
  "sourceType": "module"
28
31
  },
29
32
  "rules": {
30
- "max-len": ["warn", {
31
- "code": 130
32
- }],
33
+ // Ignore platform dependent linebreak
33
34
  "linebreak-style": "off",
34
- "jsdoc/require-jsdoc": "off",
35
+ // Remove maximum length limit
36
+ "max-len": "off",
37
+ // Enforce camelCase for variable names
38
+ "camelcase": ["error", {
39
+ "properties": "never"
40
+ }],
41
+ // Enforce indent of two spaces
42
+ "indent": [
43
+ "error", 2, {
44
+ "SwitchCase": 1
45
+ }
46
+ ],
47
+ // Remove trailing whitespace
48
+ "no-trailing-spaces": "error",
49
+ // Enforce use of single quotes
50
+ "quotes": ["error", "single"],
51
+ // Enforce use of semicolon to end lines
52
+ "semi": "error",
53
+ // Enforce consistent spacing before & after arrow function
54
+ "arrow-spacing": "error",
55
+ // Enforce omitting parentheses when unnecessary for arrow functions
56
+ "arrow-parens": ["error", "as-needed"],
57
+ // Disallow multiple imports of same module
58
+ "no-duplicate-imports": "error",
59
+ // Enforce let or const instead of var
60
+ "no-var": "error",
61
+ // Enforce consistent brace style usage (1TBS default)
62
+ "brace-style": "error",
63
+ //
64
+ // -- IMPORT RULES --
65
+ //
66
+ // Report any invalid exports, i.e. re-export of the same name
67
+ "import/export": "error",
68
+ // Report modules without exports, or exports without matching import in another module
69
+ "import/no-unused-modules": "error",
70
+ // Report potentially ambiguous parse goal (script vs. module)
35
71
  "import/unambiguous": "error",
72
+ // Report CommonJS require calls and module.exports or exports.*
36
73
  "import/no-commonjs": "error",
74
+ // Report AMD require and define calls
37
75
  "import/no-amd": "error",
76
+ // No Node.js builtin modules
38
77
  "import/no-nodejs-modules": "error",
78
+ // Report imported names marked with @deprecated documentation tag
39
79
  "import/no-deprecated": "error",
80
+ // Ensure all imports appear before other statements
81
+ "import/first": "error",
82
+ // Ensure consistent use of file extension within the import path
40
83
  "import/extensions": ["error", "always"],
84
+ // Enforce a newline after import statements
85
+ "import/newline-after-import": "error",
86
+ // Ensure imports point to a file/module that can be resolved
41
87
  "import/no-unresolved": ["error", {
42
88
  "commonjs": true
43
- }]
89
+ }],
90
+ // Limit the maximum number of dependencies a module can have
91
+ "import/max-dependencies": "error",
92
+ // Prefer a default export if module exports a single name
93
+ "import/prefer-default-export": "error",
94
+ // Forbid unassigned imports
95
+ "import/no-unassigned-import": ["error", {
96
+ "allow": ["**/app.mjs"]
97
+ }],
98
+ //
99
+ // -- JSDOC RULES --
100
+ //
101
+ // Checks for presence of jsdoc comments, on class declarations as well as functions
102
+ "jsdoc/require-jsdoc": "off"
44
103
  }
45
104
  }
package/CHANGELOG.md CHANGED
@@ -5,6 +5,40 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
 
8
+ ## [1.11.0] - 2022-01-08
9
+
10
+ ### Added
11
+ - New language: `hr` Croatian [#61](https://github.com/forzagreen/n2words/pull/61). Thanks to [@lagavuliner](https://github.com/lagavuliner) !
12
+
13
+ ### Fixed
14
+ - Fix translations for Serbian [#60](https://github.com/forzagreen/n2words/pull/60) [#61](https://github.com/forzagreen/n2words/pull/61). Thanks to [@lagavuliner](https://github.com/lagavuliner) !
15
+
16
+
17
+ ## [1.10.1] - 2021-10-31
18
+
19
+ ### Fixed
20
+ - Correct translation of number 18 for NL.mjs [#59](https://github.com/forzagreen/n2words/pull/59). Thanks to [@K4CZP3R](https://github.com/K4CZP3R) !
21
+ - Update dev dependencies.
22
+
23
+
24
+ ## [1.10.0] - 2021-08-22
25
+ ### Added
26
+ - New language: `id` Indonesian [#58](https://github.com/forzagreen/n2words/pull/58).
27
+
28
+ ### Changed
29
+ - Migrate to ES6 classes [#55](https://github.com/forzagreen/n2words/pull/55). Thanks to [@TylerVigario](https://github.com/TylerVigario) !
30
+
31
+ ### Fixed
32
+ - Accept numbers as string [#57](https://github.com/forzagreen/n2words/pull/57).
33
+
34
+
35
+ ## [1.9.1] - 2021-08-14
36
+ ### Changed
37
+ - Configs: update dependencies, linting, camelCase [#51](https://github.com/forzagreen/n2words/pull/51). Thanks to [@TylerVigario](https://github.com/TylerVigario) !
38
+
39
+ ### Fixed
40
+ - Fix Polish translation [#49](https://github.com/forzagreen/n2words/pull/49). Thanks to [@krzyhan](https://github.com/krzyhan) !
41
+
8
42
  ## [1.9.0] - 2020-12-19
9
43
  ### Added
10
44
  - New language: `zh` Chinese [#43](https://github.com/forzagreen/n2words/pull/43). Thanks to [@ljinke](https://github.com/ljinke) !
package/README.md CHANGED
@@ -3,12 +3,25 @@
3
3
  [![Node CI](https://github.com/forzagreen/n2words/workflows/Node%20CI/badge.svg?branch=master)](https://github.com/forzagreen/n2words/actions)
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
- [![Gitter](https://img.shields.io/gitter/room/forzagreen/n2words)](https://gitter.im/forzagreen/n2words)
6
+ [![npm](https://img.shields.io/npm/dw/n2words)](https://npmjs.com/package/n2words)
7
7
 
8
8
  n2words converts numbers to words. It supports multiple languages.
9
9
 
10
10
  n2words is a lightweight, easy to use package, with no dependencies. It works both in Node.js and in browsers.
11
11
 
12
+
13
+ ## How To
14
+
15
+ ```js
16
+ n2words(123) // 'one hundred and twenty-three'
17
+ n2words(-1.5) // 'minus one point five'
18
+
19
+ n2words(123, {lang: 'fr'}) // 'cent vingt-trois'
20
+ n2words(123, {lang: 'es'}) // 'ciento veintitrés'
21
+ n2words(123, {lang: 'ar'}) // 'مائة و ثلاثة و عشرون'
22
+ ```
23
+
24
+
12
25
  ## Install
13
26
 
14
27
  ```sh
@@ -23,14 +36,29 @@ n2words is available on [jsDelivr](https://jsdelivr.com/package/npm/n2words).
23
36
 
24
37
  ```js
25
38
  var n2words = require('n2words')
39
+
40
+ // Dynamic Import (source files)
41
+ import('n2words/lib/n2words.mjs').then(n2words => {
42
+ // Available via "default" method
43
+ n2words.default(100)
44
+ })
45
+
46
+ // Individual languages
47
+ import('n2words/lib/i18n/EN.mjs').then(n2wordsEN => {
48
+ n2wordsEN.default(100)
49
+ })
26
50
  ```
27
51
 
28
- ### ES6
52
+ ### ESM
29
53
 
30
54
  ```js
31
55
  import n2words from 'n2words'
32
- // or to import source ES Modules without bundle and polyfills
56
+
57
+ // ES6+
33
58
  import n2words from 'n2words/lib/n2words.mjs'
59
+
60
+ // Individual languages
61
+ import n2wordsEN from 'n2words/lib/i18n/EN.mjs'
34
62
  ```
35
63
 
36
64
  ### Browser
@@ -39,17 +67,6 @@ import n2words from 'n2words/lib/n2words.mjs'
39
67
  <script src="n2words.js"></script>
40
68
  ```
41
69
 
42
- ## Example
43
-
44
- ```js
45
- n2words(123) // 'one hundred and twenty-three'
46
- n2words(-1.5) // 'minus one point five'
47
-
48
- n2words(123, {lang: 'en'}) // 'one hundred and twenty-three'
49
- n2words(123, {lang: 'fr'}) // 'cent vingt-trois'
50
- n2words(123, {lang: 'es'}) // 'ciento veintitrés'
51
- ```
52
-
53
70
  ## Features
54
71
 
55
72
  - Cardinal numbers
@@ -67,7 +84,9 @@ n2words(123, {lang: 'es'}) // 'ciento veintitrés'
67
84
  - `fr` (French)
68
85
  - `fa` (Farsi)
69
86
  - `he` (Hebrew)
87
+ - `hr` (Croatian)
70
88
  - `hu` (Hungarian)
89
+ - `id` (Indonesian)
71
90
  - `it` (Italian)
72
91
  - `ko` (Korean)
73
92
  - `lt` (Lithuanian)