n2words 1.23.0 → 1.24.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 (317) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +182 -53
  3. package/dist/languages/ar.js +2 -0
  4. package/dist/languages/ar.js.map +1 -0
  5. package/dist/languages/az.js +2 -0
  6. package/dist/languages/az.js.map +1 -0
  7. package/dist/languages/bn.js +2 -0
  8. package/dist/languages/bn.js.map +1 -0
  9. package/dist/languages/cs.js +2 -0
  10. package/dist/languages/cs.js.map +1 -0
  11. package/dist/languages/da.js +2 -0
  12. package/dist/languages/da.js.map +1 -0
  13. package/dist/languages/de.js +2 -0
  14. package/dist/languages/de.js.map +1 -0
  15. package/dist/languages/el.js +2 -0
  16. package/dist/languages/el.js.map +1 -0
  17. package/dist/languages/en.js +2 -0
  18. package/dist/languages/en.js.map +1 -0
  19. package/dist/languages/es.js +2 -0
  20. package/dist/languages/es.js.map +1 -0
  21. package/dist/languages/fa.js +2 -0
  22. package/dist/languages/fa.js.map +1 -0
  23. package/dist/languages/fil.js +2 -0
  24. package/dist/languages/fil.js.map +1 -0
  25. package/dist/languages/fr-BE.js +2 -0
  26. package/dist/languages/fr-BE.js.map +1 -0
  27. package/dist/languages/fr.js +2 -0
  28. package/dist/languages/fr.js.map +1 -0
  29. package/dist/languages/gu.js +2 -0
  30. package/dist/languages/gu.js.map +1 -0
  31. package/dist/languages/he.js +2 -0
  32. package/dist/languages/he.js.map +1 -0
  33. package/dist/languages/hi.js +2 -0
  34. package/dist/languages/hi.js.map +1 -0
  35. package/dist/languages/hr.js +2 -0
  36. package/dist/languages/hr.js.map +1 -0
  37. package/dist/languages/hu.js +2 -0
  38. package/dist/languages/hu.js.map +1 -0
  39. package/dist/languages/id.js +2 -0
  40. package/dist/languages/id.js.map +1 -0
  41. package/dist/languages/it.js +2 -0
  42. package/dist/languages/it.js.map +1 -0
  43. package/dist/languages/ja.js +2 -0
  44. package/dist/languages/ja.js.map +1 -0
  45. package/dist/languages/kn.js +2 -0
  46. package/dist/languages/kn.js.map +1 -0
  47. package/dist/languages/ko.js +2 -0
  48. package/dist/languages/ko.js.map +1 -0
  49. package/dist/languages/lt.js +2 -0
  50. package/dist/languages/lt.js.map +1 -0
  51. package/dist/languages/lv.js +2 -0
  52. package/dist/languages/lv.js.map +1 -0
  53. package/dist/languages/mr.js +2 -0
  54. package/dist/languages/mr.js.map +1 -0
  55. package/dist/languages/ms.js +2 -0
  56. package/dist/languages/ms.js.map +1 -0
  57. package/dist/languages/nb.js +2 -0
  58. package/dist/languages/nb.js.map +1 -0
  59. package/dist/languages/nl.js +2 -0
  60. package/dist/languages/nl.js.map +1 -0
  61. package/dist/languages/pa-Guru.js +2 -0
  62. package/dist/languages/pa-Guru.js.map +1 -0
  63. package/dist/languages/pl.js +2 -0
  64. package/dist/languages/pl.js.map +1 -0
  65. package/dist/languages/pt.js +2 -0
  66. package/dist/languages/pt.js.map +1 -0
  67. package/dist/languages/ro.js +2 -0
  68. package/dist/languages/ro.js.map +1 -0
  69. package/dist/languages/ru.js +2 -0
  70. package/dist/languages/ru.js.map +1 -0
  71. package/dist/languages/sr-Latn.js +2 -0
  72. package/dist/languages/sr-Latn.js.map +1 -0
  73. package/dist/languages/sv.js +2 -0
  74. package/dist/languages/sv.js.map +1 -0
  75. package/dist/languages/sw.js +2 -0
  76. package/dist/languages/sw.js.map +1 -0
  77. package/dist/languages/ta.js +2 -0
  78. package/dist/languages/ta.js.map +1 -0
  79. package/dist/languages/te.js +2 -0
  80. package/dist/languages/te.js.map +1 -0
  81. package/dist/languages/th.js +2 -0
  82. package/dist/languages/th.js.map +1 -0
  83. package/dist/languages/tr.js +2 -0
  84. package/dist/languages/tr.js.map +1 -0
  85. package/dist/languages/uk.js +2 -0
  86. package/dist/languages/uk.js.map +1 -0
  87. package/dist/languages/ur.js +2 -0
  88. package/dist/languages/ur.js.map +1 -0
  89. package/dist/languages/vi.js +2 -0
  90. package/dist/languages/vi.js.map +1 -0
  91. package/dist/languages/zh-Hans.js +2 -0
  92. package/dist/languages/zh-Hans.js.map +1 -0
  93. package/dist/n2words.js +1 -1
  94. package/dist/n2words.js.map +1 -1
  95. package/lib/classes/abstract-language.js +211 -110
  96. package/lib/classes/greedy-scale-language.js +195 -0
  97. package/lib/classes/slavic-language.js +251 -0
  98. package/lib/classes/south-asian-language.js +161 -0
  99. package/lib/classes/turkic-language.js +63 -0
  100. package/lib/languages/ar.js +243 -0
  101. package/lib/languages/az.js +58 -0
  102. package/lib/languages/bn.js +126 -0
  103. package/lib/languages/cs.js +212 -0
  104. package/lib/languages/da.js +167 -0
  105. package/lib/languages/de.js +135 -0
  106. package/lib/languages/el.js +116 -0
  107. package/lib/languages/en.js +123 -0
  108. package/lib/languages/es.js +153 -0
  109. package/lib/languages/fa.js +127 -0
  110. package/lib/languages/fil.js +162 -0
  111. package/lib/languages/fr-BE.js +61 -0
  112. package/lib/languages/fr.js +145 -0
  113. package/lib/languages/gu.js +156 -0
  114. package/lib/languages/he.js +329 -0
  115. package/lib/languages/hi.js +126 -0
  116. package/lib/languages/hr.js +157 -0
  117. package/lib/languages/hu.js +155 -0
  118. package/lib/languages/id.js +174 -0
  119. package/lib/languages/it.js +148 -0
  120. package/lib/languages/ja.js +190 -0
  121. package/lib/languages/kn.js +71 -0
  122. package/lib/languages/ko.js +83 -0
  123. package/lib/languages/lt.js +171 -0
  124. package/lib/languages/lv.js +153 -0
  125. package/lib/languages/mr.js +156 -0
  126. package/lib/languages/ms.js +146 -0
  127. package/lib/languages/nb.js +120 -0
  128. package/lib/languages/nl.js +206 -0
  129. package/lib/languages/pa-Guru.js +126 -0
  130. package/lib/languages/pl.js +189 -0
  131. package/lib/languages/pt.js +147 -0
  132. package/lib/languages/ro.js +380 -0
  133. package/lib/languages/ru.js +116 -0
  134. package/lib/languages/sr-Latn.js +157 -0
  135. package/lib/languages/sv.js +127 -0
  136. package/lib/languages/sw.js +121 -0
  137. package/lib/languages/ta.js +226 -0
  138. package/lib/languages/te.js +229 -0
  139. package/lib/languages/th.js +123 -0
  140. package/lib/languages/tr.js +83 -0
  141. package/lib/{i18n → languages}/uk.js +50 -23
  142. package/lib/languages/ur.js +126 -0
  143. package/lib/languages/vi.js +193 -0
  144. package/lib/languages/zh-Hans.js +165 -0
  145. package/lib/n2words.js +246 -75
  146. package/package.json +80 -72
  147. package/typings/classes/abstract-language.d.ts +144 -0
  148. package/typings/classes/greedy-scale-language.d.ts +148 -0
  149. package/typings/classes/slavic-language.d.ts +145 -0
  150. package/typings/classes/south-asian-language.d.ts +101 -0
  151. package/typings/classes/turkic-language.d.ts +42 -0
  152. package/typings/languages/ar.d.ts +93 -0
  153. package/typings/languages/az.d.ts +25 -0
  154. package/typings/languages/bn.d.ts +1 -0
  155. package/typings/languages/cs.d.ts +120 -0
  156. package/typings/languages/da.d.ts +53 -0
  157. package/typings/languages/de.d.ts +26 -0
  158. package/typings/languages/el.d.ts +11 -0
  159. package/typings/languages/en.d.ts +30 -0
  160. package/typings/languages/es.d.ts +43 -0
  161. package/typings/languages/fa.d.ts +81 -0
  162. package/typings/languages/fil.d.ts +12 -0
  163. package/typings/languages/fr-BE.d.ts +41 -0
  164. package/typings/languages/fr.d.ts +43 -0
  165. package/typings/languages/gu.d.ts +12 -0
  166. package/typings/languages/he.d.ts +197 -0
  167. package/typings/languages/hi.d.ts +1 -0
  168. package/typings/languages/hr.d.ts +110 -0
  169. package/typings/languages/hu.d.ts +37 -0
  170. package/typings/languages/id.d.ts +69 -0
  171. package/typings/languages/it.d.ts +51 -0
  172. package/typings/languages/ja.d.ts +58 -0
  173. package/typings/languages/kn.d.ts +11 -0
  174. package/typings/languages/ko.d.ts +25 -0
  175. package/typings/languages/lt.d.ts +110 -0
  176. package/typings/languages/lv.d.ts +99 -0
  177. package/typings/languages/mr.d.ts +12 -0
  178. package/typings/languages/ms.d.ts +37 -0
  179. package/typings/languages/nb.d.ts +27 -0
  180. package/typings/languages/nl.d.ts +65 -0
  181. package/typings/languages/pa-Guru.d.ts +1 -0
  182. package/typings/languages/pl.d.ts +116 -0
  183. package/typings/languages/pt.d.ts +39 -0
  184. package/typings/languages/ro.d.ts +229 -0
  185. package/typings/languages/ru.d.ts +108 -0
  186. package/typings/languages/sr-Latn.d.ts +98 -0
  187. package/typings/languages/sv.d.ts +30 -0
  188. package/typings/languages/sw.d.ts +1 -0
  189. package/typings/languages/ta.d.ts +1 -0
  190. package/typings/languages/te.d.ts +1 -0
  191. package/typings/languages/th.d.ts +1 -0
  192. package/typings/languages/tr.d.ts +46 -0
  193. package/typings/languages/uk.d.ts +117 -0
  194. package/typings/languages/ur.d.ts +1 -0
  195. package/typings/languages/vi.d.ts +116 -0
  196. package/typings/languages/zh-Hans.d.ts +57 -0
  197. package/typings/n2words.d.ts +177 -0
  198. package/dist/ar.js +0 -2
  199. package/dist/ar.js.map +0 -1
  200. package/dist/az.js +0 -2
  201. package/dist/az.js.map +0 -1
  202. package/dist/cz.js +0 -2
  203. package/dist/cz.js.map +0 -1
  204. package/dist/de.js +0 -2
  205. package/dist/de.js.map +0 -1
  206. package/dist/dk.js +0 -2
  207. package/dist/dk.js.map +0 -1
  208. package/dist/en.js +0 -2
  209. package/dist/en.js.map +0 -1
  210. package/dist/es.js +0 -2
  211. package/dist/es.js.map +0 -1
  212. package/dist/fa.js +0 -2
  213. package/dist/fa.js.map +0 -1
  214. package/dist/fr-BE.js +0 -2
  215. package/dist/fr-BE.js.map +0 -1
  216. package/dist/fr.js +0 -2
  217. package/dist/fr.js.map +0 -1
  218. package/dist/he.js +0 -2
  219. package/dist/he.js.map +0 -1
  220. package/dist/hr.js +0 -2
  221. package/dist/hr.js.map +0 -1
  222. package/dist/hu.js +0 -2
  223. package/dist/hu.js.map +0 -1
  224. package/dist/id.js +0 -2
  225. package/dist/id.js.map +0 -1
  226. package/dist/it.js +0 -2
  227. package/dist/it.js.map +0 -1
  228. package/dist/ko.js +0 -2
  229. package/dist/ko.js.map +0 -1
  230. package/dist/lt.js +0 -2
  231. package/dist/lt.js.map +0 -1
  232. package/dist/lv.js +0 -2
  233. package/dist/lv.js.map +0 -1
  234. package/dist/n2words.d.ts +0 -2
  235. package/dist/nl.js +0 -2
  236. package/dist/nl.js.map +0 -1
  237. package/dist/no.js +0 -2
  238. package/dist/no.js.map +0 -1
  239. package/dist/pl.js +0 -2
  240. package/dist/pl.js.map +0 -1
  241. package/dist/pt.js +0 -2
  242. package/dist/pt.js.map +0 -1
  243. package/dist/ro.js +0 -2
  244. package/dist/ro.js.map +0 -1
  245. package/dist/ru.js +0 -2
  246. package/dist/ru.js.map +0 -1
  247. package/dist/sr.js +0 -2
  248. package/dist/sr.js.map +0 -1
  249. package/dist/tr.js +0 -2
  250. package/dist/tr.js.map +0 -1
  251. package/dist/uk.js +0 -2
  252. package/dist/uk.js.map +0 -1
  253. package/dist/vi.js +0 -2
  254. package/dist/vi.js.map +0 -1
  255. package/dist/zh.js +0 -2
  256. package/dist/zh.js.map +0 -1
  257. package/lib/classes/abstract-language.d.ts +0 -54
  258. package/lib/classes/base-language.d.ts +0 -58
  259. package/lib/classes/base-language.js +0 -172
  260. package/lib/i18n/ar.d.ts +0 -41
  261. package/lib/i18n/ar.js +0 -209
  262. package/lib/i18n/az.d.ts +0 -15
  263. package/lib/i18n/az.js +0 -66
  264. package/lib/i18n/cz.d.ts +0 -68
  265. package/lib/i18n/cz.js +0 -135
  266. package/lib/i18n/de.d.ts +0 -17
  267. package/lib/i18n/de.js +0 -103
  268. package/lib/i18n/dk.d.ts +0 -14
  269. package/lib/i18n/dk.js +0 -110
  270. package/lib/i18n/en.d.ts +0 -22
  271. package/lib/i18n/en.js +0 -86
  272. package/lib/i18n/es.d.ts +0 -16
  273. package/lib/i18n/es.js +0 -110
  274. package/lib/i18n/fa.d.ts +0 -54
  275. package/lib/i18n/fa.js +0 -106
  276. package/lib/i18n/fr-BE.d.ts +0 -11
  277. package/lib/i18n/fr-BE.js +0 -20
  278. package/lib/i18n/fr.d.ts +0 -15
  279. package/lib/i18n/fr.js +0 -99
  280. package/lib/i18n/he.d.ts +0 -61
  281. package/lib/i18n/he.js +0 -132
  282. package/lib/i18n/hr.d.ts +0 -68
  283. package/lib/i18n/hr.js +0 -129
  284. package/lib/i18n/hu.d.ts +0 -17
  285. package/lib/i18n/hu.js +0 -135
  286. package/lib/i18n/id.d.ts +0 -43
  287. package/lib/i18n/id.js +0 -156
  288. package/lib/i18n/it.d.ts +0 -29
  289. package/lib/i18n/it.js +0 -137
  290. package/lib/i18n/ko.d.ts +0 -15
  291. package/lib/i18n/ko.js +0 -56
  292. package/lib/i18n/lt.d.ts +0 -68
  293. package/lib/i18n/lt.js +0 -138
  294. package/lib/i18n/lv.d.ts +0 -57
  295. package/lib/i18n/lv.js +0 -120
  296. package/lib/i18n/nl.d.ts +0 -20
  297. package/lib/i18n/nl.js +0 -125
  298. package/lib/i18n/no.d.ts +0 -15
  299. package/lib/i18n/no.js +0 -77
  300. package/lib/i18n/pl.d.ts +0 -67
  301. package/lib/i18n/pl.js +0 -126
  302. package/lib/i18n/pt.d.ts +0 -26
  303. package/lib/i18n/pt.js +0 -118
  304. package/lib/i18n/ro.d.ts +0 -109
  305. package/lib/i18n/ro.js +0 -360
  306. package/lib/i18n/ru.d.ts +0 -30
  307. package/lib/i18n/ru.js +0 -198
  308. package/lib/i18n/sr.d.ts +0 -56
  309. package/lib/i18n/sr.js +0 -127
  310. package/lib/i18n/tr.d.ts +0 -15
  311. package/lib/i18n/tr.js +0 -64
  312. package/lib/i18n/uk.d.ts +0 -78
  313. package/lib/i18n/vi.d.ts +0 -70
  314. package/lib/i18n/vi.js +0 -151
  315. package/lib/i18n/zh.d.ts +0 -18
  316. package/lib/i18n/zh.js +0 -78
  317. package/lib/n2words.d.ts +0 -9
package/lib/i18n/sr.d.ts DELETED
@@ -1,56 +0,0 @@
1
- /**
2
- * Converts a value to cardinal (written) form.
3
- * @param {number|string|bigint} value Number to be convert.
4
- * @param {object} [options] Options for class.
5
- * @returns {string} Value in cardinal (written) format.
6
- * @throws {Error} Value cannot be invalid.
7
- */
8
- export default function floatToCardinal(value: number | string | bigint, 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
- tens: {
22
- 0: string;
23
- 1: string;
24
- 2: string;
25
- 3: string;
26
- 4: string;
27
- 5: string;
28
- 6: string;
29
- 7: string;
30
- 8: string;
31
- 9: string;
32
- };
33
- twenties: {
34
- 2: string;
35
- 3: string;
36
- 4: string;
37
- 5: string;
38
- 6: string;
39
- 7: string;
40
- 8: string;
41
- 9: string;
42
- };
43
- hundreds: {
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
- };
54
- SCALE: (string | boolean)[][];
55
- }
56
- import { N2WordsRU } from './ru.js';
package/lib/i18n/sr.js DELETED
@@ -1,127 +0,0 @@
1
- import { N2WordsRU } from './ru.js';
2
-
3
- export class N2WordsSR extends N2WordsRU {
4
- ones = {
5
- 1: ['jedan', 'jedna'],
6
- 2: ['dva', 'dve'],
7
- 3: ['tri', 'tri'],
8
- 4: ['četiri', 'četiri'],
9
- 5: ['pet', 'pet'],
10
- 6: ['šest', 'šest'],
11
- 7: ['sedam', 'sedam'],
12
- 8: ['osam', 'osam'],
13
- 9: ['devet', 'devet']
14
- };
15
-
16
- tens = {
17
- 0: 'deset',
18
- 1: 'jedanaest',
19
- 2: 'dvanaest',
20
- 3: 'trinaest',
21
- 4: 'četrnaest',
22
- 5: 'petnaest',
23
- 6: 'šesnaest',
24
- 7: 'sedamnaest',
25
- 8: 'osamnaest',
26
- 9: 'devetnaest'
27
- };
28
-
29
- twenties = {
30
- 2: 'dvadeset',
31
- 3: 'trideset',
32
- 4: 'četrdeset',
33
- 5: 'pedeset',
34
- 6: 'šezdeset',
35
- 7: 'sedamdeset',
36
- 8: 'osamdeset',
37
- 9: 'devedeset'
38
- };
39
-
40
- hundreds = {
41
- 1: 'sto',
42
- 2: 'dvesta',
43
- 3: 'trista',
44
- 4: 'četiristo',
45
- 5: 'petsto',
46
- 6: 'šesto',
47
- 7: 'sedamsto',
48
- 8: 'osamsto',
49
- 9: 'devetsto'
50
- };
51
-
52
- SCALE = [
53
- ['', '', '', false],
54
- ['hiljada', 'hiljade', 'hiljada', true], // 10 ^ 3
55
- ['milion', 'miliona', 'miliona', false], // 10 ^ 6
56
- ['milijarda', 'milijarde', 'milijarda', false], // 10 ^ 9
57
- ['bilion', 'biliona', 'biliona', false], // 10 ^ 12
58
- ['bilijarda', 'bilijarde', 'bilijarda', false], // 10 ^ 15
59
- ['trilion', 'triliona', 'triliona', false], // 10 ^ 18
60
- ['trilijarda', 'trilijarde', 'trilijarda', false], // 10 ^ 21
61
- ['kvadrilion', 'kvadriliona', 'kvadriliona', false], // 10 ^ 24
62
- ['kvadrilijarda', 'kvadrilijarde', 'kvadrilijarda', false], // 10 ^ 27
63
- ['kvintilion', 'kvintiliona', 'kvintiliona', false], // 10 ^ 30
64
- ];
65
-
66
- constructor(options) {
67
- super(Object.assign({
68
- negativeWord: 'minus',
69
- separatorWord: 'zapeta',
70
- zero: 'nula'
71
- }, options));
72
- }
73
-
74
- pluralize(n, forms) {
75
- let form = 2;
76
- if ((n % 100n < 10n) || (n % 100n > 20n)) {
77
- if (n % 10n == 1n) {
78
- form = 0;
79
- } else if ((n % 10n > 1n) && (n % 10n < 5n)) {
80
- form = 1;
81
- }
82
- }
83
- return forms[form];
84
- }
85
-
86
- toCardinal(number) {
87
- if (number == 0) {
88
- return this.zero;
89
- }
90
- const words = [];
91
- const chunks = this.splitByX(number.toString(), 3);
92
- let index = chunks.length;
93
- for (const x of chunks) {
94
- index = index - 1;
95
- // if (x == 0) { continue; }
96
- const [n1, n2, n3] = this.getDigits(x);
97
- if (n3 > 0) {
98
- words.push(this.hundreds[n3]);
99
- }
100
- if (n2 > 1) {
101
- words.push(this.twenties[n2]);
102
- }
103
- if (n2 == 1) {
104
- words.push(this.tens[n1]);
105
- } else if (n1 > 0) {
106
- const isFeminine = (this.feminine || this.SCALE[index][3]);
107
- const genderIndex = isFeminine ? 1 : 0;
108
- words.push(this.ones[n1][genderIndex]);
109
- }
110
- if ((index > 0) && (x != 0)) {
111
- words.push(this.pluralize(x, this.SCALE[index]));
112
- }
113
- }
114
- return words.join(' ');
115
- }
116
- }
117
-
118
- /**
119
- * Converts a value to cardinal (written) form.
120
- * @param {number|string|bigint} value Number to be convert.
121
- * @param {object} [options] Options for class.
122
- * @returns {string} Value in cardinal (written) format.
123
- * @throws {Error} Value cannot be invalid.
124
- */
125
- export default function floatToCardinal (value, options = {}) {
126
- return new N2WordsSR(options).floatToCardinal(value);
127
- }
package/lib/i18n/tr.d.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * Converts a value to cardinal (written) form.
3
- * @param {number|string|bigint} value Number to be convert.
4
- * @param {object} [options] Options for class.
5
- * @returns {string} Value in cardinal (written) format.
6
- * @throws {Error} Value cannot be invalid.
7
- */
8
- export default function floatToCardinal(value: number | string | bigint, 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/base-language.js';
package/lib/i18n/tr.js DELETED
@@ -1,64 +0,0 @@
1
- import BaseLanguage from '../classes/base-language.js';
2
-
3
- export class N2WordsTR extends BaseLanguage {
4
- constructor(options = {}) {
5
- super(Object.assign({
6
- negativeWord: 'eksi',
7
- separatorWord: 'virgül',
8
- zero: 'sıfır',
9
- spaceSeparator: (options.dropSpaces === true ? '' : ' '),
10
- }, options), [
11
- [1_000_000_000_000_000_000n, 'kentilyon'],
12
- [1_000_000_000_000_000n, 'katrilyon'],
13
- [1_000_000_000_000n, 'trilyon'],
14
- [1_000_000_000n, 'milyar'],
15
- [1_000_000n, 'milyon'],
16
- [1000n, 'bin'],
17
- [100n, 'yüz'],
18
- [90n, 'doksan'],
19
- [80n, 'seksen'],
20
- [70n, 'yetmiş'],
21
- [60n, 'altmış'],
22
- [50n, 'elli'],
23
- [40n, 'kırk'],
24
- [30n, 'otuz'],
25
- [20n, 'yirmi'],
26
- [10n, 'on'],
27
- [9n, 'dokuz'],
28
- [8n, 'sekiz'],
29
- [7n, 'yedi'],
30
- [6n, 'altı'],
31
- [5n, 'beş'],
32
- [4n, 'dört'],
33
- [3n, 'üç'],
34
- [2n, 'iki'],
35
- [1n, 'bir'],
36
- [0n, 'sıfır']
37
- ]);
38
- }
39
-
40
- merge(lPair, rPair) {
41
- const lText = Object.keys(lPair)[0];
42
- const rText = Object.keys(rPair)[0];
43
- const lNumber = BigInt(Object.values(lPair)[0]);
44
- const rNumber = BigInt(Object.values(rPair)[0]);
45
- if (lNumber == 1 && (rNumber <= 100 || rNumber == 1000)) {
46
- return { [rText]: rNumber };
47
- } else if (rNumber > lNumber) {
48
- return { [`${lText}${this.spaceSeparator}${rText}`]: lNumber * rNumber };
49
- } else {
50
- return { [`${lText}${this.spaceSeparator}${rText}`]: lNumber + rNumber };
51
- }
52
- }
53
- }
54
-
55
- /**
56
- * Converts a value to cardinal (written) form.
57
- * @param {number|string|bigint} value Number to be convert.
58
- * @param {object} [options] Options for class.
59
- * @returns {string} Value in cardinal (written) format.
60
- * @throws {Error} Value cannot be invalid.
61
- */
62
- export default function floatToCardinal (value, options = {}) {
63
- return new N2WordsTR(options).floatToCardinal(value);
64
- }
package/lib/i18n/uk.d.ts DELETED
@@ -1,78 +0,0 @@
1
- /**
2
- * Converts a value to cardinal (written) form.
3
- * @param {number|string|bigint} value Number to be convert.
4
- * @param {object} [options] Options for class.
5
- * @returns {string} Value in cardinal (written) format.
6
- * @throws {Error} Value cannot be invalid.
7
- */
8
- export default function floatToCardinal(value: number | string | bigint, options?: object): string;
9
- export class N2WordsUK 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
- onesFeminine: {
22
- 1: string;
23
- 2: string;
24
- 3: string;
25
- 4: string;
26
- 5: string;
27
- 6: string;
28
- 7: string;
29
- 8: string;
30
- 9: string;
31
- };
32
- tens: {
33
- 0: string;
34
- 1: string;
35
- 2: string;
36
- 3: string;
37
- 4: string;
38
- 5: string;
39
- 6: string;
40
- 7: string;
41
- 8: string;
42
- 9: string;
43
- };
44
- twenties: {
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
- };
54
- hundreds: {
55
- 1: string;
56
- 2: string;
57
- 3: string;
58
- 4: string;
59
- 5: string;
60
- 6: string;
61
- 7: string;
62
- 8: string;
63
- 9: string;
64
- };
65
- thousands: {
66
- 1: string[];
67
- 2: string[];
68
- 3: string[];
69
- 4: string[];
70
- 5: string[];
71
- 6: string[];
72
- 7: string[];
73
- 8: string[];
74
- 9: string[];
75
- 10: string[];
76
- };
77
- }
78
- import { N2WordsRU } from './ru.js';
package/lib/i18n/vi.d.ts DELETED
@@ -1,70 +0,0 @@
1
- /**
2
- * Converts a value to cardinal (written) form.
3
- * @param {number|string|bigint} value Number to be convert.
4
- * @param {object} [options] Options for class.
5
- * @returns {string} Value in cardinal (written) format.
6
- * @throws {Error} Value cannot be invalid.
7
- */
8
- export default function floatToCardinal(value: number | string | bigint, 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/abstract-language.js';
package/lib/i18n/vi.js DELETED
@@ -1,151 +0,0 @@
1
- import AbstractLanguage from '../classes/abstract-language.js';
2
-
3
- export class N2WordsID extends AbstractLanguage {
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({
63
- negativeWord: 'âm',
64
- separatorWord: 'phẩy',
65
- zero: 'không'
66
- }, options));
67
- }
68
-
69
- convertLess100(number) {
70
- let unitsPart = number % 10;
71
- let tensPart = number - unitsPart;
72
- let tensPartText = this.tens[tensPart];
73
- if (unitsPart == 0) {
74
- return tensPartText;
75
- }
76
- let unitsPartText = this.base[unitsPart];
77
- let suffix = unitsPartText;
78
- if (unitsPart == 1) {
79
- suffix = 'mốt';
80
- }
81
- if (unitsPart == 5) {
82
- suffix = 'lăm';
83
- }
84
- return tensPartText + ' ' + suffix;
85
- }
86
-
87
- convertLess1000(number) {
88
- let words = [];
89
- let tensUnitsPart = number % 100;
90
- let hundredsPart = number - tensUnitsPart;
91
- if (hundredsPart > 0) {
92
- words.push(this.base[hundredsPart / 100], 'trăm');
93
- }
94
- if (0 < tensUnitsPart && tensUnitsPart < 10) {
95
- if (words.length > 0) {
96
- words.push('lẻ');
97
- }
98
- if (tensUnitsPart == 5) {
99
- words.push('năm');
100
- } else {
101
- words.push(this.base[tensUnitsPart]);
102
- }
103
- }
104
- if (tensUnitsPart >= 10) {
105
- words.push(this.toCardinal(tensUnitsPart));
106
- }
107
- return words.join(' ');
108
- }
109
-
110
- convertMore1000(number) {
111
- let words = [];
112
- let division = number / 1000n;
113
- let power = 1;
114
- while (division >= 1000n) {
115
- division = division / 1000n;
116
- power = power + 1;
117
- }
118
- let r = number - (division * BigInt(Math.pow(1000, power)));
119
- words.push(this.toCardinal(division), this.thousands[power]);
120
- if (r > 0n) {
121
- if (r <= 99n) {
122
- words.push('lẻ');
123
- }
124
- words.push(this.toCardinal(r));
125
- }
126
- return words.join(' ');
127
- }
128
-
129
- toCardinal(number) {
130
- if (number < 20n) {
131
- return this.base[Number(number)];
132
- } else {
133
- if (number < 100n) {
134
- return this.convertLess100(Number(number));
135
- } else {
136
- return (number < 1000n ? this.convertLess1000(Number(number)) : this.convertMore1000(number));
137
- }
138
- }
139
- }
140
- }
141
-
142
- /**
143
- * Converts a value to cardinal (written) form.
144
- * @param {number|string|bigint} value Number to be convert.
145
- * @param {object} [options] Options for class.
146
- * @returns {string} Value in cardinal (written) format.
147
- * @throws {Error} Value cannot be invalid.
148
- */
149
- export default function floatToCardinal (value, options = {}) {
150
- return new N2WordsID(options).floatToCardinal(value);
151
- }
package/lib/i18n/zh.d.ts DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * Converts a value to cardinal (written) form.
3
- * @param {number|string|bigint} value Number to be convert.
4
- * @param {object} [options] Options for class.
5
- * @returns {string} Value in cardinal (written) format.
6
- * @throws {Error} Value cannot be invalid.
7
- */
8
- export default function floatToCardinal(value: number | string | bigint, 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): string;
15
- digit(number_: any): any;
16
- zeroDigit(number_: any): number;
17
- }
18
- import BaseLanguage from '../classes/base-language.js';
package/lib/i18n/zh.js DELETED
@@ -1,78 +0,0 @@
1
- import BaseLanguage from '../classes/base-language.js';
2
-
3
- export class N2WordsZH extends BaseLanguage {
4
- constructor(options) {
5
- super(Object.assign({
6
- negativeWord: '负',
7
- separatorWord: '点',
8
- zero: '零',
9
- spaceSeparator: ''
10
- }, options), [
11
- [1_000_000_000_000n, '万'],
12
- [100_000_000n, '亿'],
13
- [10_000n, '万'],
14
- [1000n, '仟'],
15
- [100n, '佰'],
16
- [10n, '拾'],
17
- [9n, '玖'],
18
- [8n, '捌'],
19
- [7n, '柒'],
20
- [6n, '陆'],
21
- [5n, '伍'],
22
- [4n, '肆'],
23
- [3n, '叁'],
24
- [2n, '贰'],
25
- [1n, '壹'],
26
- [0n, '零']
27
- ]);
28
- }
29
-
30
- merge(lPair, rPair) {
31
- // {'one':1}, {'hundred':100}
32
- const ltext = Object.keys(lPair)[0];
33
- const lnum = BigInt(Object.values(lPair)[0]);
34
- const rtext = Object.keys(rPair)[0];
35
- const rnum = BigInt(Object.values(rPair)[0]);
36
-
37
- let result = { [`${ltext}${rtext}`]: lnum + rnum };
38
-
39
- if (lnum == 1 && rnum < 10) {
40
- result = { [rtext]: rnum };
41
- } else if (rnum > lnum) {
42
- result = { [`${ltext}${rtext}`]: lnum * rnum };
43
- } else if (this.zeroDigit(lnum) > this.digit(rnum)) {
44
- result = { [`${ltext}${this.zero}${rtext}`]: lnum + rnum };
45
- }
46
-
47
- return result;
48
- }
49
-
50
- decimalToCardinal(decimal) {
51
- const decimalPartArray = [...decimal];
52
-
53
- const decimalPartWordsArray = decimalPartArray.map(decimal =>
54
- this.getCardWord(decimal)
55
- );
56
-
57
- return decimalPartWordsArray.join(this.spaceSeparator);
58
- }
59
-
60
- digit(number_) {
61
- return number_.toString().length;
62
- }
63
-
64
- zeroDigit(number_) {
65
- return [...number_.toString()].filter(c => c == '0').length;
66
- }
67
- }
68
-
69
- /**
70
- * Converts a value to cardinal (written) form.
71
- * @param {number|string|bigint} value Number to be convert.
72
- * @param {object} [options] Options for class.
73
- * @returns {string} Value in cardinal (written) format.
74
- * @throws {Error} Value cannot be invalid.
75
- */
76
- export default function floatToCardinal (value, options = {}) {
77
- return new N2WordsZH(options).floatToCardinal(value);
78
- }
package/lib/n2words.d.ts DELETED
@@ -1,9 +0,0 @@
1
- export default floatToCardinal;
2
- /**
3
- * Converts a number to written form.
4
- * @param {number|string|bigint} value The number to convert.
5
- * @param {object} [options] User options.
6
- * @returns {string} Value in written format.
7
- * TODO [2024-06] Migrate to object destructing for parameters
8
- */
9
- declare function floatToCardinal(value: number | string | bigint, options?: object): string;