numberstring 0.1.0 → 1.0.1
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/CONTRIBUTING.md +49 -0
- package/LICENSE +21 -21
- package/README.md +349 -22
- package/index.js +700 -156
- package/languages/ar.js +128 -0
- package/languages/da.js +103 -0
- package/languages/de.js +103 -0
- package/languages/en.js +73 -0
- package/languages/es.js +106 -0
- package/languages/fi.js +103 -0
- package/languages/fr.js +99 -0
- package/languages/hi.js +124 -0
- package/languages/id.js +105 -0
- package/languages/index.js +131 -0
- package/languages/is.js +103 -0
- package/languages/it.js +129 -0
- package/languages/ja.js +122 -0
- package/languages/ko.js +122 -0
- package/languages/nl.js +112 -0
- package/languages/no.js +103 -0
- package/languages/pl.js +146 -0
- package/languages/pt.js +145 -0
- package/languages/ru.js +125 -0
- package/languages/sv.js +103 -0
- package/languages/th.js +123 -0
- package/languages/tr.js +102 -0
- package/languages/zh.js +116 -0
- package/package.json +27 -11
- package/.codeclimate.yml +0 -34
- package/.npmignore +0 -31
- package/.travis.yml +0 -32
- package/codecov.yml +0 -4
- package/npm-shrinkwrap.json +0 -1466
- package/test/test.js +0 -123
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributing to numberstring
|
|
2
|
+
|
|
3
|
+
First off, thanks for taking the time to contribute!
|
|
4
|
+
|
|
5
|
+
## How Can I Contribute?
|
|
6
|
+
|
|
7
|
+
### Reporting Bugs
|
|
8
|
+
|
|
9
|
+
- Check if the bug has already been reported in Issues
|
|
10
|
+
- If not, open a new issue with a clear title and description
|
|
11
|
+
- Include code samples and expected vs actual behavior
|
|
12
|
+
|
|
13
|
+
### Suggesting Features
|
|
14
|
+
|
|
15
|
+
- Open an issue describing the feature
|
|
16
|
+
- Explain why it would be useful
|
|
17
|
+
|
|
18
|
+
### Adding a New Language
|
|
19
|
+
|
|
20
|
+
We'd love help adding more languages! Here's how:
|
|
21
|
+
|
|
22
|
+
1. Create a new file in `languages/` (e.g., `pt.js` for Portuguese)
|
|
23
|
+
2. Follow the pattern in `languages/en.js`
|
|
24
|
+
3. Export a default function that converts numbers to words
|
|
25
|
+
4. Add your language to `languages/index.js`
|
|
26
|
+
5. Add tests in `test/index.test.js`
|
|
27
|
+
6. Update README.md with the new language
|
|
28
|
+
7. Submit a PR!
|
|
29
|
+
|
|
30
|
+
### Pull Request Process
|
|
31
|
+
|
|
32
|
+
1. Fork the repo and create your branch from `main`
|
|
33
|
+
2. Run `npm install` to install dependencies
|
|
34
|
+
3. Make your changes
|
|
35
|
+
4. Run `npm test` to ensure tests pass
|
|
36
|
+
5. Run `npm run lint` to check code style
|
|
37
|
+
6. Update documentation if needed
|
|
38
|
+
7. Submit your PR!
|
|
39
|
+
|
|
40
|
+
### Code Style
|
|
41
|
+
|
|
42
|
+
- ES2022+ syntax (const/let, arrow functions, async/await)
|
|
43
|
+
- ESM modules only
|
|
44
|
+
- Add JSDoc comments for public functions
|
|
45
|
+
- Maintain test coverage
|
|
46
|
+
|
|
47
|
+
## Code of Conduct
|
|
48
|
+
|
|
49
|
+
Be respectful and inclusive. We welcome contributors of all backgrounds and experience levels.
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2016 Brian Funk
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Brian Funk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,22 +1,349 @@
|
|
|
1
|
-
[](https://github.com/brianfunk/numberstring)
|
|
2
|
-
[](https://github.com/brianfunk/numberstring)
|
|
2
|
+
[](https://www.npmjs.com/package/numberstring)
|
|
3
|
+
[](https://www.npmjs.com/package/numberstring)
|
|
4
|
+
[](https://github.com/brianfunk/numberstring/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/ellerbrock/open-source-badge/)
|
|
6
|
+
[](http://semver.org/spec/v2.0.0.html)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://www.linkedin.com/in/brianrandyfunk)
|
|
9
|
+
|
|
10
|
+
# numberstring
|
|
11
|
+
|
|
12
|
+
> Number One Way to Makes Words from Numbers
|
|
13
|
+
|
|
14
|
+
Transform any number into beautiful words. From `42` to `"forty-two"`, from `1000000` to `"one million"`. Supports **22 languages**, ordinals, currency, Roman numerals, and more!
|
|
15
|
+
|
|
16
|
+
## Why numberstring?
|
|
17
|
+
|
|
18
|
+
- **Zero dependencies** - Lightweight and fast
|
|
19
|
+
- **22 languages** - English, Spanish, French, German, Danish, Chinese, Hindi, Russian, Portuguese, Japanese, Korean, Arabic, Italian, Dutch, Turkish, Polish, Swedish, Indonesian, Thai, Norwegian, Finnish, Icelandic
|
|
20
|
+
- **Huge range** - Supports 0 to decillions (10^36) with BigInt
|
|
21
|
+
- **Feature-rich** - Ordinals, decimals, currency, fractions, years, phone numbers
|
|
22
|
+
- **Roman numerals** - Convert to and from Roman numerals
|
|
23
|
+
- **Well tested** - 265 tests with 90%+ coverage
|
|
24
|
+
- **Modern ES modules** - Tree-shakeable, TypeScript-friendly
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install numberstring
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import numberstring from 'numberstring';
|
|
36
|
+
|
|
37
|
+
numberstring(42); // 'forty-two'
|
|
38
|
+
numberstring(1000000); // 'one million'
|
|
39
|
+
numberstring(10n ** 18n); // 'one quintillion' (BigInt!)
|
|
40
|
+
numberstring(123, { cap: 'title' }); // 'One Hundred Twenty-Three'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## API Reference
|
|
44
|
+
|
|
45
|
+
### Core Functions
|
|
46
|
+
|
|
47
|
+
#### `numberstring(n, [options])`
|
|
48
|
+
|
|
49
|
+
Convert a number to English words.
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
numberstring(42); // 'forty-two'
|
|
53
|
+
numberstring(100, { cap: 'title' }); // 'One Hundred'
|
|
54
|
+
numberstring(100, { punc: '!' }); // 'one hundred!'
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### `ordinal(n, [options])`
|
|
58
|
+
|
|
59
|
+
Convert to ordinal words (first, second, etc.).
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
import { ordinal } from 'numberstring';
|
|
63
|
+
|
|
64
|
+
ordinal(1); // 'first'
|
|
65
|
+
ordinal(2); // 'second'
|
|
66
|
+
ordinal(21); // 'twenty-first'
|
|
67
|
+
ordinal(100); // 'one hundredth'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### `decimal(n, [options])`
|
|
71
|
+
|
|
72
|
+
Convert decimal numbers to words.
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
import { decimal } from 'numberstring';
|
|
76
|
+
|
|
77
|
+
decimal(3.14); // 'three point one four'
|
|
78
|
+
decimal(0.5); // 'zero point five'
|
|
79
|
+
decimal(-3.14); // 'negative three point one four'
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### `currency(amount, [options])`
|
|
83
|
+
|
|
84
|
+
Convert currency amounts to words.
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
import { currency } from 'numberstring';
|
|
88
|
+
|
|
89
|
+
currency('$123.45'); // 'one hundred twenty-three dollars and forty-five cents'
|
|
90
|
+
currency('€50'); // 'fifty euros'
|
|
91
|
+
currency('£1.01'); // 'one pound and one penny'
|
|
92
|
+
currency('¥1000'); // 'one thousand yen'
|
|
93
|
+
currency('₹100.50'); // 'one hundred rupees and fifty paise'
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Supported currencies: `$` `€` `£` `¥` `₹` `元` (USD, EUR, GBP, JPY, INR, CNY)
|
|
97
|
+
|
|
98
|
+
#### `roman(n, [options])`
|
|
99
|
+
|
|
100
|
+
Convert to Roman numerals.
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
import { roman } from 'numberstring';
|
|
104
|
+
|
|
105
|
+
roman(42); // 'XLII'
|
|
106
|
+
roman(1999); // 'MCMXCIX'
|
|
107
|
+
roman(4, { lower: true }); // 'iv'
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### `parse(str)`
|
|
111
|
+
|
|
112
|
+
Parse English words back to a number.
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
import { parse } from 'numberstring';
|
|
116
|
+
|
|
117
|
+
parse('forty-two'); // 42
|
|
118
|
+
parse('one thousand'); // 1000
|
|
119
|
+
parse('one quintillion'); // 1000000000000000000n (BigInt)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Utility Functions
|
|
123
|
+
|
|
124
|
+
#### `negative(n, [options])`
|
|
125
|
+
|
|
126
|
+
Handle negative numbers.
|
|
127
|
+
|
|
128
|
+
```javascript
|
|
129
|
+
import { negative } from 'numberstring';
|
|
130
|
+
|
|
131
|
+
negative(-42); // 'negative forty-two'
|
|
132
|
+
negative(42); // 'forty-two'
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
#### `fraction(numerator, denominator, [options])`
|
|
136
|
+
|
|
137
|
+
Convert fractions to words.
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
import { fraction } from 'numberstring';
|
|
141
|
+
|
|
142
|
+
fraction(1, 2); // 'one half'
|
|
143
|
+
fraction(3, 4); // 'three quarters'
|
|
144
|
+
fraction(5, 8); // 'five eighths'
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### `year(y, [options])`
|
|
148
|
+
|
|
149
|
+
Convert years to spoken form.
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
import { year } from 'numberstring';
|
|
153
|
+
|
|
154
|
+
year(1984); // 'nineteen eighty-four'
|
|
155
|
+
year(2000); // 'two thousand'
|
|
156
|
+
year(2024); // 'twenty twenty-four'
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### `telephone(phone, [options])`
|
|
160
|
+
|
|
161
|
+
Convert phone numbers to words.
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
import { telephone } from 'numberstring';
|
|
165
|
+
|
|
166
|
+
telephone('555-1234'); // 'five five five one two three four'
|
|
167
|
+
telephone(8675309); // 'eight six seven five three zero nine'
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### `percent(pct, [options])`
|
|
171
|
+
|
|
172
|
+
Convert percentages to words.
|
|
173
|
+
|
|
174
|
+
```javascript
|
|
175
|
+
import { percent } from 'numberstring';
|
|
176
|
+
|
|
177
|
+
percent(50); // 'fifty percent'
|
|
178
|
+
percent('25%'); // 'twenty-five percent'
|
|
179
|
+
percent(3.5); // 'three point five percent'
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### `comma(n)`
|
|
183
|
+
|
|
184
|
+
Format a number with comma separators.
|
|
185
|
+
|
|
186
|
+
```javascript
|
|
187
|
+
import { comma } from 'numberstring';
|
|
188
|
+
|
|
189
|
+
comma(1234567); // '1,234,567'
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Multi-Language Support
|
|
193
|
+
|
|
194
|
+
numberstring supports 22 languages! Each language is in a separate file for easy tree-shaking.
|
|
195
|
+
|
|
196
|
+
```javascript
|
|
197
|
+
import { toWords } from 'numberstring';
|
|
198
|
+
|
|
199
|
+
// Using toWords with lang option
|
|
200
|
+
toWords(42, { lang: 'es' }); // 'cuarenta y dos'
|
|
201
|
+
toWords(42, { lang: 'fr' }); // 'quarante-deux'
|
|
202
|
+
toWords(42, { lang: 'de' }); // 'zweiundvierzig'
|
|
203
|
+
toWords(42, { lang: 'da' }); // 'toogfyrre'
|
|
204
|
+
toWords(42, { lang: 'zh' }); // '四十二'
|
|
205
|
+
toWords(42, { lang: 'hi' }); // 'बयालीस'
|
|
206
|
+
toWords(42, { lang: 'ru' }); // 'сорок два'
|
|
207
|
+
toWords(42, { lang: 'pt' }); // 'quarenta e dois'
|
|
208
|
+
toWords(42, { lang: 'ja' }); // '四十二'
|
|
209
|
+
toWords(42, { lang: 'ko' }); // '사십이'
|
|
210
|
+
toWords(42, { lang: 'ar' }); // 'اثنان وأربعون'
|
|
211
|
+
toWords(42, { lang: 'it' }); // 'quarantadue'
|
|
212
|
+
toWords(42, { lang: 'nl' }); // 'tweeënveertig'
|
|
213
|
+
toWords(42, { lang: 'tr' }); // 'kırk iki'
|
|
214
|
+
toWords(42, { lang: 'pl' }); // 'czterdzieści dwa'
|
|
215
|
+
toWords(42, { lang: 'sv' }); // 'fyrtiotvå'
|
|
216
|
+
toWords(42, { lang: 'id' }); // 'empat puluh dua'
|
|
217
|
+
toWords(42, { lang: 'th' }); // 'สี่สิบสอง'
|
|
218
|
+
toWords(42, { lang: 'no' }); // 'førtito'
|
|
219
|
+
toWords(42, { lang: 'fi' }); // 'neljäkymmentäkaksi'
|
|
220
|
+
toWords(42, { lang: 'is' }); // 'fjörutíu og tveir'
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Supported Languages
|
|
224
|
+
|
|
225
|
+
| Code | Language | Example (42) |
|
|
226
|
+
|------|----------|-------------|
|
|
227
|
+
| `en` | English | forty-two |
|
|
228
|
+
| `es` | Spanish | cuarenta y dos |
|
|
229
|
+
| `fr` | French | quarante-deux |
|
|
230
|
+
| `de` | German | zweiundvierzig |
|
|
231
|
+
| `da` | Danish | toogfyrre |
|
|
232
|
+
| `zh` | Chinese | 四十二 |
|
|
233
|
+
| `hi` | Hindi | बयालीस |
|
|
234
|
+
| `ru` | Russian | сорок два |
|
|
235
|
+
| `pt` | Portuguese | quarenta e dois |
|
|
236
|
+
| `ja` | Japanese | 四十二 |
|
|
237
|
+
| `ko` | Korean | 사십이 |
|
|
238
|
+
| `ar` | Arabic | اثنان وأربعون |
|
|
239
|
+
| `it` | Italian | quarantadue |
|
|
240
|
+
| `nl` | Dutch | tweeënveertig |
|
|
241
|
+
| `tr` | Turkish | kırk iki |
|
|
242
|
+
| `pl` | Polish | czterdzieści dwa |
|
|
243
|
+
| `sv` | Swedish | fyrtiotvå |
|
|
244
|
+
| `id` | Indonesian | empat puluh dua |
|
|
245
|
+
| `th` | Thai | สี่สิบสอง |
|
|
246
|
+
| `no` | Norwegian | førtito |
|
|
247
|
+
| `fi` | Finnish | neljäkymmentäkaksi |
|
|
248
|
+
| `is` | Icelandic | fjörutíu og tveir |
|
|
249
|
+
|
|
250
|
+
### Adding a New Language
|
|
251
|
+
|
|
252
|
+
Languages are modular! To add a new language:
|
|
253
|
+
|
|
254
|
+
1. Create `languages/xx.js` following the pattern in `languages/en.js`
|
|
255
|
+
2. Export your conversion function
|
|
256
|
+
3. Add to `languages/index.js`
|
|
257
|
+
4. Submit a PR!
|
|
258
|
+
|
|
259
|
+
## Options
|
|
260
|
+
|
|
261
|
+
| Option | Type | Description |
|
|
262
|
+
|--------|------|-------------|
|
|
263
|
+
| `cap` | `string` | Capitalization: `'title'`, `'upper'`, or `'lower'` |
|
|
264
|
+
| `punc` | `string` | Punctuation: `'!'`, `'?'`, or `'.'` |
|
|
265
|
+
| `lang` | `string` | Language code for `toWords()` |
|
|
266
|
+
| `point` | `string` | Word for decimal point (default: `'point'`) |
|
|
267
|
+
| `lower` | `boolean` | Lowercase Roman numerals |
|
|
268
|
+
|
|
269
|
+
## Supported Scales
|
|
270
|
+
|
|
271
|
+
| Scale | Power | Example |
|
|
272
|
+
|-------|-------|---------|
|
|
273
|
+
| Ones | 10^0 | `five` |
|
|
274
|
+
| Thousands | 10^3 | `five thousand` |
|
|
275
|
+
| Millions | 10^6 | `five million` |
|
|
276
|
+
| Billions | 10^9 | `five billion` |
|
|
277
|
+
| Trillions | 10^12 | `five trillion` |
|
|
278
|
+
| Quadrillions | 10^15 | `five quadrillion` |
|
|
279
|
+
| **Quintillions** | 10^18 | `five quintillion` *(BigInt)* |
|
|
280
|
+
| **Sextillions** | 10^21 | `five sextillion` *(BigInt)* |
|
|
281
|
+
| **Septillions** | 10^24 | `five septillion` *(BigInt)* |
|
|
282
|
+
| **Octillions** | 10^27 | `five octillion` *(BigInt)* |
|
|
283
|
+
| **Nonillions** | 10^30 | `five nonillion` *(BigInt)* |
|
|
284
|
+
| **Decillions** | 10^33 | `five decillion` *(BigInt)* |
|
|
285
|
+
|
|
286
|
+
## REST API Server
|
|
287
|
+
|
|
288
|
+
numberstring includes a ready-to-use REST API server!
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
cd server
|
|
292
|
+
npm install
|
|
293
|
+
npm start
|
|
294
|
+
# Server running at http://localhost:3456
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Endpoints
|
|
298
|
+
|
|
299
|
+
| Endpoint | Description | Example |
|
|
300
|
+
|----------|-------------|---------|
|
|
301
|
+
| `GET /convert/:n` | Number to words | `/convert/42` → `"forty-two"` |
|
|
302
|
+
| `GET /convert/:n?lang=es` | Multi-language | `/convert/42?lang=es` → `"cuarenta y dos"` |
|
|
303
|
+
| `GET /ordinal/:n` | Ordinal words | `/ordinal/3` → `"third"` |
|
|
304
|
+
| `GET /decimal/:n` | Decimal words | `/decimal/3.14` → `"three point one four"` |
|
|
305
|
+
| `GET /currency/:amt` | Currency words | `/currency/$99.99` → `"ninety-nine dollars..."` |
|
|
306
|
+
| `GET /roman/:n` | Roman numerals | `/roman/2024` → `"MMXXIV"` |
|
|
307
|
+
| `GET /parse/:words` | Words to number | `/parse/forty-two` → `42` |
|
|
308
|
+
| `GET /comma/:n` | Format with commas | `/comma/1000000` → `"1,000,000"` |
|
|
309
|
+
| `GET /languages` | List languages | Returns supported language codes |
|
|
310
|
+
|
|
311
|
+
### Example
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
curl http://localhost:3456/convert/1000000000000000
|
|
315
|
+
# {"input":"1000000000000000","output":"one quadrillion","lang":"en"}
|
|
316
|
+
|
|
317
|
+
curl "http://localhost:3456/convert/42?lang=fr"
|
|
318
|
+
# {"input":"42","output":"quarante-deux","lang":"fr"}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
## Development
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
npm install # Install dependencies
|
|
325
|
+
npm test # Run tests
|
|
326
|
+
npm run lint # Run linter
|
|
327
|
+
npm run test:coverage # Test with coverage
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Contributing
|
|
331
|
+
|
|
332
|
+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on the process for submitting pull requests.
|
|
333
|
+
|
|
334
|
+
We especially welcome contributions for new languages! See the Contributing guide for details.
|
|
335
|
+
|
|
336
|
+
## Versioning
|
|
337
|
+
|
|
338
|
+
This project uses [Semantic Versioning 2.0](http://semver.org/spec/v2.0.0.html).
|
|
339
|
+
|
|
340
|
+
## Requirements
|
|
341
|
+
|
|
342
|
+
- Node.js 18+
|
|
343
|
+
- ES modules (`import`/`export`)
|
|
344
|
+
|
|
345
|
+
## License
|
|
346
|
+
|
|
347
|
+
MIT
|
|
348
|
+
|
|
349
|
+
### # " "
|